summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/arch/riscv64/bn_arch.h')
-rw-r--r--src/lib/libcrypto/bn/arch/riscv64/bn_arch.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h b/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h
index 4d6571f9cb..1b4267acc0 100644
--- a/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h
+++ b/src/lib/libcrypto/bn/arch/riscv64/bn_arch.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_arch.h,v 1.1 2023/01/20 10:04:34 jsing Exp $ */ 1/* $OpenBSD: bn_arch.h,v 1.2 2023/01/31 05:57:08 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -20,5 +20,29 @@
20 20
21#ifndef OPENSSL_NO_ASM 21#ifndef OPENSSL_NO_ASM
22 22
23#if 0 /* Needs testing and enabling. */
24#if defined(__GNUC__)
25#define HAVE_BN_UMUL_HILO
26
27static inline void
28bn_umul_hilo(BN_ULONG a, BN_ULONG b, BN_ULONG *out_h, BN_ULONG *out_l)
29{
30 BN_ULONG h, l;
31
32 /*
33 * Unsigned multiplication using a mulh/mul pair. Note that the order
34 * of these instructions is important, as they can potentially be fused
35 * into a single operation.
36 */
37 __asm__ ("mulh %0, %2, %3; mul %1, %2, %3"
38 : "=r"(h), "=r"(l)
39 : "r"(a), "r"(b));
40
41 *out_h = h;
42 *out_l = l;
43}
44#endif /* __GNUC__ */
45#endif
46
23#endif 47#endif
24#endif 48#endif