Bluetooth: Add suport for enabling encryption
If LTK for connection is stored use it to start encryption instead of initiating pairing. Change-Id: Ia1322b028c1ed132c3678c4ff1b4cba1ada7f50d Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
This commit is contained in:
parent
a3dabad67b
commit
18c1b9d0a9
1 changed files with 11 additions and 4 deletions
|
@ -422,6 +422,8 @@ const bt_addr_le_t *bt_conn_get_dst(const struct bt_conn *conn)
|
|||
|
||||
int bt_security(struct bt_conn *conn, bt_security_t sec)
|
||||
{
|
||||
struct bt_keys *keys;
|
||||
|
||||
if (conn->state != BT_CONN_CONNECTED) {
|
||||
return -ENOTCONN;
|
||||
}
|
||||
|
@ -436,16 +438,21 @@ int bt_security(struct bt_conn *conn, bt_security_t sec)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (conn->encrypt) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (conn->role == BT_HCI_ROLE_SLAVE) {
|
||||
/* TODO Add Security Request support */
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (conn->encrypt) {
|
||||
return 0;
|
||||
keys = bt_keys_find(BT_KEYS_LTK, &conn->dst);
|
||||
if (keys) {
|
||||
return bt_hci_le_start_encryption(conn->handle, keys->ltk.rand,
|
||||
keys->ltk.ediv,
|
||||
keys->ltk.val);
|
||||
}
|
||||
|
||||
/* TODO check for master LTK */
|
||||
|
||||
return smp_send_pairing_req(conn);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue