Skip to content

Commit 19c11c9

Browse files
ebiggersherbertx
authored andcommitted
crypto: arm64/chacha - add XChaCha12 support
Now that the ARM64 NEON implementation of ChaCha20 and XChaCha20 has been refactored to support varying the number of rounds, add support for XChaCha12. This is identical to XChaCha20 except for the number of rounds, which is 12 instead of 20. This can be used by Adiantum. Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 95a34b7 commit 19c11c9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

arch/arm64/crypto/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ config CRYPTO_AES_ARM64_NEON_BLK
101101
select CRYPTO_SIMD
102102

103103
config CRYPTO_CHACHA20_NEON
104-
tristate "ChaCha20 and XChaCha20 stream ciphers using NEON instructions"
104+
tristate "ChaCha20, XChaCha20, and XChaCha12 stream ciphers using NEON instructions"
105105
depends on KERNEL_MODE_NEON
106106
select CRYPTO_BLKCIPHER
107107
select CRYPTO_CHACHA20

arch/arm64/crypto/chacha-neon-glue.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,22 @@ static struct skcipher_alg algs[] = {
161161
.setkey = crypto_chacha20_setkey,
162162
.encrypt = xchacha_neon,
163163
.decrypt = xchacha_neon,
164+
}, {
165+
.base.cra_name = "xchacha12",
166+
.base.cra_driver_name = "xchacha12-neon",
167+
.base.cra_priority = 300,
168+
.base.cra_blocksize = 1,
169+
.base.cra_ctxsize = sizeof(struct chacha_ctx),
170+
.base.cra_module = THIS_MODULE,
171+
172+
.min_keysize = CHACHA_KEY_SIZE,
173+
.max_keysize = CHACHA_KEY_SIZE,
174+
.ivsize = XCHACHA_IV_SIZE,
175+
.chunksize = CHACHA_BLOCK_SIZE,
176+
.walksize = 4 * CHACHA_BLOCK_SIZE,
177+
.setkey = crypto_chacha12_setkey,
178+
.encrypt = xchacha_neon,
179+
.decrypt = xchacha_neon,
164180
}
165181
};
166182

@@ -187,3 +203,5 @@ MODULE_ALIAS_CRYPTO("chacha20");
187203
MODULE_ALIAS_CRYPTO("chacha20-neon");
188204
MODULE_ALIAS_CRYPTO("xchacha20");
189205
MODULE_ALIAS_CRYPTO("xchacha20-neon");
206+
MODULE_ALIAS_CRYPTO("xchacha12");
207+
MODULE_ALIAS_CRYPTO("xchacha12-neon");

0 commit comments

Comments
 (0)