summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/bn/arch/riscv64/bn_arch.h19
1 files changed, 18 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 a8c50eb06d..e67de835cf 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.6 2023/07/09 10:36:53 jsing Exp $ */ 1/* $OpenBSD: bn_arch.h,v 1.7 2023/07/09 10:37:32 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2023 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -63,6 +63,23 @@ bn_mulw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0)
63 *out_r0 = r0; 63 *out_r0 = r0;
64} 64}
65 65
66#define HAVE_BN_SUBW
67
68static inline void
69bn_subw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_borrow, BN_ULONG *out_r0)
70{
71 BN_ULONG borrow, r0;
72
73 __asm__ (
74 "sub %[r0], %[a], %[b] \n"
75 "sltu %[borrow], %[a], %[r0] \n"
76 : [borrow]"=r"(borrow), [r0]"=&r"(r0)
77 : [a]"r"(a), [b]"r"(b));
78
79 *out_borrow = borrow;
80 *out_r0 = r0;
81}
82
66#endif /* __GNUC__ */ 83#endif /* __GNUC__ */
67 84
68#endif 85#endif