Bluetooth: Move le_start_encryption to conn.c
Change-Id: Id9c042663e6f58aba6ec34165b7b244650317969 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
a33047f7a5
commit
5f33744a4c
5 changed files with 30 additions and 30 deletions
|
@ -459,9 +459,9 @@ int bt_security(struct bt_conn *conn, bt_security_t sec)
|
|||
|
||||
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);
|
||||
return bt_conn_le_start_encryption(conn, keys->ltk.rand,
|
||||
keys->ltk.ediv,
|
||||
keys->ltk.val);
|
||||
}
|
||||
|
||||
return bt_smp_send_pairing_req(conn);
|
||||
|
@ -567,3 +567,23 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer)
|
|||
|
||||
return conn;
|
||||
}
|
||||
|
||||
int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand,
|
||||
uint16_t ediv, const uint8_t *ltk)
|
||||
{
|
||||
struct bt_hci_cp_le_start_encryption *cp;
|
||||
struct bt_buf *buf;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_START_ENCRYPTION, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = bt_buf_add(buf, sizeof(*cp));
|
||||
cp->handle = sys_cpu_to_le16(conn->handle);
|
||||
cp->rand = rand;
|
||||
cp->ediv = ediv;
|
||||
memcpy(cp->ltk, ltk, sizeof(cp->ltk));
|
||||
|
||||
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_START_ENCRYPTION, buf, NULL);
|
||||
}
|
||||
|
|
|
@ -106,3 +106,7 @@ struct bt_conn *bt_conn_lookup_state(const bt_addr_le_t *peer,
|
|||
|
||||
/* Set connection object in certain state and perform action related to state */
|
||||
void bt_conn_set_state(struct bt_conn *conn, bt_conn_state_t state);
|
||||
|
||||
/* rand and ediv should be in BT order */
|
||||
int bt_conn_le_start_encryption(struct bt_conn *conn, uint64_t rand,
|
||||
uint16_t ediv, const uint8_t *ltk);
|
||||
|
|
|
@ -1557,23 +1557,3 @@ int bt_hci_le_conn_update(uint16_t handle, uint16_t min, uint16_t max,
|
|||
|
||||
return bt_hci_cmd_send(BT_HCI_OP_LE_CONN_UPDATE, buf);
|
||||
}
|
||||
|
||||
int bt_hci_le_start_encryption(uint16_t handle, uint64_t rand, uint16_t ediv,
|
||||
const uint8_t *ltk)
|
||||
{
|
||||
struct bt_hci_cp_le_start_encryption *cp;
|
||||
struct bt_buf *buf;
|
||||
|
||||
buf = bt_hci_cmd_create(BT_HCI_OP_LE_START_ENCRYPTION, sizeof(*cp));
|
||||
if (!buf) {
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
cp = bt_buf_add(buf, sizeof(*cp));
|
||||
cp->handle = sys_cpu_to_le16(handle);
|
||||
cp->rand = rand;
|
||||
cp->ediv = ediv;
|
||||
memcpy(cp->ltk, ltk, sizeof(cp->ltk));
|
||||
|
||||
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_START_ENCRYPTION, buf, NULL);
|
||||
}
|
||||
|
|
|
@ -162,8 +162,4 @@ const char *bt_addr_le_str(const bt_addr_le_t *addr);
|
|||
int bt_hci_le_conn_update(uint16_t handle, uint16_t min, uint16_t max,
|
||||
uint16_t latency, uint16_t timeout);
|
||||
|
||||
/* rand and ediv should be in BT order */
|
||||
int bt_hci_le_start_encryption(uint16_t handle, uint64_t rand, uint16_t ediv,
|
||||
const uint8_t *ltk);
|
||||
|
||||
int bt_le_scan_update(void);
|
||||
|
|
|
@ -595,7 +595,7 @@ static uint8_t smp_pairing_random(struct bt_conn *conn, struct bt_buf *buf)
|
|||
}
|
||||
|
||||
/* Rand and EDiv are 0 for the STK */
|
||||
if (bt_hci_le_start_encryption(conn->handle, 0, 0, stk)) {
|
||||
if (bt_conn_le_start_encryption(conn, 0, 0, stk)) {
|
||||
BT_ERR("Failed to start encryption\n");
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
@ -847,8 +847,8 @@ static uint8_t smp_security_request(struct bt_conn *conn, struct bt_buf *buf)
|
|||
goto pair;
|
||||
}
|
||||
|
||||
if (bt_hci_le_start_encryption(conn->handle, keys->ltk.rand,
|
||||
keys->ltk.ediv, keys->ltk.val) < 0) {
|
||||
if (bt_conn_le_start_encryption(conn, keys->ltk.rand, keys->ltk.ediv,
|
||||
keys->ltk.val) < 0) {
|
||||
return BT_SMP_ERR_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue