Bluetooth: Add SMP encryption key check
Fixes PTS test case TC_EKS_BI_02_C sending correct failed reply to wrong key size. ... > ACL Data RX: Handle 64 flags 0x02 dlen 11 SMP: Pairing Request (0x01) len 6 IO capability: KeyboardDisplay (0x04) OOB data: Authentication data not present (0x00) Authentication requirement: No bonding, No MITM, Legacy, No Keypresses (0x00) Max encryption key size: 6 Initiator key distribution: <none> (0x00) Responder key distribution: <none> (0x00) < ACL Data TX: Handle 64 flags 0x00 dlen 6 SMP: Pairing Failed (0x05) len 1 Reason: Encryption key size (0x06) ... Change-Id: I1c02cbc03d1aaf6221d7a6ddfd9bc7ab30ca9586 Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
0aadf6ce69
commit
82c913d53c
1 changed files with 6 additions and 1 deletions
|
@ -89,6 +89,11 @@ static int smp_pairing_req(struct bt_conn *conn, struct bt_buf *buf)
|
|||
if (!rsp_buf)
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
|
||||
if ((req->max_key_size > BT_SMP_MAX_ENC_KEY_SIZE) ||
|
||||
(req->max_key_size < BT_SMP_MIN_ENC_KEY_SIZE)) {
|
||||
return BT_SMP_ERR_ENC_KEY_SIZE;
|
||||
}
|
||||
|
||||
rsp = (void *)bt_buf_add(rsp_buf, sizeof(*rsp));
|
||||
|
||||
/* For JustWorks pairing simplify rsp parameters.
|
||||
|
@ -97,7 +102,7 @@ static int smp_pairing_req(struct bt_conn *conn, struct bt_buf *buf)
|
|||
rsp->auth_req = req->auth_req;
|
||||
rsp->io_capability = BT_SMP_IO_NO_INPUT_OUTPUT;
|
||||
rsp->oob_flag = BT_SMP_OOB_NOT_PRESENT;
|
||||
rsp->max_key_size = BT_SMP_MAX_ENC_KEY_SIZE;
|
||||
rsp->max_key_size = req->max_key_size;
|
||||
rsp->init_key_dist = 0;
|
||||
rsp->resp_key_dist = 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue