summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/arch
diff options
context:
space:
mode:
authorjsing <>2023-02-22 05:46:37 +0000
committerjsing <>2023-02-22 05:46:37 +0000
commitb78cccc526d31cefe3af77cef6ddab0981e8a45b (patch)
tree3ef166da90c41a8837c572bb101b829f7820919c /src/lib/libcrypto/bn/arch
parent6f66480e47f11d7c590e1c3719c68facc3cc379a (diff)
downloadopenbsd-b78cccc526d31cefe3af77cef6ddab0981e8a45b.tar.gz
openbsd-b78cccc526d31cefe3af77cef6ddab0981e8a45b.tar.bz2
openbsd-b78cccc526d31cefe3af77cef6ddab0981e8a45b.zip
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@
Diffstat (limited to 'src/lib/libcrypto/bn/arch')
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.c17
1 files changed, 10 insertions, 7 deletions
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 @@
1/* $OpenBSD: bn_arch.c,v 1.5 2023/02/16 11:13:05 jsing Exp $ */ 1/* $OpenBSD: bn_arch.c,v 1.6 2023/02/22 05:46:37 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -23,13 +23,15 @@
23 23
24#ifdef HAVE_BN_ADD 24#ifdef HAVE_BN_ADD
25BN_ULONG 25BN_ULONG
26bn_add(BIGNUM *r, int rn, const BIGNUM *a, const BIGNUM *b) 26bn_add(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
27 int b_len)
27{ 28{
28 return bignum_add(rn, (uint64_t *)r->d, a->top, (uint64_t *)a->d, 29 return bignum_add(r_len, (uint64_t *)r, a_len, (uint64_t *)a,
29 b->top, (uint64_t *)b->d); 30 b_len, (uint64_t *)b);
30} 31}
31#endif 32#endif
32 33
34
33#ifdef HAVE_BN_ADD_WORDS 35#ifdef HAVE_BN_ADD_WORDS
34BN_ULONG 36BN_ULONG
35bn_add_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n) 37bn_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)
41 43
42#ifdef HAVE_BN_SUB 44#ifdef HAVE_BN_SUB
43BN_ULONG 45BN_ULONG
44bn_sub(BIGNUM *r, int rn, const BIGNUM *a, const BIGNUM *b) 46bn_sub(BN_ULONG *r, int r_len, const BN_ULONG *a, int a_len, const BN_ULONG *b,
47 int b_len)
45{ 48{
46 return bignum_sub(rn, (uint64_t *)r->d, a->top, (uint64_t *)a->d, 49 return bignum_sub(r_len, (uint64_t *)r, a_len, (uint64_t *)a,
47 b->top, (uint64_t *)b->d); 50 b_len, (uint64_t *)b);
48} 51}
49#endif 52#endif
50 53