OSDN Git Service

SecurityManager: Add CreateBondOutOfBand interface.
authorMartin Brabham <optedoblivion@google.com>
Mon, 16 Nov 2020 18:45:25 +0000 (10:45 -0800)
committerMartin Brabham <optedoblivion@google.com>
Mon, 16 Nov 2020 19:37:52 +0000 (11:37 -0800)
Allow for creating bonds with remote Out of Band data.

Bug: 162984360
Tag: #gd-refactor
Test: cert/run --host SecurityTest
Change-Id: I6f6d85cc22fd5b1a1abf6b629ecdd37950b4d239

gd/security/internal/security_manager_impl.cc
gd/security/internal/security_manager_impl.h
gd/security/security_manager.cc
gd/security/security_manager.h

index 117e18d..4e99c58 100644 (file)
@@ -127,6 +127,11 @@ void SecurityManagerImpl::CreateBond(hci::AddressWithType device) {
   }
 }
 
+void SecurityManagerImpl::CreateBondOutOfBand(
+    hci::AddressWithType device, pairing::OobData remote_p192_oob_data, pairing::OobData remote_p256_oob_data) {
+  // TODO(optedoblivion): Implement when ClassicPairingHandler is ready.
+}
+
 void SecurityManagerImpl::CreateBondLe(hci::AddressWithType address) {
   auto record = security_database_.FindOrCreate(address);
   if (record->IsPaired()) {
index aecf0cd..b8798dc 100644 (file)
@@ -30,6 +30,7 @@
 #include "security/channel/security_manager_channel.h"
 #include "security/initial_informations.h"
 #include "security/pairing/classic_pairing_handler.h"
+#include "security/pairing/oob_data.h"
 #include "security/pairing_handler_le.h"
 #include "security/record/security_record.h"
 #include "security/record/security_record_database.h"
@@ -87,6 +88,18 @@ class SecurityManagerImpl : public channel::ISecurityManagerChannelListener, pub
   void CreateBond(hci::AddressWithType address);
 
   /**
+   * Initiates bond over Classic transport with device, if not bonded yet.
+   *
+   * Allows for OobData to be passed in for use while pairing
+   *
+   * @param address device address we want to bond with
+   * @param remote_p192_oob_data P192 data given to the stack
+   * @param remote_p256_oob_data P256 data given to the stack
+   */
+  void CreateBondOutOfBand(
+      hci::AddressWithType address, pairing::OobData remote_p192_oob_data, pairing::OobData remote_p256_oob_data);
+
+  /**
    * Initiates bond over Low Energy transport with device, if not bonded yet.
    *
    * @param address device address we want to bond with
index bc9bd53..d7252e6 100644 (file)
@@ -36,6 +36,16 @@ void SecurityManager::CreateBond(hci::AddressWithType device) {
                                            std::forward<hci::AddressWithType>(device)));
 }
 
+void SecurityManager::CreateBondOutOfBand(
+    hci::AddressWithType device, pairing::OobData remote_p192_oob_data, pairing::OobData remote_p256_oob_data) {
+  security_handler_->Post(common::BindOnce(
+      &internal::SecurityManagerImpl::CreateBondOutOfBand,
+      common::Unretained(security_manager_impl_),
+      std::forward<hci::AddressWithType>(device),
+      remote_p192_oob_data,
+      remote_p256_oob_data));
+}
+
 void SecurityManager::CreateBondLe(hci::AddressWithType device) {
   security_handler_->Post(common::BindOnce(&internal::SecurityManagerImpl::CreateBondLe,
                                            common::Unretained(security_manager_impl_),
index aa8bd7c..8447b9c 100644 (file)
@@ -24,6 +24,7 @@
 #include "hci/address_with_type.h"
 #include "hci/le_address_manager.h"
 #include "security/internal/security_manager_impl.h"
+#include "security/pairing/oob_data.h"
 #include "security/security_manager_listener.h"
 
 namespace bluetooth {
@@ -45,11 +46,25 @@ class SecurityManager : public UICallbacks {
   /**
    * Initiates bond over Classic transport with device, if not bonded yet.
    *
+   * This will initiate the Numeric Comparison bonding method
+   *
    * @param address device address we want to bond with
    */
   void CreateBond(hci::AddressWithType address);
 
   /**
+   * Initiates bond over Classic transport with device, if not bonded yet.
+   *
+   * This will initiate the Out of Band bonding method
+   *
+   * @param address device address we want to bond with
+   * @param remote_p192_oob_data comparison and random for p192
+   * @param remote_p256_oob_data comparison and random for p256
+   */
+  void CreateBondOutOfBand(
+      hci::AddressWithType address, pairing::OobData remote_p192_oob_data, pairing::OobData remote_p256_oob_data);
+
+  /**
    * Initiates bond over Low Energy transport with device, if not bonded yet.
    *
    * @param address device address we want to bond with