• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   FacadeConfigurationApi(const FacadeConfigurationApi&) = delete;
39   FacadeConfigurationApi& operator=(const FacadeConfigurationApi&) = delete;
40 
41   friend class internal::SecurityManagerImpl;
42   friend class SecurityModule;
43 
44   void SetDisconnectCallback(internal::SecurityManagerImpl::FacadeDisconnectCallback callback);
45   void SetIoCapability(hci::IoCapability io_capability);
46   void SetAuthenticationRequirements(hci::AuthenticationRequirements authentication_requirement);
47   void EnforceSecurityPolicy(
48       hci::AddressWithType remote,
49       l2cap::classic::SecurityPolicy policy,
50       l2cap::classic::SecurityEnforcementInterface::ResultCallback callback);
51 
52   void SetLeIoCapability(security::IoCapability io_capability);
53   void SetLeAuthRequirements(uint8_t auth_req);
54   void SetLeMaximumEncryptionKeySize(uint8_t maximum_encryption_key_size);
55   void SetLeOobDataPresent(OobDataFlag oob_present);
56   void GetLeOutOfBandData(std::array<uint8_t, 16>* confirmation_value, std::array<uint8_t, 16>* random_value);
57   void SetOutOfBandData(
58       hci::AddressWithType remote_address,
59       std::array<uint8_t, 16> confirmation_value,
60       std::array<uint8_t, 16> random_value);
61 
62  protected:
FacadeConfigurationApi(os::Handler * security_handler,internal::SecurityManagerImpl * security_manager_impl)63   FacadeConfigurationApi(os::Handler* security_handler, internal::SecurityManagerImpl* security_manager_impl)
64       : security_handler_(security_handler), security_manager_impl_(security_manager_impl) {}
65 
66  private:
67   os::Handler* security_handler_ = nullptr;
68   internal::SecurityManagerImpl* security_manager_impl_;
69 };
70 
71 }  // namespace security
72 }  // namespace bluetooth
73