Message ID | 20190627120314.7197-23-ard.biesheuvel@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | crypto: DES/3DES cleanup | expand |
On Thu, Jun 27, 2019 at 02:03:06PM +0200, Ard Biesheuvel wrote: > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > --- > drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 22 ++++---------------- > drivers/crypto/sunxi-ss/sun4i-ss.h | 2 +- > 2 files changed, 5 insertions(+), 19 deletions(-) > > diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c > index b060a0810934..93b383654af0 100644 > --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c > +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c > @@ -533,25 +533,11 @@ int sun4i_ss_des_setkey(struct crypto_skcipher *tfm, const u8 *key, > unsigned int keylen) > { > struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm); > - struct sun4i_ss_ctx *ss = op->ss; > - u32 flags; > - u32 tmp[DES_EXPKEY_WORDS]; > int ret; > > - if (unlikely(keylen != DES_KEY_SIZE)) { > - dev_err(ss->dev, "Invalid keylen %u\n", keylen); > - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); > - return -EINVAL; > - } > - > - flags = crypto_skcipher_get_flags(tfm); > - > - ret = des_ekey(tmp, key); > - if (unlikely(!ret) && (flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { > - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY); > - dev_dbg(ss->dev, "Weak key %u\n", keylen); > - return -EINVAL; > - } > + err = crypto_des_verify_key(crypto_skcipher_tfm(tfm), key); > + if (unlikely(err)) > + return err; > > op->keylen = keylen; > memcpy(op->key, key, keylen); > @@ -569,7 +555,7 @@ int sun4i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, > struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm); > int err; > > - err = des3_verify_key(tfm, key); > + err = crypto_des3_ede_verify_key(crypto_skcipher_tfm(tfm), key); > if (unlikely(err)) > return err; > There is a build error here: drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_des_setkey': drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:538:2: error: 'err' undeclared (first use in this function) err = crypto_des_verify_key(crypto_skcipher_tfm(tfm), key); ^~~ drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:538:2: note: each undeclared identifier is reported only once for each function it appears in drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:536:6: warning: unused variable 'ret' [-Wunused-variable] int ret; ^~~
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c index b060a0810934..93b383654af0 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c @@ -533,25 +533,11 @@ int sun4i_ss_des_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm); - struct sun4i_ss_ctx *ss = op->ss; - u32 flags; - u32 tmp[DES_EXPKEY_WORDS]; int ret; - if (unlikely(keylen != DES_KEY_SIZE)) { - dev_err(ss->dev, "Invalid keylen %u\n", keylen); - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } - - flags = crypto_skcipher_get_flags(tfm); - - ret = des_ekey(tmp, key); - if (unlikely(!ret) && (flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY); - dev_dbg(ss->dev, "Weak key %u\n", keylen); - return -EINVAL; - } + err = crypto_des_verify_key(crypto_skcipher_tfm(tfm), key); + if (unlikely(err)) + return err; op->keylen = keylen; memcpy(op->key, key, keylen); @@ -569,7 +555,7 @@ int sun4i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm); int err; - err = des3_verify_key(tfm, key); + err = crypto_des3_ede_verify_key(crypto_skcipher_tfm(tfm), key); if (unlikely(err)) return err; diff --git a/drivers/crypto/sunxi-ss/sun4i-ss.h b/drivers/crypto/sunxi-ss/sun4i-ss.h index 8c4ec9e93565..3c62624d8faa 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss.h +++ b/drivers/crypto/sunxi-ss/sun4i-ss.h @@ -30,7 +30,7 @@ #include <crypto/internal/hash.h> #include <crypto/internal/skcipher.h> #include <crypto/aes.h> -#include <crypto/des.h> +#include <crypto/internal/des.h> #include <crypto/internal/rng.h> #include <crypto/rng.h>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 22 ++++---------------- drivers/crypto/sunxi-ss/sun4i-ss.h | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) -- 2.20.1