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

@ -146,6 +146,17 @@ struct bt_conn_cb {
*/
void bt_conn_cb_register(struct bt_conn_cb *cb);
/** @brief Get encryption key size.
*
* This function gets encryption key size.
* If there is no security (encryption) enabled 0 will be returned.
*
* @param conn Existing connection object.
*
* @return Encryption key size.
*/
uint8_t bt_conn_enc_key_size(struct bt_conn *conn);
#if defined(CONFIG_BLUETOOTH_CENTRAL)
/** @brief Automatically connect to remote device if it's in range.
*