1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <crypto/internal/hash.h>
27#include <linux/init.h>
28#include <linux/module.h>
29#include <crypto/sha.h>
30
31#include "crypt_s390.h"
32#include "sha.h"
33
34static int sha1_init(struct shash_desc *desc)
35{
36 struct s390_sha_ctx *sctx = shash_desc_ctx(desc);
37
38 sctx->state[0] = SHA1_H0;
39 sctx->state[1] = SHA1_H1;
40 sctx->state[2] = SHA1_H2;
41 sctx->state[3] = SHA1_H3;
42 sctx->state[4] = SHA1_H4;
43 sctx->count = 0;
44 sctx->func = KIMD_SHA_1;
45
46 return 0;
47}
48
49static struct shash_alg alg = {
50 .digestsize = SHA1_DIGEST_SIZE,
51 .init = sha1_init,
52 .update = s390_sha_update,
53 .final = s390_sha_final,
54 .descsize = sizeof(struct s390_sha_ctx),
55 .base = {
56 .cra_name = "sha1",
57 .cra_driver_name= "sha1-s390",
58 .cra_priority = CRYPT_S390_PRIORITY,
59 .cra_flags = CRYPTO_ALG_TYPE_SHASH,
60 .cra_blocksize = SHA1_BLOCK_SIZE,
61 .cra_module = THIS_MODULE,
62 }
63};
64
65static int __init sha1_s390_init(void)
66{
67 if (!crypt_s390_func_available(KIMD_SHA_1))
68 return -EOPNOTSUPP;
69 return crypto_register_shash(&alg);
70}
71
72static void __exit sha1_s390_fini(void)
73{
74 crypto_unregister_shash(&alg);
75}
76
77module_init(sha1_s390_init);
78module_exit(sha1_s390_fini);
79
80MODULE_ALIAS("sha1");
81MODULE_LICENSE("GPL");
82MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm");
83