crypto: x86/chacha - add XChaCha12 support
authorEric Biggers <ebiggers@google.com>
Wed, 5 Dec 2018 06:20:04 +0000 (22:20 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 13 Dec 2018 10:24:58 +0000 (18:24 +0800)
Now that the x86_64 SIMD implementations of ChaCha20 and XChaCha20 have
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: Martin Willi <martin@strongswan.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/chacha_glue.c
crypto/Kconfig

index 35fd02b50d27fadde03ed22a14f159e685b43885..d19c2908be906108d595484121d562e4a599c109 100644 (file)
@@ -232,6 +232,21 @@ static struct skcipher_alg algs[] = {
                .setkey                 = crypto_chacha20_setkey,
                .encrypt                = xchacha_simd,
                .decrypt                = xchacha_simd,
+       }, {
+               .base.cra_name          = "xchacha12",
+               .base.cra_driver_name   = "xchacha12-simd",
+               .base.cra_priority      = 300,
+               .base.cra_blocksize     = 1,
+               .base.cra_ctxsize       = sizeof(struct chacha_ctx),
+               .base.cra_module        = THIS_MODULE,
+
+               .min_keysize            = CHACHA_KEY_SIZE,
+               .max_keysize            = CHACHA_KEY_SIZE,
+               .ivsize                 = XCHACHA_IV_SIZE,
+               .chunksize              = CHACHA_BLOCK_SIZE,
+               .setkey                 = crypto_chacha12_setkey,
+               .encrypt                = xchacha_simd,
+               .decrypt                = xchacha_simd,
        },
 };
 
@@ -268,3 +283,5 @@ MODULE_ALIAS_CRYPTO("chacha20");
 MODULE_ALIAS_CRYPTO("chacha20-simd");
 MODULE_ALIAS_CRYPTO("xchacha20");
 MODULE_ALIAS_CRYPTO("xchacha20-simd");
+MODULE_ALIAS_CRYPTO("xchacha12");
+MODULE_ALIAS_CRYPTO("xchacha12-simd");
index dc3a0e3ea2ac00242aa685cca16320233a4bd3c2..045af6eeb7e2ef01bec8bb6784f5ad82356a540e 100644 (file)
@@ -1473,8 +1473,8 @@ config CRYPTO_CHACHA20_X86_64
        select CRYPTO_BLKCIPHER
        select CRYPTO_CHACHA20
        help
-         SSSE3, AVX2, and AVX-512VL optimized implementations of the ChaCha20
-         and XChaCha20 stream ciphers.
+         SSSE3, AVX2, and AVX-512VL optimized implementations of the ChaCha20,
+         XChaCha20, and XChaCha12 stream ciphers.
 
 config CRYPTO_SEED
        tristate "SEED cipher algorithm"