diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-07-12 01:17:32 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-07-18 05:35:37 -0400 |
commit | a0129733a3f5eaa973c1ea76848d905b851548f1 (patch) | |
tree | 38cc14bf68e805cf0c5a7ea2b5998961fb10f63a /crypto | |
parent | 4e6c3df4d729f85997cbf276bfa8ffd8579b8e77 (diff) |
crypto: null - Add new default null skcipher
Current the default null skcipher is actually a crypto_blkcipher.
This patch creates a synchronous crypto_skcipher version of the
null cipher which unfortunately has to settle for the name skcipher2.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/crypto_null.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c index 941c9a434d50..c3f683910d07 100644 --- a/crypto/crypto_null.c +++ b/crypto/crypto_null.c | |||
@@ -28,6 +28,8 @@ | |||
28 | static DEFINE_MUTEX(crypto_default_null_skcipher_lock); | 28 | static DEFINE_MUTEX(crypto_default_null_skcipher_lock); |
29 | static struct crypto_blkcipher *crypto_default_null_skcipher; | 29 | static struct crypto_blkcipher *crypto_default_null_skcipher; |
30 | static int crypto_default_null_skcipher_refcnt; | 30 | static int crypto_default_null_skcipher_refcnt; |
31 | static struct crypto_skcipher *crypto_default_null_skcipher2; | ||
32 | static int crypto_default_null_skcipher2_refcnt; | ||
31 | 33 | ||
32 | static int null_compress(struct crypto_tfm *tfm, const u8 *src, | 34 | static int null_compress(struct crypto_tfm *tfm, const u8 *src, |
33 | unsigned int slen, u8 *dst, unsigned int *dlen) | 35 | unsigned int slen, u8 *dst, unsigned int *dlen) |
@@ -188,6 +190,42 @@ void crypto_put_default_null_skcipher(void) | |||
188 | } | 190 | } |
189 | EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher); | 191 | EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher); |
190 | 192 | ||
193 | struct crypto_skcipher *crypto_get_default_null_skcipher2(void) | ||
194 | { | ||
195 | struct crypto_skcipher *tfm; | ||
196 | |||
197 | mutex_lock(&crypto_default_null_skcipher_lock); | ||
198 | tfm = crypto_default_null_skcipher2; | ||
199 | |||
200 | if (!tfm) { | ||
201 | tfm = crypto_alloc_skcipher("ecb(cipher_null)", | ||
202 | 0, CRYPTO_ALG_ASYNC); | ||
203 | if (IS_ERR(tfm)) | ||
204 | goto unlock; | ||
205 | |||
206 | crypto_default_null_skcipher2 = tfm; | ||
207 | } | ||
208 | |||
209 | crypto_default_null_skcipher2_refcnt++; | ||
210 | |||
211 | unlock: | ||
212 | mutex_unlock(&crypto_default_null_skcipher_lock); | ||
213 | |||
214 | return tfm; | ||
215 | } | ||
216 | EXPORT_SYMBOL_GPL(crypto_get_default_null_skcipher2); | ||
217 | |||
218 | void crypto_put_default_null_skcipher2(void) | ||
219 | { | ||
220 | mutex_lock(&crypto_default_null_skcipher_lock); | ||
221 | if (!--crypto_default_null_skcipher2_refcnt) { | ||
222 | crypto_free_skcipher(crypto_default_null_skcipher2); | ||
223 | crypto_default_null_skcipher2 = NULL; | ||
224 | } | ||
225 | mutex_unlock(&crypto_default_null_skcipher_lock); | ||
226 | } | ||
227 | EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher2); | ||
228 | |||
191 | static int __init crypto_null_mod_init(void) | 229 | static int __init crypto_null_mod_init(void) |
192 | { | 230 | { |
193 | int ret = 0; | 231 | int ret = 0; |