Skip to content

Commit 6aeb49b

Browse files
jkivilinherbertx
authored andcommitted
crypto: sha256 - use crypto_[un]register_shashes
Combine all shash algs to be registered and use new crypto_[un]register_shashes functions. This simplifies init/exit code. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent a5e7a2d commit 6aeb49b

1 file changed

Lines changed: 5 additions & 20 deletions

File tree

‎crypto/sha256_generic.c‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static int sha256_import(struct shash_desc *desc, const void *in)
336336
return 0;
337337
}
338338

339-
static struct shash_alg sha256 = {
339+
static struct shash_alg sha256_algs[2] = { {
340340
.digestsize = SHA256_DIGEST_SIZE,
341341
.init = sha256_init,
342342
.update = sha256_update,
@@ -352,9 +352,7 @@ static struct shash_alg sha256 = {
352352
.cra_blocksize = SHA256_BLOCK_SIZE,
353353
.cra_module = THIS_MODULE,
354354
}
355-
};
356-
357-
static struct shash_alg sha224 = {
355+
}, {
358356
.digestsize = SHA224_DIGEST_SIZE,
359357
.init = sha224_init,
360358
.update = sha256_update,
@@ -367,29 +365,16 @@ static struct shash_alg sha224 = {
367365
.cra_blocksize = SHA224_BLOCK_SIZE,
368366
.cra_module = THIS_MODULE,
369367
}
370-
};
368+
} };
371369

372370
static int __init sha256_generic_mod_init(void)
373371
{
374-
int ret = 0;
375-
376-
ret = crypto_register_shash(&sha224);
377-
378-
if (ret < 0)
379-
return ret;
380-
381-
ret = crypto_register_shash(&sha256);
382-
383-
if (ret < 0)
384-
crypto_unregister_shash(&sha224);
385-
386-
return ret;
372+
return crypto_register_shashes(sha256_algs, ARRAY_SIZE(sha256_algs));
387373
}
388374

389375
static void __exit sha256_generic_mod_fini(void)
390376
{
391-
crypto_unregister_shash(&sha224);
392-
crypto_unregister_shash(&sha256);
377+
crypto_unregister_shashes(sha256_algs, ARRAY_SIZE(sha256_algs));
393378
}
394379

395380
module_init(sha256_generic_mod_init);

0 commit comments

Comments
 (0)