diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2023-02-15 18:10:17 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2023-02-15 18:10:17 +0000 |
commit | c83c6c066c8f362ee3bf280f59d8ad451034aaa0 (patch) | |
tree | cf2a5ba38a9e364ac5526f63ff3012043a5bb93b | |
parent | 4213e93d235b16e4fa47e2f63262222da5c78c16 (diff) |
Place bn_mul_add_words() after bn_mul_words().
-rw-r--r-- | lib/libcrypto/bn/bn_mul.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/lib/libcrypto/bn/bn_mul.c b/lib/libcrypto/bn/bn_mul.c index 965c1ad0365..1d56e57b76b 100644 --- a/lib/libcrypto/bn/bn_mul.c +++ b/lib/libcrypto/bn/bn_mul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mul.c,v 1.32 2023/02/14 18:37:15 jsing Exp $ */ +/* $OpenBSD: bn_mul.c,v 1.33 2023/02/15 18:10:16 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -67,44 +67,6 @@ #include "bn_local.h" /* - * bn_mul_add_words() computes (carry:r[i]) = a[i] * w + r[i] + carry, where - * a is an array of words and w is a single word. This should really be called - * bn_mulw_add_words() since only one input is an array. This is used as a step - * in the multiplication of word arrays. - */ -#ifndef HAVE_BN_MUL_ADD_WORDS -BN_ULONG -bn_mul_add_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) -{ - BN_ULONG carry = 0; - - assert(num >= 0); - if (num <= 0) - return 0; - -#ifndef OPENSSL_SMALL_FOOTPRINT - while (num & ~3) { - bn_mulw_addw_addw(a[0], w, r[0], carry, &carry, &r[0]); - bn_mulw_addw_addw(a[1], w, r[1], carry, &carry, &r[1]); - bn_mulw_addw_addw(a[2], w, r[2], carry, &carry, &r[2]); - bn_mulw_addw_addw(a[3], w, r[3], carry, &carry, &r[3]); - a += 4; - r += 4; - num -= 4; - } -#endif - while (num) { - bn_mulw_addw_addw(a[0], w, r[0], carry, &carry, &r[0]); - a++; - r++; - num--; - } - - return carry; -} -#endif - -/* * bn_mul_comba4() computes r[] = a[] * b[] using Comba multiplication * (https://everything2.com/title/Comba+multiplication), where a and b are both * four word arrays, producing an eight word array result. @@ -269,6 +231,44 @@ bn_mul_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) } #endif +/* + * bn_mul_add_words() computes (carry:r[i]) = a[i] * w + r[i] + carry, where + * a is an array of words and w is a single word. This should really be called + * bn_mulw_add_words() since only one input is an array. This is used as a step + * in the multiplication of word arrays. + */ +#ifndef HAVE_BN_MUL_ADD_WORDS +BN_ULONG +bn_mul_add_words(BN_ULONG *r, const BN_ULONG *a, int num, BN_ULONG w) +{ + BN_ULONG carry = 0; + + assert(num >= 0); + if (num <= 0) + return 0; + +#ifndef OPENSSL_SMALL_FOOTPRINT + while (num & ~3) { + bn_mulw_addw_addw(a[0], w, r[0], carry, &carry, &r[0]); + bn_mulw_addw_addw(a[1], w, r[1], carry, &carry, &r[1]); + bn_mulw_addw_addw(a[2], w, r[2], carry, &carry, &r[2]); + bn_mulw_addw_addw(a[3], w, r[3], carry, &carry, &r[3]); + a += 4; + r += 4; + num -= 4; + } +#endif + while (num) { + bn_mulw_addw_addw(a[0], w, r[0], carry, &carry, &r[0]); + a++; + r++; + num--; + } + + return carry; +} +#endif + #if defined(OPENSSL_NO_ASM) || !defined(OPENSSL_BN_ASM_PART_WORDS) /* * Here follows a specialised variant of bn_sub_words(), which has the property |