Commit 861580a9 authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

Bluetooth: Update smp_random to return a response code

Since we're now calling smp_random() "inline" we can have it directly
return a response code and have the shared command handler send the
response.
Signed-off-by: default avatarJohan Hedberg <johan.hedberg@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 4a74d658
...@@ -503,19 +503,17 @@ static void smp_confirm(struct smp_chan *smp) ...@@ -503,19 +503,17 @@ static void smp_confirm(struct smp_chan *smp)
smp_failure(conn, reason); smp_failure(conn, reason);
} }
static void smp_random(struct smp_chan *smp) static u8 smp_random(struct smp_chan *smp)
{ {
struct l2cap_conn *conn = smp->conn; struct l2cap_conn *conn = smp->conn;
struct hci_conn *hcon = conn->hcon; struct hci_conn *hcon = conn->hcon;
struct hci_dev *hdev = hcon->hdev; struct hci_dev *hdev = hcon->hdev;
struct crypto_blkcipher *tfm = hdev->tfm_aes; struct crypto_blkcipher *tfm = hdev->tfm_aes;
u8 reason, confirm[16]; u8 confirm[16];
int ret; int ret;
if (IS_ERR_OR_NULL(tfm)) { if (IS_ERR_OR_NULL(tfm))
reason = SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
goto error;
}
BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave"); BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
...@@ -528,15 +526,12 @@ static void smp_random(struct smp_chan *smp) ...@@ -528,15 +526,12 @@ static void smp_random(struct smp_chan *smp)
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
if (ret) { if (ret)
reason = SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
goto error;
}
if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) { if (memcmp(smp->pcnf, confirm, sizeof(smp->pcnf)) != 0) {
BT_ERR("Pairing failed (confirmation values mismatch)"); BT_ERR("Pairing failed (confirmation values mismatch)");
reason = SMP_CONFIRM_FAILED; return SMP_CONFIRM_FAILED;
goto error;
} }
if (hcon->out) { if (hcon->out) {
...@@ -549,10 +544,8 @@ static void smp_random(struct smp_chan *smp) ...@@ -549,10 +544,8 @@ static void smp_random(struct smp_chan *smp)
memset(stk + smp->enc_key_size, 0, memset(stk + smp->enc_key_size, 0,
SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size); SMP_MAX_ENC_KEY_SIZE - smp->enc_key_size);
if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags)) { if (test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &hcon->flags))
reason = SMP_UNSPECIFIED; return SMP_UNSPECIFIED;
goto error;
}
hci_le_start_enc(hcon, ediv, rand, stk); hci_le_start_enc(hcon, ediv, rand, stk);
hcon->enc_key_size = smp->enc_key_size; hcon->enc_key_size = smp->enc_key_size;
...@@ -574,10 +567,7 @@ static void smp_random(struct smp_chan *smp) ...@@ -574,10 +567,7 @@ static void smp_random(struct smp_chan *smp)
ediv, rand); ediv, rand);
} }
return; return 0;
error:
smp_failure(conn, reason);
} }
static struct smp_chan *smp_chan_create(struct l2cap_conn *conn) static struct smp_chan *smp_chan_create(struct l2cap_conn *conn)
...@@ -815,9 +805,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb) ...@@ -815,9 +805,7 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd)); memcpy(smp->rrnd, skb->data, sizeof(smp->rrnd));
skb_pull(skb, sizeof(smp->rrnd)); skb_pull(skb, sizeof(smp->rrnd));
smp_random(smp); return smp_random(smp);
return 0;
} }
static u8 smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level) static u8 smp_ltk_encrypt(struct l2cap_conn *conn, u8 sec_level)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment