Bluetooth: Add bt_conn_enc_key_size function

This patch adds bt_conn_enc_key_size function which will be used
by application to check encryption keys size of a encrypted connection.
This will be used especialy by GATT applications, because some
attributes to be accessed require encryption with specified
minimum encryption key length.

> ACL Data RX: Handle 64 flags 0x02 dlen 7         [hci0] 708547.536685
      ATT: Read Request (0x0a) len 2
        Handle: 0x0003
< ACL Data TX: Handle 64 flags 0x00 dlen 9         [hci0] 708547.544302
      ATT: Error Response (0x01) len 4
        Read Request (0x0a)
        Handle: 0x0003
        Error: Insufficient Encryption Key Size (0x0c)

Change-Id: Idbc9afde7ec80504898bd8d1e193f3e71a93f3f9
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2015-11-03 14:01:34 +01:00 committed by Anas Nashif
commit 992237bc51
3 changed files with 18 additions and 0 deletions

View file

@ -628,6 +628,8 @@ static uint8_t err_to_att(int err)
return BT_ATT_ERR_INVALID_OFFSET;
case -EFBIG:
return BT_ATT_ERR_INVALID_ATTRIBUTE_LEN;
case -EACCES:
return BT_ATT_ERR_ENCRYPTION_KEY_SIZE;
default:
return BT_ATT_ERR_UNLIKELY;
}