diff options
author | Stephan Mueller <smueller@chronox.de> | 2016-02-09 09:37:47 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-02-16 15:07:51 -0500 |
commit | 28856a9e52c7cac712af6c143de04766617535dc (patch) | |
tree | 4ee6c79e76f8eadc0148bfeb09fd146c9d53fabf /arch/x86/crypto/serpent_sse2_glue.c | |
parent | 730d02e27670fa5b6a55778d11023c5897d87d57 (diff) |
crypto: xts - consolidate sanity check for keys
The patch centralizes the XTS key check logic into the service function
xts_check_key which is invoked from the different XTS implementations.
With this, the XTS implementations in ARM, ARM64, PPC and S390 have now
a sanity check for the XTS keys similar to the other arches.
In addition, this service function received a check to ensure that the
key != the tweak key which is mandated by FIPS 140-2 IG A.9. As the
check is not present in the standards defining XTS, it is only enforced
in FIPS mode of the kernel.
Signed-off-by: Stephan Mueller <smueller@chronox.de>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/x86/crypto/serpent_sse2_glue.c')
-rw-r--r-- | arch/x86/crypto/serpent_sse2_glue.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/arch/x86/crypto/serpent_sse2_glue.c b/arch/x86/crypto/serpent_sse2_glue.c index 3643dd508f45..8943407e8917 100644 --- a/arch/x86/crypto/serpent_sse2_glue.c +++ b/arch/x86/crypto/serpent_sse2_glue.c | |||
@@ -309,16 +309,11 @@ static int xts_serpent_setkey(struct crypto_tfm *tfm, const u8 *key, | |||
309 | unsigned int keylen) | 309 | unsigned int keylen) |
310 | { | 310 | { |
311 | struct serpent_xts_ctx *ctx = crypto_tfm_ctx(tfm); | 311 | struct serpent_xts_ctx *ctx = crypto_tfm_ctx(tfm); |
312 | u32 *flags = &tfm->crt_flags; | ||
313 | int err; | 312 | int err; |
314 | 313 | ||
315 | /* key consists of keys of equal size concatenated, therefore | 314 | err = xts_check_key(tfm, key, keylen); |
316 | * the length must be even | 315 | if (err) |
317 | */ | 316 | return err; |
318 | if (keylen % 2) { | ||
319 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
320 | return -EINVAL; | ||
321 | } | ||
322 | 317 | ||
323 | /* first half of xts-key is for crypt */ | 318 | /* first half of xts-key is for crypt */ |
324 | err = __serpent_setkey(&ctx->crypt_ctx, key, keylen / 2); | 319 | err = __serpent_setkey(&ctx->crypt_ctx, key, keylen / 2); |