nimble/sm: Fix AuthReq/KeyDist validation in pairing req/rsp

The reserved bits in AuthReq and key distribution flags shall be
ignored on reception thus non-zero values do not make pairing command
invalid. This is to ensure compatibility with future specs.

This fixes following PTS test cases for SM:
- TP/JW/BI-03-C
- TP/JW/BI-04-C

Reference:
Bluetooth Specification 4.2, Vol 3, Part H, Section 3.5.2
Bluetooth Specification 4.2, Vol 3, Part H, Section 3.6.1

X-Original-Commit: 9627249a1fd3ce031fdca821646692adb9ebe31a
This commit is contained in:
Andrzej Kaczmarek
2016-12-12 23:58:47 +01:00
parent 724e41d3fc
commit 29c4294df6
-12
View File
@@ -101,24 +101,12 @@ ble_sm_pair_cmd_is_valid(struct ble_sm_pair_cmd *cmd)
return 0;
}
if (cmd->authreq & BLE_SM_PAIR_AUTHREQ_RESERVED) {
return 0;
}
if (cmd->max_enc_key_size < BLE_SM_PAIR_KEY_SZ_MIN ||
cmd->max_enc_key_size > BLE_SM_PAIR_KEY_SZ_MAX) {
return 0;
}
if (cmd->init_key_dist & BLE_SM_PAIR_KEY_DIST_RESERVED) {
return 0;
}
if (cmd->resp_key_dist & BLE_SM_PAIR_KEY_DIST_RESERVED) {
return 0;
}
return 1;
}