diff options
| author | jsing <> | 2023-06-21 07:48:41 +0000 |
|---|---|---|
| committer | jsing <> | 2023-06-21 07:48:41 +0000 |
| commit | b0edbf3f98eba4b1effd31584dae0af06eb2deff (patch) | |
| tree | 279fd7ba83f6adb19a12c4a0d34196850a955e43 /src/lib/libcrypto/bn/bn_internal.h | |
| parent | 88e97173c6cf4f4ec8c6138cff25d7b1c51a54e9 (diff) | |
| download | openbsd-b0edbf3f98eba4b1effd31584dae0af06eb2deff.tar.gz openbsd-b0edbf3f98eba4b1effd31584dae0af06eb2deff.tar.bz2 openbsd-b0edbf3f98eba4b1effd31584dae0af06eb2deff.zip | |
Provide and use bn_clzw() in place of bn_word_clz().
On some architectures, we can provide an optimised (often single
instruction) count-leading-zero implementation. In order to do this
effectively, provide bn_clzw() as a static inline that can be replaced
by an architecture specific version. The default implementation defers
to the bn_word_clz() function (which may also be architecture specific).
ok tb@
Diffstat (limited to 'src/lib/libcrypto/bn/bn_internal.h')
| -rw-r--r-- | src/lib/libcrypto/bn/bn_internal.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_internal.h b/src/lib/libcrypto/bn/bn_internal.h index f5c69c5d77..b712b736f6 100644 --- a/src/lib/libcrypto/bn/bn_internal.h +++ b/src/lib/libcrypto/bn/bn_internal.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_internal.h,v 1.13 2023/06/21 07:41:55 jsing Exp $ */ | 1 | /* $OpenBSD: bn_internal.h,v 1.14 2023/06/21 07:48:41 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2023 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -58,6 +58,14 @@ bn_ct_eq_zero_mask(BN_ULONG w) | |||
| 58 | } | 58 | } |
| 59 | #endif | 59 | #endif |
| 60 | 60 | ||
| 61 | #ifndef HAVE_BN_CLZW | ||
| 62 | static inline int | ||
| 63 | bn_clzw(BN_ULONG w) | ||
| 64 | { | ||
| 65 | return bn_word_clz(w); | ||
| 66 | } | ||
| 67 | #endif | ||
| 68 | |||
| 61 | /* | 69 | /* |
| 62 | * Big number primitives are named as the operation followed by a suffix | 70 | * Big number primitives are named as the operation followed by a suffix |
| 63 | * that indicates the number of words that it operates on, where 'w' means | 71 | * that indicates the number of words that it operates on, where 'w' means |
