summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/arch/amd64
diff options
context:
space:
mode:
authorjsing <>2023-01-31 05:53:49 +0000
committerjsing <>2023-01-31 05:53:49 +0000
commitd01df6f0fe7345b00a19d3fd859f0465dd8a4fef (patch)
treef6eafed2d63abe3f401102b16ad76629ca2657c6 /src/lib/libcrypto/bn/arch/amd64
parentd984e83f80012236dbd144f0263f290c7ce95c8a (diff)
downloadopenbsd-d01df6f0fe7345b00a19d3fd859f0465dd8a4fef.tar.gz
openbsd-d01df6f0fe7345b00a19d3fd859f0465dd8a4fef.tar.bz2
openbsd-d01df6f0fe7345b00a19d3fd859f0465dd8a4fef.zip
Provide inline assembly versions of bn_umul_hilo() for aarch64/amd64/i386.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/bn/arch/amd64')
-rw-r--r--src/lib/libcrypto/bn/arch/amd64/bn_arch.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/arch/amd64/bn_arch.h b/src/lib/libcrypto/bn/arch/amd64/bn_arch.h
index 6b7eaf5eee..9e4b6b9442 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.8 2023/01/28 16:33:34 jsing Exp $ */ 1/* $OpenBSD: bn_arch.h,v 1.9 2023/01/31 05:53:49 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -61,5 +61,27 @@ bn_div_rem_words_inline(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q,
61} 61}
62#endif /* __GNUC__ */ 62#endif /* __GNUC__ */
63 63
64#if defined(__GNUC__)
65#define HAVE_BN_UMUL_HILO
66
67static inline void
68bn_umul_hilo(BN_ULONG a, BN_ULONG b, BN_ULONG *out_h, BN_ULONG *out_l)
69{
70 BN_ULONG h, l;
71
72 /*
73 * Unsigned multiplication of %rax, with the double word result being
74 * stored in %rdx:%rax.
75 */
76 __asm__ ("mulq %3"
77 : "=d"(h), "=a"(l)
78 : "a"(a), "rm"(b)
79 : "cc");
80
81 *out_h = h;
82 *out_l = l;
83}
84#endif /* __GNUC__ */
85
64#endif 86#endif
65#endif 87#endif