diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2019-08-15 05:00:55 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-08-22 00:39:41 -0400 |
commit | 21f5a15e0f26c7ea15bee9ed3c5fd1daa40b0b77 (patch) | |
tree | c65ae42084365612ab2d09e0f6188f8cd8f4de66 /drivers/crypto/inside-secure | |
parent | 894b68d8be4b305615ab3be52667478fe5f6e0b5 (diff) |
crypto: safexcel/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>
Diffstat (limited to 'drivers/crypto/inside-secure')
-rw-r--r-- | drivers/crypto/inside-secure/safexcel_cipher.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/drivers/crypto/inside-secure/safexcel_cipher.c b/drivers/crypto/inside-secure/safexcel_cipher.c index 5682fe8b606e..16c4d5460334 100644 --- a/drivers/crypto/inside-secure/safexcel_cipher.c +++ b/drivers/crypto/inside-secure/safexcel_cipher.c | |||
@@ -220,7 +220,6 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8 *key, | |||
220 | struct safexcel_crypto_priv *priv = ctx->priv; | 220 | struct safexcel_crypto_priv *priv = ctx->priv; |
221 | struct crypto_authenc_keys keys; | 221 | struct crypto_authenc_keys keys; |
222 | struct crypto_aes_ctx aes; | 222 | struct crypto_aes_ctx aes; |
223 | u32 flags; | ||
224 | int err = -EINVAL; | 223 | int err = -EINVAL; |
225 | 224 | ||
226 | if (crypto_authenc_extractkeys(&keys, key, len) != 0) | 225 | if (crypto_authenc_extractkeys(&keys, key, len) != 0) |
@@ -241,12 +240,7 @@ static int safexcel_aead_setkey(struct crypto_aead *ctfm, const u8 *key, | |||
241 | /* Encryption key */ | 240 | /* Encryption key */ |
242 | switch (ctx->alg) { | 241 | switch (ctx->alg) { |
243 | case SAFEXCEL_3DES: | 242 | case SAFEXCEL_3DES: |
244 | if (keys.enckeylen != DES3_EDE_KEY_SIZE) | 243 | err = verify_aead_des3_key(ctfm, keys.enckey, keys.enckeylen); |
245 | goto badkey; | ||
246 | flags = crypto_aead_get_flags(ctfm); | ||
247 | err = __des3_verify_key(&flags, keys.enckey); | ||
248 | crypto_aead_set_flags(ctfm, flags); | ||
249 | |||
250 | if (unlikely(err)) | 244 | if (unlikely(err)) |
251 | goto badkey_expflags; | 245 | goto badkey_expflags; |
252 | break; | 246 | break; |
@@ -1192,16 +1186,12 @@ static int safexcel_cbc_des_decrypt(struct skcipher_request *req) | |||
1192 | static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key, | 1186 | static int safexcel_des_setkey(struct crypto_skcipher *ctfm, const u8 *key, |
1193 | unsigned int len) | 1187 | unsigned int len) |
1194 | { | 1188 | { |
1195 | struct crypto_tfm *tfm = crypto_skcipher_tfm(ctfm); | 1189 | struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm); |
1196 | struct safexcel_cipher_ctx *ctx = crypto_tfm_ctx(tfm); | ||
1197 | u32 tmp[DES_EXPKEY_WORDS]; | ||
1198 | int ret; | 1190 | int ret; |
1199 | 1191 | ||
1200 | ret = des_ekey(tmp, key); | 1192 | ret = verify_skcipher_des_key(ctfm, key); |
1201 | if (!ret && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { | 1193 | if (ret) |
1202 | tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; | 1194 | return ret; |
1203 | return -EINVAL; | ||
1204 | } | ||
1205 | 1195 | ||
1206 | /* if context exits and key changed, need to invalidate it */ | 1196 | /* if context exits and key changed, need to invalidate it */ |
1207 | if (ctx->base.ctxr_dma) | 1197 | if (ctx->base.ctxr_dma) |
@@ -1299,8 +1289,8 @@ static int safexcel_des3_ede_setkey(struct crypto_skcipher *ctfm, | |||
1299 | struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm); | 1289 | struct safexcel_cipher_ctx *ctx = crypto_skcipher_ctx(ctfm); |
1300 | int err; | 1290 | int err; |
1301 | 1291 | ||
1302 | err = des3_verify_key(ctfm, key); | 1292 | err = verify_skcipher_des3_key(ctfm, key); |
1303 | if (unlikely(err)) | 1293 | if (err) |
1304 | return err; | 1294 | return err; |
1305 | 1295 | ||
1306 | /* if context exits and key changed, need to invalidate it */ | 1296 | /* if context exits and key changed, need to invalidate it */ |