diff options
| author | tb <> | 2024-03-02 09:27:31 +0000 |
|---|---|---|
| committer | tb <> | 2024-03-02 09:27:31 +0000 |
| commit | c9bc42b7edc08f714c31d8ec1a974cc5b287ef4c (patch) | |
| tree | d56583ceff6f4723ec51bb6b5743dbe552a6a98d /src/lib/libc | |
| parent | 2309a3f36e13452642a7ad2ed127e96ed774e1c5 (diff) | |
| download | openbsd-c9bc42b7edc08f714c31d8ec1a974cc5b287ef4c.tar.gz openbsd-c9bc42b7edc08f714c31d8ec1a974cc5b287ef4c.tar.bz2 openbsd-c9bc42b7edc08f714c31d8ec1a974cc5b287ef4c.zip | |
Make BN_mod_exp2_mont() and BN_mod_exp_mont_word() internal
The former could be useful but nothing uses it. The latter is a
dangerous implementation detail of Montgomery exponentiation that
should never have been leaked out of the library. Fix this.
ok jsing
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/Symbols.list | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/Symbols.namespace | 2 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn.h | 7 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_exp.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_local.h | 8 | ||||
| -rw-r--r-- | src/lib/libcrypto/hidden/openssl/bn.h | 4 |
6 files changed, 10 insertions, 17 deletions
diff --git a/src/lib/libcrypto/Symbols.list b/src/lib/libcrypto/Symbols.list index c439138eb7..5099a6f1f8 100644 --- a/src/lib/libcrypto/Symbols.list +++ b/src/lib/libcrypto/Symbols.list | |||
| @@ -407,10 +407,8 @@ BN_mask_bits | |||
| 407 | BN_mod_add | 407 | BN_mod_add |
| 408 | BN_mod_add_quick | 408 | BN_mod_add_quick |
| 409 | BN_mod_exp | 409 | BN_mod_exp |
| 410 | BN_mod_exp2_mont | ||
| 411 | BN_mod_exp_mont | 410 | BN_mod_exp_mont |
| 412 | BN_mod_exp_mont_consttime | 411 | BN_mod_exp_mont_consttime |
| 413 | BN_mod_exp_mont_word | ||
| 414 | BN_mod_inverse | 412 | BN_mod_inverse |
| 415 | BN_mod_lshift | 413 | BN_mod_lshift |
| 416 | BN_mod_lshift1 | 414 | BN_mod_lshift1 |
diff --git a/src/lib/libcrypto/Symbols.namespace b/src/lib/libcrypto/Symbols.namespace index 772fb1876b..aff315a305 100644 --- a/src/lib/libcrypto/Symbols.namespace +++ b/src/lib/libcrypto/Symbols.namespace | |||
| @@ -2221,8 +2221,6 @@ _libre_BN_lshift | |||
| 2221 | _libre_BN_lshift1 | 2221 | _libre_BN_lshift1 |
| 2222 | _libre_BN_exp | 2222 | _libre_BN_exp |
| 2223 | _libre_BN_mod_exp_mont_consttime | 2223 | _libre_BN_mod_exp_mont_consttime |
| 2224 | _libre_BN_mod_exp_mont_word | ||
| 2225 | _libre_BN_mod_exp2_mont | ||
| 2226 | _libre_BN_mask_bits | 2224 | _libre_BN_mask_bits |
| 2227 | _libre_BN_print_fp | 2225 | _libre_BN_print_fp |
| 2228 | _libre_BN_print | 2226 | _libre_BN_print |
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h index 39a5180c2c..7921075294 100644 --- a/src/lib/libcrypto/bn/bn.h +++ b/src/lib/libcrypto/bn/bn.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn.h,v 1.76 2024/03/02 09:24:59 tb Exp $ */ | 1 | /* $OpenBSD: bn.h,v 1.77 2024/03/02 09:27:31 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -391,11 +391,6 @@ int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | |||
| 391 | #endif | 391 | #endif |
| 392 | int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, | 392 | int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, |
| 393 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); | 393 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); |
| 394 | int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, | ||
| 395 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
| 396 | int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, | ||
| 397 | const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, | ||
| 398 | BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
| 399 | 394 | ||
| 400 | int BN_mask_bits(BIGNUM *a, int n); | 395 | int BN_mask_bits(BIGNUM *a, int n); |
| 401 | int BN_print_fp(FILE *fp, const BIGNUM *a); | 396 | int BN_print_fp(FILE *fp, const BIGNUM *a); |
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c index e4e06db149..04852424f7 100644 --- a/src/lib/libcrypto/bn/bn_exp.c +++ b/src/lib/libcrypto/bn/bn_exp.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_exp.c,v 1.51 2024/03/02 09:24:59 tb Exp $ */ | 1 | /* $OpenBSD: bn_exp.c,v 1.52 2024/03/02 09:27:31 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -961,7 +961,6 @@ err: | |||
| 961 | BN_CTX_end(ctx); | 961 | BN_CTX_end(ctx); |
| 962 | return (ret); | 962 | return (ret); |
| 963 | } | 963 | } |
| 964 | LCRYPTO_ALIAS(BN_mod_exp_mont_word); | ||
| 965 | 964 | ||
| 966 | int | 965 | int |
| 967 | BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | 966 | BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, |
| @@ -1353,4 +1352,3 @@ err: | |||
| 1353 | BN_CTX_end(ctx); | 1352 | BN_CTX_end(ctx); |
| 1354 | return (ret); | 1353 | return (ret); |
| 1355 | } | 1354 | } |
| 1356 | LCRYPTO_ALIAS(BN_mod_exp2_mont); | ||
diff --git a/src/lib/libcrypto/bn/bn_local.h b/src/lib/libcrypto/bn/bn_local.h index e5c4cddc92..5acb546d07 100644 --- a/src/lib/libcrypto/bn/bn_local.h +++ b/src/lib/libcrypto/bn/bn_local.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_local.h,v 1.39 2024/03/02 09:24:59 tb Exp $ */ | 1 | /* $OpenBSD: bn_local.h,v 1.40 2024/03/02 09:27:31 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -308,6 +308,12 @@ int BN_div_ct(BIGNUM *q, BIGNUM *r, const BIGNUM *n, const BIGNUM *d, | |||
| 308 | int BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); | 308 | int BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); |
| 309 | int BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); | 309 | int BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); |
| 310 | 310 | ||
| 311 | int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, | ||
| 312 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
| 313 | int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, | ||
| 314 | const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, | ||
| 315 | BN_CTX *ctx, BN_MONT_CTX *m_ctx); | ||
| 316 | |||
| 311 | int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, | 317 | int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, |
| 312 | const BIGNUM *m, BN_CTX *ctx); | 318 | const BIGNUM *m, BN_CTX *ctx); |
| 313 | 319 | ||
diff --git a/src/lib/libcrypto/hidden/openssl/bn.h b/src/lib/libcrypto/hidden/openssl/bn.h index 1aa5b10d9d..f6f00cf766 100644 --- a/src/lib/libcrypto/hidden/openssl/bn.h +++ b/src/lib/libcrypto/hidden/openssl/bn.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn.h,v 1.5 2024/03/02 09:24:59 tb Exp $ */ | 1 | /* $OpenBSD: bn.h,v 1.6 2024/03/02 09:27:31 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2023 Bob Beck <beck@openbsd.org> |
| 4 | * | 4 | * |
| @@ -97,8 +97,6 @@ LCRYPTO_USED(BN_lshift); | |||
| 97 | LCRYPTO_USED(BN_lshift1); | 97 | LCRYPTO_USED(BN_lshift1); |
| 98 | LCRYPTO_USED(BN_exp); | 98 | LCRYPTO_USED(BN_exp); |
| 99 | LCRYPTO_USED(BN_mod_exp_mont_consttime); | 99 | LCRYPTO_USED(BN_mod_exp_mont_consttime); |
| 100 | LCRYPTO_USED(BN_mod_exp_mont_word); | ||
| 101 | LCRYPTO_USED(BN_mod_exp2_mont); | ||
| 102 | LCRYPTO_USED(BN_mask_bits); | 100 | LCRYPTO_USED(BN_mask_bits); |
| 103 | LCRYPTO_USED(BN_print_fp); | 101 | LCRYPTO_USED(BN_print_fp); |
| 104 | LCRYPTO_USED(BN_print); | 102 | LCRYPTO_USED(BN_print); |
