kernel_optimize_test/crypto
Eric Biggers de61d7ae5d crypto: chacha20-generic - add XChaCha20 support
Add support for the XChaCha20 stream cipher.  XChaCha20 is the
application of the XSalsa20 construction
(https://cr.yp.to/snuffle/xsalsa-20081128.pdf) to ChaCha20 rather than
to Salsa20.  XChaCha20 extends ChaCha20's nonce length from 64 bits (or
96 bits, depending on convention) to 192 bits, while provably retaining
ChaCha20's security.  XChaCha20 uses the ChaCha20 permutation to map the
key and first 128 nonce bits to a 256-bit subkey.  Then, it does the
ChaCha20 stream cipher with the subkey and remaining 64 bits of nonce.

We need XChaCha support in order to add support for the Adiantum
encryption mode.  Note that to meet our performance requirements, we
actually plan to primarily use the variant XChaCha12.  But we believe
it's wise to first add XChaCha20 as a baseline with a higher security
margin, in case there are any situations where it can be used.
Supporting both variants is straightforward.

Since XChaCha20's subkey differs for each request, XChaCha20 can't be a
template that wraps ChaCha20; that would require re-keying the
underlying ChaCha20 for every request, which wouldn't be thread-safe.
Instead, we make XChaCha20 its own top-level algorithm which calls the
ChaCha20 streaming implementation internally.

Similar to the existing ChaCha20 implementation, we define the IV to be
the nonce and stream position concatenated together.  This allows users
to seek to any position in the stream.

I considered splitting the code into separate chacha20-common, chacha20,
and xchacha20 modules, so that chacha20 and xchacha20 could be
enabled/disabled independently.  However, since nearly all the code is
shared anyway, I ultimately decided there would have been little benefit
to the added complexity of separate modules.

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Martin Willi <martin@strongswan.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2018-11-20 14:26:55 +08:00
..
asymmetric_keys KEYS: asym_tpm: Add support for the sign operation [ver #2] 2018-10-26 09:30:47 +01:00
async_tx
842.c
ablkcipher.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
acompress.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
aead.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
aegis.h
aegis128.c
aegis128l.c
aegis256.c
aes_generic.c crypto: arm/aes - add some hardening against cache-timing attacks 2018-11-09 17:36:48 +08:00
aes_ti.c crypto: aes_ti - disable interrupts while accessing S-box 2018-11-09 17:36:48 +08:00
af_alg.c
ahash.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
akcipher.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
algapi.c
algboss.c
algif_aead.c
algif_hash.c
algif_rng.c
algif_skcipher.c
ansi_cprng.c
anubis.c
api.c
arc4.c
authenc.c
authencesn.c
blkcipher.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
blowfish_common.c
blowfish_generic.c
camellia_generic.c
cast_common.c
cast5_generic.c
cast6_generic.c
cbc.c
ccm.c
cfb.c crypto: cfb - fix decryption 2018-11-09 17:40:59 +08:00
chacha20_generic.c crypto: chacha20-generic - add XChaCha20 support 2018-11-20 14:26:55 +08:00
chacha20poly1305.c crypto: chacha20poly1305 - export CHACHAPOLY_IV_SIZE 2018-11-16 14:11:03 +08:00
cipher.c
cmac.c
compress.c
crc32_generic.c
crc32c_generic.c
crct10dif_common.c
crct10dif_generic.c
cryptd.c
crypto_engine.c
crypto_null.c
crypto_user_base.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
crypto_user_stat.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
crypto_wq.c
ctr.c
cts.c
deflate.c
des_generic.c
dh_helper.c
dh.c
drbg.c
ecb.c
ecc_curve_defs.h
ecc.c crypto: ecc - regularize scalar for scalar multiplication 2018-11-16 14:11:04 +08:00
ecc.h
ecdh_helper.c
ecdh.c
echainiv.c
fcrypt.c
fips.c
gcm.c
gf128mul.c
ghash-generic.c
hash_info.c crypto: streebog - register Streebog in hash info for IMA 2018-11-16 14:09:40 +08:00
hmac.c
internal.h
jitterentropy-kcapi.c
jitterentropy.c
Kconfig crypto: chacha20-generic - add XChaCha20 support 2018-11-20 14:26:55 +08:00
keywrap.c
khazad.c
kpp.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
lrw.c
lz4.c crypto: remove useless initializations of cra_list 2018-11-20 14:26:55 +08:00
lz4hc.c crypto: remove useless initializations of cra_list 2018-11-20 14:26:55 +08:00
lzo.c
Makefile crypto: streebog - add Streebog hash function 2018-11-16 14:09:40 +08:00
md4.c
md5.c
memneq.c
michael_mic.c
morus640.c
morus1280.c
ofb.c
pcbc.c
pcrypt.c pcrypt: use format specifier in kobject_add 2018-11-09 17:41:39 +08:00
poly1305_generic.c
proc.c
ripemd.h
rmd128.c
rmd160.c
rmd256.c
rmd320.c
rng.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
rsa_helper.c
rsa-pkcs1pad.c crypto: rsa-pkcs1pad: Allow hash to be optional [ver #2] 2018-10-26 09:30:46 +01:00
rsa.c
rsaprivkey.asn1
rsapubkey.asn1
salsa20_generic.c
scatterwalk.c
scompress.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
seed.c
seqiv.c
serpent_generic.c
sha1_generic.c
sha3_generic.c
sha256_generic.c
sha512_generic.c
shash.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
simd.c crypto: simd - correctly take reqsize of wrapped skcipher into account 2018-11-09 17:35:43 +08:00
skcipher.c crypto: user - clean up report structure copying 2018-11-09 17:41:39 +08:00
sm3_generic.c
sm4_generic.c
streebog_generic.c crypto: streebog - add Streebog hash function 2018-11-16 14:09:40 +08:00
tcrypt.c crypto: streebog - add Streebog test vectors 2018-11-16 14:11:02 +08:00
tcrypt.h
tea.c
testmgr.c crypto: chacha20-generic - add XChaCha20 support 2018-11-20 14:26:55 +08:00
testmgr.h crypto: chacha20-generic - add XChaCha20 support 2018-11-20 14:26:55 +08:00
tgr192.c
twofish_common.c
twofish_generic.c
vmac.c
wp512.c
xcbc.c
xor.c
xts.c
zstd.c