On Thu, 27 Jun 2019 at 11:58, Horia Geanta <horia.geanta@xxxxxxx> wrote: > > On 6/22/2019 3:32 AM, Ard Biesheuvel wrote: > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> > > --- > > drivers/crypto/caam/caamalg.c | 13 +++-------- > > drivers/crypto/caam/caamalg_qi.c | 23 ++++++++++---------- > > drivers/crypto/caam/caamalg_qi2.c | 23 ++++++++++---------- > > drivers/crypto/caam/compat.h | 2 +- > > 4 files changed, 26 insertions(+), 35 deletions(-) > > > Compiling the patch set, I get the following errors: > Thanks for the report, will fix for the next revision. > drivers/crypto/caam/caamalg.c: In function 'des3_aead_setkey': > drivers/crypto/caam/caamalg.c:642:51: error: 'tfm' undeclared (first use in this function) > err = crypto_des3_ede_verify_key(crypto_aead_tfm(tfm), keys.enckey, > ^ > drivers/crypto/caam/caamalg.c:642:51: note: each undeclared identifier is reported only once for each function it appears in > drivers/crypto/caam/caamalg.c: In function 'des_skcipher_setkey': > drivers/crypto/caam/caamalg.c:783:2: error: implicit declaration of function 'des_verify_key' [-Werror=implicit-function-declaration] > err = des_verify_key(crypto_skcipher_tfm(skcipher), key, keylen); > ^ > drivers/crypto/caam/caamalg.c: In function 'des3_skcipher_setkey': > drivers/crypto/caam/caamalg.c:795:28: warning: passing argument 1 of 'des3_ede_verify_key' from incompatible pointer type > err = des3_ede_verify_key(crypto_skcipher_tfm(skcipher), key, keylen); > ^ > In file included from drivers/crypto/caam/compat.h:35:0, > from drivers/crypto/caam/caamalg.c:49: > ./include/crypto/internal/des.h:49:19: note: expected 'const u8 *' but argument is of type 'struct crypto_tfm *' > static inline int des3_ede_verify_key(const u8 *key, unsigned int key_len, > ^ > drivers/crypto/caam/caamalg.c:795:59: warning: passing argument 2 of 'des3_ede_verify_key' makes integer from pointer without a cast > err = des3_ede_verify_key(crypto_skcipher_tfm(skcipher), key, keylen); > ^ > In file included from drivers/crypto/caam/compat.h:35:0, > from drivers/crypto/caam/caamalg.c:49: > ./include/crypto/internal/des.h:49:19: note: expected 'unsigned int' but argument is of type 'const u8 *' > static inline int des3_ede_verify_key(const u8 *key, unsigned int key_len, > ^ > > > diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c > > index 5d4fa65a015f..b4ab64146b21 100644 > > --- a/drivers/crypto/caam/caamalg.c > > +++ b/drivers/crypto/caam/caamalg.c > > @@ -633,23 +633,16 @@ static int des3_aead_setkey(struct crypto_aead *aead, const u8 *key, > > unsigned int keylen) > > { > > struct crypto_authenc_keys keys; > > - u32 flags; > > int err; > > > > err = crypto_authenc_extractkeys(&keys, key, keylen); > > if (unlikely(err)) > > goto badkey; > > > > - err = -EINVAL; > > - if (keys.enckeylen != DES3_EDE_KEY_SIZE) > > - goto badkey; > > - > > - flags = crypto_aead_get_flags(aead); > > - err = __des3_verify_key(&flags, keys.enckey); > > - if (unlikely(err)) { > > - crypto_aead_set_flags(aead, flags); > > + err = crypto_des3_ede_verify_key(crypto_aead_tfm(tfm), keys.enckey, > > + keys.enckeylen); > > + if (unlikely(err)) > > goto out; > > - } > > > > err = aead_setkey(aead, key, keylen); > > > > diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c > > index 32f0f8a72067..01d92ef0142a 100644 > > --- a/drivers/crypto/caam/caamalg_qi.c > > +++ b/drivers/crypto/caam/caamalg_qi.c > > @@ -296,23 +296,16 @@ static int des3_aead_setkey(struct crypto_aead *aead, const u8 *key, > > unsigned int keylen) > > { > > struct crypto_authenc_keys keys; > > - u32 flags; > > int err; > > > > err = crypto_authenc_extractkeys(&keys, key, keylen); > > if (unlikely(err)) > > goto badkey; > > > > - err = -EINVAL; > > - if (keys.enckeylen != DES3_EDE_KEY_SIZE) > > - goto badkey; > > - > > - flags = crypto_aead_get_flags(aead); > > - err = __des3_verify_key(&flags, keys.enckey); > > - if (unlikely(err)) { > > - crypto_aead_set_flags(aead, flags); > > + err = crypto_des3_ede_verify_key(crypto_aead_tfm(aead), keys.enckey, > > + keys.enckeylen); > > + if (unlikely(err)) > > goto out; > > - } > > > > err = aead_setkey(aead, key, keylen); > > > > @@ -697,8 +690,14 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, > > static int des3_skcipher_setkey(struct crypto_skcipher *skcipher, > > const u8 *key, unsigned int keylen) > > { > > - return unlikely(des3_verify_key(skcipher, key)) ?: > > - skcipher_setkey(skcipher, key, keylen); > > + int err; > > + > > + err = crypto_des3_ede_verify_key(crypto_skcipher_tfm(skcipher), key, > > + keylen); > > + if (unlikely(err)) > > + return err; > > + > > + return skcipher_setkey(skcipher, key, keylen); > > } > > > > static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, > > diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c > > index 06bf32c32cbd..074fbb8356e5 100644 > > --- a/drivers/crypto/caam/caamalg_qi2.c > > +++ b/drivers/crypto/caam/caamalg_qi2.c > > @@ -329,23 +329,16 @@ static int des3_aead_setkey(struct crypto_aead *aead, const u8 *key, > > unsigned int keylen) > > { > > struct crypto_authenc_keys keys; > > - u32 flags; > > int err; > > > > err = crypto_authenc_extractkeys(&keys, key, keylen); > > if (unlikely(err)) > > goto badkey; > > > > - err = -EINVAL; > > - if (keys.enckeylen != DES3_EDE_KEY_SIZE) > > - goto badkey; > > - > > - flags = crypto_aead_get_flags(aead); > > - err = __des3_verify_key(&flags, keys.enckey); > > - if (unlikely(err)) { > > - crypto_aead_set_flags(aead, flags); > > + err = crypto_des3_ede_verify_key(crypto_aead_tfm(aead), keys.enckey, > > + keys.enckeylen); > > + if (unlikely(err)) > > goto out; > > - } > > > > err = aead_setkey(aead, key, keylen); > > > > @@ -999,8 +992,14 @@ static int skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, > > static int des3_skcipher_setkey(struct crypto_skcipher *skcipher, > > const u8 *key, unsigned int keylen) > > { > > - return unlikely(des3_verify_key(skcipher, key)) ?: > > - skcipher_setkey(skcipher, key, keylen); > > + int err; > > + > > + err = crypto_des3_ede_verify_key(crypto_skcipher_tfm(skcipher), key, > > + keylen); > > + if (unlikely(err)) > > + return err; > > + > > + return skcipher_setkey(skcipher, key, keylen); > > } > > > > static int xts_skcipher_setkey(struct crypto_skcipher *skcipher, const u8 *key, > > diff --git a/drivers/crypto/caam/compat.h b/drivers/crypto/caam/compat.h > > index 8639b2df0371..60e2a54c19f1 100644 > > --- a/drivers/crypto/caam/compat.h > > +++ b/drivers/crypto/caam/compat.h > > @@ -32,7 +32,7 @@ > > #include <crypto/null.h> > > #include <crypto/aes.h> > > #include <crypto/ctr.h> > > -#include <crypto/des.h> > > +#include <crypto/internal/des.h> > > #include <crypto/gcm.h> > > #include <crypto/sha.h> > > #include <crypto/md5.h> > > >