From d2c5cd2f1fdd7e1f11ad56afcf2d4f66e6ab2e75 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 22 Jan 2025 19:41:07 +0100 Subject: [PATCH] hci: encryption_key_type tracks link key of current encryption --- src/hci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hci.c b/src/hci.c index d5da6ffd2..eff8d787b 100644 --- a/src/hci.c +++ b/src/hci.c @@ -4168,9 +4168,6 @@ static void event_handler(uint8_t *packet, uint16_t size){ #ifdef ENABLE_CLASSIC else { - // Encryption has been enabled with link key stored in connection, track link key type - conn->encryption_key_type = conn->link_key_type; - // Detect Secure Connection -> Legacy Connection Downgrade Attack (BIAS) bool sc_used_during_pairing = gap_secure_connection_for_link_key_type(conn->encryption_key_type); bool connected_uses_aes_ccm = encryption_enabled == 2; @@ -4197,6 +4194,9 @@ static void event_handler(uint8_t *packet, uint16_t size){ #endif } + // Encryption has been enabled with link key stored in connection, track link key type + conn->encryption_key_type = conn->link_key_type; + #ifdef ENABLE_MUTUAL_AUTHENTICATION_FOR_LEGACY_SECURE_CONNECTIONS // if AES-CCM is used, authentication used SC -> authentication was mutual and we can skip explicit authentication if (connected_uses_aes_ccm){