1 /* 2 * 3 * Copyright 2020 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 */ 18 19 #pragma once 20 21 #include <memory> 22 #include <vector> 23 24 #include "hci/address_with_type.h" 25 #include "hci/hci_packets.h" 26 #include "security/internal/security_manager_impl.h" 27 #include "security/smp_packets.h" 28 29 namespace bluetooth { 30 namespace security { 31 32 /** 33 * Manages the security attributes, pairing, bonding of devices, and the 34 * encryption/decryption of communications. 35 */ 36 class FacadeConfigurationApi { 37 public: 38 friend class internal::SecurityManagerImpl; 39 friend class SecurityModule; 40 41 void SetIoCapability(hci::IoCapability io_capability); 42 void SetAuthenticationRequirements(hci::AuthenticationRequirements authentication_requirement); 43 void SetOobDataPresent(hci::OobDataPresent oob_present); 44 void EnforceSecurityPolicy( 45 hci::AddressWithType remote, 46 l2cap::classic::SecurityPolicy policy, 47 l2cap::classic::SecurityEnforcementInterface::ResultCallback callback); 48 49 void SetLeIoCapability(security::IoCapability io_capability); 50 void SetLeAuthRequirements(uint8_t auth_req); 51 void SetLeOobDataPresent(OobDataFlag oob_present); 52 void GetOutOfBandData(std::array<uint8_t, 16>* le_sc_confirmation_value, std::array<uint8_t, 16>* le_sc_random_value); 53 void SetOutOfBandData( 54 hci::AddressWithType remote_address, 55 std::array<uint8_t, 16> le_sc_confirmation_value, 56 std::array<uint8_t, 16> le_sc_random_value); 57 58 protected: FacadeConfigurationApi(os::Handler * security_handler,internal::SecurityManagerImpl * security_manager_impl)59 FacadeConfigurationApi(os::Handler* security_handler, internal::SecurityManagerImpl* security_manager_impl) 60 : security_handler_(security_handler), security_manager_impl_(security_manager_impl) {} 61 62 private: 63 os::Handler* security_handler_ = nullptr; 64 internal::SecurityManagerImpl* security_manager_impl_; 65 DISALLOW_COPY_AND_ASSIGN(FacadeConfigurationApi); 66 }; 67 68 } // namespace security 69 } // namespace bluetooth 70