Commit dcb15794 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: ux500/des - switch to new verification routines

Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 9d574ae8
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <crypto/aes.h> #include <crypto/aes.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/ctr.h> #include <crypto/ctr.h>
#include <crypto/des.h> #include <crypto/internal/des.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <linux/platform_data/crypto-ux500.h> #include <linux/platform_data/crypto-ux500.h>
...@@ -987,26 +987,13 @@ static int des_ablkcipher_setkey(struct crypto_ablkcipher *cipher, ...@@ -987,26 +987,13 @@ static int des_ablkcipher_setkey(struct crypto_ablkcipher *cipher,
const u8 *key, unsigned int keylen) const u8 *key, unsigned int keylen)
{ {
struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher);
u32 *flags = &cipher->base.crt_flags; int err;
u32 tmp[DES_EXPKEY_WORDS];
int ret;
pr_debug(DEV_DBG_NAME " [%s]", __func__); pr_debug(DEV_DBG_NAME " [%s]", __func__);
if (keylen != DES_KEY_SIZE) {
*flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_BAD_KEY_LEN",
__func__);
return -EINVAL;
}
ret = des_ekey(tmp, key); err = verify_ablkcipher_des_key(cipher, key);
if (unlikely(ret == 0) && if (err)
(*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { return err;
*flags |= CRYPTO_TFM_RES_WEAK_KEY;
pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_WEAK_KEY",
__func__);
return -EINVAL;
}
memcpy(ctx->key, key, keylen); memcpy(ctx->key, key, keylen);
ctx->keylen = keylen; ctx->keylen = keylen;
...@@ -1019,17 +1006,13 @@ static int des3_ablkcipher_setkey(struct crypto_ablkcipher *cipher, ...@@ -1019,17 +1006,13 @@ static int des3_ablkcipher_setkey(struct crypto_ablkcipher *cipher,
const u8 *key, unsigned int keylen) const u8 *key, unsigned int keylen)
{ {
struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher);
u32 flags;
int err; int err;
pr_debug(DEV_DBG_NAME " [%s]", __func__); pr_debug(DEV_DBG_NAME " [%s]", __func__);
flags = crypto_ablkcipher_get_flags(cipher); err = verify_ablkcipher_des3_key(cipher, key);
err = __des3_verify_key(&flags, key); if (err)
if (unlikely(err)) {
crypto_ablkcipher_set_flags(cipher, flags);
return err; return err;
}
memcpy(ctx->key, key, keylen); memcpy(ctx->key, key, keylen);
ctx->keylen = keylen; ctx->keylen = keylen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment