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

Commit aa5befb4 authored by Martin Brabham's avatar Martin Brabham Committed by Automerger Merge Worker
Browse files

Security Facade: Implement CreateBondOutOfBand am: ca07cae6 am: 84e8886c

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1502234

Change-Id: I8a34d5235616210a55e795438688815b45717e64
parents 8bcc827a 84e8886c
Loading
Loading
Loading
Loading
+34 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include "l2cap/le/l2cap_le_module.h"
#include "os/handler.h"
#include "security/facade.grpc.pb.h"
#include "security/pairing/oob_data.h"
#include "security/security_manager_listener.h"
#include "security/security_module.h"
#include "security/ui.h"
@@ -93,11 +94,43 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
                            ::google::protobuf::Empty* response) override {
    hci::Address peer;
    ASSERT(hci::Address::FromString(request->address().address(), peer));
    hci::AddressType peer_type = hci::AddressType::PUBLIC_DEVICE_ADDRESS;
    hci::AddressType peer_type = static_cast<hci::AddressType>(request->type());
    security_module_->GetSecurityManager()->CreateBond(hci::AddressWithType(peer, peer_type));
    return ::grpc::Status::OK;
  }

  ::grpc::Status CreateBondOutOfBand(
      ::grpc::ServerContext* context,
      const ::bluetooth::security::OobDataBondMessage* request,
      ::google::protobuf::Empty* response) override {
    hci::Address peer;
    ASSERT(hci::Address::FromString(request->address().address().address(), peer));
    hci::AddressType peer_type = static_cast<hci::AddressType>(request->address().type());
    pairing::SimplePairingHash c;
    pairing::SimplePairingRandomizer r;
    std::copy(
        std::begin(request->p192_data().le_sc_confirmation_value()),
        std::end(request->p192_data().le_sc_confirmation_value()),
        c.data());
    std::copy(
        std::begin(request->p192_data().le_sc_random_value()),
        std::end(request->p192_data().le_sc_random_value()),
        r.data());
    pairing::OobData p192_data(c, r);
    std::copy(
        std::begin(request->p256_data().le_sc_confirmation_value()),
        std::end(request->p256_data().le_sc_confirmation_value()),
        c.data());
    std::copy(
        std::begin(request->p256_data().le_sc_random_value()),
        std::end(request->p256_data().le_sc_random_value()),
        r.data());
    pairing::OobData p256_data(c, r);
    security_module_->GetSecurityManager()->CreateBondOutOfBand(
        hci::AddressWithType(peer, peer_type), p192_data, p256_data);
    return ::grpc::Status::OK;
  }

  ::grpc::Status CreateBondLe(::grpc::ServerContext* context, const facade::BluetoothAddressWithType* request,
                              ::google::protobuf::Empty* response) override {
    hci::Address peer;