nimble/att: Support "Insufficient Encryption Key Size" error code
Access to attributes which require minimum key size on a link encrypted with shorter encryption key shall fail with "Insufficient Encryption Key Size" error code. Reference: Bluetooth Specification 4.2, Vol. 3, Part C, Section 10.3.1 Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/7fd14c4e Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7fd14c4e Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7fd14c4e Branch: refs/heads/develop Commit: 7fd14c4e2b89a7006a4759e0407aca1498cac2f0 Parents: 4ce5761 Author: Andrzej Kaczmarek <[email protected]> Authored: Sat Dec 31 22:18:48 2016 +0100 Committer: Andrzej Kaczmarek <[email protected]> Committed: Wed Jan 4 14:14:24 2017 +0100 ---------------------------------------------------------------------- net/nimble/host/src/ble_att_svr.c | 5 +++++ 1 file changed, 5 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7fd14c4e/net/nimble/host/src/ble_att_svr.c ---------------------------------------------------------------------- diff --git a/net/nimble/host/src/ble_att_svr.c b/net/nimble/host/src/ble_att_svr.c index 9e0724d..cdd02a8 100644 --- a/net/nimble/host/src/ble_att_svr.c +++ b/net/nimble/host/src/ble_att_svr.c @@ -324,6 +324,11 @@ ble_att_svr_check_perms(uint16_t conn_handle, int is_read, return BLE_HS_ATT_ERR(*out_att_err); } + if (entry->ha_min_key_size > sec_state.key_size) { + *out_att_err = BLE_ATT_ERR_INSUFFICIENT_KEY_SZ; + return BLE_HS_ATT_ERR(*out_att_err); + } + if (author) { /* XXX: Prompt user for authorization. */ }
