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 SetDisconnectCallback(internal::SecurityManagerImpl::FacadeDisconnectCallback callback); 42 void SetIoCapability(hci::IoCapability io_capability); 43 void SetAuthenticationRequirements(hci::AuthenticationRequirements authentication_requirement); 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 SetLeMaximumEncryptionKeySize(uint8_t maximum_encryption_key_size); 52 void SetLeOobDataPresent(OobDataFlag oob_present); 53 void GetLeOutOfBandData(std::array<uint8_t, 16>* confirmation_value, std::array<uint8_t, 16>* random_value); 54 void SetOutOfBandData( 55 hci::AddressWithType remote_address, 56 std::array<uint8_t, 16> confirmation_value, 57 std::array<uint8_t, 16> random_value); 58 59 protected: FacadeConfigurationApi(os::Handler * security_handler,internal::SecurityManagerImpl * security_manager_impl)60 FacadeConfigurationApi(os::Handler* security_handler, internal::SecurityManagerImpl* security_manager_impl) 61 : security_handler_(security_handler), security_manager_impl_(security_manager_impl) {} 62 63 private: 64 os::Handler* security_handler_ = nullptr; 65 internal::SecurityManagerImpl* security_manager_impl_; 66 DISALLOW_COPY_AND_ASSIGN(FacadeConfigurationApi); 67 }; 68 69 } // namespace security 70 } // namespace bluetooth 71