[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 09/19] crypto: Add generic 32-bit carry-less multiply routines
From: |
Richard Henderson |
Subject: |
[PULL 09/19] crypto: Add generic 32-bit carry-less multiply routines |
Date: |
Fri, 15 Sep 2023 09:42:21 -0700 |
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/crypto/clmul.h | 7 +++++++
crypto/clmul.c | 13 +++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/crypto/clmul.h b/include/crypto/clmul.h
index 72672b237c..80de516464 100644
--- a/include/crypto/clmul.h
+++ b/include/crypto/clmul.h
@@ -54,4 +54,11 @@ uint64_t clmul_16x2_even(uint64_t, uint64_t);
*/
uint64_t clmul_16x2_odd(uint64_t, uint64_t);
+/**
+ * clmul_32:
+ *
+ * Perform a 32x32->64 carry-less multiply.
+ */
+uint64_t clmul_32(uint32_t, uint32_t);
+
#endif /* CRYPTO_CLMUL_H */
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;
+}
--
2.34.1
- [PULL 00/19] crypto: Provide clmul.h and host accel, Richard Henderson, 2023/09/15
- [PULL 01/19] crypto: Add generic 8-bit carry-less multiply routines, Richard Henderson, 2023/09/15
- [PULL 02/19] target/arm: Use clmul_8* routines, Richard Henderson, 2023/09/15
- [PULL 03/19] target/s390x: Use clmul_8* routines, Richard Henderson, 2023/09/15
- [PULL 04/19] target/ppc: Use clmul_8* routines, Richard Henderson, 2023/09/15
- [PULL 05/19] crypto: Add generic 16-bit carry-less multiply routines, Richard Henderson, 2023/09/15
- [PULL 06/19] target/arm: Use clmul_16* routines, Richard Henderson, 2023/09/15
- [PULL 07/19] target/s390x: Use clmul_16* routines, Richard Henderson, 2023/09/15
- [PULL 08/19] target/ppc: Use clmul_16* routines, Richard Henderson, 2023/09/15
- [PULL 09/19] crypto: Add generic 32-bit carry-less multiply routines,
Richard Henderson <=
- [PULL 10/19] target/arm: Use clmul_32* routines, Richard Henderson, 2023/09/15
- [PULL 12/19] target/ppc: Use clmul_32* routines, Richard Henderson, 2023/09/15
- [PULL 11/19] target/s390x: Use clmul_32* routines, Richard Henderson, 2023/09/15
- [PULL 15/19] target/i386: Use clmul_64, Richard Henderson, 2023/09/15
- [PULL 16/19] target/s390x: Use clmul_64, Richard Henderson, 2023/09/15
- [PULL 17/19] target/ppc: Use clmul_64, Richard Henderson, 2023/09/15
- [PULL 18/19] host/include/i386: Implement clmul.h, Richard Henderson, 2023/09/15
- [PULL 13/19] crypto: Add generic 64-bit carry-less multiply routine, Richard Henderson, 2023/09/15
- [PULL 14/19] target/arm: Use clmul_64, Richard Henderson, 2023/09/15
- [PULL 19/19] host/include/aarch64: Implement clmul.h, Richard Henderson, 2023/09/15