diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2023-07-11 09:54:06 +0100 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2023-09-15 13:57:00 +0000 |
commit | 9a65a570fab1bf2e907d593631a6b588a821d365 (patch) | |
tree | 74e3199721976c3d50a45b97282c76de65485740 /crypto | |
parent | a2c67342eed42f181aa123803bc246b8fad7d1d9 (diff) |
crypto: Add generic 32-bit carry-less multiply routines
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/clmul.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crypto/clmul.c b/crypto/clmul.c index 2c87cfbf8a..36ada1be9d 100644 --- a/crypto/clmul.c +++ b/crypto/clmul.c @@ -79,3 +79,16 @@ uint64_t clmul_16x2_odd(uint64_t n, uint64_t m) { return clmul_16x2_even(n >> 16, m >> 16); } + +uint64_t clmul_32(uint32_t n, uint32_t m32) +{ + uint64_t r = 0; + uint64_t m = m32; + + for (int i = 0; i < 32; ++i) { + r ^= n & 1 ? m : 0; + n >>= 1; + m <<= 1; + } + return r; +} |