From 6bb5c601c21b47afb4744e7bc8a8350c392822bd Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 25 May 2025 04:53:05 +0000 Subject: Fix previous. --- src/lib/libcrypto/Makefile | 3 +- src/lib/libcrypto/bn/bn_add.c | 69 +------------------------------------- src/lib/libcrypto/bn/bn_internal.h | 6 ++-- 3 files changed, 6 insertions(+), 72 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/Makefile b/src/lib/libcrypto/Makefile index db3bc767d9..a05042986c 100644 --- a/src/lib/libcrypto/Makefile +++ b/src/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.231 2024/12/19 23:56:32 tb Exp $ +# $OpenBSD: Makefile,v 1.232 2025/05/25 04:53:05 jsing Exp $ LIB= crypto LIBREBUILD=y @@ -159,6 +159,7 @@ SRCS+= bss_sock.c # bn/ SRCS+= bn_add.c +SRCS+= bn_add_sub.c SRCS+= bn_bpsw.c SRCS+= bn_const.c SRCS+= bn_convert.c diff --git a/src/lib/libcrypto/bn/bn_add.c b/src/lib/libcrypto/bn/bn_add.c index db1767ea55..81fa60e429 100644 --- a/src/lib/libcrypto/bn/bn_add.c +++ b/src/lib/libcrypto/bn/bn_add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_add.c,v 1.28 2025/05/25 04:16:36 jsing Exp $ */ +/* $OpenBSD: bn_add.c,v 1.29 2025/05/25 04:53:05 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -65,39 +65,6 @@ #include "bn_internal.h" #include "err_local.h" -/* - * bn_add_words() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b - * are both arrays of words. Any carry resulting from the addition is returned. - */ -#ifndef HAVE_BN_ADD_WORDS -BN_ULONG -bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) -{ - BN_ULONG carry = 0; - - assert(n >= 0); - if (n <= 0) - return 0; - - while (n & ~3) { - bn_qwaddqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0], - carry, &carry, &r[3], &r[2], &r[1], &r[0]); - a += 4; - b += 4; - r += 4; - n -= 4; - } - while (n) { - bn_addw_addw(a[0], b[0], carry, &carry, &r[0]); - a++; - b++; - r++; - n--; - } - return carry; -} -#endif - /* * bn_add() computes (carry:r[i]) = a[i] + b[i] + carry, where a and b are both * arrays of words (r may be the same as a or b). The length of a and b may @@ -145,40 +112,6 @@ bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, } #endif -/* - * bn_sub_words() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b - * are both arrays of words. Any borrow resulting from the subtraction is - * returned. - */ -#ifndef HAVE_BN_SUB_WORDS -BN_ULONG -bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n) -{ - BN_ULONG borrow = 0; - - assert(n >= 0); - if (n <= 0) - return 0; - - while (n & ~3) { - bn_qwsubqw(a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0], - borrow, &borrow, &r[3], &r[2], &r[1], &r[0]); - a += 4; - b += 4; - r += 4; - n -= 4; - } - while (n) { - bn_subw_subw(a[0], b[0], borrow, &borrow, &r[0]); - a++; - b++; - r++; - n--; - } - return borrow; -} -#endif - /* * bn_sub() computes (borrow:r[i]) = a[i] - b[i] - borrow, where a and b are both * arrays of words (r may be the same as a or b). The length of a and b may diff --git a/src/lib/libcrypto/bn/bn_internal.h b/src/lib/libcrypto/bn/bn_internal.h index 18fd7550a6..895a194c93 100644 --- a/src/lib/libcrypto/bn/bn_internal.h +++ b/src/lib/libcrypto/bn/bn_internal.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_internal.h,v 1.16 2025/05/25 04:30:55 jsing Exp $ */ +/* $OpenBSD: bn_internal.h,v 1.17 2025/05/25 04:53:05 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -31,9 +31,9 @@ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int num); BN_ULONG bn_sub_words_borrow(const BN_ULONG *a, const BN_ULONG *b, size_t n); -void bn_add_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, +BN_ULONG bn_add_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, BN_ULONG mask, size_t n); -void bn_sub_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, +BN_ULONG bn_sub_words_masked(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, BN_ULONG mask, size_t n); #ifndef HAVE_BN_CT_NE_ZERO -- cgit v1.2.3-55-g6feb