diff options
| author | jsing <> | 2022-11-26 13:56:33 +0000 |
|---|---|---|
| committer | jsing <> | 2022-11-26 13:56:33 +0000 |
| commit | bcbac728558eebfaa4404c405e7dc22769585345 (patch) | |
| tree | 9f1339c5b70b0cfa4e8a0a5c70345e837a21ce77 /src/lib/libcrypto/bn/bn_mod.c | |
| parent | 90d0616c736d954d327f399daa636de8e6a2c4d5 (diff) | |
| download | openbsd-bcbac728558eebfaa4404c405e7dc22769585345.tar.gz openbsd-bcbac728558eebfaa4404c405e7dc22769585345.tar.bz2 openbsd-bcbac728558eebfaa4404c405e7dc22769585345.zip | |
Remove BIGNUM consistency macros.
Compiling with BN_DEBUG (and if you want to take it further, BN_DEBUG_RAND)
supposedly adds consistency checks to the BN code. These are rarely if ever
used and introduce a bunch of clutter in the code. Furthermore, there are
hacks in place to undo things that the debugging code does.
Remove all of this mess and instead rely on always enabled checks, more
readable code and proper regress coverage to ensure correct behaviour.
"Good riddance." tb@
Diffstat (limited to 'src/lib/libcrypto/bn/bn_mod.c')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_mod.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/src/lib/libcrypto/bn/bn_mod.c b/src/lib/libcrypto/bn/bn_mod.c index 897ff434e9..5be8252f2d 100644 --- a/src/lib/libcrypto/bn/bn_mod.c +++ b/src/lib/libcrypto/bn/bn_mod.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_mod.c,v 1.12 2017/01/29 17:49:22 beck Exp $ */ | 1 | /* $OpenBSD: bn_mod.c,v 1.13 2022/11/26 13:56:33 jsing Exp $ */ |
| 2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> | 2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> |
| 3 | * for the OpenSSL project. */ | 3 | * for the OpenSSL project. */ |
| 4 | /* ==================================================================== | 4 | /* ==================================================================== |
| @@ -182,9 +182,6 @@ BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | |||
| 182 | BIGNUM *t; | 182 | BIGNUM *t; |
| 183 | int ret = 0; | 183 | int ret = 0; |
| 184 | 184 | ||
| 185 | bn_check_top(a); | ||
| 186 | bn_check_top(b); | ||
| 187 | bn_check_top(m); | ||
| 188 | 185 | ||
| 189 | BN_CTX_start(ctx); | 186 | BN_CTX_start(ctx); |
| 190 | if ((t = BN_CTX_get(ctx)) == NULL) | 187 | if ((t = BN_CTX_get(ctx)) == NULL) |
| @@ -198,7 +195,6 @@ BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, | |||
| 198 | } | 195 | } |
| 199 | if (!BN_nnmod(r, t,m, ctx)) | 196 | if (!BN_nnmod(r, t,m, ctx)) |
| 200 | goto err; | 197 | goto err; |
| 201 | bn_check_top(r); | ||
| 202 | ret = 1; | 198 | ret = 1; |
| 203 | 199 | ||
| 204 | err: | 200 | err: |
| @@ -220,7 +216,6 @@ BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx) | |||
| 220 | { | 216 | { |
| 221 | if (!BN_lshift1(r, a)) | 217 | if (!BN_lshift1(r, a)) |
| 222 | return 0; | 218 | return 0; |
| 223 | bn_check_top(r); | ||
| 224 | return BN_nnmod(r, r, m, ctx); | 219 | return BN_nnmod(r, r, m, ctx); |
| 225 | } | 220 | } |
| 226 | 221 | ||
| @@ -231,7 +226,6 @@ BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m) | |||
| 231 | { | 226 | { |
| 232 | if (!BN_lshift1(r, a)) | 227 | if (!BN_lshift1(r, a)) |
| 233 | return 0; | 228 | return 0; |
| 234 | bn_check_top(r); | ||
| 235 | if (BN_cmp(r, m) >= 0) | 229 | if (BN_cmp(r, m) >= 0) |
| 236 | return BN_sub(r, r, m); | 230 | return BN_sub(r, r, m); |
| 237 | return 1; | 231 | return 1; |
| @@ -254,7 +248,6 @@ BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx) | |||
| 254 | } | 248 | } |
| 255 | 249 | ||
| 256 | ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m)); | 250 | ret = BN_mod_lshift_quick(r, r, n, (abs_m ? abs_m : m)); |
| 257 | bn_check_top(r); | ||
| 258 | 251 | ||
| 259 | BN_free(abs_m); | 252 | BN_free(abs_m); |
| 260 | return ret; | 253 | return ret; |
| @@ -302,7 +295,6 @@ BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m) | |||
| 302 | return 0; | 295 | return 0; |
| 303 | } | 296 | } |
| 304 | } | 297 | } |
| 305 | bn_check_top(r); | ||
| 306 | 298 | ||
| 307 | return 1; | 299 | return 1; |
| 308 | } | 300 | } |
