Skip to content

Commit bdb063a

Browse files
ebiggersherbertx
authored andcommitted
crypto: arm/chacha - add XChaCha12 support
Now that the 32-bit ARM 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. XChaCha12 is faster than XChaCha20 but has a lower security margin, though still greater than AES-256's since the best known attacks make it through only 7 rounds. See the patch "crypto: chacha - add XChaCha12 support" for more details about why we need XChaCha12 support. 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 3cc2151 commit bdb063a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

arch/arm/crypto/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ config CRYPTO_CRC32_ARM_CE
126126
select CRYPTO_HASH
127127

128128
config CRYPTO_CHACHA20_NEON
129-
tristate "NEON accelerated ChaCha20 stream cipher algorithms"
129+
tristate "NEON accelerated ChaCha stream cipher algorithms"
130130
depends on KERNEL_MODE_NEON
131131
select CRYPTO_BLKCIPHER
132132
select CRYPTO_CHACHA20

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

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
2-
* ChaCha20 (RFC7539) and XChaCha20 stream ciphers, NEON accelerated
2+
* ARM NEON accelerated ChaCha and XChaCha stream ciphers,
3+
* including ChaCha20 (RFC7539)
34
*
45
* Copyright (C) 2016 Linaro, Ltd. <ard.biesheuvel@linaro.org>
56
*
@@ -154,6 +155,22 @@ static struct skcipher_alg algs[] = {
154155
.setkey = crypto_chacha20_setkey,
155156
.encrypt = xchacha_neon,
156157
.decrypt = xchacha_neon,
158+
}, {
159+
.base.cra_name = "xchacha12",
160+
.base.cra_driver_name = "xchacha12-neon",
161+
.base.cra_priority = 300,
162+
.base.cra_blocksize = 1,
163+
.base.cra_ctxsize = sizeof(struct chacha_ctx),
164+
.base.cra_module = THIS_MODULE,
165+
166+
.min_keysize = CHACHA_KEY_SIZE,
167+
.max_keysize = CHACHA_KEY_SIZE,
168+
.ivsize = XCHACHA_IV_SIZE,
169+
.chunksize = CHACHA_BLOCK_SIZE,
170+
.walksize = 4 * CHACHA_BLOCK_SIZE,
171+
.setkey = crypto_chacha12_setkey,
172+
.encrypt = xchacha_neon,
173+
.decrypt = xchacha_neon,
157174
}
158175
};
159176

@@ -180,3 +197,5 @@ MODULE_ALIAS_CRYPTO("chacha20");
180197
MODULE_ALIAS_CRYPTO("chacha20-neon");
181198
MODULE_ALIAS_CRYPTO("xchacha20");
182199
MODULE_ALIAS_CRYPTO("xchacha20-neon");
200+
MODULE_ALIAS_CRYPTO("xchacha12");
201+
MODULE_ALIAS_CRYPTO("xchacha12-neon");

0 commit comments

Comments
 (0)