m_scanCallback = callback;
m_scanCallbackUserData = userData;
// Starting scan can fail for some time just after enabling the adapter, so retry it for 1s
- constexpr auto SLEEP_PERIOD_US = 10'000;
+ constexpr auto SLEEP_PERIOD_US = 10000;
for (int i = 0; i < 1'000'000 / SLEEP_PERIOD_US; ++i) {
err = bt_adapter_le_start_scan(ScanCallback, this);
if (err == BT_ERROR_OPERATION_FAILED) {
assert(innerCryptoData->eidKey.size() == 64);
auto serviceDataRaw = reinterpret_cast<const uint8_t *>(serviceData);
// Compute HMAC tag.
- auto hmacKey =
- CryptoBuffer(innerCryptoData->eidKey.begin() + 32, innerCryptoData->eidKey.end());
+ auto hmacKey = CryptoBuffer(innerCryptoData->eidKey.begin() + 32,
+ innerCryptoData->eidKey.end());
auto encryptedAdvert = CryptoBuffer(serviceDataRaw, serviceDataRaw + ADVERT_LEN);
auto hmac = Crypto::HmacSha256(hmacKey, encryptedAdvert);
// Check if the computed tag matches the advertised tag.
auto *encryptedAdvertTag = serviceDataRaw + ADVERT_LEN;
if (std::memcmp(hmac.data(), encryptedAdvertTag, ENCRYPTED_ADVERT_TAG_LEN) == 0) {
// Tag matches, decrypt.
- auto aesKey =
- CryptoBuffer(innerCryptoData->eidKey.begin(), innerCryptoData->eidKey.begin() + 32);
- innerCryptoData->decryptedAdvert = Crypto::DecryptAes256ECB(aesKey, encryptedAdvert);
+ auto aesKey = CryptoBuffer(innerCryptoData->eidKey.begin(),
+ innerCryptoData->eidKey.begin() + 32);
+ innerCryptoData->decryptedAdvert =
+ Crypto::DecryptAes256ECB(aesKey, encryptedAdvert);
return IBluetooth::Scanning::STOP;
}
} catch (const std::exception &e) {
constexpr size_t p256X962Length = 1 + 32 + 32;
if (peerHandshakeMessage.size() < p256X962Length)
THROW_UNKNOWN("invalid handshake response length: " << peerHandshakeMessage.size()
- << " expected: " << p256X962Length);
+ << " expected: " << p256X962Length);
auto peerPointBytes =
CryptoBuffer(peerHandshakeMessage.begin(), peerHandshakeMessage.begin() + p256X962Length);