Bluetooth: BR/EDR: Initiate encryption on link
Adds method to start encrypting the link by local controller. Encryption implies successful authentication to be done before. > HCI Event: Auth Complete (0x06) plen 3 Status: Success (0x00) Handle: 11 < HCI Command: Set Connection Encryption (0x01|0x0013) plen 3 Handle: 11 Encryption: Enabled (0x01) > HCI Event: Command Status (0x0f) plen 4 Set Connection Encryption (0x01|0x0013) ncmd 1 Status: Success (0x00) > HCI Event: Encryption Change (0x08) plen 4 Status: Success (0x00) Handle: 11 Encryption: Enabled with E0 (0x01) Change-Id: I3bbfc6ca77a6fd088582ab45f14d7c122aec7f05 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This commit is contained in:
parent
99483fded6
commit
bf62dfad70
|
@ -262,6 +262,12 @@ struct bt_hci_cp_auth_requested {
|
|||
uint16_t handle;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_SET_CONN_ENCRYPT BT_OP(BT_OGF_LINK_CTRL, 0x0013)
|
||||
struct bt_hci_cp_set_conn_encrypt {
|
||||
uint16_t handle;
|
||||
uint8_t encrypt;
|
||||
} __packed;
|
||||
|
||||
#define BT_HCI_OP_REMOTE_NAME_REQUEST BT_OP(BT_OGF_LINK_CTRL, 0x0019)
|
||||
struct bt_hci_cp_remote_name_request {
|
||||
bt_addr_t bdaddr;
|
||||
|
|
|
@ -1708,6 +1708,26 @@ check_names:
|
|||
discovery_results_count = 0;
|
||||
}
|
||||
|
||||
static void link_encr(const uint16_t handle)
|
||||
{
|
||||
struct bt_hci_cp_set_conn_encrypt *encr;
|
||||
struct net_buf *buf;
|
||||
|
||||
BT_DBG("");
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_SET_CONN_ENCRYPT, sizeof(*encr));
|
||||
if (!buf) {
|
||||
BT_ERR("Out of command buffers");
|
||||
return;
|
||||
}
|
||||
|
||||
encr = net_buf_add(buf, sizeof(*encr));
|
||||
encr->handle = sys_cpu_to_le16(handle);
|
||||
encr->encrypt = 0x01;
|
||||
|
||||
bt_hci_cmd_send_sync(BT_HCI_OP_SET_CONN_ENCRYPT, buf, NULL);
|
||||
}
|
||||
|
||||
static void auth_complete(struct net_buf *buf)
|
||||
{
|
||||
struct bt_hci_evt_auth_complete *evt = (void *)buf->data;
|
||||
|
@ -1732,6 +1752,8 @@ static void auth_complete(struct net_buf *buf)
|
|||
|
||||
/* Reset required security level to current operational */
|
||||
conn->required_sec_level = conn->sec_level;
|
||||
} else {
|
||||
link_encr(handle);
|
||||
}
|
||||
|
||||
bt_conn_unref(conn);
|
||||
|
|
Loading…
Reference in New Issue