diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/bn/arch/aarch64/bn_arch.h | 22 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/arch/amd64/bn_arch.h | 24 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/arch/i386/bn_arch.h | 24 |
3 files changed, 67 insertions, 3 deletions
diff --git a/src/lib/libcrypto/bn/arch/aarch64/bn_arch.h b/src/lib/libcrypto/bn/arch/aarch64/bn_arch.h index 136adf0e97..5cf25adc48 100644 --- a/src/lib/libcrypto/bn/arch/aarch64/bn_arch.h +++ b/src/lib/libcrypto/bn/arch/aarch64/bn_arch.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_arch.h,v 1.1 2023/01/20 10:04:33 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.h,v 1.2 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 | * |
| @@ -15,10 +15,30 @@ | |||
| 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #include <openssl/bn.h> | ||
| 19 | |||
| 18 | #ifndef HEADER_BN_ARCH_H | 20 | #ifndef HEADER_BN_ARCH_H |
| 19 | #define HEADER_BN_ARCH_H | 21 | #define HEADER_BN_ARCH_H |
| 20 | 22 | ||
| 21 | #ifndef OPENSSL_NO_ASM | 23 | #ifndef OPENSSL_NO_ASM |
| 22 | 24 | ||
| 25 | #if defined(__GNUC__) | ||
| 26 | #define HAVE_BN_UMUL_HILO | ||
| 27 | |||
| 28 | static inline void | ||
| 29 | bn_umul_hilo(BN_ULONG a, BN_ULONG b, BN_ULONG *out_h, BN_ULONG *out_l) | ||
| 30 | { | ||
| 31 | BN_ULONG h, l; | ||
| 32 | |||
| 33 | /* Unsigned multiplication using a umulh/mul pair. */ | ||
| 34 | __asm__ ("umulh %0, %2, %3; mul %1, %2, %3" | ||
| 35 | : "=r"(h), "=r"(l) | ||
| 36 | : "r"(a), "r"(b)); | ||
| 37 | |||
| 38 | *out_h = h; | ||
| 39 | *out_l = l; | ||
| 40 | } | ||
| 41 | #endif /* __GNUC__ */ | ||
| 42 | |||
| 23 | #endif | 43 | #endif |
| 24 | #endif | 44 | #endif |
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 | |||
| 67 | static inline void | ||
| 68 | bn_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 |
diff --git a/src/lib/libcrypto/bn/arch/i386/bn_arch.h b/src/lib/libcrypto/bn/arch/i386/bn_arch.h index e2b4957efc..268c51e41a 100644 --- a/src/lib/libcrypto/bn/arch/i386/bn_arch.h +++ b/src/lib/libcrypto/bn/arch/i386/bn_arch.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_arch.h,v 1.7 2023/01/28 16:33:34 jsing Exp $ */ | 1 | /* $OpenBSD: bn_arch.h,v 1.8 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 | * |
| @@ -60,5 +60,27 @@ bn_div_rem_words_inline(BN_ULONG h, BN_ULONG l, BN_ULONG d, BN_ULONG *out_q, | |||
| 60 | } | 60 | } |
| 61 | #endif /* __GNUC__ */ | 61 | #endif /* __GNUC__ */ |
| 62 | 62 | ||
| 63 | #if defined(__GNUC__) | ||
| 64 | #define HAVE_BN_UMUL_HILO | ||
| 65 | |||
| 66 | static inline void | ||
| 67 | bn_umul_hilo(BN_ULONG a, BN_ULONG b, BN_ULONG *out_h, BN_ULONG *out_l) | ||
| 68 | { | ||
| 69 | BN_ULONG h, l; | ||
| 70 | |||
| 71 | /* | ||
| 72 | * Unsigned multiplication of %eax, with the double word result being | ||
| 73 | * stored in %edx:%eax. | ||
| 74 | */ | ||
| 75 | __asm__ ("mull %3" | ||
| 76 | : "=d"(h), "=a"(l) | ||
| 77 | : "a"(a), "rm"(b) | ||
| 78 | : "cc"); | ||
| 79 | |||
| 80 | *out_h = h; | ||
| 81 | *out_l = l; | ||
| 82 | } | ||
| 83 | #endif /* __GNUC__ */ | ||
| 84 | |||
| 63 | #endif | 85 | #endif |
| 64 | #endif | 86 | #endif |
