l2cap: return 'ecbm all refused insufficient encryption' if encryption required but unencrypted

This commit is contained in:
Matthias Ringwald 2023-06-21 14:46:49 +02:00
parent 2052d96cc1
commit 7dd21e2481

View File

@ -3874,8 +3874,12 @@ static int l2cap_ecbm_signaling_handler_dispatch(hci_con_handle_t handle, uint16
}
// security: check encryption
// L2CAP.TS.p31 does not check for Connection refused - insufficient encryption which might be send for no encryption
if (service->required_security_level >= LEVEL_2) {
if (gap_encryption_key_size(handle) == 0){
l2cap_register_signaling_response(handle, L2CAP_CREDIT_BASED_CONNECTION_REQUEST, sig_id,
num_channels_and_signaling_cid, L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_INSUFFICIENT_ENCRYPTION);
return 1;
}
if (gap_encryption_key_size(handle) < 16) {
l2cap_register_signaling_response(handle, L2CAP_CREDIT_BASED_CONNECTION_REQUEST, sig_id,
num_channels_and_signaling_cid, L2CAP_ECBM_CONNECTION_RESULT_ALL_REFUSED_ENCYRPTION_KEY_SIZE_TOO_SHORT);