From b78cccc526d31cefe3af77cef6ddab0981e8a45b Mon Sep 17 00:00:00 2001 From: jsing <> Date: Wed, 22 Feb 2023 05:46:37 +0000 Subject: Rework bn_add()/bn_sub() to operate on word arrays. Rather than working on BIGNUMs, change bn_add()/bn_sub() to operate on word arrays that potentially differ in length. This matches the behaviour of s2n-bignum's bignum_add() and bignum_sub(). ok tb@ --- src/lib/libcrypto/bn/arch/amd64/bn_arch.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/lib/libcrypto/bn/arch') diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c index a4a2d93ada..55275aa14e 100644 --- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c +++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_arch.c,v 1.5 2023/02/16 11:13:05 jsing Exp $ */ +/* $OpenBSD: bn_arch.c,v 1.6 2023/02/22 05:46:37 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -23,13 +23,15 @@ #ifdef HAVE_BN_ADD BN_ULONG -bn_add(BIGNUM *r, int rn, const BIGNUM *a, const BIGNUM *b) +bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, + int b_len) { - return bignum_add(rn, (uint64_t *)r->d, a->top, (uint64_t *)a->d, - b->top, (uint64_t *)b->d); + return bignum_add(r_len, (uint64_t *)r, a_len, (uint64_t *)a, + b_len, (uint64_t *)b); } #endif + #ifdef HAVE_BN_ADD_WORDS BN_ULONG bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) @@ -41,10 +43,11 @@ bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) #ifdef HAVE_BN_SUB BN_ULONG -bn_sub(BIGNUM *r, int rn, const BIGNUM *a, const BIGNUM *b) +bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b, + int b_len) { - return bignum_sub(rn, (uint64_t *)r->d, a->top, (uint64_t *)a->d, - b->top, (uint64_t *)b->d); + return bignum_sub(r_len, (uint64_t *)r, a_len, (uint64_t *)a, + b_len, (uint64_t *)b); } #endif -- cgit v1.2.3-55-g6feb