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

Commit 9e9d8b08 authored by Marvin Younan's avatar Marvin Younan Committed by Gerrit Code Review
Browse files

Merge "Revert "RootCanal: Tie the random number generator to the dual mode controller instance""

parents f9250172 cc83b6d2
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

#include <algorithm>
#include <memory>
#include <random>

#include "crypto/crypto.h"
#include "log.h"
@@ -2245,12 +2246,17 @@ void DualModeController::LeEncrypt(CommandView command) {
      kNumCommandPackets, ErrorCode::SUCCESS, encrypted_data));
}

static std::random_device rd{};
static std::mt19937_64 s_mt{rd()};

void DualModeController::LeRand(CommandView command) {
  auto command_view = bluetooth::hci::LeRandView::Create(command);
  ASSERT(command_view.IsValid());

  uint64_t random_val = s_mt();

  send_event_(bluetooth::hci::LeRandCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, random_generator_()));
      kNumCommandPackets, ErrorCode::SUCCESS, random_val));
}

void DualModeController::LeReadSupportedStates(CommandView command) {
+1 −4
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@

#include <cstdint>
#include <memory>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
@@ -563,6 +562,7 @@ class DualModeController : public Device {
  void WriteConnectionAcceptTimeout(CommandView command);

  // Vendor-specific Commands

  void LeGetVendorCapabilities(CommandView command);
  void LeEnergyInfo(CommandView command);
  void LeMultiAdv(CommandView command);
@@ -606,9 +606,6 @@ class DualModeController : public Device {
  // with RootCanal.
  bluetooth::hci::LoopbackMode loopback_mode_{LoopbackMode::NO_LOOPBACK};

  // Random value generator, always seeded with 0 to be deterministic.
  std::mt19937_64 random_generator_{0};

  // Flag set to true after the HCI Reset command has been received
  // the first time.
  bool controller_reset_{false};