gap: reject pin code request if secure connections only mode is active

This commit is contained in:
Matthias Ringwald 2021-06-19 18:04:49 +02:00
parent b54464ca65
commit 50dcc63caa

View File

@ -2734,13 +2734,20 @@ static void event_handler(uint8_t *packet, uint16_t size){
if (!conn) break; if (!conn) break;
hci_pairing_started(conn, false); hci_pairing_started(conn, false);
// non-bondable mode: pin code negative reply will be sent (event is not forwarded to app) // abort pairing if: non-bondable mode (event is not forwarded to app)
if (!hci_stack->bondable){ if (!hci_stack->bondable ){
conn->authentication_flags |= AUTH_FLAG_DENY_PIN_CODE_REQUEST; conn->authentication_flags |= AUTH_FLAG_DENY_PIN_CODE_REQUEST;
hci_pairing_complete(conn, ERROR_CODE_PAIRING_NOT_ALLOWED); hci_pairing_complete(conn, ERROR_CODE_PAIRING_NOT_ALLOWED);
hci_run(); hci_run();
return; 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; break;
case HCI_EVENT_IO_CAPABILITY_RESPONSE: case HCI_EVENT_IO_CAPABILITY_RESPONSE: