aboutsummaryrefslogtreecommitdiffstats
path: root/include/crypto/chacha.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/crypto/chacha.h')
-rw-r--r--include/crypto/chacha.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/crypto/chacha.h b/include/crypto/chacha.h
index d1e723c6a37d..542f896115f4 100644
--- a/include/crypto/chacha.h
+++ b/include/crypto/chacha.h
@@ -51,4 +51,19 @@ int crypto_chacha12_setkey(struct crypto_skcipher *tfm, const u8 *key,
int crypto_chacha_crypt(struct skcipher_request *req);
int crypto_xchacha_crypt(struct skcipher_request *req);
+enum chacha_constants { /* expand 32-byte k */
+ CHACHA_CONSTANT_EXPA = 0x61707865U,
+ CHACHA_CONSTANT_ND_3 = 0x3320646eU,
+ CHACHA_CONSTANT_2_BY = 0x79622d32U,
+ CHACHA_CONSTANT_TE_K = 0x6b206574U
+};
+
+static inline void chacha_init_consts(u32 *state)
+{
+ state[0] = CHACHA_CONSTANT_EXPA;
+ state[1] = CHACHA_CONSTANT_ND_3;
+ state[2] = CHACHA_CONSTANT_2_BY;
+ state[3] = CHACHA_CONSTANT_TE_K;
+}
+
#endif /* _CRYPTO_CHACHA_H */