bthost: Always use conn->prnd for Pairing Random
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 17 Dec 2020 18:24:47 +0000 (10:24 -0800)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:34 +0000 (19:08 +0530)
Since it is now properly set with random bytes it shall be used when
responding.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
emulator/smp.c

index f339e15..db0065d 100755 (executable)
@@ -508,7 +508,8 @@ static void pairing_cfm(struct smp_conn *conn, const void *data, uint16_t len)
 
        if (conn->out) {
                memset(rsp, 0, sizeof(rsp));
-               smp_send(conn, BT_L2CAP_SMP_PAIRING_RANDOM, rsp, sizeof(rsp));
+               smp_send(conn, BT_L2CAP_SMP_PAIRING_RANDOM, conn->prnd,
+                                       sizeof(conn->prnd));
        } else {
                bt_crypto_c1(conn->smp->crypto, conn->tk, conn->prnd,
                                conn->prsp, conn->preq, conn->ia_type,
@@ -545,8 +546,6 @@ static uint8_t sc_random(struct smp_conn *conn)
 
 static void pairing_rnd(struct smp_conn *conn, const void *data, uint16_t len)
 {
-       uint8_t rsp[16];
-
        memcpy(conn->rrnd, data + 1, 16);
 
        if (conn->sc) {
@@ -563,8 +562,8 @@ static void pairing_rnd(struct smp_conn *conn, const void *data, uint16_t len)
        if (conn->out)
                return;
 
-       memset(rsp, 0, sizeof(rsp));
-       smp_send(conn, BT_L2CAP_SMP_PAIRING_RANDOM, rsp, sizeof(rsp));
+       smp_send(conn, BT_L2CAP_SMP_PAIRING_RANDOM, conn->prnd,
+                               sizeof(conn->prnd));
 }
 
 static void encrypt_info(struct smp_conn *conn, const void *data, uint16_t len)