aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/Kconfig1
-rw-r--r--crypto/crypto_null.c64
2 files changed, 42 insertions, 23 deletions
diff --git a/crypto/Kconfig b/crypto/Kconfig
index aede80246df2..359a7c24af38 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -102,6 +102,7 @@ config CRYPTO_NULL
102 tristate "Null algorithms" 102 tristate "Null algorithms"
103 select CRYPTO_ALGAPI 103 select CRYPTO_ALGAPI
104 select CRYPTO_BLKCIPHER 104 select CRYPTO_BLKCIPHER
105 select CRYPTO_HASH
105 help 106 help
106 These are 'Null' algorithms, used by IPsec, which do nothing. 107 These are 'Null' algorithms, used by IPsec, which do nothing.
107 108
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c
index 1f7d53013a22..cb71c9122bc0 100644
--- a/crypto/crypto_null.c
+++ b/crypto/crypto_null.c
@@ -17,6 +17,7 @@
17 * 17 *
18 */ 18 */
19 19
20#include <crypto/internal/hash.h>
20#include <crypto/internal/skcipher.h> 21#include <crypto/internal/skcipher.h>
21#include <linux/init.h> 22#include <linux/init.h>
22#include <linux/module.h> 23#include <linux/module.h>
@@ -38,15 +39,31 @@ static int null_compress(struct crypto_tfm *tfm, const u8 *src,
38 return 0; 39 return 0;
39} 40}
40 41
41static void null_init(struct crypto_tfm *tfm) 42static int null_init(struct shash_desc *desc)
42{ } 43{
44 return 0;
45}
43 46
44static void null_update(struct crypto_tfm *tfm, const u8 *data, 47static int null_update(struct shash_desc *desc, const u8 *data,
45 unsigned int len) 48 unsigned int len)
46{ } 49{
50 return 0;
51}
47 52
48static void null_final(struct crypto_tfm *tfm, u8 *out) 53static int null_final(struct shash_desc *desc, u8 *out)
49{ } 54{
55 return 0;
56}
57
58static int null_digest(struct shash_desc *desc, const u8 *data,
59 unsigned int len, u8 *out)
60{
61 return 0;
62}
63
64static int null_hash_setkey(struct crypto_shash *tfm, const u8 *key,
65 unsigned int keylen)
66{ return 0; }
50 67
51static int null_setkey(struct crypto_tfm *tfm, const u8 *key, 68static int null_setkey(struct crypto_tfm *tfm, const u8 *key,
52 unsigned int keylen) 69 unsigned int keylen)
@@ -89,19 +106,20 @@ static struct crypto_alg compress_null = {
89 .coa_decompress = null_compress } } 106 .coa_decompress = null_compress } }
90}; 107};
91 108
92static struct crypto_alg digest_null = { 109static struct shash_alg digest_null = {
93 .cra_name = "digest_null", 110 .digestsize = NULL_DIGEST_SIZE,
94 .cra_flags = CRYPTO_ALG_TYPE_DIGEST, 111 .setkey = null_hash_setkey,
95 .cra_blocksize = NULL_BLOCK_SIZE, 112 .init = null_init,
96 .cra_ctxsize = 0, 113 .update = null_update,
97 .cra_module = THIS_MODULE, 114 .finup = null_digest,
98 .cra_list = LIST_HEAD_INIT(digest_null.cra_list), 115 .digest = null_digest,
99 .cra_u = { .digest = { 116 .final = null_final,
100 .dia_digestsize = NULL_DIGEST_SIZE, 117 .base = {
101 .dia_setkey = null_setkey, 118 .cra_name = "digest_null",
102 .dia_init = null_init, 119 .cra_flags = CRYPTO_ALG_TYPE_SHASH,
103 .dia_update = null_update, 120 .cra_blocksize = NULL_BLOCK_SIZE,
104 .dia_final = null_final } } 121 .cra_module = THIS_MODULE,
122 }
105}; 123};
106 124
107static struct crypto_alg cipher_null = { 125static struct crypto_alg cipher_null = {
@@ -154,7 +172,7 @@ static int __init crypto_null_mod_init(void)
154 if (ret < 0) 172 if (ret < 0)
155 goto out_unregister_cipher; 173 goto out_unregister_cipher;
156 174
157 ret = crypto_register_alg(&digest_null); 175 ret = crypto_register_shash(&digest_null);
158 if (ret < 0) 176 if (ret < 0)
159 goto out_unregister_skcipher; 177 goto out_unregister_skcipher;
160 178
@@ -166,7 +184,7 @@ out:
166 return ret; 184 return ret;
167 185
168out_unregister_digest: 186out_unregister_digest:
169 crypto_unregister_alg(&digest_null); 187 crypto_unregister_shash(&digest_null);
170out_unregister_skcipher: 188out_unregister_skcipher:
171 crypto_unregister_alg(&skcipher_null); 189 crypto_unregister_alg(&skcipher_null);
172out_unregister_cipher: 190out_unregister_cipher:
@@ -177,7 +195,7 @@ out_unregister_cipher:
177static void __exit crypto_null_mod_fini(void) 195static void __exit crypto_null_mod_fini(void)
178{ 196{
179 crypto_unregister_alg(&compress_null); 197 crypto_unregister_alg(&compress_null);
180 crypto_unregister_alg(&digest_null); 198 crypto_unregister_shash(&digest_null);
181 crypto_unregister_alg(&skcipher_null); 199 crypto_unregister_alg(&skcipher_null);
182 crypto_unregister_alg(&cipher_null); 200 crypto_unregister_alg(&cipher_null);
183} 201}