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

Commit e05c7d38 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

SecurityRecord: naming and comments clarification

Change-Id: I1de20bb38d76d1dfd91d6f16e0909d7db7561203
parent 55056992
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -28,30 +28,31 @@ namespace bluetooth {
namespace security {
namespace record {

enum BondState { NOT_BONDED, PAIRING, PAIRED, BONDED };
enum BondState {
  /* CreateBond was called, or remote send Pairing Request */
  PAIRING,
  /* Link key has been exchanged, but not stored */
  PAIRED,
  /* Link Keys are stored persistently */
  BONDED
};

class SecurityRecord {
 public:
  explicit SecurityRecord(hci::AddressWithType address) : pseudo_address_(address), state_(NOT_BONDED) {}
  explicit SecurityRecord(hci::AddressWithType address) : pseudo_address_(address), state_(PAIRING) {}

  /**
   * Returns true if the device is bonded to another device
   * Returns true if Link Keys are stored persistently
   */
  bool IsBonded() {
    return state_ == BONDED;
  }

  /* Link key has been exchanged, but not stored */
  bool IsPaired() {
    return state_ == PAIRED;
  }

  /**
   * Returns true if a device is currently pairing to another device
   */
  bool IsPairing() {
    return state_ == PAIRING;
  }

  void SetLinkKey(std::array<uint8_t, 16> link_key, hci::KeyType key_type) {
    link_key_ = link_key;
    key_type_ = key_type;