diff options
author | Brent Cook <busterb@gmail.com> | 2022-03-12 11:26:23 -0600 |
---|---|---|
committer | Brent Cook <busterb@gmail.com> | 2022-03-13 12:17:53 -0500 |
commit | 3a4ec28b238edf9d85759b7a3d78fd85e4d5aaef (patch) | |
tree | 3ba574146927790cc700a030606a47ea34fced63 | |
parent | 86a33787ef9af9679de9b7da990e543682dc9be1 (diff) | |
download | portable-3a4ec28b238edf9d85759b7a3d78fd85e4d5aaef.tar.gz portable-3a4ec28b238edf9d85759b7a3d78fd85e4d5aaef.tar.bz2 portable-3a4ec28b238edf9d85759b7a3d78fd85e4d5aaef.zip |
add infinite loop fix in BN_mod_sqrt
-rw-r--r-- | patches/bn_sqrt.patch | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/patches/bn_sqrt.patch b/patches/bn_sqrt.patch new file mode 100644 index 0000000..495de31 --- /dev/null +++ b/patches/bn_sqrt.patch | |||
@@ -0,0 +1,38 @@ | |||
1 | --- crypto/bn/bn_sqrt.c.orig Fri Feb 18 16:30:39 2022 | ||
2 | +++ crypto/bn/bn_sqrt.c Sat Mar 12 11:23:53 2022 | ||
3 | @@ -351,21 +351,22 @@ | ||
4 | goto vrfy; | ||
5 | } | ||
6 | |||
7 | - | ||
8 | - /* find smallest i such that b^(2^i) = 1 */ | ||
9 | - i = 1; | ||
10 | - if (!BN_mod_sqr(t, b, p, ctx)) | ||
11 | - goto end; | ||
12 | - while (!BN_is_one(t)) { | ||
13 | - i++; | ||
14 | - if (i == e) { | ||
15 | - BNerror(BN_R_NOT_A_SQUARE); | ||
16 | - goto end; | ||
17 | + /* Find the smallest i with 0 < i < e such that b^(2^i) = 1. */ | ||
18 | + for (i = 1; i < e; i++) { | ||
19 | + if (i == 1) { | ||
20 | + if (!BN_mod_sqr(t, b, p, ctx)) | ||
21 | + goto end; | ||
22 | + } else { | ||
23 | + if (!BN_mod_sqr(t, t, p, ctx)) | ||
24 | + goto end; | ||
25 | } | ||
26 | - if (!BN_mod_mul(t, t, t, p, ctx)) | ||
27 | - goto end; | ||
28 | + if (BN_is_one(t)) | ||
29 | + break; | ||
30 | } | ||
31 | - | ||
32 | + if (i >= e) { | ||
33 | + BNerror(BN_R_NOT_A_SQUARE); | ||
34 | + goto end; | ||
35 | + } | ||
36 | |||
37 | /* t := y^2^(e - i - 1) */ | ||
38 | if (!BN_copy(t, y)) | ||