drm/amd/display: Add NULL test for 'timing generator' in 'dcn21_set_pipe()'
[platform/kernel/linux-starfive.git] / crypto / cipher.c
index b47141e..47c77a3 100644 (file)
@@ -90,3 +90,31 @@ void crypto_cipher_decrypt_one(struct crypto_cipher *tfm,
        cipher_crypt_one(tfm, dst, src, false);
 }
 EXPORT_SYMBOL_NS_GPL(crypto_cipher_decrypt_one, CRYPTO_INTERNAL);
+
+struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher)
+{
+       struct crypto_tfm *tfm = crypto_cipher_tfm(cipher);
+       struct crypto_alg *alg = tfm->__crt_alg;
+       struct crypto_cipher *ncipher;
+       struct crypto_tfm *ntfm;
+
+       if (alg->cra_init)
+               return ERR_PTR(-ENOSYS);
+
+       if (unlikely(!crypto_mod_get(alg)))
+               return ERR_PTR(-ESTALE);
+
+       ntfm = __crypto_alloc_tfmgfp(alg, CRYPTO_ALG_TYPE_CIPHER,
+                                    CRYPTO_ALG_TYPE_MASK, GFP_ATOMIC);
+       if (IS_ERR(ntfm)) {
+               crypto_mod_put(alg);
+               return ERR_CAST(ntfm);
+       }
+
+       ntfm->crt_flags = tfm->crt_flags;
+
+       ncipher = __crypto_cipher_cast(ntfm);
+
+       return ncipher;
+}
+EXPORT_SYMBOL_GPL(crypto_clone_cipher);