Commit 304daa4f authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: omap/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 d4b90dbc
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include <linux/crypto.h> #include <linux/crypto.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <crypto/des.h> #include <crypto/internal/des.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/engine.h> #include <crypto/engine.h>
...@@ -650,20 +650,13 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, ...@@ -650,20 +650,13 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
unsigned int keylen) unsigned int keylen)
{ {
struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); int err;
pr_debug("enter, keylen: %d\n", keylen); pr_debug("enter, keylen: %d\n", keylen);
/* Do we need to test against weak key? */ err = verify_ablkcipher_des_key(cipher, key);
if (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) { if (err)
u32 tmp[DES_EXPKEY_WORDS]; return err;
int ret = des_ekey(tmp, key);
if (!ret) {
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
return -EINVAL;
}
}
memcpy(ctx->key, key, keylen); memcpy(ctx->key, key, keylen);
ctx->keylen = keylen; ctx->keylen = keylen;
...@@ -672,20 +665,16 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, ...@@ -672,20 +665,16 @@ static int omap_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
} }
static int omap_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key, static int omap_des3_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
unsigned int keylen) unsigned int keylen)
{ {
struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher); struct omap_des_ctx *ctx = crypto_ablkcipher_ctx(cipher);
u32 flags;
int err; int err;
pr_debug("enter, keylen: %d\n", keylen); pr_debug("enter, keylen: %d\n", keylen);
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