summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2024-03-02 09:27:31 +0000
committertb <>2024-03-02 09:27:31 +0000
commitc9bc42b7edc08f714c31d8ec1a974cc5b287ef4c (patch)
treed56583ceff6f4723ec51bb6b5743dbe552a6a98d /src
parent2309a3f36e13452642a7ad2ed127e96ed774e1c5 (diff)
downloadopenbsd-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 'src')
-rw-r--r--src/lib/libcrypto/Symbols.list2
-rw-r--r--src/lib/libcrypto/Symbols.namespace2
-rw-r--r--src/lib/libcrypto/bn/bn.h7
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c4
-rw-r--r--src/lib/libcrypto/bn/bn_local.h8
-rw-r--r--src/lib/libcrypto/hidden/openssl/bn.h4
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
407BN_mod_add 407BN_mod_add
408BN_mod_add_quick 408BN_mod_add_quick
409BN_mod_exp 409BN_mod_exp
410BN_mod_exp2_mont
411BN_mod_exp_mont 410BN_mod_exp_mont
412BN_mod_exp_mont_consttime 411BN_mod_exp_mont_consttime
413BN_mod_exp_mont_word
414BN_mod_inverse 412BN_mod_inverse
415BN_mod_lshift 413BN_mod_lshift
416BN_mod_lshift1 414BN_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
392int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, 392int 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);
394int 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);
396int 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
400int BN_mask_bits(BIGNUM *a, int n); 395int BN_mask_bits(BIGNUM *a, int n);
401int BN_print_fp(FILE *fp, const BIGNUM *a); 396int 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}
964LCRYPTO_ALIAS(BN_mod_exp_mont_word);
965 964
966int 965int
967BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, 966BN_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}
1356LCRYPTO_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,
308int BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); 308int BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
309int BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); 309int BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx);
310 310
311int 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);
313int 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
311int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 317int 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);
97LCRYPTO_USED(BN_lshift1); 97LCRYPTO_USED(BN_lshift1);
98LCRYPTO_USED(BN_exp); 98LCRYPTO_USED(BN_exp);
99LCRYPTO_USED(BN_mod_exp_mont_consttime); 99LCRYPTO_USED(BN_mod_exp_mont_consttime);
100LCRYPTO_USED(BN_mod_exp_mont_word);
101LCRYPTO_USED(BN_mod_exp2_mont);
102LCRYPTO_USED(BN_mask_bits); 100LCRYPTO_USED(BN_mask_bits);
103LCRYPTO_USED(BN_print_fp); 101LCRYPTO_USED(BN_print_fp);
104LCRYPTO_USED(BN_print); 102LCRYPTO_USED(BN_print);