From 07629853174025353c44cf72938e7858d37f6527 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 2 Mar 2024 09:24:59 +0000 Subject: [PATCH] Make BN_mod_exp_simple() internal This function is very slow and useful for testing purposes only. It should never have been part of the public API. Remove it from there. ok jsing --- lib/libcrypto/Symbols.list | 1 - lib/libcrypto/Symbols.namespace | 1 - lib/libcrypto/bn/bn.h | 4 +--- lib/libcrypto/bn/bn_exp.c | 3 +-- lib/libcrypto/bn/bn_local.h | 5 ++++- lib/libcrypto/hidden/openssl/bn.h | 3 +-- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/libcrypto/Symbols.list b/lib/libcrypto/Symbols.list index 19f88c6917e..c439138eb7b 100644 --- a/lib/libcrypto/Symbols.list +++ b/lib/libcrypto/Symbols.list @@ -411,7 +411,6 @@ BN_mod_exp2_mont BN_mod_exp_mont BN_mod_exp_mont_consttime BN_mod_exp_mont_word -BN_mod_exp_simple BN_mod_inverse BN_mod_lshift BN_mod_lshift1 diff --git a/lib/libcrypto/Symbols.namespace b/lib/libcrypto/Symbols.namespace index e97629108a1..772fb1876ba 100644 --- a/lib/libcrypto/Symbols.namespace +++ b/lib/libcrypto/Symbols.namespace @@ -2223,7 +2223,6 @@ _libre_BN_exp _libre_BN_mod_exp_mont_consttime _libre_BN_mod_exp_mont_word _libre_BN_mod_exp2_mont -_libre_BN_mod_exp_simple _libre_BN_mask_bits _libre_BN_print_fp _libre_BN_print diff --git a/lib/libcrypto/bn/bn.h b/lib/libcrypto/bn/bn.h index e00953ea2ca..39a5180c2ca 100644 --- a/lib/libcrypto/bn/bn.h +++ b/lib/libcrypto/bn/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.75 2023/07/31 05:04:06 tb Exp $ */ +/* $OpenBSD: bn.h,v 1.76 2024/03/02 09:24:59 tb Exp $ */ /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -396,8 +396,6 @@ int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); int BN_mask_bits(BIGNUM *a, int n); int BN_print_fp(FILE *fp, const BIGNUM *a); diff --git a/lib/libcrypto/bn/bn_exp.c b/lib/libcrypto/bn/bn_exp.c index 8293ae54f99..e4e06db1495 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.50 2023/10/19 10:27:27 tb Exp $ */ +/* $OpenBSD: bn_exp.c,v 1.51 2024/03/02 09:24:59 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -304,7 +304,6 @@ BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, return ret; } -LCRYPTO_ALIAS(BN_mod_exp_simple); /* BN_mod_exp_mont_consttime() stores the precomputed powers in a specific layout * so that accessing any of these table values shows the same access pattern as far diff --git a/lib/libcrypto/bn/bn_local.h b/lib/libcrypto/bn/bn_local.h index a9ce466db38..e5c4cddc927 100644 --- a/lib/libcrypto/bn/bn_local.h +++ b/lib/libcrypto/bn/bn_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_local.h,v 1.38 2023/08/09 09:23:03 tb Exp $ */ +/* $OpenBSD: bn_local.h,v 1.39 2024/03/02 09:24:59 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -308,6 +308,9 @@ int BN_div_ct(BIGNUM *q, BIGNUM *r, const BIGNUM *n, const BIGNUM *d, int BN_mod_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); int BN_mod_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); +int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, + const BIGNUM *m, BN_CTX *ctx); + BIGNUM *BN_mod_inverse_ct(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); BIGNUM *BN_mod_inverse_nonct(BIGNUM *ret, const BIGNUM *a, const BIGNUM *n, diff --git a/lib/libcrypto/hidden/openssl/bn.h b/lib/libcrypto/hidden/openssl/bn.h index 9942cf6fc74..1aa5b10d9d6 100644 --- a/lib/libcrypto/hidden/openssl/bn.h +++ b/lib/libcrypto/hidden/openssl/bn.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn.h,v 1.4 2023/07/29 03:13:38 tb Exp $ */ +/* $OpenBSD: bn.h,v 1.5 2024/03/02 09:24:59 tb Exp $ */ /* * Copyright (c) 2023 Bob Beck * @@ -99,7 +99,6 @@ LCRYPTO_USED(BN_exp); LCRYPTO_USED(BN_mod_exp_mont_consttime); LCRYPTO_USED(BN_mod_exp_mont_word); LCRYPTO_USED(BN_mod_exp2_mont); -LCRYPTO_USED(BN_mod_exp_simple); LCRYPTO_USED(BN_mask_bits); LCRYPTO_USED(BN_print_fp); LCRYPTO_USED(BN_print); -- 2.20.1