@@ -65,6 +65,10 @@ static int null_hash_setkey(struct crypto_shash *tfm, const u8 *key,
6565 unsigned int keylen )
6666{ return 0 ; }
6767
68+ static int null_skcipher_setkey (struct crypto_skcipher * tfm , const u8 * key ,
69+ unsigned int keylen )
70+ { return 0 ; }
71+
6872static int null_setkey (struct crypto_tfm * tfm , const u8 * key ,
6973 unsigned int keylen )
7074{ return 0 ; }
@@ -74,21 +78,18 @@ static void null_crypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src)
7478 memcpy (dst , src , NULL_BLOCK_SIZE );
7579}
7680
77- static int skcipher_null_crypt (struct blkcipher_desc * desc ,
78- struct scatterlist * dst ,
79- struct scatterlist * src , unsigned int nbytes )
81+ static int null_skcipher_crypt (struct skcipher_request * req )
8082{
81- struct blkcipher_walk walk ;
83+ struct skcipher_walk walk ;
8284 int err ;
8385
84- blkcipher_walk_init (& walk , dst , src , nbytes );
85- err = blkcipher_walk_virt (desc , & walk );
86+ err = skcipher_walk_virt (& walk , req , false);
8687
8788 while (walk .nbytes ) {
8889 if (walk .src .virt .addr != walk .dst .virt .addr )
8990 memcpy (walk .dst .virt .addr , walk .src .virt .addr ,
9091 walk .nbytes );
91- err = blkcipher_walk_done ( desc , & walk , 0 );
92+ err = skcipher_walk_done ( & walk , 0 );
9293 }
9394
9495 return err ;
@@ -109,7 +110,22 @@ static struct shash_alg digest_null = {
109110 }
110111};
111112
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 [] = { {
113129 .cra_name = "cipher_null" ,
114130 .cra_flags = CRYPTO_ALG_TYPE_CIPHER ,
115131 .cra_blocksize = NULL_BLOCK_SIZE ,
@@ -121,22 +137,6 @@ static struct crypto_alg null_algs[3] = { {
121137 .cia_setkey = null_setkey ,
122138 .cia_encrypt = null_crypt ,
123139 .cia_decrypt = null_crypt } }
124- }, {
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 } }
140140}, {
141141 .cra_name = "compress_null" ,
142142 .cra_flags = CRYPTO_ALG_TYPE_COMPRESS ,
@@ -199,8 +199,14 @@ static int __init crypto_null_mod_init(void)
199199 if (ret < 0 )
200200 goto out_unregister_algs ;
201201
202+ ret = crypto_register_skcipher (& skcipher_null );
203+ if (ret < 0 )
204+ goto out_unregister_shash ;
205+
202206 return 0 ;
203207
208+ out_unregister_shash :
209+ crypto_unregister_shash (& digest_null );
204210out_unregister_algs :
205211 crypto_unregister_algs (null_algs , ARRAY_SIZE (null_algs ));
206212out :
@@ -209,8 +215,9 @@ static int __init crypto_null_mod_init(void)
209215
210216static void __exit crypto_null_mod_fini (void )
211217{
212- crypto_unregister_shash (& digest_null );
213218 crypto_unregister_algs (null_algs , ARRAY_SIZE (null_algs ));
219+ crypto_unregister_shash (& digest_null );
220+ crypto_unregister_skcipher (& skcipher_null );
214221}
215222
216223module_init (crypto_null_mod_init );
0 commit comments