f1f156a8aeace5a93ba54ae6fec800d0678c7bef
[openwrt/staging/dedeckeh.git] / package / libs / wolfssl / patches / 200-ecc-rng.patch
1 Since commit 6467de5a8840 ("Randomize z ordinates in scalar
2 mult when timing resistant") wolfssl requires a RNG for an EC
3 key when the hardened built option is selected.
4
5 wc_ecc_set_rng is only available when built hardened, so there
6 is no safe way to install the RNG to the key regardless whether
7 or not wolfssl is compiled hardened.
8
9 Always export wc_ecc_set_rng so tools such as hostapd can install
10 RNG regardless of the built settings for wolfssl.
11
12 --- a/wolfcrypt/src/ecc.c
13 +++ b/wolfcrypt/src/ecc.c
14 @@ -11655,21 +11655,21 @@ void wc_ecc_fp_free(void)
15
16 #endif /* FP_ECC */
17
18 -#ifdef ECC_TIMING_RESISTANT
19 int wc_ecc_set_rng(ecc_key* key, WC_RNG* rng)
20 {
21 int err = 0;
22
23 +#ifdef ECC_TIMING_RESISTANT
24 if (key == NULL) {
25 err = BAD_FUNC_ARG;
26 }
27 else {
28 key->rng = rng;
29 }
30 +#endif
31
32 return err;
33 }
34 -#endif
35
36 #ifdef HAVE_ECC_ENCRYPT
37
38 --- a/wolfssl/wolfcrypt/ecc.h
39 +++ b/wolfssl/wolfcrypt/ecc.h
40 @@ -650,10 +650,8 @@ WOLFSSL_API
41 void wc_ecc_fp_free(void);
42 WOLFSSL_LOCAL
43 void wc_ecc_fp_init(void);
44 -#ifdef ECC_TIMING_RESISTANT
45 WOLFSSL_API
46 int wc_ecc_set_rng(ecc_key* key, WC_RNG* rng);
47 -#endif
48
49 WOLFSSL_API
50 int wc_ecc_set_curve(ecc_key* key, int keysize, int curve_id);