From 50dcc63caa3a0867b9cf31676e8d0b92e2c26de3 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Sat, 19 Jun 2021 18:04:49 +0200 Subject: [PATCH] gap: reject pin code request if secure connections only mode is active --- src/hci.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/hci.c b/src/hci.c index 3a500636f..3d913de04 100644 --- a/src/hci.c +++ b/src/hci.c @@ -2734,13 +2734,20 @@ static void event_handler(uint8_t *packet, uint16_t size){ if (!conn) break; hci_pairing_started(conn, false); - // non-bondable mode: pin code negative reply will be sent (event is not forwarded to app) - if (!hci_stack->bondable){ + // abort pairing if: non-bondable mode (event is not forwarded to app) + if (!hci_stack->bondable ){ conn->authentication_flags |= AUTH_FLAG_DENY_PIN_CODE_REQUEST; hci_pairing_complete(conn, ERROR_CODE_PAIRING_NOT_ALLOWED); hci_run(); return; } + // abort pairing if: Secure Connections Only mode (event is not forwarded to app) + if (hci_stack->gap_secure_connections_only_mode){ + conn->authentication_flags |= AUTH_FLAG_DENY_PIN_CODE_REQUEST; + hci_pairing_complete(conn, ERROR_CODE_INSUFFICIENT_SECURITY); + hci_run(); + return; + } break; case HCI_EVENT_IO_CAPABILITY_RESPONSE: