diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2014-06-06 08:33:30 -0400 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2014-12-03 10:51:18 -0500 |
commit | 6c0dcc5014caeb9c39db816a7e0169255923ccba (patch) | |
tree | f7d796382de99f7e7f80c320d2c51b6ac4c113df /net/bluetooth/smp.c | |
parent | aeb7d461f9c895bb6d09e9d175696849e9f290c8 (diff) |
Bluetooth: Add check for accidentally generating a debug key
It is very unlikely, but to have a 100% guarantee of the generated key
type we need to reject any keys which happen to match the debug key.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/smp.c')
-rw-r--r-- | net/bluetooth/smp.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index ddc76cf45cfb..63d5ba7774e0 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
@@ -1399,9 +1399,17 @@ static u8 sc_send_public_key(struct smp_chan *smp) | |||
1399 | { | 1399 | { |
1400 | BT_DBG(""); | 1400 | BT_DBG(""); |
1401 | 1401 | ||
1402 | /* Generate local key pair for Secure Connections */ | 1402 | while (true) { |
1403 | if (!ecc_make_key(smp->local_pk, smp->local_sk)) | 1403 | /* Generate local key pair for Secure Connections */ |
1404 | return SMP_UNSPECIFIED; | 1404 | if (!ecc_make_key(smp->local_pk, smp->local_sk)) |
1405 | return SMP_UNSPECIFIED; | ||
1406 | |||
1407 | /* This is unlikely, but we need to check that we didn't | ||
1408 | * accidentially generate a debug key. | ||
1409 | */ | ||
1410 | if (memcmp(smp->local_sk, debug_sk, 32)) | ||
1411 | break; | ||
1412 | } | ||
1405 | 1413 | ||
1406 | BT_DBG("Local Public Key X: %32phN", smp->local_pk); | 1414 | BT_DBG("Local Public Key X: %32phN", smp->local_pk); |
1407 | BT_DBG("Local Public Key Y: %32phN", &smp->local_pk[32]); | 1415 | BT_DBG("Local Public Key Y: %32phN", &smp->local_pk[32]); |