summaryrefslogtreecommitdiff
path: root/include/crypto/chacha.h
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2019-11-08 15:22:10 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2019-11-17 04:02:39 +0300
commit84e03fa39fbe95a5567d43bff458c6d3b3a23ad1 (patch)
treea778b9890a4fbcf41e2228105f11b3a174eda239 /include/crypto/chacha.h
parent28e8d89b1ce8d2e7badfb5f69971dd635acb8863 (diff)
downloadlinux-84e03fa39fbe95a5567d43bff458c6d3b3a23ad1.tar.xz
crypto: x86/chacha - expose SIMD ChaCha routine as library function
Wire the existing x86 SIMD ChaCha code into the new ChaCha library interface, so that users of the library interface will get the accelerated version when available. Given that calls into the library API will always go through the routines in this module if it is enabled, switch to static keys to select the optimal implementation available (which may be none at all, in which case we defer to the generic implementation for all invocations). Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/crypto/chacha.h')
-rw-r--r--include/crypto/chacha.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/crypto/chacha.h b/include/crypto/chacha.h
index 5c662f8fecac..2676f4fbd4c1 100644
--- a/include/crypto/chacha.h
+++ b/include/crypto/chacha.h
@@ -25,6 +25,12 @@
#define CHACHA_BLOCK_SIZE 64
#define CHACHAPOLY_IV_SIZE 12
+#ifdef CONFIG_X86_64
+#define CHACHA_STATE_WORDS ((CHACHA_BLOCK_SIZE + 12) / sizeof(u32))
+#else
+#define CHACHA_STATE_WORDS (CHACHA_BLOCK_SIZE / sizeof(u32))
+#endif
+
/* 192-bit nonce, then 64-bit stream position */
#define XCHACHA_IV_SIZE 32