diff options
Diffstat (limited to 'crypto/crypto_null.c')
-rw-r--r-- | crypto/crypto_null.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/crypto/crypto_null.c b/crypto/crypto_null.c index 0bae59922a80..01630a9c7e01 100644 --- a/crypto/crypto_null.c +++ b/crypto/crypto_null.c | |||
@@ -65,6 +65,10 @@ static int null_hash_setkey(struct crypto_shash *tfm, const u8 *key, | |||
65 | unsigned int keylen) | 65 | unsigned int keylen) |
66 | { return 0; } | 66 | { return 0; } |
67 | 67 | ||
68 | static int null_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key, | ||
69 | unsigned int keylen) | ||
70 | { return 0; } | ||
71 | |||
68 | static int null_setkey(struct crypto_tfm *tfm, const u8 *key, | 72 | static int null_setkey(struct crypto_tfm *tfm, const u8 *key, |
69 | unsigned int keylen) | 73 | unsigned int keylen) |
70 | { return 0; } | 74 | { return 0; } |
@@ -74,21 +78,18 @@ static void null_crypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) | |||
74 | memcpy(dst, src, NULL_BLOCK_SIZE); | 78 | memcpy(dst, src, NULL_BLOCK_SIZE); |
75 | } | 79 | } |
76 | 80 | ||
77 | static int skcipher_null_crypt(struct blkcipher_desc *desc, | 81 | static int null_skcipher_crypt(struct skcipher_request *req) |
78 | struct scatterlist *dst, | ||
79 | struct scatterlist *src, unsigned int nbytes) | ||
80 | { | 82 | { |
81 | struct blkcipher_walk walk; | 83 | struct skcipher_walk walk; |
82 | int err; | 84 | int err; |
83 | 85 | ||
84 | blkcipher_walk_init(&walk, dst, src, nbytes); | 86 | err = skcipher_walk_virt(&walk, req, false); |
85 | err = blkcipher_walk_virt(desc, &walk); | ||
86 | 87 | ||
87 | while (walk.nbytes) { | 88 | while (walk.nbytes) { |
88 | if (walk.src.virt.addr != walk.dst.virt.addr) | 89 | if (walk.src.virt.addr != walk.dst.virt.addr) |
89 | memcpy(walk.dst.virt.addr, walk.src.virt.addr, | 90 | memcpy(walk.dst.virt.addr, walk.src.virt.addr, |
90 | walk.nbytes); | 91 | walk.nbytes); |
91 | err = blkcipher_walk_done(desc, &walk, 0); | 92 | err = skcipher_walk_done(&walk, 0); |
92 | } | 93 | } |
93 | 94 | ||
94 | return err; | 95 | return err; |
@@ -109,7 +110,22 @@ static struct shash_alg digest_null = { | |||
109 | } | 110 | } |
110 | }; | 111 | }; |
111 | 112 | ||
112 | static struct crypto_alg null_algs[3] = { { | 113 | static struct skcipher_alg skcipher_null = { |
114 | .base.cra_name = "ecb(cipher_null)", | ||
115 | .base.cra_driver_name = "ecb-cipher_null", | ||
116 | .base.cra_priority = 100, | ||
117 | .base.cra_blocksize = NULL_BLOCK_SIZE, | ||
118 | .base.cra_ctxsize = 0, | ||
119 | .base.cra_module = THIS_MODULE, | ||
120 | .min_keysize = NULL_KEY_SIZE, | ||
121 | .max_keysize = NULL_KEY_SIZE, | ||
122 | .ivsize = NULL_IV_SIZE, | ||
123 | .setkey = null_skcipher_setkey, | ||
124 | .encrypt = null_skcipher_crypt, | ||
125 | .decrypt = null_skcipher_crypt, | ||
126 | }; | ||
127 | |||
128 | static struct crypto_alg null_algs[] = { { | ||
113 | .cra_name = "cipher_null", | 129 | .cra_name = "cipher_null", |
114 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, | 130 | .cra_flags = CRYPTO_ALG_TYPE_CIPHER, |
115 | .cra_blocksize = NULL_BLOCK_SIZE, | 131 | .cra_blocksize = NULL_BLOCK_SIZE, |
@@ -122,22 +138,6 @@ static struct crypto_alg null_algs[3] = { { | |||
122 | .cia_encrypt = null_crypt, | 138 | .cia_encrypt = null_crypt, |
123 | .cia_decrypt = null_crypt } } | 139 | .cia_decrypt = null_crypt } } |
124 | }, { | 140 | }, { |
125 | .cra_name = "ecb(cipher_null)", | ||
126 | .cra_driver_name = "ecb-cipher_null", | ||
127 | .cra_priority = 100, | ||
128 | .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, | ||
129 | .cra_blocksize = NULL_BLOCK_SIZE, | ||
130 | .cra_type = &crypto_blkcipher_type, | ||
131 | .cra_ctxsize = 0, | ||
132 | .cra_module = THIS_MODULE, | ||
133 | .cra_u = { .blkcipher = { | ||
134 | .min_keysize = NULL_KEY_SIZE, | ||
135 | .max_keysize = NULL_KEY_SIZE, | ||
136 | .ivsize = NULL_IV_SIZE, | ||
137 | .setkey = null_setkey, | ||
138 | .encrypt = skcipher_null_crypt, | ||
139 | .decrypt = skcipher_null_crypt } } | ||
140 | }, { | ||
141 | .cra_name = "compress_null", | 141 | .cra_name = "compress_null", |
142 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, | 142 | .cra_flags = CRYPTO_ALG_TYPE_COMPRESS, |
143 | .cra_blocksize = NULL_BLOCK_SIZE, | 143 | .cra_blocksize = NULL_BLOCK_SIZE, |
@@ -199,8 +199,14 @@ static int __init crypto_null_mod_init(void) | |||
199 | if (ret < 0) | 199 | if (ret < 0) |
200 | goto out_unregister_algs; | 200 | goto out_unregister_algs; |
201 | 201 | ||
202 | ret = crypto_register_skcipher(&skcipher_null); | ||
203 | if (ret < 0) | ||
204 | goto out_unregister_shash; | ||
205 | |||
202 | return 0; | 206 | return 0; |
203 | 207 | ||
208 | out_unregister_shash: | ||
209 | crypto_unregister_shash(&digest_null); | ||
204 | out_unregister_algs: | 210 | out_unregister_algs: |
205 | crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); | 211 | crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); |
206 | out: | 212 | out: |
@@ -209,8 +215,9 @@ out: | |||
209 | 215 | ||
210 | static void __exit crypto_null_mod_fini(void) | 216 | static void __exit crypto_null_mod_fini(void) |
211 | { | 217 | { |
212 | crypto_unregister_shash(&digest_null); | ||
213 | crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); | 218 | crypto_unregister_algs(null_algs, ARRAY_SIZE(null_algs)); |
219 | crypto_unregister_shash(&digest_null); | ||
220 | crypto_unregister_skcipher(&skcipher_null); | ||
214 | } | 221 | } |
215 | 222 | ||
216 | module_init(crypto_null_mod_init); | 223 | module_init(crypto_null_mod_init); |