blob: 269dcaac75ce3edb971e4a4cd93ed1c5cd1096a9 [file] [log] [blame]
developer7b43f2d2022-04-29 17:53:25 +08001From 21ce83b4ae2b9563175fdb4fc4312096cc399cf8 Mon Sep 17 00:00:00 2001
2From: David Bauer <mail@david-bauer.net>
3Date: Wed, 5 May 2021 00:44:34 +0200
4Subject: [PATCH] wolfssl: add RNG to EC key
5
6Since upstream commit 6467de5a8840 ("Randomize z ordinates in
7scalar mult when timing resistant") WolfSSL requires a RNG for
8the EC key when built hardened which is the default.
9
10Set the RNG for the EC key to fix connections for OWE clients.
11
12Signed-off-by: David Bauer <mail@david-bauer.net>
13---
14 src/crypto/crypto_wolfssl.c | 4 ++++
15 1 file changed, 4 insertions(+)
16
17--- a/src/crypto/crypto_wolfssl.c
18+++ b/src/crypto/crypto_wolfssl.c
developer198585d2022-09-22 17:12:54 +080019@@ -1340,6 +1340,7 @@ int ecc_projective_add_point(ecc_point *
developer7b43f2d2022-04-29 17:53:25 +080020
21 struct crypto_ec {
22 ecc_key key;
23+ WC_RNG rng;
24 mp_int a;
25 mp_int prime;
26 mp_int order;
developer198585d2022-09-22 17:12:54 +080027@@ -1394,6 +1395,8 @@ struct crypto_ec * crypto_ec_init(int gr
developer7b43f2d2022-04-29 17:53:25 +080028 return NULL;
29
30 if (wc_ecc_init(&e->key) != 0 ||
31+ wc_InitRng(&e->rng) != 0 ||
32+ wc_ecc_set_rng(&e->key, &e->rng) != 0 ||
33 wc_ecc_set_curve(&e->key, 0, curve_id) != 0 ||
34 mp_init(&e->a) != MP_OKAY ||
35 mp_init(&e->prime) != MP_OKAY ||
developer198585d2022-09-22 17:12:54 +080036@@ -1425,6 +1428,7 @@ void crypto_ec_deinit(struct crypto_ec*
developer7b43f2d2022-04-29 17:53:25 +080037 mp_clear(&e->order);
38 mp_clear(&e->prime);
39 mp_clear(&e->a);
40+ wc_FreeRng(&e->rng);
41 wc_ecc_free(&e->key);
42 os_free(e);
43 }