summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2025-09-01 15:35:25 +0000
committerjsing <>2025-09-01 15:35:25 +0000
commit99d47c1078643352842f47b6330086d9affefb59 (patch)
tree876dbe24967342f1e8d8f06b3df8bec76ea639b3 /src
parentedd4db8b24106490f82c1a694d4e2b35afe9c6cb (diff)
downloadopenbsd-99d47c1078643352842f47b6330086d9affefb59.tar.gz
openbsd-99d47c1078643352842f47b6330086d9affefb59.tar.bz2
openbsd-99d47c1078643352842f47b6330086d9affefb59.zip
Use bn_mul_words() from bn_mod_mul_words().
Use bn_mul_words() and bn_montgomery_reduce_words(), rather than using bn_montgomery_multiply_words(). This provides better performance on architectures that have assembly optimised bn_mul_words(), such as amd64.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_mod_words.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/lib/libcrypto/bn/bn_mod_words.c b/src/lib/libcrypto/bn/bn_mod_words.c
index 7c07b49fab..93c6567364 100644
--- a/src/lib/libcrypto/bn/bn_mod_words.c
+++ b/src/lib/libcrypto/bn/bn_mod_words.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mod_words.c,v 1.4 2025/09/01 15:18:55 jsing Exp $ */ 1/* $OpenBSD: bn_mod_words.c,v 1.5 2025/09/01 15:35:25 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2024 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -75,16 +75,14 @@ bn_mod_mul_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
75{ 75{
76 if (n == 4) { 76 if (n == 4) {
77 bn_mul_comba4(t, a, b); 77 bn_mul_comba4(t, a, b);
78 bn_montgomery_reduce_words(r, t, m, m0, n);
79 } else if (n == 6) { 78 } else if (n == 6) {
80 bn_mul_comba6(t, a, b); 79 bn_mul_comba6(t, a, b);
81 bn_montgomery_reduce_words(r, t, m, m0, n);
82 } else if (n == 8) { 80 } else if (n == 8) {
83 bn_mul_comba8(t, a, b); 81 bn_mul_comba8(t, a, b);
84 bn_montgomery_reduce_words(r, t, m, m0, n);
85 } else { 82 } else {
86 bn_montgomery_multiply_words(r, a, b, m, t, m0, n); 83 bn_mul_words(t, a, n, b, n);
87 } 84 }
85 bn_montgomery_reduce_words(r, t, m, m0, n);
88} 86}
89#endif 87#endif
90 88