From 6dd041f33aace183dc48cc97fd82ef45d7b055be Mon Sep 17 00:00:00 2001 From: beck Date: Wed, 10 Apr 2024 14:58:06 +0000 Subject: [PATCH] Hide symbols in bn.h Mark them LCRYPTO_UNUSED appropriately and remove the LIBRESSL_INTERNAL guards around them ok tb@ --- lib/libcrypto/Symbols.namespace | 5 +++++ lib/libcrypto/bn/bn.h | 11 ++--------- lib/libcrypto/bn/bn_div.c | 3 ++- lib/libcrypto/bn/bn_exp.c | 4 +++- lib/libcrypto/bn/bn_gcd.c | 10 +++------- lib/libcrypto/hidden/openssl/bn.h | 7 ++++++- 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index 09c0db44cec..2df5dd6f7df 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -3196,3 +3196,8 @@ _libre_RC2_decrypt _libre_RC2_cbc_encrypt _libre_RC2_cfb64_encrypt _libre_RC2_ofb64_encrypt +_libre_BN_div +_libre_BN_mod_exp +_libre_BN_mod_exp_mont +_libre_BN_gcd +_libre_BN_mod_inverse diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h index 79210752940..523ff42877a 100644 --- a/lib/libcrypto/bn/bn.h +++ b/lib/libcrypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.77 2024/03/02 09:27:31 tb Exp $ */ +/* $OpenBSD: bn.h,v 1.78 2024/04/10 14:58:06 beck Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -350,11 +350,10 @@ void BN_set_negative(BIGNUM *b, int n); int BN_is_negative(const BIGNUM *b); -#ifndef LIBRESSL_INTERNAL int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); #define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) -#endif + int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, BN_CTX *ctx); int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m); @@ -383,12 +382,10 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); int BN_lshift1(BIGNUM *r, const BIGNUM *a); int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -#ifndef LIBRESSL_INTERNAL int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx); int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -#endif int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont); @@ -407,14 +404,10 @@ char * BN_bn2dec(const BIGNUM *a); int BN_hex2bn(BIGNUM **a, const char *str); int BN_dec2bn(BIGNUM **a, const char *str); int BN_asc2bn(BIGNUM **a, const char *str); -#ifndef LIBRESSL_INTERNAL int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -#endif int BN_kronecker(const BIGNUM *a,const BIGNUM *b,BN_CTX *ctx); /* returns -2 for error */ -#ifndef LIBRESSL_INTERNAL BIGNUM *BN_mod_inverse(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); -#endif BIGNUM *BN_mod_sqrt(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); diff --git a/lib/libcrypto/bn/bn_div.c b/lib/libcrypto/bn/bn_div.c index 3225fa44249..09a8a364df4 100644 --- a/lib/libcrypto/bn/bn_div.c +++ b/lib/libcrypto/bn/bn_div.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_div.c,v 1.40 2023/03/27 10:21:23 tb Exp $ */ +/* $OpenBSD: bn_div.c,v 1.41 2024/04/10 14:58:06 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -441,6 +441,7 @@ BN_div(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, return BN_div_internal(quotient, remainder, numerator, divisor, ctx, ct); } +LCRYPTO_ALIAS(BN_div); int BN_div_nonct(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, diff --git a/lib/libcrypto/bn/bn_exp.c b/lib/libcrypto/bn/bn_exp.c index 04852424f7e..c51296c3c33 100644 --- a/lib/libcrypto/bn/bn_exp.c +++ b/lib/libcrypto/bn/bn_exp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_exp.c,v 1.52 2024/03/02 09:27:31 tb Exp $ */ +/* $OpenBSD: bn_exp.c,v 1.53 2024/04/10 14:58:06 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -799,6 +799,7 @@ BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, return BN_mod_exp_mont_internal(rr, a, p, m, ctx, in_mont, (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)); } +LCRYPTO_ALIAS(BN_mod_exp_mont); int BN_mod_exp_mont_ct(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, @@ -1160,6 +1161,7 @@ BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, return BN_mod_exp_internal(r, a, p, m, ctx, (BN_get_flags(p, BN_FLG_CONSTTIME) != 0)); } +LCRYPTO_ALIAS(BN_mod_exp); int BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, diff --git a/lib/libcrypto/bn/bn_gcd.c b/lib/libcrypto/bn/bn_gcd.c index 6b3d8a3cb9c..fa5d71a7f35 100644 --- a/lib/libcrypto/bn/bn_gcd.c +++ b/lib/libcrypto/bn/bn_gcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_gcd.c,v 1.28 2023/06/02 17:15:30 tb Exp $ */ +/* $OpenBSD: bn_gcd.c,v 1.29 2024/04/10 14:58:06 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -195,12 +195,7 @@ BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) BN_CTX_end(ctx); return (ret); } - -int -BN_gcd_nonct(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) -{ - return BN_gcd(r, in_a, in_b, ctx); -} +LCRYPTO_ALIAS(BN_gcd); /* * BN_gcd_no_branch is a special version of BN_mod_inverse_no_branch. @@ -808,6 +803,7 @@ BN_mod_inverse(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) (BN_get_flags(n, BN_FLG_CONSTTIME) != 0)); return BN_mod_inverse_internal(in, a, n, ctx, ct); } +LCRYPTO_ALIAS(BN_mod_inverse); BIGNUM * BN_mod_inverse_nonct(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx) diff --git a/lib/libcrypto/hidden/openssl/bn.h b/lib/libcrypto/hidden/openssl/bn.h index f6f00cf7664..af3465c790a 100644 --- a/lib/libcrypto/hidden/openssl/bn.h +++ b/lib/libcrypto/hidden/openssl/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.6 2024/03/02 09:27:31 tb Exp $ */ +/* $OpenBSD: bn.h,v 1.7 2024/04/10 14:58:06 beck Exp $ */ /* * Copyright (c) 2023 Bob Beck * @@ -136,5 +136,10 @@ LCRYPTO_USED(BN_get_rfc3526_prime_4096); LCRYPTO_USED(BN_get_rfc3526_prime_6144); LCRYPTO_USED(BN_get_rfc3526_prime_8192); LCRYPTO_USED(ERR_load_BN_strings); +LCRYPTO_UNUSED(BN_div); +LCRYPTO_UNUSED(BN_mod_exp); +LCRYPTO_UNUSED(BN_mod_exp_mont); +LCRYPTO_UNUSED(BN_gcd); +LCRYPTO_UNUSED(BN_mod_inverse); #endif /* _LIBCRYPTO_BN_H */ -- 2.20.1