diff options
| author | Eric Biggers <ebiggers@google.com> | 2025-04-05 11:26:09 -0700 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2025-04-07 13:22:28 +0800 |
| commit | d23fce15abd480811098c0bca6d4edeb17824279 (patch) | |
| tree | 7e4e5ecd3a741e5b33cc1790dd220d46acf57833 /crypto | |
| parent | 632ab0978f0895ca2e477b053d9933768cf0339a (diff) | |
crypto: chacha - remove <crypto/internal/chacha.h>
<crypto/internal/chacha.h> is now included only by crypto/chacha.c, so
fold it into there.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
| -rw-r--r-- | crypto/chacha.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/crypto/chacha.c b/crypto/chacha.c index 2009038c5e56..5103bc0b2881 100644 --- a/crypto/chacha.c +++ b/crypto/chacha.c @@ -8,10 +8,43 @@ #include <linux/unaligned.h> #include <crypto/algapi.h> -#include <crypto/internal/chacha.h> +#include <crypto/chacha.h> #include <crypto/internal/skcipher.h> #include <linux/module.h> +struct chacha_ctx { + u32 key[8]; + int nrounds; +}; + +static int chacha_setkey(struct crypto_skcipher *tfm, + const u8 *key, unsigned int keysize, int nrounds) +{ + struct chacha_ctx *ctx = crypto_skcipher_ctx(tfm); + int i; + + if (keysize != CHACHA_KEY_SIZE) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(ctx->key); i++) + ctx->key[i] = get_unaligned_le32(key + i * sizeof(u32)); + + ctx->nrounds = nrounds; + return 0; +} + +static int chacha20_setkey(struct crypto_skcipher *tfm, + const u8 *key, unsigned int keysize) +{ + return chacha_setkey(tfm, key, keysize, 20); +} + +static int chacha12_setkey(struct crypto_skcipher *tfm, + const u8 *key, unsigned int keysize) +{ + return chacha_setkey(tfm, key, keysize, 12); +} + static int chacha_stream_xor(struct skcipher_request *req, const struct chacha_ctx *ctx, const u8 *iv, bool arch) |
