static void skcipher_set_needkey(struct crypto_skcipher *tfm)
 {
-       if (tfm->keysize)
+       if (crypto_skcipher_max_keysize(tfm) != 0)
                crypto_skcipher_set_flags(tfm, CRYPTO_TFM_NEED_KEY);
 }
 
        skcipher->setkey = skcipher_setkey;
        skcipher->encrypt = alg->encrypt;
        skcipher->decrypt = alg->decrypt;
-       skcipher->keysize = alg->max_keysize;
 
        skcipher_set_needkey(skcipher);
 
 
                                           char *name, size_t max_namelen)
 {
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
-       const unsigned int maxkeysize = tfm->keysize;
+       const unsigned int maxkeysize = crypto_skcipher_max_keysize(tfm);
        const unsigned int ivsize = crypto_skcipher_ivsize(tfm);
        struct scatterlist src, dst;
        u8 iv[MAX_IVLEN];
                                         struct cipher_test_sglists *tsgls)
 {
        struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
+       const unsigned int maxkeysize = crypto_skcipher_max_keysize(tfm);
        const unsigned int ivsize = crypto_skcipher_ivsize(tfm);
        const unsigned int blocksize = crypto_skcipher_blocksize(tfm);
        const unsigned int maxdatasize = (2 * PAGE_SIZE) - TESTMGR_POISON_LEN;
 
        /* Check the algorithm properties for consistency. */
 
-       if (tfm->keysize != generic_tfm->keysize) {
+       if (maxkeysize != crypto_skcipher_max_keysize(generic_tfm)) {
                pr_err("alg: skcipher: max keysize for %s (%u) doesn't match generic impl (%u)\n",
-                      driver, tfm->keysize, generic_tfm->keysize);
+                      driver, maxkeysize,
+                      crypto_skcipher_max_keysize(generic_tfm));
                err = -EINVAL;
                goto out;
        }
         * the other implementation against them.
         */
 
-       vec.key = kmalloc(tfm->keysize, GFP_KERNEL);
+       vec.key = kmalloc(maxkeysize, GFP_KERNEL);
        vec.iv = kmalloc(ivsize, GFP_KERNEL);
        vec.ptext = kmalloc(maxdatasize, GFP_KERNEL);
        vec.ctext = kmalloc(maxdatasize, GFP_KERNEL);
 
        }
        crypto_skcipher_set_flags(*key_tfm, CRYPTO_TFM_REQ_FORBID_WEAK_KEYS);
        if (*key_size == 0)
-               *key_size = crypto_skcipher_default_keysize(*key_tfm);
+               *key_size = crypto_skcipher_max_keysize(*key_tfm);
        get_random_bytes(dummy_key, *key_size);
        rc = crypto_skcipher_setkey(*key_tfm, dummy_key, *key_size);
        if (rc) {
 
        if (mount_crypt_stat->global_default_cipher_key_size == 0) {
                printk(KERN_WARNING "No key size specified at mount; "
                       "defaulting to [%d]\n",
-                      crypto_skcipher_default_keysize(tfm));
+                      crypto_skcipher_max_keysize(tfm));
                mount_crypt_stat->global_default_cipher_key_size =
-                       crypto_skcipher_default_keysize(tfm);
+                       crypto_skcipher_max_keysize(tfm);
        }
        if (crypt_stat->key_size == 0)
                crypt_stat->key_size =
 
        int (*decrypt)(struct skcipher_request *req);
 
        unsigned int reqsize;
-       unsigned int keysize;
 
        struct crypto_tfm base;
 };
        return crypto_skcipher_setkey(&tfm->base, key, keylen);
 }
 
-static inline unsigned int crypto_skcipher_default_keysize(
+static inline unsigned int crypto_skcipher_max_keysize(
        struct crypto_skcipher *tfm)
 {
-       return tfm->keysize;
+       return crypto_skcipher_alg(tfm)->max_keysize;
 }
 
 /**