summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2025-09-01 15:15:44 +0000
committerjsing <>2025-09-01 15:15:44 +0000
commitb788687c68f1df8051cd54ab960dd9f91c4671d8 (patch)
treefb826dc3b1eb9132e0022ac63ca84c14bfb7d2e5 /src/lib
parent9515b20985a5c9b31bc131b27b865722251c24f1 (diff)
downloadopenbsd-b788687c68f1df8051cd54ab960dd9f91c4671d8.tar.gz
openbsd-b788687c68f1df8051cd54ab960dd9f91c4671d8.tar.bz2
openbsd-b788687c68f1df8051cd54ab960dd9f91c4671d8.zip
Provide bn_mul_words() on amd64.
This uses s2n-bignum's bignum_mul() and provides significant performance gains for a range of multiplication sizes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.c11
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.h3
2 files changed, 12 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 5f3549fc26..0fe6070efa 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.15 2025/08/31 09:34:51 jsing Exp $ */ 1/* $OpenBSD: bn_arch.c,v 1.16 2025/09/01 15:15:44 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -126,6 +126,15 @@ bn_mul_comba8(BN_ULONG *rd, const BN_ULONG *ad, const BN_ULONG *bd)
126} 126}
127#endif 127#endif
128 128
129#ifdef HAVE_BN_MUL_WORDS
130void
131bn_mul_words(BN_ULONG *r, BN_ULONG *a, int a_len, BN_ULONG *b, int b_len)
132{
133 bignum_mul(a_len + b_len, (uint64_t *)r, a_len, (const uint64_t *)a,
134 b_len, (const uint64_t *)b);
135}
136#endif
137
129#ifdef HAVE_BN_MULW_ADD_WORDS 138#ifdef HAVE_BN_MULW_ADD_WORDS
130BN_ULONG 139BN_ULONG
131bn_mulw_add_words(BN_ULONG *rd, const BN_ULONG *ad, int num, BN_ULONG w) 140bn_mulw_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 f42c6bc201..3cb1d1d274 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.18 2025/08/30 07:54:27 jsing Exp $ */ 1/* $OpenBSD: bn_arch.h,v 1.19 2025/09/01 15:15:44 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -33,6 +33,7 @@
33#define HAVE_BN_MUL_COMBA4 33#define HAVE_BN_MUL_COMBA4
34#define HAVE_BN_MUL_COMBA6 34#define HAVE_BN_MUL_COMBA6
35#define HAVE_BN_MUL_COMBA8 35#define HAVE_BN_MUL_COMBA8
36#define HAVE_BN_MUL_WORDS
36#define HAVE_BN_MULW_ADD_WORDS 37#define HAVE_BN_MULW_ADD_WORDS
37#define HAVE_BN_MULW_WORDS 38#define HAVE_BN_MULW_WORDS
38 39