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

Commit c236c1f8 authored by Martin Brabham's avatar Martin Brabham
Browse files

Cert: Add API for enforce_security_policy to the facade

Bug: 145638034
Test: cert/run --host --test_filter=SecurityTest
Tag: #gd-refactor
Change-Id: I798e957f0ff5ec0c78c53e9d919e69aed6474fe5
parent 31b5e6ff
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -148,7 +148,10 @@ class PySecurity(Closable):
        """
            Call to enforce classic security policy
        """
        pass
        self._device.security.EnforceSecurityPolicy(
            SecurityPolicyMessage(
                address=common.BluetoothAddressWithType(address=common.BluetoothAddress(address=address), type=type),
                policy=policy))

    def close(self):
        if self._ui_event_stream is not None:
+12 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#include "grpc/grpc_event_queue.h"
#include "hci/address_with_type.h"
#include "l2cap/classic/security_policy.h"
#include "os/handler.h"
#include "security/facade.grpc.pb.h"
#include "security/security_manager_listener.h"
@@ -147,6 +148,17 @@ class SecurityModuleFacadeService : public SecurityModuleFacade::Service, public
    return ::grpc::Status::OK;
  }

  ::grpc::Status EnforceSecurityPolicy(
      ::grpc::ServerContext* context,
      const SecurityPolicyMessage* 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());
    hci::AddressWithType peer_with_type(peer, peer_type);
    return ::grpc::Status::OK;
  }

  void DisplayPairingPrompt(const bluetooth::hci::AddressWithType& peer, std::string name) {
    LOG_INFO("%s", peer.ToString().c_str());
    UiMsg display_yes_no;
+7 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ package bluetooth.security;

import "google/protobuf/empty.proto";
import "facade/common.proto";
import "l2cap/classic/facade.proto";

service SecurityModuleFacade {
  rpc CreateBond(facade.BluetoothAddressWithType) returns (google.protobuf.Empty) {}
@@ -18,6 +19,7 @@ service SecurityModuleFacade {
  rpc SendUiCallback(UiCallbackMsg) returns (google.protobuf.Empty) {}
  rpc FetchUiEvents(google.protobuf.Empty) returns (stream UiMsg) {}
  rpc FetchBondEvents(google.protobuf.Empty) returns (stream BondMsg) {}
  rpc EnforceSecurityPolicy(SecurityPolicyMessage) returns (google.protobuf.Empty) {}
}

enum UiMsgType {
@@ -106,3 +108,8 @@ enum OobDataPresent {
message OobDataMessage {
  OobDataPresent data_present = 1;
}

message SecurityPolicyMessage {
  facade.BluetoothAddressWithType address = 1;
  l2cap.classic.ClassicSecurityPolicy policy = 2;
}