From c5be342b23e96c81d70771de2ec6c5607c0b6e30 Mon Sep 17 00:00:00 2001 From: Chinmay Chhajed Date: Wed, 1 Sep 2021 15:28:01 +0530 Subject: [PATCH] Compare only X component of public key to avoid impersonation attack. --- nimble/host/src/ble_sm_sc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nimble/host/src/ble_sm_sc.c b/nimble/host/src/ble_sm_sc.c index 333310702..8614e8652 100644 --- a/nimble/host/src/ble_sm_sc.c +++ b/nimble/host/src/ble_sm_sc.c @@ -611,9 +611,9 @@ ble_sm_sc_public_key_rx(uint16_t conn_handle, struct os_mbuf **om, } cmd = (struct ble_sm_public_key *)(*om)->om_data; - /* Check if the peer public key is same as our generated public key. - * Return fail if the public keys match. */ - if (memcmp(cmd, ble_sm_sc_pub_key, 64) == 0) { + /* Check if the X component of peer public key is same as X + * component of our generated public key. Return fail if they match. */ + if (memcmp(cmd->x, ble_sm_sc_pub_key, 32) == 0) { res->enc_cb = 1; res->sm_err = BLE_SM_ERR_AUTHREQ; return;