diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-12-05 05:08:36 -0500 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-01-10 16:16:44 -0500 |
commit | ecfc43292f68566c144afca966b46b371c26d56c (patch) | |
tree | ef332abe1573434836a90e188257a252ca9f896a /crypto/ablkcipher.c | |
parent | 927eead52c958829ef62c8aa5da2751033a2cf98 (diff) |
[CRYPTO] skcipher: Add skcipher_geniv_alloc/skcipher_geniv_free
This patch creates the infrastructure to help the construction of givcipher
templates that wrap around existing blkcipher/ablkcipher algorithms by adding
an IV generator to them.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/ablkcipher.c')
-rw-r--r-- | crypto/ablkcipher.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/ablkcipher.c b/crypto/ablkcipher.c index 8f48b4d58fca..092d9659b861 100644 --- a/crypto/ablkcipher.c +++ b/crypto/ablkcipher.c | |||
@@ -80,6 +80,7 @@ static int crypto_init_ablkcipher_ops(struct crypto_tfm *tfm, u32 type, | |||
80 | crt->setkey = setkey; | 80 | crt->setkey = setkey; |
81 | crt->encrypt = alg->encrypt; | 81 | crt->encrypt = alg->encrypt; |
82 | crt->decrypt = alg->decrypt; | 82 | crt->decrypt = alg->decrypt; |
83 | crt->base = __crypto_ablkcipher_cast(tfm); | ||
83 | crt->ivsize = alg->ivsize; | 84 | crt->ivsize = alg->ivsize; |
84 | 85 | ||
85 | return 0; | 86 | return 0; |
@@ -122,11 +123,13 @@ static int crypto_init_givcipher_ops(struct crypto_tfm *tfm, u32 type, | |||
122 | if (alg->ivsize > PAGE_SIZE / 8) | 123 | if (alg->ivsize > PAGE_SIZE / 8) |
123 | return -EINVAL; | 124 | return -EINVAL; |
124 | 125 | ||
125 | crt->setkey = setkey; | 126 | crt->setkey = tfm->__crt_alg->cra_flags & CRYPTO_ALG_GENIV ? |
127 | alg->setkey : setkey; | ||
126 | crt->encrypt = alg->encrypt; | 128 | crt->encrypt = alg->encrypt; |
127 | crt->decrypt = alg->decrypt; | 129 | crt->decrypt = alg->decrypt; |
128 | crt->givencrypt = alg->givencrypt; | 130 | crt->givencrypt = alg->givencrypt; |
129 | crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt; | 131 | crt->givdecrypt = alg->givdecrypt ?: no_givdecrypt; |
132 | crt->base = __crypto_ablkcipher_cast(tfm); | ||
130 | crt->ivsize = alg->ivsize; | 133 | crt->ivsize = alg->ivsize; |
131 | 134 | ||
132 | return 0; | 135 | return 0; |
@@ -155,6 +158,11 @@ const struct crypto_type crypto_givcipher_type = { | |||
155 | }; | 158 | }; |
156 | EXPORT_SYMBOL_GPL(crypto_givcipher_type); | 159 | EXPORT_SYMBOL_GPL(crypto_givcipher_type); |
157 | 160 | ||
161 | const char *crypto_default_geniv(const struct crypto_alg *alg) | ||
162 | { | ||
163 | return alg->cra_flags & CRYPTO_ALG_ASYNC ? "eseqiv" : "chainiv"; | ||
164 | } | ||
165 | |||
158 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, | 166 | int crypto_grab_skcipher(struct crypto_skcipher_spawn *spawn, const char *name, |
159 | u32 type, u32 mask) | 167 | u32 type, u32 mask) |
160 | { | 168 | { |