summaryrefslogtreecommitdiffstats
path: root/net/bluetooth/selftest.c
diff options
context:
space:
mode:
authorTudor Ambarus <tudor.ambarus@microchip.com>2017-09-28 10:14:55 -0400
committerMarcel Holtmann <marcel@holtmann.org>2017-10-06 14:35:47 -0400
commitc0153b0b901a16663ff91504fea25fb51d57cc29 (patch)
treec67d9808af8d276eaa5f92a021ae17d129cd5124 /net/bluetooth/selftest.c
parent168ed65483a1777c2570f4c0a4a64e20a823cf25 (diff)
Bluetooth: let the crypto subsystem generate the ecc privkey
That Bluetooth SMP knows about the private key is pointless, since the detection of debug key usage is actually via the public key portion. With this patch, the Bluetooth SMP will stop keeping a copy of the ecdh private key and will let the crypto subsystem to generate and handle the ecdh private key, potentially benefiting of hardware ecc private key generation and retention. The loop that tries to generate a correct private key is now removed and we trust the crypto subsystem to generate a correct private key. This backup logic should be done in crypto, if really needed. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/selftest.c')
-rw-r--r--net/bluetooth/selftest.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/net/bluetooth/selftest.c b/net/bluetooth/selftest.c
index ce99648ed870..2d1519d0affa 100644
--- a/net/bluetooth/selftest.c
+++ b/net/bluetooth/selftest.c
@@ -152,11 +152,11 @@ static int __init test_ecdh_sample(struct crypto_kpp *tfm, const u8 priv_a[32],
152 dhkey_a = &tmp[0]; 152 dhkey_a = &tmp[0];
153 dhkey_b = &tmp[32]; 153 dhkey_b = &tmp[32];
154 154
155 ret = compute_ecdh_secret(tfm, pub_b, priv_a, dhkey_a); 155 ret = set_ecdh_privkey(tfm, priv_a);
156 if (ret) 156 if (ret)
157 goto out; 157 goto out;
158 158
159 ret = compute_ecdh_secret(tfm, pub_a, priv_b, dhkey_b); 159 ret = compute_ecdh_secret(tfm, pub_b, dhkey_a);
160 if (ret) 160 if (ret)
161 goto out; 161 goto out;
162 162
@@ -165,9 +165,17 @@ static int __init test_ecdh_sample(struct crypto_kpp *tfm, const u8 priv_a[32],
165 goto out; 165 goto out;
166 } 166 }
167 167
168 ret = set_ecdh_privkey(tfm, priv_b);
169 if (ret)
170 goto out;
171
172 ret = compute_ecdh_secret(tfm, pub_a, dhkey_b);
173 if (ret)
174 goto out;
175
168 if (memcmp(dhkey_b, dhkey, 32)) 176 if (memcmp(dhkey_b, dhkey, 32))
169 ret = -EINVAL; 177 ret = -EINVAL;
170 178 /* fall through*/
171out: 179out:
172 kfree(tmp); 180 kfree(tmp);
173 return ret; 181 return ret;