Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crypto: ux500/des - switch to new verification routines

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ard Biesheuvel and committed by
Herbert Xu
dcb15794 9d574ae8

+7 -24
+7 -24
drivers/crypto/ux500/cryp/cryp_core.c
··· 29 29 #include <crypto/aes.h> 30 30 #include <crypto/algapi.h> 31 31 #include <crypto/ctr.h> 32 - #include <crypto/des.h> 32 + #include <crypto/internal/des.h> 33 33 #include <crypto/scatterwalk.h> 34 34 35 35 #include <linux/platform_data/crypto-ux500.h> ··· 987 987 const u8 *key, unsigned int keylen) 988 988 { 989 989 struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); 990 - u32 *flags = &cipher->base.crt_flags; 991 - u32 tmp[DES_EXPKEY_WORDS]; 992 - int ret; 990 + int err; 993 991 994 992 pr_debug(DEV_DBG_NAME " [%s]", __func__); 995 - if (keylen != DES_KEY_SIZE) { 996 - *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; 997 - pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_BAD_KEY_LEN", 998 - __func__); 999 - return -EINVAL; 1000 - } 1001 993 1002 - ret = des_ekey(tmp, key); 1003 - if (unlikely(ret == 0) && 1004 - (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { 1005 - *flags |= CRYPTO_TFM_RES_WEAK_KEY; 1006 - pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_WEAK_KEY", 1007 - __func__); 1008 - return -EINVAL; 1009 - } 994 + err = verify_ablkcipher_des_key(cipher, key); 995 + if (err) 996 + return err; 1010 997 1011 998 memcpy(ctx->key, key, keylen); 1012 999 ctx->keylen = keylen; ··· 1006 1019 const u8 *key, unsigned int keylen) 1007 1020 { 1008 1021 struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); 1009 - u32 flags; 1010 1022 int err; 1011 1023 1012 1024 pr_debug(DEV_DBG_NAME " [%s]", __func__); 1013 1025 1014 - flags = crypto_ablkcipher_get_flags(cipher); 1015 - err = __des3_verify_key(&flags, key); 1016 - if (unlikely(err)) { 1017 - crypto_ablkcipher_set_flags(cipher, flags); 1026 + err = verify_ablkcipher_des3_key(cipher, key); 1027 + if (err) 1018 1028 return err; 1019 - } 1020 1029 1021 1030 memcpy(ctx->key, key, keylen); 1022 1031 ctx->keylen = keylen;