Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4962756b authored by Martin Brabham's avatar Martin Brabham
Browse files

SecurityManager: Add CreateBondOutOfBand interface.

Allow for creating bonds with remote Out of Band data.

Bug: 162984360
Tag: #gd-refactor
Test: cert/run --host SecurityTest
Change-Id: I6f6d85cc22fd5b1a1abf6b629ecdd37950b4d239
parent 9d029a47
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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()) {
+13 −0
Original line number Diff line number Diff line
@@ -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"
@@ -86,6 +87,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.
   *
+10 −0
Original line number Diff line number Diff line
@@ -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_),
+15 −0
Original line number Diff line number Diff line
@@ -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,10 +46,24 @@ 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.
   *