summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2025-08-14 15:17:19 +0000
committerjsing <>2025-08-14 15:17:19 +0000
commit278945f44c7c245ab97c000f622ed5ad243818a1 (patch)
tree96319286404ec4a3845b96c17dea500c519ef3ea /src
parent6dbe806d026a9b65d3decbcd23fb9b70559bf259 (diff)
downloadopenbsd-278945f44c7c245ab97c000f622ed5ad243818a1.tar.gz
openbsd-278945f44c7c245ab97c000f622ed5ad243818a1.tar.bz2
openbsd-278945f44c7c245ab97c000f622ed5ad243818a1.zip
Provide bn_mod_add_words() and bn_mod_sub_words() on amd64.
These use s2n-bignum's bignum_modadd() and bignum_modsub() routines. ok tb@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.c22
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.h5
2 files changed, 25 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.c b/src/lib/libcrypto/bn/arch/amd64/bn_arch.c
index 38a4350d17..97dc7b90c7 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.9 2025/08/12 10:00:40 jsing Exp $ */ 1/* $OpenBSD: bn_arch.c,v 1.10 2025/08/14 15:17:19 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -60,6 +60,26 @@ bn_sub_words(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd, int n)
60} 60}
61#endif 61#endif
62 62
63#ifdef HAVE_BN_MOD_ADD_WORDS
64void
65bn_mod_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
66 const BN_ULONG *m, size_t n)
67{
68 bignum_modadd(n, (uint64_t *)r, (const uint64_t *)a,
69 (const uint64_t *)b, (const uint64_t *)m);
70}
71#endif
72
73#ifdef HAVE_BN_MOD_SUB_WORDS
74void
75bn_mod_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
76 const BN_ULONG *m, size_t n)
77{
78 bignum_modsub(n, (uint64_t *)r, (const uint64_t *)a,
79 (const uint64_t *)b, (const uint64_t *)m);
80}
81#endif
82
63#ifdef HAVE_BN_MUL_ADD_WORDS 83#ifdef HAVE_BN_MUL_ADD_WORDS
64BN_ULONG 84BN_ULONG
65bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) 85bn_mul_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w)
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.h b/src/lib/libcrypto/bn/arch/amd64/bn_arch.h
index 927cd75208..d07a898b80 100644
--- a/src/lib/libcrypto/bn/arch/amd64/bn_arch.h
+++ b/src/lib/libcrypto/bn/arch/amd64/bn_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_arch.h,v 1.14 2024/03/26 06:09:25 jsing Exp $ */ 1/* $OpenBSD: bn_arch.h,v 1.15 2025/08/14 15:17:19 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -27,6 +27,9 @@
27 27
28#define HAVE_BN_DIV_WORDS 28#define HAVE_BN_DIV_WORDS
29 29
30#define HAVE_BN_MOD_ADD_WORDS
31#define HAVE_BN_MOD_SUB_WORDS
32
30#define HAVE_BN_MUL_ADD_WORDS 33#define HAVE_BN_MUL_ADD_WORDS
31#define HAVE_BN_MUL_COMBA4 34#define HAVE_BN_MUL_COMBA4
32#define HAVE_BN_MUL_COMBA8 35#define HAVE_BN_MUL_COMBA8