summaryrefslogtreecommitdiff
path: root/tools/rootcanal
diff options
context:
space:
mode:
author Jakub Pawlowski <jpawlowski@google.com> 2024-09-04 21:56:25 +0200
committer Jakub Pawłowski <jpawlowski@google.com> 2024-09-11 21:33:58 +0000
commitd269a647dac5f8434a5eefd2ccc2dafdb5c0795d (patch)
tree92285ca4930964dfe43a18014f85cdb4b056ad9f /tools/rootcanal
parentdbacea0f8c8d6649196fbbcff99f73d1fe6e80ae (diff)
Encryption Change V2
Bug: 365846652 Bug: 366018699 Test: mma -j32 Flag: encryption_change_v2 Change-Id: I387b0df153e7dcf7d02a460e182ef12523509a42
Diffstat (limited to 'tools/rootcanal')
-rw-r--r--tools/rootcanal/model/controller/link_layer_controller.cc18
-rw-r--r--tools/rootcanal/packets/hci_packets.pdl8
2 files changed, 23 insertions, 3 deletions
diff --git a/tools/rootcanal/model/controller/link_layer_controller.cc b/tools/rootcanal/model/controller/link_layer_controller.cc
index 047ea9c96e..e793ac16e3 100644
--- a/tools/rootcanal/model/controller/link_layer_controller.cc
+++ b/tools/rootcanal/model/controller/link_layer_controller.cc
@@ -83,8 +83,16 @@ AddressWithType PeerIdentityAddress(Address address, PeerAddressType peer_addres
}
bool LinkLayerController::IsEventUnmasked(EventCode event) const {
- uint64_t bit = UINT64_C(1) << (static_cast<uint8_t>(event) - 1);
- return (event_mask_ & bit) != 0;
+ uint8_t evt = static_cast<uint8_t>(event);
+
+ if (evt <= 64) {
+ uint64_t bit = UINT64_C(1) << (evt - 1);
+ return (event_mask_ & bit) != 0;
+ } else {
+ evt -= 64;
+ uint64_t bit = UINT64_C(1) << (evt - 1);
+ return (event_mask_page_2_ & bit) != 0;
+ }
}
bool LinkLayerController::IsLeEventUnmasked(SubeventCode subevent) const {
@@ -5638,7 +5646,11 @@ ErrorCode LinkLayerController::LeLongTermKeyRequestReply(uint16_t handle,
}
} else {
connections_.Encrypt(handle);
- if (IsEventUnmasked(EventCode::ENCRYPTION_CHANGE)) {
+ if (IsEventUnmasked(EventCode::ENCRYPTION_CHANGE_V2)) {
+ send_event_(bluetooth::hci::EncryptionChangeV2Builder::Create(
+ ErrorCode::SUCCESS, handle, bluetooth::hci::EncryptionEnabled::ON,
+ 0x10 /* key_size */));
+ } else if (IsEventUnmasked(EventCode::ENCRYPTION_CHANGE)) {
send_event_(bluetooth::hci::EncryptionChangeBuilder::Create(
ErrorCode::SUCCESS, handle, bluetooth::hci::EncryptionEnabled::ON));
}
diff --git a/tools/rootcanal/packets/hci_packets.pdl b/tools/rootcanal/packets/hci_packets.pdl
index 2b404bdff1..6cb90fea7f 100644
--- a/tools/rootcanal/packets/hci_packets.pdl
+++ b/tools/rootcanal/packets/hci_packets.pdl
@@ -749,6 +749,7 @@ enum EventCode : 8 {
REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION = 0x3D,
LE_META_EVENT = 0x3e,
NUMBER_OF_COMPLETED_DATA_BLOCKS = 0x48,
+ ENCRYPTION_CHANGE_V2 = 0x59,
VENDOR_SPECIFIC = 0xFF,
}
@@ -4767,6 +4768,13 @@ packet EncryptionChange : Event (event_code = ENCRYPTION_CHANGE) {
encryption_enabled : EncryptionEnabled,
}
+packet EncryptionChangeV2 : Event (event_code = ENCRYPTION_CHANGE_V2) {
+ status : ErrorCode,
+ connection_handle : 12,
+ _reserved_ : 4,
+ encryption_enabled : EncryptionEnabled,
+ key_size : 8,
+}
packet ChangeConnectionLinkKeyComplete : Event (event_code = CHANGE_CONNECTION_LINK_KEY_COMPLETE) {
status : ErrorCode,
connection_handle : 12,