crypto: HPolyC support
Subsystems (13)
Eric Biggers
maintainercover crypto: HPolyC support
From: Eric Biggers <[email protected]>
Hi all,
(Please note that this patchset is a true RFC, i.e. we're not ready for it to be merged quite yet!)
It was officially decided to *not* allow Android devices to use Speck encryption [1]. We've been working to find an alternative way to bring storage encryption to entry-level Android devices like the inexpensive "Android Go" devices sold in developing countries. Unfortunately, often these devices still ship with no encryption, since for cost reasons they have to use older CPUs like ARM Cortex-A7; and these CPUs lack the ARMv8 Cryptography Extensions, making AES-XTS much too slow.
As we explained in detail earlier, e.g. in [2], this is a very challenging problem due to the lack of encryption algorithms that meet the very strict performance requirements, while still being secure and suitable for practical use in dm-crypt and fscrypt. And as we saw with Speck, in this day and age the choice of cryptographic primitives also has a large political element, restricting the options even further.
Therefore, we (well, Paul Crowley did the real work) designed a new encryption mode, HPolyC. In essence, HPolyC makes it secure to use the ChaCha stream cipher for disk encryption. HPolyC is specified by our paper here: https://eprint.iacr.org/2018/720.pdf ("HPolyC:
length-preserving encryption for entry-level processors"). Reference code and test vectors are here: https://github.com/google/hpolyc. Many of the high-level concepts of HPolyC are not new; similar existing modes include XCB, HCTR, HCH, and HMC. HPolyC and these modes are true wide-block modes (tweakable super-pseudorandom permutations), so they actually provide a stronger notion of security than XTS.
HPolyC encrypts each message using XChaCha12 or XChaCha20 sandwiched between two passes of Poly1305, plus a single block cipher invocation (e.g. AES-256) per message. On ARM Cortex-A7, on 4096-byte messages HPolyC-XChaCha12-AES is slightly faster than Speck128/256-XTS. Note that for long messages, the block cipher is not performance-critical since it's only invoked once per message; that's why we can use AES in HPolyC, despite the fully AES-based encryption modes being too slow.
HPolyC is a construction, not a primitive. It is proven secure if XChaCha and AES are secure, subject to a security bound. Unless there is a mistake in this proof, one therefore does not need to trust HPolyC; one need only trust XChaCha (which itself has a security reduction to ChaCha) and AES.
This RFC patchset implements HPolyC for Linux's crypto API. Patches 1-8 add support for XChaCha20, XChaCha12, and NEON-accelerated Poly1305. The final patch adds the actual HPolyC template. Note: my patches may eventually need to be redone on top of Jason Donenfeld's new crypto library for WireGuard. But, I decided to send them out now anyway since there was a strong desire to give HPolyC a wider audience and I had already written the patches, and to inform the design discussion for the new crypto library.
We attest that no "backdoor" or other weakness was inserted into HPolyC, its implementation, or any other aspect of our work; and that to the best of our knowledge, HPolyC's security proof is correct. You don't have to trust us, though: since HPolyC is a construction, not a primitive, its security proof can be independently verified by anyone. We invite additional independent review of HPolyC; and out of caution (since we did publish our paper only very recently, and we are only human, and humans can make mistakes even in proofs), we recommend that this patchset not be merged or used in production quite yet. Also, this proposal is not final, and may yet be changed if improvements are found.
This patchset can also be found in git at
https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git
branch "hpolyc-v1".
Footnotes:
[1] Yes, that means we won't actually be needing my implementations of Speck for the crypto API. So, we no longer have any objection to them being removed. I just ask that if anyone would like to restart that discussion, you please start a new thread rather than using this one, so as to not derail any discussion on HPolyC.
[2] https://www.spinics.net/lists/linux-crypto/msg33000.html
Eric Biggers (9):
crypto: chacha20-generic - add HChaCha20 library function
crypto: chacha20-generic - add XChaCha20 support
crypto: chacha20-generic - refactor to allow varying number of rounds
crypto: chacha - add XChaCha12 support
crypto: arm/chacha20 - add XChaCha20 support
crypto: arm/chacha20 - refactor to allow varying number of rounds
crypto: arm/chacha - add XChaCha12 support
crypto: arm/poly1305 - add NEON accelerated Poly1305 implementation
crypto: hpolyc - add support for the HPolyC encryption mode
arch/arm/crypto/Kconfig | 7 +-
arch/arm/crypto/Makefile | 6 +-
...hacha20-neon-core.S => chacha-neon-core.S} | 107 +-
arch/arm/crypto/chacha-neon-glue.c | 207 +++
arch/arm/crypto/chacha20-neon-glue.c | 127 --
arch/arm/crypto/poly1305-neon-core.S | 1115 ++++++++++++++
arch/arm/crypto/poly1305-neon-glue.c | 325 ++++
arch/arm64/crypto/chacha20-neon-glue.c | 40 +-
arch/x86/crypto/chacha20_glue.c | 52 +-
crypto/Kconfig | 48 +-
crypto/Makefile | 3 +-
crypto/chacha20_generic.c | 136 --
crypto/chacha20poly1305.c | 10 +-
crypto/chacha_generic.c | 216 +++
crypto/hpolyc.c | 577 ++++++++
crypto/testmgr.c | 24 +
crypto/testmgr.h | 1313 +++++++++++++++++
drivers/char/random.c | 50 +-
include/crypto/chacha.h | 56 +
include/crypto/chacha20.h | 28 -
lib/Makefile | 2 +-
lib/{chacha20.c => chacha.c} | 61 +-
22 files changed, 4083 insertions(+), 427 deletions(-)
rename arch/arm/crypto/{chacha20-neon-core.S => chacha-neon-core.S} (89%)
create mode 100644 arch/arm/crypto/chacha-neon-glue.c
delete mode 100644 arch/arm/crypto/chacha20-neon-glue.c
create mode 100644 arch/arm/crypto/poly1305-neon-core.S
create mode 100644 arch/arm/crypto/poly1305-neon-glue.c
delete mode 100644 crypto/chacha20_generic.c
create mode 100644 crypto/chacha_generic.c
create mode 100644 crypto/hpolyc.c
create mode 100644 include/crypto/chacha.h
delete mode 100644 include/crypto/chacha20.h
rename lib/{chacha20.c => chacha.c} (57%)Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Eric Biggers
maintainerRFC PATCH 1/9 crypto: chacha20-generic - add HChaCha20 library function
From: Eric Biggers <[email protected]>
Refactor the unkeyed permutation part of chacha20_block() into its own function, then add hchacha20_block() which is the ChaCha equivalent of HSalsa20 and is an intermediate step towards XChaCha20 (see
https://cr.yp.to/snuffle/xsalsa-20081128.pdf). HChaCha20 skips the final addition of the initial state, and outputs only certain words of the state. It should not be used for streaming directly.
--- include/crypto/chacha20.h | 2 ++ lib/chacha20.c | 52 +++++++++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 7 deletions(-)
include/crypto/chacha20.h +2 -0
@@ -20,6 +20,8 @@ struct chacha20_ctx { };void chacha20_block (u32 *state,u32 *stream); +void hchacha20_block (const u32 *in,u32 *out); +void crypto_chacha20_init (u32 *state,struct chacha20_ctx *ctx,u8 *iv);int crypto_chacha20_setkey (struct crypto_skcipher *tfm,const u8 *key,unsigned int keysize);
lib/chacha20.c +45 -7
74 lines not on this page · raw message
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Eric Biggers
maintainerRFC PATCH 2/9 crypto: chacha20-generic - add XChaCha20 support
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
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 XChaCha20 support in order to add support for the HPolyC construction, which uses XChaCha. Note that to meet our performance requirements, we actually plan to primarily use the reduced-round 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.
--- crypto/Kconfig | 14 +- crypto/chacha20_generic.c | 120 +++++--- crypto/testmgr.c | 6 + crypto/testmgr.h | 577 ++++++++++++++++++++++++++++++++++++++ include/crypto/chacha20.h | 14 +- 5 files changed, 689 insertions(+), 42 deletions(-)
crypto/Kconfig +9 -5
@@ -1437,18 +1437,22 @@ config CRYPTO_SALSA20 Bernstein <[email protected]>. See <http://cr.yp.to/snuffle.html> config CRYPTO_CHACHA20 - tristate "ChaCha20 cipher algorithm" + tristate "ChaCha20 stream cipher algorithms" select CRYPTO_BLKCIPHER help - ChaCha20 cipher algorithm, RFC7539. + The ChaCha20 and XChaCha20 stream cipher algorithms. ChaCha20 is a 256-bit high-speed stream cipher designed by Daniel J. Bernstein and further specified in RFC7539 for use in IETF protocols. - This is the portable C implementation of ChaCha20. - - See also: + This is the portable C implementation of ChaCha20. See also: <http://cr.yp.to/chacha/chacha-20080128.pdf> + XChaCha20 is the application of the XSalsa20 construction to ChaCha20 + rather than to Salsa20. XChaCha20 extends ChaCha20's nonce length + from 64 bits (or 96 bits using the RFC7539 convention) to 192 bits, + while provably retaining ChaCha20's security. See also: + <https://cr.yp.to/snuffle/xsalsa-20081128.pdf> + config CRYPTO_CHACHA20_X86_64 tristate "ChaCha20 cipher algorithm (x86_64/SSSE3/AVX2)" depends on X86 && 64BIT
crypto/chacha20_generic.c +84 -36
157 lines not on this page · raw message
crypto/testmgr.c +6 -0
@@ -3544,6 +3544,12 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .hash = __VECS(aes_xcbc128_tv_template) } + }, { + .alg = "xchacha20", + .test = alg_test_skcipher, + .suite = { + .cipher =__VECS (xchacha20_tv_template) + }, }, { .alg = "xts(aes)", .test = alg_test_skcipher,
crypto/testmgr.h +577 -0
583 lines not on this page · raw message
include/crypto/chacha20.h +13 -1
@@ -1,6 +1,10 @@/* SPDX-License-Identifier: GPL-2.0 */ /* -* Common values for the ChaCha20 algorithm +* Common values and helper functions for the ChaCha20 and XChaCha20 algorithms. +* +* XChaCha20 extends ChaCha20's nonce to 192 bits, while provably retaining +* ChaCha20's security. Here they share the same key size, tfm context, and +* setkey function; only their IV size and encrypt/decrypt function differ. */ #ifndef _CRYPTO_CHACHA20_H
@@ -10,11 +14,16 @@#include <linux/types.h> #include <linux/crypto.h> +/* 32-bit stream position, then 96-bit nonce (RFC7539 convention) */ #define CHACHA20_IV_SIZE 16 +#define CHACHA20_KEY_SIZE 32#define CHACHA20_BLOCK_SIZE 64#define CHACHA20_BLOCK_WORDS (CHACHA20_BLOCK_SIZE / sizeof(u32)) +/* 192-bit nonce, then 64-bit stream position */ +#define XCHACHA20_IV_SIZE 32 +struct chacha20_ctx {u32 key[8 ]; };
@@ -23,8 +32,11 @@ void chacha20_block(u32 *state, u32 *stream);void hchacha20_block (const u32 *in,u32 *out);void crypto_chacha20_init (u32 *state,struct chacha20_ctx *ctx,u8 *iv); +int crypto_chacha20_setkey (struct crypto_skcipher *tfm,const u8 *key,unsigned int keysize); +int crypto_chacha20_crypt (struct skcipher_request *req); +int crypto_xchacha20_crypt (struct skcipher_request *req);#endif
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Eric Biggers
maintainerRFC PATCH 3/9 crypto: chacha20-generic - refactor to allow varying number of rounds
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
In preparation for adding XChaCha12 support, rename/refactor chacha20-generic to support different numbers of rounds.
The only difference between ChaCha{8,12,20} are the number of rounds itself; all other parts of the algorithm are the same. Therefore, remove the "20" from all definitions, structures, functions, files, etc. that will be shared by all ChaCha versions.
Also make ->setkey() store the round count in the chacha_ctx (previously chacha20_ctx). The generic code then passes the round count through to chacha_block(). There will be a ->setkey() function for each explicitly allowed round count; the encrypt/decrypt functions will be the same. I decided not to do it the opposite way (same ->setkey() function for all round counts, with different encrypt/decrypt functions) because that would have required more boilerplate code in architecture-specific implementations of ChaCha and XChaCha.
To be as careful as possible, we whitelist the allowed round counts in the low-level generic code. Currently only 20 is allowed, i.e. no actual use of reduced-round ChaCha is introduced by this patch.
---
arch/arm/crypto/chacha20-neon-glue.c | 44 +++----
arch/arm64/crypto/chacha20-neon-glue.c | 40 +++----
arch/x86/crypto/chacha20_glue.c | 52 ++++-----
crypto/Makefile | 2 +-
crypto/chacha20poly1305.c | 10 +-
.../{chacha20_generic.c => chacha_generic.c} | 110 ++++++++++--------
drivers/char/random.c | 50 ++++----
include/crypto/chacha.h | 47 ++++++++
include/crypto/chacha20.h | 42 -------
lib/Makefile | 2 +-
lib/{chacha20.c => chacha.c} | 43 ++++---
11 files changed, 230 insertions(+), 212 deletions(-)
rename crypto/{chacha20_generic.c => chacha_generic.c} (56%)
create mode 100644 include/crypto/chacha.h
delete mode 100644 include/crypto/chacha20.h
rename lib/{chacha20.c => chacha.c} (67%)arch/arm/crypto/chacha20-neon-glue.c +22 -22
@@ -19,7 +19,7 @@*/ #include <crypto/algapi.h> -#include <crypto/chacha20.h> +#include <crypto/chacha.h> #include <crypto/internal/skcipher.h> #include <linux/kernel.h> #include <linux/module.h>
@@ -34,20 +34,20 @@ asmlinkage void chacha20_4block_xor_neon(u32 *state, u8 *dst, const u8 *src);static void chacha20_doneon (u32 *state,u8 *dst,const u8 *src,unsigned int bytes) { -u8 buf[CHACHA20_BLOCK_SIZE ]; +u8 buf[CHACHA_BLOCK_SIZE ]; -while (bytes >=CHACHA20_BLOCK_SIZE *4 ) { +while (bytes >=CHACHA_BLOCK_SIZE *4 ) {chacha20_4block_xor_neon (state, dst, src); - bytes -=CHACHA20_BLOCK_SIZE *4 ; - src +=CHACHA20_BLOCK_SIZE *4 ; - dst +=CHACHA20_BLOCK_SIZE *4 ; + bytes -=CHACHA_BLOCK_SIZE *4 ; + src +=CHACHA_BLOCK_SIZE *4 ; + dst +=CHACHA_BLOCK_SIZE *4 ; state[12 ] +=4 ; } -while (bytes >=CHACHA20_BLOCK_SIZE ) { +while (bytes >=CHACHA_BLOCK_SIZE ) {chacha20_block_xor_neon (state, dst, src); - bytes -=CHACHA20_BLOCK_SIZE ; - src +=CHACHA20_BLOCK_SIZE ; - dst +=CHACHA20_BLOCK_SIZE ; + bytes -=CHACHA_BLOCK_SIZE ; + src +=CHACHA_BLOCK_SIZE ; + dst +=CHACHA_BLOCK_SIZE ; state[12 ]++; }if (bytes) {
@@ -60,17 +60,17 @@ static void chacha20_doneon(u32 *state, u8 *dst, const u8 *src,static int chacha20_neon (struct skcipher_request *req) {struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req); -struct chacha20_ctx *ctx =crypto_skcipher_ctx (tfm); +struct chacha_ctx *ctx =crypto_skcipher_ctx (tfm);struct skcipher_walk walk;u32 state[16 ];int err; -if (req->cryptlen <=CHACHA20_BLOCK_SIZE || !may_use_simd ()) -return crypto_chacha20_crypt (req); +if (req->cryptlen <=CHACHA_BLOCK_SIZE || !may_use_simd ()) +return crypto_chacha_crypt (req); err =skcipher_walk_virt (&walk, req, true); -crypto_chacha20_init (state, ctx, walk.iv); +crypto_chacha_init (state, ctx, walk.iv);kernel_neon_begin ();while (walk.nbytes >0 ) {
@@ -93,17 +93,17 @@ static struct skcipher_alg alg = { .base.cra_driver_name = "chacha20-neon", .base.cra_priority = 300, .base.cra_blocksize = 1, - .base.cra_ctxsize = sizeof(struct chacha20_ctx), + .base.cra_ctxsize = sizeof(struct chacha_ctx), .base.cra_module = THIS_MODULE, - .min_keysize = CHACHA20_KEY_SIZE, - .max_keysize = CHACHA20_KEY_SIZE, - .ivsize = CHACHA20_IV_SIZE, - .chunksize = CHACHA20_BLOCK_SIZE, - .walksize = 4 * CHACHA20_BLOCK_SIZE, + .min_keysize = CHACHA_KEY_SIZE, + .max_keysize = CHACHA_KEY_SIZE, + .ivsize = CHACHA_IV_SIZE, + .chunksize = CHACHA_BLOCK_SIZE, + .walksize = 4 * CHACHA_BLOCK_SIZE, .setkey = crypto_chacha20_setkey, - .encrypt = chacha20_neon, - .decrypt = chacha20_neon, + .encrypt = chacha_neon, + .decrypt = chacha_neon, };static int __init chacha20_simd_mod_init (void )
arch/arm64/crypto/chacha20-neon-glue.c +20 -20
@@ -19,7 +19,7 @@*/ #include <crypto/algapi.h> -#include <crypto/chacha20.h> +#include <crypto/chacha.h> #include <crypto/internal/skcipher.h> #include <linux/kernel.h> #include <linux/module.h>
@@ -34,15 +34,15 @@ asmlinkage void chacha20_4block_xor_neon(u32 *state, u8 *dst, const u8 *src);static void chacha20_doneon (u32 *state,u8 *dst,const u8 *src,unsigned int bytes) { -u8 buf[CHACHA20_BLOCK_SIZE ]; +u8 buf[CHACHA_BLOCK_SIZE ]; -while (bytes >=CHACHA20_BLOCK_SIZE *4 ) { +while (bytes >=CHACHA_BLOCK_SIZE *4 ) {kernel_neon_begin ();chacha20_4block_xor_neon (state, dst, src);kernel_neon_end (); - bytes -=CHACHA20_BLOCK_SIZE *4 ; - src +=CHACHA20_BLOCK_SIZE *4 ; - dst +=CHACHA20_BLOCK_SIZE *4 ; + bytes -=CHACHA_BLOCK_SIZE *4 ; + src +=CHACHA_BLOCK_SIZE *4 ; + dst +=CHACHA_BLOCK_SIZE *4 ; state[12 ] +=4 ; }
@@ -50,11 +50,11 @@ static void chacha20_doneon(u32 *state, u8 *dst, const u8 *src,return ;kernel_neon_begin (); -while (bytes >=CHACHA20_BLOCK_SIZE ) { +while (bytes >=CHACHA_BLOCK_SIZE ) {chacha20_block_xor_neon (state, dst, src); - bytes -=CHACHA20_BLOCK_SIZE ; - src +=CHACHA20_BLOCK_SIZE ; - dst +=CHACHA20_BLOCK_SIZE ; + bytes -=CHACHA_BLOCK_SIZE ; + src +=CHACHA_BLOCK_SIZE ; + dst +=CHACHA_BLOCK_SIZE ; state[12 ]++; }if (bytes) {
@@ -68,17 +68,17 @@ static void chacha20_doneon(u32 *state, u8 *dst, const u8 *src,static int chacha20_neon (struct skcipher_request *req) {struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req); -struct chacha20_ctx *ctx =crypto_skcipher_ctx (tfm); +struct chacha_ctx *ctx =crypto_skcipher_ctx (tfm);struct skcipher_walk walk;u32 state[16 ];int err; -if (!may_use_simd () || req->cryptlen <=CHACHA20_BLOCK_SIZE ) -return crypto_chacha20_crypt (req); +if (!may_use_simd () || req->cryptlen <=CHACHA_BLOCK_SIZE ) +return crypto_chacha_crypt (req); err =skcipher_walk_virt (&walk, req, false); -crypto_chacha20_init (state, ctx, walk.iv); +crypto_chacha_init (state, ctx, walk.iv);while (walk.nbytes >0 ) {unsigned int nbytes = walk.nbytes;
@@ -99,14 +99,14 @@ static struct skcipher_alg alg = { .base.cra_driver_name = "chacha20-neon", .base.cra_priority = 300, .base.cra_blocksize = 1, - .base.cra_ctxsize = sizeof(struct chacha20_ctx), + .base.cra_ctxsize = sizeof(struct chacha_ctx), .base.cra_module = THIS_MODULE, - .min_keysize = CHACHA20_KEY_SIZE, - .max_keysize = CHACHA20_KEY_SIZE, - .ivsize = CHACHA20_IV_SIZE, - .chunksize = CHACHA20_BLOCK_SIZE, - .walksize = 4 * CHACHA20_BLOCK_SIZE, + .min_keysize = CHACHA_KEY_SIZE, + .max_keysize = CHACHA_KEY_SIZE, + .ivsize = CHACHA_IV_SIZE, + .chunksize = CHACHA_BLOCK_SIZE, + .walksize = 4 * CHACHA_BLOCK_SIZE, .setkey = crypto_chacha20_setkey, .encrypt = chacha20_neon, .decrypt = chacha20_neon,
arch/x86/crypto/chacha20_glue.c +26 -26
104 lines not on this page · raw message
crypto/Makefile +1 -1
@@ -117,7 +117,7 @@ obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o obj-$(CONFIG_CRYPTO_SEED) += seed.o obj-$(CONFIG_CRYPTO_SPECK) += speck.o obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o -obj-$(CONFIG_CRYPTO_CHACHA20) += chacha20_generic.o +obj-$(CONFIG_CRYPTO_CHACHA20) += chacha_generic.o obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o obj-$(CONFIG_CRYPTO_DEFLATE) += deflate.o obj-$(CONFIG_CRYPTO_MICHAEL_MIC) += michael_mic.o
crypto/chacha20poly1305.c +5 -5
@@ -13,7 +13,7 @@#include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> #include <crypto/scatterwalk.h> -#include <crypto/chacha20.h> +#include <crypto/chacha.h> #include <crypto/poly1305.h> #include <linux/err.h> #include <linux/init.h>
@@ -51,7 +51,7 @@ struct poly_req { };struct chacha_req { -u8 iv[CHACHA20_IV_SIZE ]; +u8 iv[CHACHA_IV_SIZE ];struct scatterlist src[1 ];struct skcipher_request req;/* must be last member */ };
@@ -91,7 +91,7 @@ static void chacha_iv(u8 *iv, struct aead_request *req, u32 icb)memcpy (iv, &leicb,sizeof (leicb));memcpy (iv +sizeof (leicb), ctx->salt, ctx->saltlen);memcpy (iv +sizeof (leicb) + ctx->saltlen, req->iv, -CHACHA20_IV_SIZE -sizeof (leicb) - ctx->saltlen); +CHACHA_IV_SIZE -sizeof (leicb) - ctx->saltlen); }static int poly_verify_tag (struct aead_request *req)
@@ -494,7 +494,7 @@ static int chachapoly_setkey(struct crypto_aead *aead, const u8 *key,struct chachapoly_ctx *ctx =crypto_aead_ctx (aead);int err; -if (keylen != ctx->saltlen +CHACHA20_KEY_SIZE ) +if (keylen != ctx->saltlen +CHACHA_KEY_SIZE )return -EINVAL ; keylen -= ctx->saltlen;
@@ -639,7 +639,7 @@ static int chachapoly_create(struct crypto_template *tmpl, struct rtattr **tb, err = -EINVAL ;/* Need 16-byte IV size, including Initial Block Counter value */ -if (crypto_skcipher_alg_ivsize (chacha) !=CHACHA20_IV_SIZE ) +if (crypto_skcipher_alg_ivsize (chacha) !=CHACHA_IV_SIZE ) goto out_drop_chacha;/* Not a stream cipher? */ if (chacha->base.cra_blocksize !=1 )
crypto/chacha_generic.c renamed from crypto/chacha20_generic.c +59 -51
216 lines not on this page · raw message
drivers/char/random.c +25 -25
158 lines not on this page · raw message
include/crypto/chacha.h new file +47 -0
47 lines not on this page · raw message
include/crypto/chacha20.h deleted +0 -42
42 lines not on this page · raw message
lib/Makefile +1 -1
@@ -20,7 +20,7 @@ KCOV_INSTRUMENT_dynamic_debug.o := n lib-y := ctype.o string.o vsprintf.o cmdline.o \ rbtree.o radix-tree.o timerqueue.o\ idr.o int_sqrt.o extable.o \ - sha1.o chacha20.o irq_regs.o argv_split.o \ + sha1.o chacha.o irq_regs.o argv_split.o \ flex_proportions.o ratelimit.o show_mem.o \ is_single_threaded.o plist.o decompress.o kobject_uevent.o \ earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
lib/chacha.c renamed from lib/chacha20.c +24 -19
91 lines not on this page · raw message
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Jason A. Donenfeld
maintainerRe: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
Hey Eric,
Quoted 2 lines · Eric Biggers
In preparation for adding XChaCha12 support, rename/refactor chacha20-generic to support different numbers of rounds.
I'm interested in learning the motivation behind going with ChaCha12. So far, the vast majority of users of ChaCha have been getting along quite fine with ChaCha20 and enjoying the very large security margin this provides. In some ways, introducing ChaCha12 into the ecosystem feels like a bit of a step backwards, even if it probably still provides adequate security (though ChaCha8 probably shouldn't be used or included at all). I realize the simple answer is just, "because it's faster." But I'm wondering specifically about the speed requirements and on what hardware and in what circumstances you found ChaCha20 was too slow, and if this is the kind of circumstance you expect to persist into the future.
Jason
Re: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
Salsa20 was one of the earlier ARX proposals, and set a very conservative number of rounds as befits our state of knowledge at the time. Since then we've learned a lot more about cryptanalysis of such offerings, and I think we can be comfortable with fewer rounds. The best attack on ChaCha breaks 7 rounds, and that attack requires 2^248 operations. Every round of ChaCha makes attacks vastly harder.
Performance is absolutely crucial when it comes to disk encryption; users and vendors will push back hard against encryption that degrades the user experience. So we're always going to choose the fastest option that gives us a solid margin of security, and here that's ChaCha12.
I'd like to turn the question around. Why 20? DJB's 20 round proposal predates his 12 round proposal, but I don't think that's a reason to choose it when all cryptanalysis has considered reduced-round variants. The 20 round variant is more widely used, but again I think that's informative more about the historical order of things than the security. If 20 is better than 12, is 24 better than 20? What is it that draws you to 20 rounds specifically?
Quoted 24 lines · Jason A. Donenfeld
Hey Eric,
Quoted 2 lines · Eric Biggers
In preparation for adding XChaCha12 support, rename/refactor chacha20-generic to support different numbers of rounds.
I'm interested in learning the motivation behind going with ChaCha12. So far, the vast majority of users of ChaCha have been getting along quite fine with ChaCha20 and enjoying the very large security margin this provides. In some ways, introducing ChaCha12 into the ecosystem feels like a bit of a step backwards, even if it probably still provides adequate security (though ChaCha8 probably shouldn't be used or included at all). I realize the simple answer is just, "because it's faster." But I'm wondering specifically about the speed requirements and on what hardware and in what circumstances you found ChaCha20 was too slow, and if this is the kind of circumstance you expect to persist into the future.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-fscrypt" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
In reply to Jason A. DonenfeldSalsa20 was one of the earlier ARX proposals, and set a very conservative number of rounds as befits our state of knowledge at the time. Since then we've learned a lot more about cryptanalysis of such offerings, and I think we can be comfortable with fewer rounds. The best attack on ChaCha breaks 7 rounds, and that attack requires 2^248 operations. Every round of ChaCha makes attacks vastly harder.
Performance is absolutely crucial when it comes to disk encryption; users and vendors will push back hard against encryption that degrades the user experience. So we're always going to choose the fastest option that gives us a solid margin of security, and here that's ChaCha12.
I'd like to turn the question around. Why 20? DJB's 20 round proposal predates his 12 round proposal, but I don't think that's a reason to choose it when all cryptanalysis has considered reduced-round variants. The 20 round variant is more widely used, but again I think that's informative more about the historical order of things than the security. If 20 is better than 12, is 24 better than 20? What is it that draws you to 20 rounds specifically?
(apologies for reposting, I forgot to set Plain Text Mode.)
Quoted 24 lines · Jason A. Donenfeld
Hey Eric,
Quoted 2 lines · Eric Biggers
In preparation for adding XChaCha12 support, rename/refactor chacha20-generic to support different numbers of rounds.
I'm interested in learning the motivation behind going with ChaCha12. So far, the vast majority of users of ChaCha have been getting along quite fine with ChaCha20 and enjoying the very large security margin this provides. In some ways, introducing ChaCha12 into the ecosystem feels like a bit of a step backwards, even if it probably still provides adequate security (though ChaCha8 probably shouldn't be used or included at all). I realize the simple answer is just, "because it's faster." But I'm wondering specifically about the speed requirements and on what hardware and in what circumstances you found ChaCha20 was too slow, and if this is the kind of circumstance you expect to persist into the future.
Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-fscrypt" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jason A. Donenfeld
maintainerRe: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
Hi Paul,
Quoted 6 lines · Paul Crowley
Salsa20 was one of the earlier ARX proposals, and set a very conservative number of rounds as befits our state of knowledge at the time. Since then we've learned a lot more about cryptanalysis of such offerings, and I think we can be comfortable with fewer rounds. The best attack on ChaCha breaks 7 rounds, and that attack requires 2^248 operations. Every round of ChaCha makes attacks vastly harder.
I'm well aware of that, which is why I mentioned that ChaCha12 _probably_ has an adequate security. My primary concerns are a bit different actually from where you're going - that it breaks from what's becoming a pretty widely accepted "norm" and, more importantly, that it increases implementation complexity. These aren't really drastic concerns, but I am in earnest wondering the type of hardware analysis you did to determine that you really do need the 12-speedup. What's the practical landscape out there look like? What disk speeds were too low for which specific kind of Android usage on which particular hardware? Did you hit the bottlenecks when paging for code or when filling up caches when writing asynchronously? And for how much longer do you foresee underpowered hardware like that being a not insignificant part of the market? I'm especially curious to know because ostensibly at Google you have all sorts metrics regarding that kind of thing.
Jason
Re: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
We've done enough performance testing to know that the short answer
is: HPolyC is still a lot slower than I'm happy with, and encryption still has a quite noticeable effect on the feel of low end devices. Indeed, this proposal may change if I find a faster way to do the first and last rounds. We don't know how long chipsets without hardware AES will be around, but especially in this post-Moore's Law era, I'd bet on Schneier's maxim: the low end doesn't go away, and if a day comes where we don't have to worry about this in handsets, we'll probably be worrying about it for IoT devices.
Quoted 28 lines · Jason A. Donenfeld
Hi Paul,
Quoted 6 lines · Paul Crowley
Salsa20 was one of the earlier ARX proposals, and set a very conservative number of rounds as befits our state of knowledge at the time. Since then we've learned a lot more about cryptanalysis of such offerings, and I think we can be comfortable with fewer rounds. The best attack on ChaCha breaks 7 rounds, and that attack requires 2^248 operations. Every round of ChaCha makes attacks vastly harder.
I'm well aware of that, which is why I mentioned that ChaCha12 _probably_ has an adequate security. My primary concerns are a bit different actually from where you're going - that it breaks from what's becoming a pretty widely accepted "norm" and, more importantly, that it increases implementation complexity. These aren't really drastic concerns, but I am in earnest wondering the type of hardware analysis you did to determine that you really do need the 12-speedup. What's the practical landscape out there look like? What disk speeds were too low for which specific kind of Android usage on which particular hardware? Did you hit the bottlenecks when paging for code or when filling up caches when writing asynchronously? And for how much longer do you foresee underpowered hardware like that being a not insignificant part of the market? I'm especially curious to know because ostensibly at Google you have all sorts metrics regarding that kind of thing.
Jason
Re: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
In reply to Paul CrowleyQuoted 1 line
The best attack on ChaCha breaks 7 rounds, and that attack requires 2^248 operations.
This number, as far as I can tell, comes from the "New features of Latin dances" paper. There have been some minor improvements in the intervening 10 years, e.g., [1, 2, 3, 4], which pull back the complexity of breaking ChaCha7 down to 2^235. In any case, every attack so far appears to hit a wall at 8 rounds, with 12 rounds---the recommended eSTREAM round number for Salsa20---seeming to offer a reasonable security margin, still somewhat better than that of the AES.
Best regards,
Samuel Neves
[1] https://eprint.iacr.org/2015/698
[2] https://eprint.iacr.org/2015/217
[3] https://eprint.iacr.org/2016/1034
[4] https://doi.org/10.1016/j.dam.2017.04.034
Eric Biggers
maintainerRe: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
Quoted 11 lines · Samuel Neves
Quoted 1 line
The best attack on ChaCha breaks 7 rounds, and that attack requires 2^248 operations.
This number, as far as I can tell, comes from the "New features of Latin dances" paper. There have been some minor improvements in the intervening 10 years, e.g., [1, 2, 3, 4], which pull back the complexity of breaking ChaCha7 down to 2^235. In any case, every attack so far appears to hit a wall at 8 rounds, with 12 rounds---the recommended eSTREAM round number for Salsa20---seeming to offer a reasonable security margin, still somewhat better than that of the AES.
Quoted 7 lines
Best regards,
Samuel Neves[1] https://eprint.iacr.org/2015/698
[2] https://eprint.iacr.org/2015/217
[3] https://eprint.iacr.org/2016/1034
[4] https://doi.org/10.1016/j.dam.2017.04.034
Thanks Samuel, I'll fix that number in the next iteration of the patchset.
- Eric
Eric Biggers
maintainerRe: [RFC PATCH 3/9] crypto: chacha20-generic - refactor to allow varying number of rounds
Quoted 15 lines · Eric Biggers
Quoted 14 lines · Samuel Neves
Quoted 1 line
The best attack on ChaCha breaks 7 rounds, and that attack requires 2^248 operations.
This number, as far as I can tell, comes from the "New features of Latin dances" paper. There have been some minor improvements in the intervening 10 years, e.g., [1, 2, 3, 4], which pull back the complexity of breaking ChaCha7 down to 2^235. In any case, every attack so far appears to hit a wall at 8 rounds, with 12 rounds---the recommended eSTREAM round number for Salsa20---seeming to offer a reasonable security margin, still somewhat better than that of the AES.
Best regards,
Samuel Neves
Quoted 7 lines
Quoted 4 lines
[1] https://eprint.iacr.org/2015/698
[2] https://eprint.iacr.org/2015/217
[3] https://eprint.iacr.org/2016/1034
[4] https://doi.org/10.1016/j.dam.2017.04.034Thanks Samuel, I'll fix that number in the next iteration of the patchset.
Oops, sorry, for some reason I thought you had quoted one of my commit messages, but it was actually Paul's email. I did mention in "crypto: chacha - add XChaCha12 support" that "the best known attack on ChaCha makes it through only 7 rounds", but I didn't specify the complexity.
- Eric
Eric Biggers
maintainerRFC PATCH 4/9 crypto: chacha - add XChaCha12 support
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Now that the generic implementation of ChaCha20 has been refactored to allow varying the number of rounds, add support for XChaCha12, which is the XSalsa construction applied to ChaCha12. ChaCha12 is one of the three ciphers specified by the original ChaCha paper
(https://cr.yp.to/chacha/chacha-20080128.pdf: "ChaCha, a variant of Salsa20"), alongside ChaCha8 and ChaCha20. ChaCha12 is faster than ChaCha20, but has a lower security margin. Still, it hasn't been broken yet, as the best known attack on ChaCha makes it through only 7 rounds.
We need XChaCha12 support so that it can be used in the construction HPolyC-XChaCha12-AES, which can provide reasonably fast disk/file encryption on low-end devices where AES-XTS is too slow as the CPUs lack AES instructions. This is an alternative to using a lightweight block cipher such as Speck128 in XTS mode. We'd prefer XChaCha20, but it's too slow on some of our target devices, so at least in some cases we do need the XChaCha12-based version.
Note that it would be trivial to add vanilla ChaCha12 in addition to XChaCha12. However, it is omitted for now as we don't currently need it, and users should generally prefer the existing 20-round variant.
Like discussed in the patch that introduced XChaCha20 support, I considered splitting the code into separate chacha-common, chacha20, xchacha20, and xchacha12 modules, so that these algorithms 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.
--- crypto/Kconfig | 10 +- crypto/chacha_generic.c | 26 +- crypto/testmgr.c | 6 + crypto/testmgr.h | 578 ++++++++++++++++++++++++++++++++++++++++ include/crypto/chacha.h | 9 + lib/chacha.c | 6 +- 6 files changed, 629 insertions(+), 6 deletions(-)
crypto/Kconfig +8 -2
@@ -1437,10 +1437,10 @@ config CRYPTO_SALSA20 Bernstein <[email protected]>. See <http://cr.yp.to/snuffle.html> config CRYPTO_CHACHA20 - tristate "ChaCha20 stream cipher algorithms" + tristate "ChaCha stream cipher algorithms" select CRYPTO_BLKCIPHER help - The ChaCha20 and XChaCha20 stream cipher algorithms. + The ChaCha20, XChaCha20, and XChaCha12 stream cipher algorithms. ChaCha20 is a 256-bit high-speed stream cipher designed by Daniel J. Bernstein and further specified in RFC7539 for use in IETF protocols.
@@ -1453,6 +1453,12 @@ config CRYPTO_CHACHA20 while provably retaining ChaCha20's security. See also: <https://cr.yp.to/snuffle/xsalsa-20081128.pdf> + XChaCha12 is XChaCha20 reduced to 12 rounds, with correspondingly + reduced security margin but increased performance. It can be needed + in some very performance-sensitive scenarios. There is no known + attack on XChaCha12 (or ChaCha12) yet, but it has a higher risk of + being broken than the 20-round variant. + config CRYPTO_CHACHA20_X86_64 tristate "ChaCha20 cipher algorithm (x86_64/SSSE3/AVX2)" depends on X86 && 64BIT
crypto/chacha_generic.c +25 -1
@@ -1,5 +1,5 @@/* -* ChaCha20 (RFC7539) and XChaCha20 stream cipher algorithms +* ChaCha and XChaCha stream ciphers, including ChaCha20 (RFC7539) * * Copyright (C) 2015 Martin Willi * Copyright (C) 2018 Google LLC
@@ -105,6 +105,13 @@ int crypto_chacha20_setkey(struct crypto_skcipher *tfm, const u8 *key, }EXPORT_SYMBOL_GPL (crypto_chacha20_setkey); +int crypto_chacha12_setkey (struct crypto_skcipher *tfm,const u8 *key, +unsigned int keysize) +{ +return chacha_setkey (tfm, key, keysize,12 ); +} +EXPORT_SYMBOL_GPL (crypto_chacha12_setkey); +int crypto_chacha_crypt (struct skcipher_request *req) {struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (req);
@@ -167,6 +174,21 @@ static struct skcipher_alg algs[] = { .setkey = crypto_chacha20_setkey, .encrypt = crypto_xchacha_crypt, .decrypt = crypto_xchacha_crypt, + }, { + .base.cra_name = "xchacha12", + .base.cra_driver_name = "xchacha12-generic", + .base.cra_priority = 100, + .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 = crypto_xchacha_crypt, + .decrypt = crypto_xchacha_crypt, } };
@@ -190,3 +212,5 @@ MODULE_ALIAS_CRYPTO("chacha20");MODULE_ALIAS_CRYPTO ("chacha20-generic" );MODULE_ALIAS_CRYPTO ("xchacha20" );MODULE_ALIAS_CRYPTO ("xchacha20-generic" ); +MODULE_ALIAS_CRYPTO ("xchacha12" ); +MODULE_ALIAS_CRYPTO ("xchacha12-generic" );
crypto/testmgr.c +6 -0
@@ -3544,6 +3544,12 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .hash = __VECS(aes_xcbc128_tv_template) } + }, { + .alg = "xchacha12", + .test = alg_test_skcipher, + .suite = { + .cipher =__VECS (xchacha12_tv_template) + }, }, { .alg = "xchacha20", .test = alg_test_skcipher,
crypto/testmgr.h +578 -0
584 lines not on this page · raw message
include/crypto/chacha.h +9 -0
@@ -5,6 +5,13 @@* XChaCha extends ChaCha's nonce to 192 bits, while provably retaining ChaCha's * security. Here they share the same key size, tfm context, and setkey * function; only their IV size and encrypt/decrypt function differ. +* +* The ChaCha paper specifies 20, 12, and 8-round variants. In general, it is +* strongly recommended to use the 20-round variant ChaCha20. However, the +* reduced-round variants can be needed in some very performance-sensitive +* scenarios where a reduced security margin may be tolerated. +* +* The generic ChaCha code currently allows only the 20 and 12-round variants. */ #ifndef _CRYPTO_CHACHA_H
@@ -40,6 +47,8 @@ void crypto_chacha_init(u32 *state, struct chacha_ctx *ctx, u8 *iv);int crypto_chacha20_setkey (struct crypto_skcipher *tfm,const u8 *key,unsigned int keysize); +int crypto_chacha12_setkey (struct crypto_skcipher *tfm,const u8 *key, +unsigned int keysize);int crypto_chacha_crypt (struct skcipher_request *req);int crypto_xchacha_crypt (struct skcipher_request *req);
lib/chacha.c +3 -3
@@ -21,7 +21,7 @@ static void chacha_permute(u32 *x, int nrounds)int i;/* whitelist the allowed round counts */ -BUG_ON (nrounds !=20 ); +BUG_ON (nrounds !=20 && nrounds !=12 );for (i =0 ; i < nrounds; i +=2 ) { x[0 ] += x[4 ]; x[12 ] =rol32 (x[12 ] ^ x[0 ],16 );
@@ -70,7 +70,7 @@ static void chacha_permute(u32 *x, int nrounds)* chacha_block - generate one keystream block and increment block counter * @state: input state matrix (16 32-bit words) * @stream: output keystream block (64 bytes) -* @nrounds: number of rounds (currently must be 20) +* @nrounds: number of rounds (20 or 12; 20 is recommended) * * This is the ChaCha core, a function from 64-byte strings to 64-byte strings. * The caller has already converted the endianness of the input. This function
@@ -96,7 +96,7 @@ EXPORT_SYMBOL(chacha_block);* hchacha_block - abbreviated ChaCha core, for XChaCha * @in: input state matrix (16 32-bit words) * @out: output (8 32-bit words) -* @nrounds: number of rounds (currently must be 20) +* @nrounds: number of rounds (20 or 12; 20 is recommended) * * HChaCha is the ChaCha equivalent of HSalsa and is an intermediate step * towards XChaCha (see https://cr.yp.to/snuffle/xsalsa-20081128.pdf). HChaCha
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Eric Biggers
maintainerRFC PATCH 5/9 crypto: arm/chacha20 - add XChaCha20 support
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add an XChaCha20 implementation that is hooked up to the ARM NEON implementation of ChaCha20. This is needed for use in the HPolyC construction for disk/file encryption; see the generic code patch, "crypto: chacha20-generic - add XChaCha20 support", for more details.
We also update the NEON code to support HChaCha20 on one block, so we can use that in XChaCha20 rather than calling the generic HChaCha20. This required factoring the permutation out into its own macro.
--- arch/arm/crypto/Kconfig | 2 +- arch/arm/crypto/chacha20-neon-core.S | 68 ++++++++++------ arch/arm/crypto/chacha20-neon-glue.c | 111 ++++++++++++++++++++------- 3 files changed, 130 insertions(+), 51 deletions(-)
arch/arm/crypto/Kconfig +1 -1
@@ -116,7 +116,7 @@ config CRYPTO_CRC32_ARM_CE select CRYPTO_HASH config CRYPTO_CHACHA20_NEON - tristate "NEON accelerated ChaCha20 symmetric cipher" + tristate "NEON accelerated ChaCha20 stream cipher algorithms" depends on KERNEL_MODE_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20
arch/arm/crypto/chacha20-neon-core.S +45 -23
89 lines not on this page · raw message
arch/arm/crypto/chacha20-neon-glue.c +84 -27
159 lines not on this page · raw message
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Eric Biggers
maintainerRFC PATCH 6/9 crypto: arm/chacha20 - refactor to allow varying number of rounds
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
In preparation for adding XChaCha12 support, rename/refactor the NEON implementation of ChaCha20 to support different numbers of rounds.
---
arch/arm/crypto/Makefile | 4 +-
...hacha20-neon-core.S => chacha-neon-core.S} | 51 +++++++++--------
...hacha20-neon-glue.c => chacha-neon-glue.c} | 56 ++++++++++---------
3 files changed, 59 insertions(+), 52 deletions(-)
rename arch/arm/crypto/{chacha20-neon-core.S => chacha-neon-core.S} (93%)
rename arch/arm/crypto/{chacha20-neon-glue.c => chacha-neon-glue.c} (73%)arch/arm/crypto/Makefile +2 -2
@@ -9,7 +9,7 @@ obj-$(CONFIG_CRYPTO_SHA1_ARM) += sha1-arm.o obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sha1-arm-neon.o obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o -obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o +obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha-neon.o obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o ce-obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o
@@ -53,7 +53,7 @@ aes-arm-ce-y := aes-ce-core.o aes-ce-glue.o ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o -chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o +chacha-neon-y := chacha-neon-core.o chacha-neon-glue.o speck-neon-y := speck-neon-core.o speck-neon-glue.o ifdef REGENERATE_ARM_CRYPTO
arch/arm/crypto/chacha-neon-core.S renamed from arch/arm/crypto/chacha20-neon-core.S +27 -24
144 lines not on this page · raw message
arch/arm/crypto/chacha-neon-glue.c renamed from arch/arm/crypto/chacha20-neon-glue.c +30 -26
138 lines not on this page · raw message
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Eric Biggers
maintainerRFC PATCH 7/9 crypto: arm/chacha - add XChaCha12 support
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
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 reduced from 20 to 12.
As I explained in more detail in the patch which added XChaCha12 to the generic code, "crypto: chacha - add XChaCha12 support", we'd prefer to use XChaCha20, but unfortunately it is not fast enough for our use case. Thus, we must settle for a reduced-round variant. See that patch for a more detailed explanation.
--- arch/arm/crypto/Kconfig | 2 +- arch/arm/crypto/chacha-neon-glue.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-)
arch/arm/crypto/Kconfig +1 -1
@@ -116,7 +116,7 @@ config CRYPTO_CRC32_ARM_CE select CRYPTO_HASH config CRYPTO_CHACHA20_NEON - tristate "NEON accelerated ChaCha20 stream cipher algorithms" + tristate "NEON accelerated ChaCha stream cipher algorithms" depends on KERNEL_MODE_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20
arch/arm/crypto/chacha-neon-glue.c +20 -1
@@ -1,5 +1,6 @@/* -* ChaCha20 (RFC7539) and XChaCha20 stream ciphers, NEON accelerated +* ARM NEON accelerated ChaCha and XChaCha stream ciphers, +* including ChaCha20 (RFC7539) * * Copyright (C) 2016 Linaro, Ltd. <[email protected]> *
@@ -160,6 +161,22 @@ static struct skcipher_alg algs[] = { .setkey = crypto_chacha20_setkey, .encrypt = xchacha_neon, .decrypt = xchacha_neon, + }, { + .base.cra_name = "xchacha12", + .base.cra_driver_name = "xchacha12-neon", + .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, + .walksize = 4 * CHACHA_BLOCK_SIZE, + .setkey = crypto_chacha12_setkey, + .encrypt = xchacha_neon, + .decrypt = xchacha_neon, } };
@@ -186,3 +203,5 @@ MODULE_ALIAS_CRYPTO("chacha20");MODULE_ALIAS_CRYPTO ("chacha20-neon" );MODULE_ALIAS_CRYPTO ("xchacha20" );MODULE_ALIAS_CRYPTO ("xchacha20-neon" ); +MODULE_ALIAS_CRYPTO ("xchacha12" ); +MODULE_ALIAS_CRYPTO ("xchacha12-neon" );
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Eric Biggers
maintainerRFC PATCH 8/9 crypto: arm/poly1305 - add NEON accelerated Poly1305 implementation
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add the Poly1305 code from OpenSSL, which was written by Andy Polyakov. I took the .S file from WireGuard, whose author has made the needed tweaks for Linux kernel integration and verified that Andy had given permission for GPLv2 distribution. I didn't make any additional changes to the .S file.
Note, for HPolyC I'd eventually like a Poly1305 implementation that allows precomputing powers of the key. But for now this implementation just provides the existing semantics where the key and nonce are treated as a "one-time key" that must be provided for every message.
--- arch/arm/crypto/Kconfig | 5 + arch/arm/crypto/Makefile | 2 + arch/arm/crypto/poly1305-neon-core.S | 1115 ++++++++++++++++++++++++++ arch/arm/crypto/poly1305-neon-glue.c | 325 ++++++++ 4 files changed, 1447 insertions(+) create mode 100644 arch/arm/crypto/poly1305-neon-core.S create mode 100644 arch/arm/crypto/poly1305-neon-glue.c
arch/arm/crypto/Kconfig +5 -0
@@ -121,6 +121,11 @@ config CRYPTO_CHACHA20_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20 +config CRYPTO_POLY1305_NEON + tristate "NEON accelerated Poly1305 authenticator algorithm" + depends on KERNEL_MODE_NEON + select CRYPTO_POLY1305 + config CRYPTO_SPECK_NEON tristate "NEON accelerated Speck cipher algorithms" depends on KERNEL_MODE_NEON
arch/arm/crypto/Makefile +2 -0
@@ -10,6 +10,7 @@ obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sha1-arm-neon.o obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha-neon.o +obj-$(CONFIG_CRYPTO_POLY1305_NEON) += poly1305-neon.o obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o ce-obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o
@@ -54,6 +55,7 @@ ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o chacha-neon-y := chacha-neon-core.o chacha-neon-glue.o +poly1305-neon-y := poly1305-neon-core.o poly1305-neon-glue.o speck-neon-y := speck-neon-core.o speck-neon-glue.o ifdef REGENERATE_ARM_CRYPTO
arch/arm/crypto/poly1305-neon-core.S new file +1115 -0
1,115 lines not on this page · raw message
arch/arm/crypto/poly1305-neon-glue.c new file +325 -0
325 lines not on this page · raw message
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Re: [RFC PATCH 8/9] crypto: arm/poly1305 - add NEON accelerated Poly1305 implementation
Quoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Add the Poly1305 code from OpenSSL, which was written by Andy Polyakov. I took the .S file from WireGuard, whose author has made the needed tweaks for Linux kernel integration and verified that Andy had given permission for GPLv2 distribution. I didn't make any additional changes to the .S file.
Quoted 6 lines
Note, for HPolyC I'd eventually like a Poly1305 implementation that allows precomputing powers of the key. But for now this implementation just provides the existing semantics where the key and nonce are treated as a "one-time key" that must be provided for every message.
Signed-off-by Eric Biggers <[email protected]>
Hi Eric,
In the past, I worked with Andy on several occasions to get my kernel changes incorporated into the upstream OpenSSL version of the 'perlasm' .pl file.
This achieves a number of things:
- we get a readable version of the code in the kernel tree,
- our changes are reviewed upstream
- upgrading involves grabbing the latest .pl file rather than merging generated code (which requires careful review)
- GPLv2 permission is made explicit, rather than something someone claims to have reached agreement on,
- no legal ambiguity whether the output of the perl script is covered by the license (which is what we incorporate here)
Note that the 'available under GPL depending on where you obtained the code' in the CRYPTOGAMS license likely conflicts with the GPL itself, but I am not a lawyer so I'd much prefer having the upstream copy mention this explicitly.
Eric Biggers
maintainerRe: [RFC PATCH 8/9] crypto: arm/poly1305 - add NEON accelerated Poly1305 implementation
Hi Ard,
Quoted 32 lines · Ard Biesheuvel
Quoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Add the Poly1305 code from OpenSSL, which was written by Andy Polyakov. I took the .S file from WireGuard, whose author has made the needed tweaks for Linux kernel integration and verified that Andy had given permission for GPLv2 distribution. I didn't make any additional changes to the .S file.
Quoted 6 lines
Note, for HPolyC I'd eventually like a Poly1305 implementation that allows precomputing powers of the key. But for now this implementation just provides the existing semantics where the key and nonce are treated as a "one-time key" that must be provided for every message.
Signed-off-by Eric Biggers <[email protected]>Hi Eric,
In the past, I worked with Andy on several occasions to get my kernel changes incorporated into the upstream OpenSSL version of the 'perlasm' .pl file.
This achieves a number of things:
- we get a readable version of the code in the kernel tree,
- our changes are reviewed upstream
- upgrading involves grabbing the latest .pl file rather than merging generated code (which requires careful review)
- GPLv2 permission is made explicit, rather than something someone claims to have reached agreement on,
- no legal ambiguity whether the output of the perl script is covered by the license (which is what we incorporate here)
Quoted 4 lines
Note that the 'available under GPL depending on where you obtained the code' in the CRYPTOGAMS license likely conflicts with the GPL itself, but I am not a lawyer so I'd much prefer having the upstream copy mention this explicitly.
First, note that Jason is proposing adding this exact same .S file as part of his new "zinc" cryptography library, along with 7 other OpenSSL .S files. So it may really be him you need to convince.
But yes, I don't really like the approach of just including the .S output of the .pl script either, as it loses semantic information that was in the .pl script. Ideally the source should either be the .pl script, or else a real hand written .S file with the proper comments and macros to make it readable -- not something in-between.
Getting the license clarification and possibly other changes upstream is a good idea too. I noticed, though, that the actual wording used in some files upstream ("Permission to use under GPLv2 terms is granted") apparently still isn't considered sufficient by some, so a separate clarification from Andy was apparently still needed: see kernel commit c2e415fe75bbc83c1...
- Eric
Re: [RFC PATCH 8/9] crypto: arm/poly1305 - add NEON accelerated Poly1305 implementation
Quoted 35 lines · Eric Biggers
Hi Ard,
Quoted 32 lines · Ard Biesheuvel
Quoted 8 lines · Eric Biggers
From: Eric Biggers <[email protected]>
Add the Poly1305 code from OpenSSL, which was written by Andy Polyakov. I took the .S file from WireGuard, whose author has made the needed tweaks for Linux kernel integration and verified that Andy had given permission for GPLv2 distribution. I didn't make any additional changes to the .S file.
Quoted 6 lines
Note, for HPolyC I'd eventually like a Poly1305 implementation that allows precomputing powers of the key. But for now this implementation just provides the existing semantics where the key and nonce are treated as a "one-time key" that must be provided for every message.
Signed-off-by Eric Biggers <[email protected]>Hi Eric,
In the past, I worked with Andy on several occasions to get my kernel changes incorporated into the upstream OpenSSL version of the 'perlasm' .pl file.
This achieves a number of things:
- we get a readable version of the code in the kernel tree,
- our changes are reviewed upstream
- upgrading involves grabbing the latest .pl file rather than merging generated code (which requires careful review)
- GPLv2 permission is made explicit, rather than something someone claims to have reached agreement on,
- no legal ambiguity whether the output of the perl script is covered by the license (which is what we incorporate here)
Quoted 9 lines
Quoted 4 lines
Note that the 'available under GPL depending on where you obtained the code' in the CRYPTOGAMS license likely conflicts with the GPL itself, but I am not a lawyer so I'd much prefer having the upstream copy mention this explicitly.
First, note that Jason is proposing adding this exact same .S file as part of his new "zinc" cryptography library, along with 7 other OpenSSL .S files. So it may really be him you need to convince.
Interesting choice of wording :-) I thought it was usually the other way around, i.e., it is the submitter who needs to convince the reviewers/maintainers.
Quoted 6 lines
But yes, I don't really like the approach of just including the .S output of the .pl script either, as it loses semantic information that was in the .pl script. Ideally the source should either be the .pl script, or else a real hand written .S file with the proper comments and macros to make it readable -- not something in-between.
Quoted 6 lines
Getting the license clarification and possibly other changes upstream is a good idea too. I noticed, though, that the actual wording used in some files upstream ("Permission to use under GPLv2 terms is granted") apparently still isn't considered sufficient by some, so a separate clarification from Andy was apparently still needed: see kernel commit
c2e415fe75bbc83c1...
Yeah. In any case, I don't think we should consider an intermediate solution of merging a chunk of generated asm now and work out these details later. This should be done right from the start.
Eric Biggers
maintainerRFC PATCH 9/9 crypto: hpolyc - add support for the HPolyC encryption mode
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
Add support for HPolyC, which is a tweakable, length-preserving encryption mode that encrypts each message using XChaCha sandwiched between two passes of Poly1305, and one invocation of a block cipher such as AES. HPolyC was designed by Paul Crowley and is fully specified by our paper https://eprint.iacr.org/2018/720.pdf
("HPolyC: length-preserving encryption for entry-level processors"). HPolyC is similar to some existing modes such as XCB, HCTR, HCH, and HMC, but by necessity it has some novelties. See the paper for details; this patch only provides a brief overview and an explanation of why HPolyC is needed in the crypto API.
HPolyC is suitable for disk/file encryption with dm-crypt and fscrypt, where currently the only other suitable options in the kernel are block cipher modes such as XTS. Moreover, on low-end devices whose processors lack AES instructions (e.g. ARM Cortex-A7), AES-XTS is much too slow to provide an acceptable user experience, resulting in "lightweight" block ciphers such as Speck being the only viable option on these devices. However, Speck is considered controversial in some circles; and other published lightweight block ciphers are too slow in software, haven't received sufficient cryptanalysis, or have other issues.
Stream ciphers such as ChaCha perform much better but are insecure if naively used directly in dm-crypt or fscrypt, due to the IV reuse when data is overwritten. Even restricting the threat model to offline attacks only isn't enough, since modern flash storage devices make no guarantee that "overwrites" are really overwrites, due to wear-leveling.
Of course, the ideal solution is to store unique nonces on-disk, ideally alongside authentication tags. Unfortunately, this is usually impractical. Hardware support for per-sector metadata is extremely rare, especially in consumer-grade devices. Software workarounds for this limitation struggle with the crash consistency problem (often ignored by academic cryptographers): the crypto metadata MUST be written atomically with regards to the data. This can be solved with data journaling, e.g. as dm-integrity does, but that has a severe performance penalty. Or, for file-level encryption only, per-block metadata is possible on copy-on-write and log-structured filesystems. However, the most common Linux filesystems, ext4 and xfs, are neither; and even f2fs is not fully log-structured as it sometimes overwrites data in-place. A solution that works for more than just btrfs and zfs is needed.
So, we're mostly stuck with length-preserving encryption for now. HPolyC therefore provides a way to securely use ChaCha in this context. Essentially, it uses a hash-XOR-hash construction where a Poly1305 hash of the tweak and message is used as the nonce for XChaCha, resulting in a different nonce whenever either the message or tweak is changed. A block cipher invocation is also needed, but only once per message. Note that Poly1305 is much faster than ChaCha20, making HPolyC faster than might be first assumed; still, due to the overhead of the two Poly1305 passes, some users will need ChaCha12 to get acceptable performance. See the Performance section of the paper. (Currently, ChaCha12 is still secure, though it has a lower security margin.)
HPolyC has a proof (section 5 of the paper) that shows it is secure if the underlying primitives are secure, subject to a security bound. Unless there is a mistake in this proof, one therefore does not need to "trust" HPolyC; they need only trust XChaCha (which itself has a security reduction to ChaCha) and AES. Unlike XTS, HPolyC is also a true wide-block mode, or tweakable super-pseudorandom permutation:
changing one plaintext bit affects all ciphertext bits, and vice versa.
HPolyC supports any message length >= 16 bytes without any need for "ciphertext stealing". Thus, it will also be useful for fscrypt filenames encryption, where CBC-CTS is currently used.
We implement HPolyC as a template that wraps existing Poly1305, XChaCha, and block cipher implementations. So, it can be used with either XChaCha20 or XChaCha12, and with any block cipher with a 256-bit key and 128-bit block size -- though we recommend and plan to use AES-256, even on processors without AES instructions, as the block cipher performance is not critical when it's invoked only once per message. We include test vectors for HPolyC-XChaCha20-AES and HPolyC-XChaCha12-AES.
--- crypto/Kconfig | 28 +++ crypto/Makefile | 1 + crypto/hpolyc.c | 577 +++++++++++++++++++++++++++++++++++++++++++++++ crypto/testmgr.c | 12 + crypto/testmgr.h | 158 +++++++++++++ 5 files changed, 776 insertions(+) create mode 100644 crypto/hpolyc.c
crypto/Kconfig +28 -0
@@ -495,6 +495,34 @@ config CRYPTO_KEYWRAP Support for key wrapping (NIST SP800-38F / RFC3394) without padding. +config CRYPTO_HPOLYC + tristate "HPolyC support" + select CRYPTO_CHACHA20 + select CRYPTO_POLY1305 + help + HPolyC is a tweakable, length-preserving encryption + construction that encrypts each message using XChaCha + sandwiched between two passes of Poly1305, and one invocation + of a block cipher such as AES on a single 128-bit block. + + Unlike bare stream ciphers such as ChaCha and + ciphertext-expanding modes (e.g. AEADs), HPolyC is suitable for + disk and file contents encryption, e.g. with dm-crypt or + fscrypt, where normally only block ciphers in the XTS, LRW, or + CBC-ESSIV modes of operation are suitable. HPolyC was designed + primarily for this use case on low-end processors that lack AES + instructions, resulting in traditional modes being too slow + unless used with certain "lightweight" block ciphers such as + Speck, but where XChaCha and Poly1305 are reasonably fast. + + HPolyC's security is proven reducible to that of the underlying + XChaCha variant and block cipher, subject to a security bound. + Unlike XTS, HPolyC is a true wide-block encryption mode, so it + actually provides an even stronger notion of security than XTS, + subject to the security bound. + + If unsure, say N. + comment "Hash modes" config CRYPTO_CMAC
crypto/Makefile +1 -0
@@ -83,6 +83,7 @@ obj-$(CONFIG_CRYPTO_LRW) += lrw.o obj-$(CONFIG_CRYPTO_XTS) += xts.o obj-$(CONFIG_CRYPTO_CTR) += ctr.o obj-$(CONFIG_CRYPTO_KEYWRAP) += keywrap.o +obj-$(CONFIG_CRYPTO_HPOLYC) += hpolyc.o obj-$(CONFIG_CRYPTO_GCM) += gcm.o obj-$(CONFIG_CRYPTO_CCM) += ccm.o obj-$(CONFIG_CRYPTO_CHACHA20POLY1305) += chacha20poly1305.o
crypto/hpolyc.c new file +577 -0
577 lines not on this page · raw message
crypto/testmgr.c +12 -0
@@ -3184,6 +3184,18 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .hash = __VECS(hmac_sha512_tv_template) } + }, { + .alg = "hpolyc(xchacha12,aes)", + .test = alg_test_skcipher, + .suite = { + .cipher =__VECS (hpolyc_xchacha12_aes_tv_template) + }, + }, { + .alg = "hpolyc(xchacha20,aes)", + .test = alg_test_skcipher, + .suite = { + .cipher =__VECS (hpolyc_xchacha20_aes_tv_template) + }, }, { .alg = "jitterentropy_rng", .fips_allowed = 1,
crypto/testmgr.h +158 -0
164 lines not on this page · raw message
Signature · 1 line
2.18.0.597.ga71716f1ad-goog
Jason A. Donenfeld
maintainerPATCH 1/1 crypto: remove speck
In reply to Eric BiggersThese are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. Therefore, this patch removes it.
--- Documentation/filesystems/fscrypt.rst | 10 - arch/arm/crypto/Kconfig | 6 - arch/arm/crypto/Makefile | 2 - arch/arm/crypto/speck-neon-core.S | 434 --------------- arch/arm/crypto/speck-neon-glue.c | 288 ---------- arch/arm64/crypto/Kconfig | 6 - arch/arm64/crypto/Makefile | 3 - arch/arm64/crypto/speck-neon-core.S | 352 ------------ arch/arm64/crypto/speck-neon-glue.c | 282 ---------- arch/m68k/configs/amiga_defconfig | 1 - arch/m68k/configs/apollo_defconfig | 1 - arch/m68k/configs/atari_defconfig | 1 - arch/m68k/configs/bvme6000_defconfig | 1 - arch/m68k/configs/hp300_defconfig | 1 - arch/m68k/configs/mac_defconfig | 1 - arch/m68k/configs/multi_defconfig | 1 - arch/m68k/configs/mvme147_defconfig | 1 - arch/m68k/configs/mvme16x_defconfig | 1 - arch/m68k/configs/q40_defconfig | 1 - arch/m68k/configs/sun3_defconfig | 1 - arch/m68k/configs/sun3x_defconfig | 1 - arch/s390/defconfig | 1 - crypto/Kconfig | 14 - crypto/Makefile | 1 - crypto/speck.c | 307 ----------- crypto/testmgr.c | 24 - crypto/testmgr.h | 738 -------------------------- fs/crypto/fscrypt_private.h | 4 - fs/crypto/keyinfo.c | 10 - include/crypto/speck.h | 62 --- include/uapi/linux/fs.h | 2 - 31 files changed, 2558 deletions(-) delete mode 100644 arch/arm/crypto/speck-neon-core.S delete mode 100644 arch/arm/crypto/speck-neon-glue.c delete mode 100644 arch/arm64/crypto/speck-neon-core.S delete mode 100644 arch/arm64/crypto/speck-neon-glue.c delete mode 100644 crypto/speck.c delete mode 100644 include/crypto/speck.h
Documentation/filesystems/fscrypt.rst +0 -10
@@ -191,21 +191,11 @@ Currently, the following pairs of encryption modes are supported: - AES-256-XTS for contents and AES-256-CTS-CBC for filenames - AES-128-CBC for contents and AES-128-CTS-CBC for filenames -- Speck128/256-XTS for contents and Speck128/256-CTS-CBC for filenames It is strongly recommended to use AES-256-XTS for contents encryption. AES-128-CBC was added only for low-powered embedded devices with crypto accelerators such as CAAM or CESA that do not support XTS. -Similarly, Speck128/256 support was only added for older or low-end -CPUs which cannot do AES fast enough -- especially ARM CPUs which have -NEON instructions but not the Cryptography Extensions -- and for which -it would not otherwise be feasible to use encryption at all. It is -not recommended to use Speck on CPUs that have AES instructions. -Speck support is only available if it has been enabled in the crypto -API via CONFIG_CRYPTO_SPECK. Also, on ARM platforms, to get -acceptable performance CONFIG_CRYPTO_SPECK_NEON must be enabled. - New encryption modes can be added relatively easily, without changes to individual filesystems. However, authenticated encryption (AE) modes are not currently supported because of the difficulty of dealing
arch/arm/crypto/Kconfig +0 -6
@@ -121,10 +121,4 @@ config CRYPTO_CHACHA20_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20 -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm/crypto/Makefile +0 -2
@@ -10,7 +10,6 @@ obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sha1-arm-neon.o obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o ce-obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o ce-obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o
@@ -54,7 +53,6 @@ ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o ifdef REGENERATE_ARM_CRYPTO quiet_cmd_perl = PERL $@
arch/arm/crypto/speck-neon-core.S deleted +0 -434
434 lines not on this page · raw message
arch/arm/crypto/speck-neon-glue.c deleted +0 -288
288 lines not on this page · raw message
arch/arm64/crypto/Kconfig +0 -6
@@ -119,10 +119,4 @@ config CRYPTO_AES_ARM64_BS select CRYPTO_AES_ARM64 select CRYPTO_SIMD -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm64/crypto/Makefile +0 -3
@@ -56,9 +56,6 @@ sha512-arm64-y := sha512-glue.o sha512-core.o obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o - obj-$(CONFIG_CRYPTO_AES_ARM64) += aes-arm64.o aes-arm64-y := aes-cipher-core.o aes-cipher-glue.o
arch/arm64/crypto/speck-neon-core.S deleted +0 -352
352 lines not on this page · raw message
arch/arm64/crypto/speck-neon-glue.c deleted +0 -282
282 lines not on this page · raw message
arch/m68k/configs/amiga_defconfig +0 -1
@@ -650,7 +650,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/apollo_defconfig +0 -1
@@ -609,7 +609,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/atari_defconfig +0 -1
@@ -631,7 +631,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/bvme6000_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/hp300_defconfig +0 -1
@@ -611,7 +611,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mac_defconfig +0 -1
@@ -633,7 +633,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/multi_defconfig +0 -1
@@ -713,7 +713,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme147_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme16x_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/q40_defconfig +0 -1
@@ -624,7 +624,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3_defconfig +0 -1
@@ -602,7 +602,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3x_defconfig +0 -1
@@ -603,7 +603,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/s390/defconfig +0 -1
@@ -221,7 +221,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_DEFLATE=m
crypto/Kconfig +0 -14
@@ -1590,20 +1590,6 @@ config CRYPTO_SM4 If unsure, say N. -config CRYPTO_SPECK - tristate "Speck cipher algorithm" - select CRYPTO_ALGAPI - help - Speck is a lightweight block cipher that is tuned for optimal - performance in software (rather than hardware). - - Speck may not be as secure as AES, and should only be used on systems - where AES is not fast enough. - - See also: <https://eprint.iacr.org/2013/404.pdf> - - If unsure, say N. - config CRYPTO_TEA tristate "TEA, XTEA and XETA cipher algorithms" select CRYPTO_ALGAPI
crypto/Makefile +0 -1
@@ -115,7 +115,6 @@ obj-$(CONFIG_CRYPTO_TEA) += tea.o obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o obj-$(CONFIG_CRYPTO_SEED) += seed.o -obj-$(CONFIG_CRYPTO_SPECK) += speck.o obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o obj-$(CONFIG_CRYPTO_CHACHA20) += chacha20_generic.o obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
crypto/speck.c deleted +0 -307
307 lines not on this page · raw message
crypto/testmgr.c +0 -24
@@ -3000,18 +3000,6 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .cipher = __VECS(sm4_tv_template) } - }, { - .alg = "ecb(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_tv_template) - } - }, { - .alg = "ecb(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_tv_template) - } }, { .alg = "ecb(tea)", .test = alg_test_skcipher,
@@ -3539,18 +3527,6 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .cipher = __VECS(serpent_xts_tv_template) } - }, { - .alg = "xts(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_xts_tv_template) - } - }, { - .alg = "xts(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_xts_tv_template) - } }, { .alg = "xts(twofish)", .test = alg_test_skcipher,
crypto/testmgr.h +0 -738
744 lines not on this page · raw message
fs/crypto/fscrypt_private.h +0 -4
@@ -83,10 +83,6 @@ static inline bool fscrypt_valid_enc_modes(u32 contents_mode, filenames_mode == FS_ENCRYPTION_MODE_AES_256_CTS)return true; -if (contents_mode ==FS_ENCRYPTION_MODE_SPECK128_256_XTS && - filenames_mode ==FS_ENCRYPTION_MODE_SPECK128_256_CTS ) -return true; -return false; }
fs/crypto/keyinfo.c +0 -10
@@ -174,16 +174,6 @@ static struct fscrypt_mode { .cipher_str = "cts(cbc(aes))", .keysize = 16, }, - [FS_ENCRYPTION_MODE_SPECK128_256_XTS] = { - .friendly_name = "Speck128/256-XTS", - .cipher_str = "xts(speck128)", - .keysize = 64, - }, - [FS_ENCRYPTION_MODE_SPECK128_256_CTS] = { - .friendly_name = "Speck128/256-CTS-CBC", - .cipher_str = "cts(cbc(speck128))", - .keysize = 32, - }, }; static struct fscrypt_mode *
include/crypto/speck.h deleted +0 -62
62 lines not on this page · raw message
include/uapi/linux/fs.h +0 -2
@@ -279,8 +279,6 @@ struct fsxattr {#define FS_ENCRYPTION_MODE_AES_256_CTS 4#define FS_ENCRYPTION_MODE_AES_128_CBC 5#define FS_ENCRYPTION_MODE_AES_128_CTS 6 -#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 -#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8struct fscrypt_policy {__u8 version;
Signature · 1 line
2.18.0
Re: [PATCH] crypto: remove speck
Quoted 3 lines · Jason A. Donenfeld
These are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. Therefore, this patch removes it.
I think it may be unwise to completely discard Speck for several reasons. The two biggest pain points for me are:
- political concerns addressed by other ciphers
- high quality lightweight block cipher implementation
- some regulated industries will need it for their problem domains
It seems to me the political concerns were addressed by not using Speck for Android. I don't believe HPolyC and Speck are orthogonal. Instead they provide the user with a choice which is usually a good thing.
I also think allowing politics a heavy hand endangers other ciphers like SM3 and SM4. I would advise against removing them just because they are Chinese ciphers. I suppose the same could be argued for North Korea and Jipsam and Pilsung (if North Korea ever offers their ciphers).
I think Eric, Ard and other contributions lead to a high quality implementation of Speck. High quality implementations that "just works" everywhere on multiple platforms are rather hard to come by. The kernel's unified implementation ensures lots of folks don't go making lots of mistakes when rolling their own.
There are verticals that will need a choice or alternative like Speck. US Aerospace, US Automotive and US Hoteliers come to mind. US Financial my use them too (they having some trading platforms with absurd requirements that make Simon and Speck appear bloated and overweight). Some of the verticals are going to need an alternative that meets technical and security goals and pass the audits.
Choice is a good thing. Users need choices for technical, regulatory and legal reasons.
Jeff
Eric Biggers
maintainerRe: [PATCH] crypto: remove speck
Hi Jeffrey,
Quoted 36 lines · Jeffrey Walton
Quoted 3 lines · Jason A. Donenfeld
These are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. Therefore, this patch removes it.
I think it may be unwise to completely discard Speck for several reasons. The two biggest pain points for me are:
- political concerns addressed by other ciphers
- high quality lightweight block cipher implementation
- some regulated industries will need it for their problem domainsIt seems to me the political concerns were addressed by not using Speck for Android. I don't believe HPolyC and Speck are orthogonal. Instead they provide the user with a choice which is usually a good thing.
I also think allowing politics a heavy hand endangers other ciphers like SM3 and SM4. I would advise against removing them just because they are Chinese ciphers. I suppose the same could be argued for North Korea and Jipsam and Pilsung (if North Korea ever offers their ciphers).
I think Eric, Ard and other contributions lead to a high quality implementation of Speck. High quality implementations that "just works" everywhere on multiple platforms are rather hard to come by. The kernel's unified implementation ensures lots of folks don't go making lots of mistakes when rolling their own.
There are verticals that will need a choice or alternative like Speck. US Aerospace, US Automotive and US Hoteliers come to mind. US Financial my use them too (they having some trading platforms with absurd requirements that make Simon and Speck appear bloated and overweight). Some of the verticals are going to need an alternative that meets technical and security goals and pass the audits.
Quoted 3 lines
Choice is a good thing. Users need choices for technical, regulatory and legal reasons.
This is about the Linux kernel, though. The purpose of the Linux kernel's crypto API is to allow kernel code to do crypto, and also sometimes to allow access to crypto accelerator hardware. It's *not* to provide a comprehensive collection of algorithms for userspace programs to use, or to provide reference implementations for crypto algorithms. Before our change in plans, we needed Speck-XTS in the kernel so that it could be used in dm-crypt and fscrypt, which are kernel features and therefore require in-kernel implementations. And of course, our proposed new solution, HPolyC, will need to be supported in the kernel too for the same reason. It's just the way transparent disk and file encryption works; the crypto needs to be done in the kernel. But do your other mentioned use cases actually need Speck to be in the Linux kernel?
I doubt it, in general. Userspace applications of Speck seem likely to use their own implementation. Remember, Speck is extraordinarily simple, and the original paper has example C code. So if someone really wanted to use Speck in a userspace application, they're likely to just add an implementation directly to their application, rather than coding up a Linux-specific thing using AF_ALG. Or they'd use a Speck implementation from a library like Crypto++.
And while I think it's clear that the reasons why a significant number of people don't want to *use* Speck (even in legitimate use cases) are heavily political, that doesn't necessarily mean that the reason for removing Speck from Linux needs to be as political. If there's code in the kernel with no known users anymore, whether it's a crypto algorithm or something like an obsolete CPU architecture, then it's eligible to be removed so that it doesn't need to be maintained -- potentially even if it breaks the userspace ABI (since it's not really broken if no one cares)... Note that Skein is another example of a crypto algorithm that was recently removed from the kernel because no one was using it, though to be fair it was in the staging directory too. It's still a bit of a double standard as there are likely other ciphers in the kernel that actually no one is using either, but it's a valid argument...
Thanks,
- Eric
Re: [PATCH] crypto: remove speck
In reply to Jason A. DonenfeldHi Jason,
Quoted 6 lines · Jason A. Donenfeld
These are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. Therefore, this patch removes it.
Signed-off-by Jason A. Donenfeld <[email protected]>Cc stable at vger.kernel.org
For context, in your commit message can you include a link to my email mentioning Android's Speck decision
(https://marc.info/?l=linux-crypto-vger&m=153359499015659)?
Also: "speck" => "Speck".
Also I think the fscrypt code points should be reserved so they don't get reused for something else:
#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 /* removed */
#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 /* removed */
Otherwise:
For the record, I think the statements Paul and I have made evaluating Speck from a technical perspective remain substantially accurate. However, clearly today there are more than just technical considerations when choosing cryptographic primitives. So ultimately, enough people didn't *want* Speck that we weren't able to offer it, even though it was only meant to replace no encryption. We've also designed and proposed an alternative solution for the ARMv7 disk encryption use case, HPolyC.
So given the above, and that I no longer know of any specific users of the Speck code (so in principle it can still be removed without breaking userspace), and that it's possible that similar considerations will make Speck difficult for others to use, and that some people heavily object to Speck being optionally supported in the kernel at all, I'm okay with it being removed...
Thanks,
- Eric
Jason A. Donenfeld
maintainerRe: [PATCH] crypto: remove speck
Quoted 4 lines · Eric Biggers
For context, in your commit message can you include a link to my email mentioning Android's Speck decision
(https://marc.info/?l=linux-crypto-vger&m=153359499015659)?
Sure.
Quoted 2 lines
Also: "speck" => "Speck".
Ack.
Quoted 6 lines
Also I think the fscrypt code points should be reserved so they don't get reused for something else:
#define
FS_ENCRYPTION_MODE_SPECK128_256_XTS7 /* removed */
#defineFS_ENCRYPTION_MODE_SPECK128_256_CTS8 /* removed */
I thought about this too, but it occurred to me it's highly improbable these were ever used, and I thought it shinier not to leave scars. But if you feel strongly about it, no problem, I'll fix that up and send in a v2 shortly.
Quoted 3 lines
For the record, I think the statements Paul and I have made evaluating Speck from a technical perspective remain substantially accurate.
It wasn't my intention to relitigate this, hence the rather short commit message. You said your thing, Tomer said his, and now I'm just trying to clear out the leftover soda cans.
Quoted 2 lines
We've also designed and proposed
an alternative solution for the ARMv7 disk encryption use case, HPolyC.
This sounds like a nice and interesting outcome of the whole thing. I'll certainly be looking forward to reading analyses of HPolyC as they come out.
Eric Biggers
maintainerRe: [PATCH] crypto: remove speck
Quoted 26 lines · Jason A. Donenfeld
Quoted 4 lines · Eric Biggers
For context, in your commit message can you include a link to my email mentioning Android's Speck decision
(https://marc.info/?l=linux-crypto-vger&m=153359499015659)?Sure.
Quoted 2 lines
Also: "speck" => "Speck".
Ack.
Quoted 6 lines
Also I think the fscrypt code points should be reserved so they don't get reused for something else:
#define
FS_ENCRYPTION_MODE_SPECK128_256_XTS7 /* removed */
#defineFS_ENCRYPTION_MODE_SPECK128_256_CTS8 /* removed */I thought about this too, but it occurred to me it's highly improbable these were ever used, and I thought it shinier not to leave scars. But if you feel strongly about it, no problem, I'll fix that up and send in a v2 shortly.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
For the record, I think the statements Paul and I have made evaluating Speck from a technical perspective remain substantially accurate.
It wasn't my intention to relitigate this, hence the rather short commit message. You said your thing, Tomer said his, and now I'm just trying to clear out the leftover soda cans.
Sure, neither do I. My intention is more to make it clear that we still don't know of any "backdoor" in Speck, or any weakness that would compromise its use in practice.
I mention this because people are naturally going to be curious about that, e.g. speculating that Google found a "backdoor" -- remember that we do have some good cryptographers! I'm just stating what we know, out of honesty and openness; I don't really intend to be arguing for Speck with this statement, and in any case we already made the decision to not use Speck.
Thanks,
- Eric
Theodore Y. Ts'o
maintainerRe: [PATCH] crypto: remove speck
Quoted 5 lines · Eric Biggers
I mention this because people are naturally going to be curious about that, e.g. speculating that Google found a "backdoor" -- remember that we do have some good cryptographers! I'm just stating what we know, out of honesty and openness; I don't really intend to be arguing for Speck with this statement, and in any case we already made the decision to not use Speck.
Let's be clear --- the arguments about whether or not to use Speck, and whether or not to remove Speck from the kernel, are purely political --- not techinical.
- Ted
Re: [PATCH] crypto: remove speck
Quoted 11 lines · Theodore Y. Ts'o
Quoted 5 lines · Eric Biggers
I mention this because people are naturally going to be curious about that, e.g. speculating that Google found a "backdoor" -- remember that we do have some good cryptographers! I'm just stating what we know, out of honesty and openness; I don't really intend to be arguing for Speck with this statement, and in any case we already made the decision to not use Speck.
Let's be clear --- the arguments about whether or not to use Speck, and whether or not to remove Speck from the kernel, are purely political --- not techinical.
Whether or not to use it may be a political rather than a technical motivation. But the reason I acked this patch is not because removing it aligns with my political conviction regarding Speck, but simply because its contributor, primary intended user and therefore de facto maintainer stated publicly that it no longer had any intention to use it going forward.
Jason A. Donenfeld
maintainerPATCH v2 1/1 crypto: remove Speck
In reply to Eric BiggersThese are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. While originally proposed for disk encryption on low-end devices, the idea was discarded [1] in favor of something else before that could really get going. Therefore, this patch removes Speck.
[1] https://marc.info/?l=linux-crypto-vger&m=153359499015659
--- Documentation/filesystems/fscrypt.rst | 10 - arch/arm/crypto/Kconfig | 6 - arch/arm/crypto/Makefile | 2 - arch/arm/crypto/speck-neon-core.S | 434 --------------- arch/arm/crypto/speck-neon-glue.c | 288 ---------- arch/arm64/crypto/Kconfig | 6 - arch/arm64/crypto/Makefile | 3 - arch/arm64/crypto/speck-neon-core.S | 352 ------------ arch/arm64/crypto/speck-neon-glue.c | 282 ---------- arch/m68k/configs/amiga_defconfig | 1 - arch/m68k/configs/apollo_defconfig | 1 - arch/m68k/configs/atari_defconfig | 1 - arch/m68k/configs/bvme6000_defconfig | 1 - arch/m68k/configs/hp300_defconfig | 1 - arch/m68k/configs/mac_defconfig | 1 - arch/m68k/configs/multi_defconfig | 1 - arch/m68k/configs/mvme147_defconfig | 1 - arch/m68k/configs/mvme16x_defconfig | 1 - arch/m68k/configs/q40_defconfig | 1 - arch/m68k/configs/sun3_defconfig | 1 - arch/m68k/configs/sun3x_defconfig | 1 - arch/s390/defconfig | 1 - crypto/Kconfig | 14 - crypto/Makefile | 1 - crypto/speck.c | 307 ----------- crypto/testmgr.c | 24 - crypto/testmgr.h | 738 -------------------------- fs/crypto/fscrypt_private.h | 4 - fs/crypto/keyinfo.c | 10 - include/crypto/speck.h | 62 --- include/uapi/linux/fs.h | 4 +- 31 files changed, 2 insertions(+), 2558 deletions(-) delete mode 100644 arch/arm/crypto/speck-neon-core.S delete mode 100644 arch/arm/crypto/speck-neon-glue.c delete mode 100644 arch/arm64/crypto/speck-neon-core.S delete mode 100644 arch/arm64/crypto/speck-neon-glue.c delete mode 100644 crypto/speck.c delete mode 100644 include/crypto/speck.h
Documentation/filesystems/fscrypt.rst +0 -10
@@ -191,21 +191,11 @@ Currently, the following pairs of encryption modes are supported: - AES-256-XTS for contents and AES-256-CTS-CBC for filenames - AES-128-CBC for contents and AES-128-CTS-CBC for filenames -- Speck128/256-XTS for contents and Speck128/256-CTS-CBC for filenames It is strongly recommended to use AES-256-XTS for contents encryption. AES-128-CBC was added only for low-powered embedded devices with crypto accelerators such as CAAM or CESA that do not support XTS. -Similarly, Speck128/256 support was only added for older or low-end -CPUs which cannot do AES fast enough -- especially ARM CPUs which have -NEON instructions but not the Cryptography Extensions -- and for which -it would not otherwise be feasible to use encryption at all. It is -not recommended to use Speck on CPUs that have AES instructions. -Speck support is only available if it has been enabled in the crypto -API via CONFIG_CRYPTO_SPECK. Also, on ARM platforms, to get -acceptable performance CONFIG_CRYPTO_SPECK_NEON must be enabled. - New encryption modes can be added relatively easily, without changes to individual filesystems. However, authenticated encryption (AE) modes are not currently supported because of the difficulty of dealing
arch/arm/crypto/Kconfig +0 -6
@@ -121,10 +121,4 @@ config CRYPTO_CHACHA20_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20 -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm/crypto/Makefile +0 -2
@@ -10,7 +10,6 @@ obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sha1-arm-neon.o obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o ce-obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o ce-obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o
@@ -54,7 +53,6 @@ ghash-arm-ce-y := ghash-ce-core.o ghash-ce-glue.o crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o ifdef REGENERATE_ARM_CRYPTO quiet_cmd_perl = PERL $@
arch/arm/crypto/speck-neon-core.S deleted +0 -434
434 lines not on this page · raw message
arch/arm/crypto/speck-neon-glue.c deleted +0 -288
288 lines not on this page · raw message
arch/arm64/crypto/Kconfig +0 -6
@@ -119,10 +119,4 @@ config CRYPTO_AES_ARM64_BS select CRYPTO_AES_ARM64 select CRYPTO_SIMD -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm64/crypto/Makefile +0 -3
@@ -56,9 +56,6 @@ sha512-arm64-y := sha512-glue.o sha512-core.o obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o - obj-$(CONFIG_CRYPTO_AES_ARM64) += aes-arm64.o aes-arm64-y := aes-cipher-core.o aes-cipher-glue.o
arch/arm64/crypto/speck-neon-core.S deleted +0 -352
352 lines not on this page · raw message
arch/arm64/crypto/speck-neon-glue.c deleted +0 -282
282 lines not on this page · raw message
arch/m68k/configs/amiga_defconfig +0 -1
@@ -650,7 +650,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/apollo_defconfig +0 -1
@@ -609,7 +609,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/atari_defconfig +0 -1
@@ -631,7 +631,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/bvme6000_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/hp300_defconfig +0 -1
@@ -611,7 +611,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mac_defconfig +0 -1
@@ -633,7 +633,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/multi_defconfig +0 -1
@@ -713,7 +713,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme147_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme16x_defconfig +0 -1
@@ -601,7 +601,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/q40_defconfig +0 -1
@@ -624,7 +624,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3_defconfig +0 -1
@@ -602,7 +602,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3x_defconfig +0 -1
@@ -603,7 +603,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/s390/defconfig +0 -1
@@ -221,7 +221,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_DEFLATE=m
crypto/Kconfig +0 -14
@@ -1590,20 +1590,6 @@ config CRYPTO_SM4 If unsure, say N. -config CRYPTO_SPECK - tristate "Speck cipher algorithm" - select CRYPTO_ALGAPI - help - Speck is a lightweight block cipher that is tuned for optimal - performance in software (rather than hardware). - - Speck may not be as secure as AES, and should only be used on systems - where AES is not fast enough. - - See also: <https://eprint.iacr.org/2013/404.pdf> - - If unsure, say N. - config CRYPTO_TEA tristate "TEA, XTEA and XETA cipher algorithms" select CRYPTO_ALGAPI
crypto/Makefile +0 -1
@@ -115,7 +115,6 @@ obj-$(CONFIG_CRYPTO_TEA) += tea.o obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o obj-$(CONFIG_CRYPTO_SEED) += seed.o -obj-$(CONFIG_CRYPTO_SPECK) += speck.o obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o obj-$(CONFIG_CRYPTO_CHACHA20) += chacha20_generic.o obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
crypto/speck.c deleted +0 -307
307 lines not on this page · raw message
crypto/testmgr.c +0 -24
@@ -3000,18 +3000,6 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .cipher = __VECS(sm4_tv_template) } - }, { - .alg = "ecb(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_tv_template) - } - }, { - .alg = "ecb(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_tv_template) - } }, { .alg = "ecb(tea)", .test = alg_test_skcipher,
@@ -3539,18 +3527,6 @@ static const struct alg_test_desc alg_test_descs[] = { .suite = { .cipher = __VECS(serpent_xts_tv_template) } - }, { - .alg = "xts(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_xts_tv_template) - } - }, { - .alg = "xts(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_xts_tv_template) - } }, { .alg = "xts(twofish)", .test = alg_test_skcipher,
crypto/testmgr.h +0 -738
744 lines not on this page · raw message
fs/crypto/fscrypt_private.h +0 -4
@@ -83,10 +83,6 @@ static inline bool fscrypt_valid_enc_modes(u32 contents_mode, filenames_mode == FS_ENCRYPTION_MODE_AES_256_CTS)return true; -if (contents_mode ==FS_ENCRYPTION_MODE_SPECK128_256_XTS && - filenames_mode ==FS_ENCRYPTION_MODE_SPECK128_256_CTS ) -return true; -return false; }
fs/crypto/keyinfo.c +0 -10
@@ -174,16 +174,6 @@ static struct fscrypt_mode { .cipher_str = "cts(cbc(aes))", .keysize = 16, }, - [FS_ENCRYPTION_MODE_SPECK128_256_XTS] = { - .friendly_name = "Speck128/256-XTS", - .cipher_str = "xts(speck128)", - .keysize = 64, - }, - [FS_ENCRYPTION_MODE_SPECK128_256_CTS] = { - .friendly_name = "Speck128/256-CTS-CBC", - .cipher_str = "cts(cbc(speck128))", - .keysize = 32, - }, }; static struct fscrypt_mode *
include/crypto/speck.h deleted +0 -62
62 lines not on this page · raw message
include/uapi/linux/fs.h +2 -2
@@ -279,8 +279,8 @@ struct fsxattr {#define FS_ENCRYPTION_MODE_AES_256_CTS 4#define FS_ENCRYPTION_MODE_AES_128_CBC 5#define FS_ENCRYPTION_MODE_AES_128_CTS 6 -#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 -#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 +#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7/* Removed, do not use. */ +#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8/* Removed, do not use. */ struct fscrypt_policy {__u8 version;
Signature · 1 line
2.18.0
Re: [PATCH v2] crypto: remove Speck
Quoted 11 lines · Jason A. Donenfeld
These are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. While originally proposed for disk encryption on low-end devices, the idea was discarded [1] in favor of something else before that could really get going. Therefore, this patch removes Speck.
[1] https://marc.info/?l=linux-crypto-vger&m=153359499015659
Signed-off-by Jason A. Donenfeld <[email protected]>Acked-by Eric Biggers <[email protected]>Cc stable at vger.kernel.org
Herbert Xu
maintainerRe: [PATCH v2] crypto: remove Speck
In reply to Jason A. DonenfeldQuoted 42 lines · Jason A. Donenfeld
These are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. While originally proposed for disk encryption on low-end devices, the idea was discarded [1] in favor of something else before that could really get going. Therefore, this patch removes Speck.
[1] https://marc.info/?l=linux-crypto-vger&m=153359499015659
Signed-off-by Jason A. Donenfeld <[email protected]>Acked-by Eric Biggers <[email protected]>Cc stable at vger.kernel.org--- Documentation/filesystems/fscrypt.rst | 10 - arch/arm/crypto/Kconfig | 6 - arch/arm/crypto/Makefile | 2 - arch/arm/crypto/speck-neon-core.S | 434 --------------- arch/arm/crypto/speck-neon-glue.c | 288 ---------- arch/arm64/crypto/Kconfig | 6 - arch/arm64/crypto/Makefile | 3 - arch/arm64/crypto/speck-neon-core.S | 352 ------------ arch/arm64/crypto/speck-neon-glue.c | 282 ---------- arch/m68k/configs/amiga_defconfig | 1 - arch/m68k/configs/apollo_defconfig | 1 - arch/m68k/configs/atari_defconfig | 1 - arch/m68k/configs/bvme6000_defconfig | 1 - arch/m68k/configs/hp300_defconfig | 1 - arch/m68k/configs/mac_defconfig | 1 - arch/m68k/configs/multi_defconfig | 1 - arch/m68k/configs/mvme147_defconfig | 1 - arch/m68k/configs/mvme16x_defconfig | 1 - arch/m68k/configs/q40_defconfig | 1 - arch/m68k/configs/sun3_defconfig | 1 - arch/m68k/configs/sun3x_defconfig | 1 - arch/s390/defconfig | 1 - crypto/Kconfig | 14 - crypto/Makefile | 1 - crypto/speck.c | 307 ----------- crypto/testmgr.c | 24 - crypto/testmgr.h | 738 -------------------------- fs/crypto/fscrypt_private.h | 4 - fs/crypto/keyinfo.c | 10 - include/crypto/speck.h | 62 ---
Quoted 8 lines
include/uapi/linux/fs.h | 4 +- 31 files changed, 2 insertions(+), 2558 deletions(-) delete mode 100644 arch/arm/crypto/speck-neon-core.S delete mode 100644 arch/arm/crypto/speck-neon-glue.c delete mode 100644 arch/arm64/crypto/speck-neon-core.S delete mode 100644 arch/arm64/crypto/speck-neon-glue.c delete mode 100644 crypto/speck.c delete mode 100644 include/crypto/speck.h
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt