summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-07-12 01:17:32 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2016-07-18 05:35:37 -0400
commita0129733a3f5eaa973c1ea76848d905b851548f1 (patch)
tree38cc14bf68e805cf0c5a7ea2b5998961fb10f63a /crypto
parent4e6c3df4d729f85997cbf276bfa8ffd8579b8e77 (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.c38
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 @@
28static DEFINE_MUTEX(crypto_default_null_skcipher_lock); 28static DEFINE_MUTEX(crypto_default_null_skcipher_lock);
29static struct crypto_blkcipher *crypto_default_null_skcipher; 29static struct crypto_blkcipher *crypto_default_null_skcipher;
30static int crypto_default_null_skcipher_refcnt; 30static int crypto_default_null_skcipher_refcnt;
31static struct crypto_skcipher *crypto_default_null_skcipher2;
32static int crypto_default_null_skcipher2_refcnt;
31 33
32static int null_compress(struct crypto_tfm *tfm, const u8 *src, 34static 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}
189EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher); 191EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher);
190 192
193struct 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
211unlock:
212 mutex_unlock(&crypto_default_null_skcipher_lock);
213
214 return tfm;
215}
216EXPORT_SYMBOL_GPL(crypto_get_default_null_skcipher2);
217
218void 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}
227EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher2);
228
191static int __init crypto_null_mod_init(void) 229static int __init crypto_null_mod_init(void)
192{ 230{
193 int ret = 0; 231 int ret = 0;