summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-07-12 13:17:32 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2016-07-18 17:35:37 +0800
commita0129733a3f5eaa973c1ea76848d905b851548f1 (patch)
tree38cc14bf68e805cf0c5a7ea2b5998961fb10f63a /crypto
parent4e6c3df4d729f85997cbf276bfa8ffd8579b8e77 (diff)
downloadlinux-a0129733a3f5eaa973c1ea76848d905b851548f1.tar.bz2
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 @@
static DEFINE_MUTEX(crypto_default_null_skcipher_lock);
static struct crypto_blkcipher *crypto_default_null_skcipher;
static int crypto_default_null_skcipher_refcnt;
+static struct crypto_skcipher *crypto_default_null_skcipher2;
+static int crypto_default_null_skcipher2_refcnt;
static int null_compress(struct crypto_tfm *tfm, const u8 *src,
unsigned int slen, u8 *dst, unsigned int *dlen)
@@ -188,6 +190,42 @@ void crypto_put_default_null_skcipher(void)
}
EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher);
+struct crypto_skcipher *crypto_get_default_null_skcipher2(void)
+{
+ struct crypto_skcipher *tfm;
+
+ mutex_lock(&crypto_default_null_skcipher_lock);
+ tfm = crypto_default_null_skcipher2;
+
+ if (!tfm) {
+ tfm = crypto_alloc_skcipher("ecb(cipher_null)",
+ 0, CRYPTO_ALG_ASYNC);
+ if (IS_ERR(tfm))
+ goto unlock;
+
+ crypto_default_null_skcipher2 = tfm;
+ }
+
+ crypto_default_null_skcipher2_refcnt++;
+
+unlock:
+ mutex_unlock(&crypto_default_null_skcipher_lock);
+
+ return tfm;
+}
+EXPORT_SYMBOL_GPL(crypto_get_default_null_skcipher2);
+
+void crypto_put_default_null_skcipher2(void)
+{
+ mutex_lock(&crypto_default_null_skcipher_lock);
+ if (!--crypto_default_null_skcipher2_refcnt) {
+ crypto_free_skcipher(crypto_default_null_skcipher2);
+ crypto_default_null_skcipher2 = NULL;
+ }
+ mutex_unlock(&crypto_default_null_skcipher_lock);
+}
+EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher2);
+
static int __init crypto_null_mod_init(void)
{
int ret = 0;