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

Commit 334b5d09 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "gd: Default to rotating addresses"

parents f7cd98b2 34953224
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include "gd/hci/controller.h"
#include "gd/hci/le_advertising_manager.h"
#include "gd/packet/packet_view.h"
#include "gd/storage/storage_module.h"
#include "main/shim/entry.h"

#include "ble_advertiser.h"
@@ -54,11 +55,15 @@ class BleAdvertiserInterfaceImpl : public BleAdvertiserInterface,
        !bluetooth::common::init_flags::gd_acl_is_enabled()) {
      // Set private policy
      auto address = bluetooth::shim::GetController()->GetMacAddress();
      auto storage = bluetooth::shim::GetStorage();
      auto adapter_config = storage->GetAdapterConfig();
      auto irk_bytes = adapter_config.GetLeIdentityResolvingKey();
      std::array<uint8_t, 16> irk{0};
      std::copy_n(irk.begin(), 16, irk_bytes->data());
      bluetooth::hci::AddressWithType address_with_type(
          address, bluetooth::hci::AddressType::PUBLIC_DEVICE_ADDRESS);
      bluetooth::crypto_toolbox::Octet16 irk = {};
      auto minimum_rotation_time = std::chrono::milliseconds(7 * 60 * 1000);
      auto maximum_rotation_time = std::chrono::milliseconds(15 * 60 * 1000);
      auto minimum_rotation_time = std::chrono::minutes(7);
      auto maximum_rotation_time = std::chrono::minutes(15);
      bluetooth::shim::GetAclManager()->SetPrivacyPolicyForInitiatorAddress(
          bluetooth::hci::LeAddressManager::AddressPolicy::USE_PUBLIC_ADDRESS,
          address_with_type, irk, minimum_rotation_time, maximum_rotation_time);
@@ -364,11 +369,6 @@ class BleAdvertiserInterfaceImpl : public BleAdvertiserInterface,
    } else {
      config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
    }

    if (!bluetooth::common::init_flags::gd_security_is_enabled()) {
      // use public address for testing
      config.own_address_type = OwnAddressType::PUBLIC_DEVICE_ADDRESS;
    }
  }
};