Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: cipher - Add crypto_clone_cipher

Allow simple ciphers to be cloned, if they don't have a cra_init
function. This basically rules out those ciphers that require a
fallback.

In future simple ciphers will be eliminated, and replaced with a
linear skcipher interface. When that happens this restriction will
disappear.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+25
+23
crypto/cipher.c
··· 90 90 cipher_crypt_one(tfm, dst, src, false); 91 91 } 92 92 EXPORT_SYMBOL_NS_GPL(crypto_cipher_decrypt_one, CRYPTO_INTERNAL); 93 + 94 + struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher) 95 + { 96 + struct crypto_tfm *tfm = crypto_cipher_tfm(cipher); 97 + struct crypto_alg *alg = tfm->__crt_alg; 98 + struct crypto_cipher *ncipher; 99 + struct crypto_tfm *ntfm; 100 + 101 + if (alg->cra_init) 102 + return ERR_PTR(-ENOSYS); 103 + 104 + ntfm = __crypto_alloc_tfm(alg, CRYPTO_ALG_TYPE_CIPHER, 105 + CRYPTO_ALG_TYPE_MASK); 106 + if (IS_ERR(ntfm)) 107 + return ERR_CAST(ntfm); 108 + 109 + ntfm->crt_flags = tfm->crt_flags; 110 + 111 + ncipher = __crypto_cipher_cast(ntfm); 112 + 113 + return ncipher; 114 + } 115 + EXPORT_SYMBOL_GPL(crypto_clone_cipher);
+2
include/crypto/internal/cipher.h
··· 176 176 void crypto_cipher_decrypt_one(struct crypto_cipher *tfm, 177 177 u8 *dst, const u8 *src); 178 178 179 + struct crypto_cipher *crypto_clone_cipher(struct crypto_cipher *cipher); 180 + 179 181 struct crypto_cipher_spawn { 180 182 struct crypto_spawn base; 181 183 };