]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[CRYPTO] api: Get rid of flags argument to setkey
authorHerbert Xu <herbert@gondor.apana.org.au>
Sun, 13 Aug 2006 04:16:39 +0000 (14:16 +1000)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 21 Sep 2006 01:41:02 +0000 (11:41 +1000)
Now that the tfm is passed directly to setkey instead of the ctx, we no
longer need to pass the &tfm->crt_flags pointer.

This patch also gets rid of a few unnecessary checks on the key length
for ciphers as the cipher layer guarantees that the key length is within
the bounds specified by the algorithm.

Rather than testing dia_setkey every time, this patch does it only once
during crypto_alloc_tfm.  The redundant check from crypto_digest_setkey
is also removed.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
24 files changed:
arch/i386/crypto/aes.c
arch/s390/crypto/aes_s390.c
arch/s390/crypto/des_s390.c
arch/x86_64/crypto/aes.c
crypto/aes.c
crypto/anubis.c
crypto/arc4.c
crypto/blowfish.c
crypto/cast5.c
crypto/cast6.c
crypto/cipher.c
crypto/crc32c.c
crypto/crypto_null.c
crypto/des.c
crypto/digest.c
crypto/khazad.c
crypto/michael_mic.c
crypto/serpent.c
crypto/tcrypt.c
crypto/tea.c
crypto/twofish_common.c
drivers/crypto/padlock-aes.c
include/crypto/twofish.h
include/linux/crypto.h

index d3806daa3de3b91c3c13c7dedc28ec451809dd67..49aad9397f10afe8facc4c13f1d3bc0fa1d7307b 100644 (file)
@@ -379,12 +379,13 @@ static void gen_tabs(void)
 }
 
 static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-                      unsigned int key_len, u32 *flags)
+                      unsigned int key_len)
 {
        int i;
        u32 ss[8];
        struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
        const __le32 *key = (const __le32 *)in_key;
+       u32 *flags = &tfm->crt_flags;
 
        /* encryption schedule */
        
index 5713c7e5bd169a52697b4d955e7daa0569d000f0..c7c43c9de0d90c0722a3dfcb02f6bf16e68e5785 100644 (file)
@@ -38,9 +38,10 @@ struct s390_aes_ctx {
 };
 
 static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-                      unsigned int key_len, u32 *flags)
+                      unsigned int key_len)
 {
        struct s390_aes_ctx *sctx = crypto_tfm_ctx(tfm);
+       u32 *flags = &tfm->crt_flags;
 
        switch (key_len) {
        case 16:
index b3f7496a79b4a3f3e10e6e6f44444e05014f0618..170757b3451daaaf9deee8d218d1b0b38912ef1e 100644 (file)
@@ -45,9 +45,10 @@ struct crypt_s390_des3_192_ctx {
 };
 
 static int des_setkey(struct crypto_tfm *tfm, const u8 *key,
-                     unsigned int keylen, u32 *flags)
+                     unsigned int keylen)
 {
        struct crypt_s390_des_ctx *dctx = crypto_tfm_ctx(tfm);
+       u32 *flags = &tfm->crt_flags;
        int ret;
 
        /* test if key is valid (not a weak key) */
@@ -167,11 +168,12 @@ static struct crypto_alg des_alg = {
  *
  */
 static int des3_128_setkey(struct crypto_tfm *tfm, const u8 *key,
-                          unsigned int keylen, u32 *flags)
+                          unsigned int keylen)
 {
        int i, ret;
        struct crypt_s390_des3_128_ctx *dctx = crypto_tfm_ctx(tfm);
-       const u8* temp_key = key;
+       const u8 *temp_key = key;
+       u32 *flags = &tfm->crt_flags;
 
        if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE))) {
                *flags |= CRYPTO_TFM_RES_BAD_KEY_SCHED;
@@ -303,11 +305,12 @@ static struct crypto_alg des3_128_alg = {
  *
  */
 static int des3_192_setkey(struct crypto_tfm *tfm, const u8 *key,
-                          unsigned int keylen, u32 *flags)
+                          unsigned int keylen)
 {
        int i, ret;
        struct crypt_s390_des3_192_ctx *dctx = crypto_tfm_ctx(tfm);
-       const u8* temp_key = key;
+       const u8 *temp_key = key;
+       u32 *flags = &tfm->crt_flags;
 
        if (!(memcmp(key, &key[DES_KEY_SIZE], DES_KEY_SIZE) &&
            memcmp(&key[DES_KEY_SIZE], &key[DES_KEY_SIZE * 2],
index 68866fab37aa15804a76065286e87cb55da85804..5cdb13ea5cc2d3d9126ebf4c93f4dfb96a7d21e0 100644 (file)
@@ -228,13 +228,14 @@ static void __init gen_tabs(void)
 }
 
 static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-                      unsigned int key_len, u32 *flags)
+                      unsigned int key_len)
 {
        struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
        const __le32 *key = (const __le32 *)in_key;
+       u32 *flags = &tfm->crt_flags;
        u32 i, j, t, u, v, w;
 
-       if (key_len != 16 && key_len != 24 && key_len != 32) {
+       if (key_len % 8) {
                *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL;
        }
index a038711831e75832cff73a0700f90f0fcd94c953..e2440773878cc960ff5b22b5240fd735a048e8f8 100644 (file)
@@ -249,13 +249,14 @@ gen_tabs (void)
 }
 
 static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-                      unsigned int key_len, u32 *flags)
+                      unsigned int key_len)
 {
        struct aes_ctx *ctx = crypto_tfm_ctx(tfm);
        const __le32 *key = (const __le32 *)in_key;
+       u32 *flags = &tfm->crt_flags;
        u32 i, t, u, v, w;
 
-       if (key_len != 16 && key_len != 24 && key_len != 32) {
+       if (key_len % 8) {
                *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL;
        }
index 7e2e1a29800e372e618d3592802e6294a76dade5..1c771f7f4dc5ee355d2f6d84ac6c76a547591fd8 100644 (file)
@@ -461,10 +461,11 @@ static const u32 rc[] = {
 };
 
 static int anubis_setkey(struct crypto_tfm *tfm, const u8 *in_key,
-                        unsigned int key_len, u32 *flags)
+                        unsigned int key_len)
 {
        struct anubis_ctx *ctx = crypto_tfm_ctx(tfm);
        const __be32 *key = (const __be32 *)in_key;
+       u32 *flags = &tfm->crt_flags;
        int N, R, i, r;
        u32 kappa[ANUBIS_MAX_N];
        u32 inter[ANUBIS_MAX_N];
index 5edc6a65b987a01fb1ab89b71a363afd49f8fac2..8be47e13a9e3327abc49712a48495652c4d294e6 100644 (file)
@@ -25,7 +25,7 @@ struct arc4_ctx {
 };
 
 static int arc4_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-                       unsigned int key_len, u32 *flags)
+                       unsigned int key_len)
 {
        struct arc4_ctx *ctx = crypto_tfm_ctx(tfm);
        int i, j = 0, k = 0;
index 490265f42b3ba91213e5deb5cb53f8a3c6d1e19e..55238c4e37f039c59872d5b049707a41cebc5160 100644 (file)
@@ -399,8 +399,7 @@ static void bf_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 /* 
  * Calculates the blowfish S and P boxes for encryption and decryption.
  */
-static int bf_setkey(struct crypto_tfm *tfm, const u8 *key,
-                    unsigned int keylen, u32 *flags)
+static int bf_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
 {
        struct bf_ctx *ctx = crypto_tfm_ctx(tfm);
        u32 *P = ctx->p;
index 08eef58c1d3dd2328cc8819537f37df06f202cfc..13ea60abc19ab6181963dc90dcc6b7a9bef6992b 100644 (file)
@@ -769,8 +769,7 @@ static void key_schedule(u32 * x, u32 * z, u32 * k)
 }
 
 
-static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key,
-                       unsigned key_len, u32 *flags)
+static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned key_len)
 {
        struct cast5_ctx *c = crypto_tfm_ctx(tfm);
        int i;
@@ -778,11 +777,6 @@ static int cast5_setkey(struct crypto_tfm *tfm, const u8 *key,
        u32 z[4];
        u32 k[16];
        __be32 p_key[4];
-       
-       if (key_len < 5 || key_len > 16) {
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       }
 
        c->rr = key_len <= 10 ? 1 : 0;
 
index 08e33bfc3ad1098233599e5c65d011c7becc3407..136ab6dfe8c5661a2f0c6190267cdf2459d37b0e 100644 (file)
@@ -382,14 +382,15 @@ static inline void W(u32 *key, unsigned int i) {
 }
 
 static int cast6_setkey(struct crypto_tfm *tfm, const u8 *in_key,
-                       unsigned key_len, u32 *flags)
+                       unsigned key_len)
 {
        int i;
        u32 key[8];
        __be32 p_key[8]; /* padded key */
        struct cast6_ctx *c = crypto_tfm_ctx(tfm);
+       u32 *flags = &tfm->crt_flags;
 
-       if (key_len < 16 || key_len > 32 || key_len % 4 != 0) {
+       if (key_len % 4 != 0) {
                *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL;
        }       
index b899eb97abd7ceac0bc752418954b66bfc0ea6e6..56406a4a88d4dd3d310bcd196245732a60d5e87d 100644 (file)
@@ -264,12 +264,12 @@ static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
 {
        struct cipher_alg *cia = &tfm->__crt_alg->cra_cipher;
        
+       tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK;
        if (keylen < cia->cia_min_keysize || keylen > cia->cia_max_keysize) {
                tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL;
        } else
-               return cia->cia_setkey(tfm, key, keylen,
-                                      &tfm->crt_flags);
+               return cia->cia_setkey(tfm, key, keylen);
 }
 
 static int ecb_encrypt(struct crypto_tfm *tfm,
index 91ecd895e957af3be5bb41993a97d2d4ac698d23..0fa744392a4c35fe12d08cd1e46fabcc5c560eb9 100644 (file)
@@ -44,13 +44,12 @@ static void chksum_init(struct crypto_tfm *tfm)
  * the seed.
  */
 static int chksum_setkey(struct crypto_tfm *tfm, const u8 *key,
-                        unsigned int keylen, u32 *flags)
+                        unsigned int keylen)
 {
        struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
 
        if (keylen != sizeof(mctx->crc)) {
-               if (flags)
-                       *flags = CRYPTO_TFM_RES_BAD_KEY_LEN;
+               tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL;
        }
        mctx->key = le32_to_cpu(*(__le32 *)key);
index a0d956b529498c84ea39f2888e63878d143adc6c..24dbb5d8617e03584bc7dd4938b06ea2736488b2 100644 (file)
@@ -48,7 +48,7 @@ static void null_final(struct crypto_tfm *tfm, u8 *out)
 { }
 
 static int null_setkey(struct crypto_tfm *tfm, const u8 *key,
-                      unsigned int keylen, u32 *flags)
+                      unsigned int keylen)
 { return 0; }
 
 static void null_crypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
index a9d3c235a6af969447848e3832d018f055f8a262..1df3a714fa47fa5e0b3362281556b0b14a94ed99 100644 (file)
@@ -784,9 +784,10 @@ static void dkey(u32 *pe, const u8 *k)
 }
 
 static int des_setkey(struct crypto_tfm *tfm, const u8 *key,
-                     unsigned int keylen, u32 *flags)
+                     unsigned int keylen)
 {
        struct des_ctx *dctx = crypto_tfm_ctx(tfm);
+       u32 *flags = &tfm->crt_flags;
        u32 tmp[DES_EXPKEY_WORDS];
        int ret;
 
@@ -864,11 +865,12 @@ static void des_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
  *
  */
 static int des3_ede_setkey(struct crypto_tfm *tfm, const u8 *key,
-                          unsigned int keylen, u32 *flags)
+                          unsigned int keylen)
 {
        const u32 *K = (const u32 *)key;
        struct des3_ede_ctx *dctx = crypto_tfm_ctx(tfm);
        u32 *expkey = dctx->expkey;
+       u32 *flags = &tfm->crt_flags;
 
        if (unlikely(!((K[0] ^ K[2]) | (K[1] ^ K[3])) ||
                     !((K[2] ^ K[4]) | (K[3] ^ K[5]))))
index 603006a7bef2abad1452b1336337065eb166fef2..0df7f392a56a8ee6274df177d2c1c277650cf0a8 100644 (file)
@@ -76,12 +76,16 @@ static void final(struct crypto_tfm *tfm, u8 *out)
                tfm->__crt_alg->cra_digest.dia_final(tfm, out);
 }
 
+static int nosetkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
+{
+       tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK;
+       return -ENOSYS;
+}
+
 static int setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen)
 {
-       u32 flags;
-       if (tfm->__crt_alg->cra_digest.dia_setkey == NULL)
-               return -ENOSYS;
-       return tfm->__crt_alg->cra_digest.dia_setkey(tfm, key, keylen, &flags);
+       tfm->crt_flags &= ~CRYPTO_TFM_RES_MASK;
+       return tfm->__crt_alg->cra_digest.dia_setkey(tfm, key, keylen);
 }
 
 static void digest(struct crypto_tfm *tfm,
@@ -100,12 +104,13 @@ int crypto_init_digest_flags(struct crypto_tfm *tfm, u32 flags)
 int crypto_init_digest_ops(struct crypto_tfm *tfm)
 {
        struct digest_tfm *ops = &tfm->crt_digest;
+       struct digest_alg *dalg = &tfm->__crt_alg->cra_digest;
        
        ops->dit_init   = init;
        ops->dit_update = update;
        ops->dit_final  = final;
        ops->dit_digest = digest;
-       ops->dit_setkey = setkey;
+       ops->dit_setkey = dalg->dia_setkey ? setkey : nosetkey;
        
        return crypto_alloc_hmac_block(tfm);
 }
index d4c9d3657b36fd29b53c88e091aac995bd975729..9fa24a2dd6ffbee4e9c7aff2d06b6f3b51cf8388 100644 (file)
@@ -755,19 +755,13 @@ static const u64 c[KHAZAD_ROUNDS + 1] = {
 };
 
 static int khazad_setkey(struct crypto_tfm *tfm, const u8 *in_key,
-                        unsigned int key_len, u32 *flags)
+                        unsigned int key_len)
 {
        struct khazad_ctx *ctx = crypto_tfm_ctx(tfm);
        const __be32 *key = (const __be32 *)in_key;
        int r;
        const u64 *S = T7;
        u64 K2, K1;
-       
-       if (key_len != 16)
-       {
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       }
 
        /* key is supposed to be 32-bit aligned */
        K2 = ((u64)be32_to_cpu(key[0]) << 32) | be32_to_cpu(key[1]);
index d061da21cfda03b3149ed54fbf7e82429a669d2d..094397b4884968b5e90ee4d8f99fe16395aae178 100644 (file)
@@ -123,14 +123,13 @@ static void michael_final(struct crypto_tfm *tfm, u8 *out)
 
 
 static int michael_setkey(struct crypto_tfm *tfm, const u8 *key,
-                         unsigned int keylen, u32 *flags)
+                         unsigned int keylen)
 {
        struct michael_mic_ctx *mctx = crypto_tfm_ctx(tfm);
        const __le32 *data = (const __le32 *)key;
 
        if (keylen != 8) {
-               if (flags)
-                       *flags = CRYPTO_TFM_RES_BAD_KEY_LEN;
+               tfm->crt_flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL;
        }
 
index de60cdddbf4a162f9a7b19f99e547c7c2081fd17..465d091cd3ec3439fe65f0e91d48adc23151667e 100644 (file)
@@ -216,7 +216,7 @@ struct serpent_ctx {
 
 
 static int serpent_setkey(struct crypto_tfm *tfm, const u8 *key,
-                         unsigned int keylen, u32 *flags)
+                         unsigned int keylen)
 {
        struct serpent_ctx *ctx = crypto_tfm_ctx(tfm);
        u32 *k = ctx->expkey;
@@ -224,13 +224,6 @@ static int serpent_setkey(struct crypto_tfm *tfm, const u8 *key,
        u32 r0,r1,r2,r3,r4;
        int i;
 
-       if ((keylen < SERPENT_MIN_KEY_SIZE)
-                       || (keylen > SERPENT_MAX_KEY_SIZE))
-       {
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       }
-
        /* Copy key, add padding */
 
        for (i = 0; i < keylen; ++i)
@@ -497,21 +490,15 @@ static struct crypto_alg serpent_alg = {
 };
 
 static int tnepres_setkey(struct crypto_tfm *tfm, const u8 *key,
-                         unsigned int keylen, u32 *flags)
+                         unsigned int keylen)
 {
        u8 rev_key[SERPENT_MAX_KEY_SIZE];
        int i;
 
-       if ((keylen < SERPENT_MIN_KEY_SIZE)
-           || (keylen > SERPENT_MAX_KEY_SIZE)) {
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       } 
-
        for (i = 0; i < keylen; ++i)
                rev_key[keylen - i - 1] = key[i];
  
-       return serpent_setkey(tfm, rev_key, keylen, flags);
+       return serpent_setkey(tfm, rev_key, keylen);
 }
 
 static void tnepres_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
index bed225e83231642ac22408f575e137d27677a955..60677707467174c75de8cffd09ecd7149b8d9802 100644 (file)
@@ -118,10 +118,7 @@ static void test_hash(char *algo, struct hash_testvec *template,
                sg_set_buf(&sg[0], hash_tv[i].plaintext, hash_tv[i].psize);
 
                crypto_digest_init(tfm);
-               if (tfm->crt_u.digest.dit_setkey) {
-                       crypto_digest_setkey(tfm, hash_tv[i].key,
-                                            hash_tv[i].ksize);
-               }
+               crypto_digest_setkey(tfm, hash_tv[i].key, hash_tv[i].ksize);
                crypto_digest_update(tfm, sg, 1);
                crypto_digest_final(tfm, result);
 
index 5367adc82fc9d9cc93827496bbe8628195072033..1c54e26fa529342d6ee893b7636233f9c317f3ba 100644 (file)
@@ -46,16 +46,10 @@ struct xtea_ctx {
 };
 
 static int tea_setkey(struct crypto_tfm *tfm, const u8 *in_key,
-                     unsigned int key_len, u32 *flags)
+                     unsigned int key_len)
 {
        struct tea_ctx *ctx = crypto_tfm_ctx(tfm);
        const __le32 *key = (const __le32 *)in_key;
-       
-       if (key_len != 16)
-       {
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       }
 
        ctx->KEY[0] = le32_to_cpu(key[0]);
        ctx->KEY[1] = le32_to_cpu(key[1]);
@@ -125,16 +119,10 @@ static void tea_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
 }
 
 static int xtea_setkey(struct crypto_tfm *tfm, const u8 *in_key,
-                      unsigned int key_len, u32 *flags)
+                      unsigned int key_len)
 {
        struct xtea_ctx *ctx = crypto_tfm_ctx(tfm);
        const __le32 *key = (const __le32 *)in_key;
-       
-       if (key_len != 16)
-       {
-               *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
-               return -EINVAL;
-       }
 
        ctx->KEY[0] = le32_to_cpu(key[0]);
        ctx->KEY[1] = le32_to_cpu(key[1]);
index 1ae0280c25135700f9d44ce8db8ee6dc66be46ef..b4b9c0c3f4ae74852a3a0fa1c71d59a17c6fbc90 100644 (file)
@@ -580,11 +580,11 @@ static const u8 calc_sb_tbl[512] = {
    ctx->a[(j) + 1] = rol32(y, 9)
 
 /* Perform the key setup. */
-int twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
-                  unsigned int key_len, u32 *flags)
+int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len)
 {
 
        struct twofish_ctx *ctx = crypto_tfm_ctx(tfm);
+       u32 *flags = &tfm->crt_flags;
 
        int i, j, k;
 
@@ -600,7 +600,7 @@ int twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
        u8 tmp;
 
        /* Check key length. */
-       if (key_len != 16 && key_len != 24 && key_len != 32)
+       if (key_len % 8)
        {
                *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL; /* unsupported key length */
index 3a2a71108d352e039e5c82f94bef9e9a33d01dc2..3e683709243e4439fd7cc388f2d37dd5db108d27 100644 (file)
@@ -308,15 +308,16 @@ static inline struct aes_ctx *aes_ctx(struct crypto_tfm *tfm)
 }
 
 static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key,
-                      unsigned int key_len, u32 *flags)
+                      unsigned int key_len)
 {
        struct aes_ctx *ctx = aes_ctx(tfm);
        const __le32 *key = (const __le32 *)in_key;
+       u32 *flags = &tfm->crt_flags;
        uint32_t i, t, u, v, w;
        uint32_t P[AES_EXTENDED_KEY_SIZE];
        uint32_t rounds;
 
-       if (key_len != 16 && key_len != 24 && key_len != 32) {
+       if (key_len % 8) {
                *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN;
                return -EINVAL;
        }
index e4328cfaaf64974c413b7674625ba144d8f5f6eb..c408522595c6855ff517e966ea16bf4c9cff19ac 100644 (file)
@@ -17,7 +17,6 @@ struct twofish_ctx {
        u32 s[4][256], w[8], k[32];
 };
 
-int twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
-                  unsigned int key_len, u32 *flags);
+int twofish_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int key_len);
 
 #endif
index d6e184c876b502b79ad80c8317a95bee73a00a3f..053bfab43e8d960a9b596826bed498ce3e1caf69 100644 (file)
@@ -106,7 +106,7 @@ struct cipher_alg {
        unsigned int cia_min_keysize;
        unsigned int cia_max_keysize;
        int (*cia_setkey)(struct crypto_tfm *tfm, const u8 *key,
-                         unsigned int keylen, u32 *flags);
+                         unsigned int keylen);
        void (*cia_encrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
        void (*cia_decrypt)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
 
@@ -131,7 +131,7 @@ struct digest_alg {
                           unsigned int len);
        void (*dia_final)(struct crypto_tfm *tfm, u8 *out);
        int (*dia_setkey)(struct crypto_tfm *tfm, const u8 *key,
-                         unsigned int keylen, u32 *flags);
+                         unsigned int keylen);
 };
 
 struct compress_alg {
@@ -397,8 +397,6 @@ static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
                                        const u8 *key, unsigned int keylen)
 {
        BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
-       if (tfm->crt_digest.dit_setkey == NULL)
-               return -ENOSYS;
        return tfm->crt_digest.dit_setkey(tfm, key, keylen);
 }