aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto_null.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/crypto_null.c')
-rw-r--r--crypto/crypto_null.c49
1 files changed, 6 insertions, 43 deletions
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c
index c3f683910d07..20ff2c746e0b 100644
--- a/crypto/crypto_null.c
+++ b/crypto/crypto_null.c
@@ -26,10 +26,8 @@
26#include <linux/string.h> 26#include <linux/string.h>
27 27
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_skcipher *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;
33 31
34static int null_compress(struct crypto_tfm *tfm, const u8 *src, 32static int null_compress(struct crypto_tfm *tfm, const u8 *src,
35 unsigned int slen, u8 *dst, unsigned int *dlen) 33 unsigned int slen, u8 *dst, unsigned int *dlen)
@@ -155,15 +153,16 @@ MODULE_ALIAS_CRYPTO("compress_null");
155MODULE_ALIAS_CRYPTO("digest_null"); 153MODULE_ALIAS_CRYPTO("digest_null");
156MODULE_ALIAS_CRYPTO("cipher_null"); 154MODULE_ALIAS_CRYPTO("cipher_null");
157 155
158struct crypto_blkcipher *crypto_get_default_null_skcipher(void) 156struct crypto_skcipher *crypto_get_default_null_skcipher(void)
159{ 157{
160 struct crypto_blkcipher *tfm; 158 struct crypto_skcipher *tfm;
161 159
162 mutex_lock(&crypto_default_null_skcipher_lock); 160 mutex_lock(&crypto_default_null_skcipher_lock);
163 tfm = crypto_default_null_skcipher; 161 tfm = crypto_default_null_skcipher;
164 162
165 if (!tfm) { 163 if (!tfm) {
166 tfm = crypto_alloc_blkcipher("ecb(cipher_null)", 0, 0); 164 tfm = crypto_alloc_skcipher("ecb(cipher_null)",
165 0, CRYPTO_ALG_ASYNC);
167 if (IS_ERR(tfm)) 166 if (IS_ERR(tfm))
168 goto unlock; 167 goto unlock;
169 168
@@ -183,49 +182,13 @@ void crypto_put_default_null_skcipher(void)
183{ 182{
184 mutex_lock(&crypto_default_null_skcipher_lock); 183 mutex_lock(&crypto_default_null_skcipher_lock);
185 if (!--crypto_default_null_skcipher_refcnt) { 184 if (!--crypto_default_null_skcipher_refcnt) {
186 crypto_free_blkcipher(crypto_default_null_skcipher); 185 crypto_free_skcipher(crypto_default_null_skcipher);
187 crypto_default_null_skcipher = NULL; 186 crypto_default_null_skcipher = NULL;
188 } 187 }
189 mutex_unlock(&crypto_default_null_skcipher_lock); 188 mutex_unlock(&crypto_default_null_skcipher_lock);
190} 189}
191EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher); 190EXPORT_SYMBOL_GPL(crypto_put_default_null_skcipher);
192 191
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
229static int __init crypto_null_mod_init(void) 192static int __init crypto_null_mod_init(void)
230{ 193{
231 int ret = 0; 194 int ret = 0;