aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/s390/crypto/sha512_s390.c57
-rw-r--r--drivers/crypto/Kconfig6
2 files changed, 54 insertions, 9 deletions
diff --git a/arch/s390/crypto/sha512_s390.c b/arch/s390/crypto/sha512_s390.c
index 4d651bbce0f4..23c7861f6aeb 100644
--- a/arch/s390/crypto/sha512_s390.c
+++ b/arch/s390/crypto/sha512_s390.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Cryptographic API. 2 * Cryptographic API.
3 * 3 *
4 * s390 implementation of the SHA512 Secure Hash Algorithm. 4 * s390 implementation of the SHA512 and SHA38 Secure Hash Algorithm.
5 * 5 *
6 * Copyright IBM Corp. 2007 6 * Copyright IBM Corp. 2007
7 * Author(s): Jan Glauber (jang@de.ibm.com) 7 * Author(s): Jan Glauber (jang@de.ibm.com)
@@ -35,7 +35,7 @@ static void sha512_init(struct crypto_tfm *tfm)
35 ctx->func = KIMD_SHA_512; 35 ctx->func = KIMD_SHA_512;
36} 36}
37 37
38static struct crypto_alg alg = { 38static struct crypto_alg sha512_alg = {
39 .cra_name = "sha512", 39 .cra_name = "sha512",
40 .cra_driver_name = "sha512-s390", 40 .cra_driver_name = "sha512-s390",
41 .cra_priority = CRYPT_S390_PRIORITY, 41 .cra_priority = CRYPT_S390_PRIORITY,
@@ -43,7 +43,7 @@ static struct crypto_alg alg = {
43 .cra_blocksize = SHA512_BLOCK_SIZE, 43 .cra_blocksize = SHA512_BLOCK_SIZE,
44 .cra_ctxsize = sizeof(struct s390_sha_ctx), 44 .cra_ctxsize = sizeof(struct s390_sha_ctx),
45 .cra_module = THIS_MODULE, 45 .cra_module = THIS_MODULE,
46 .cra_list = LIST_HEAD_INIT(alg.cra_list), 46 .cra_list = LIST_HEAD_INIT(sha512_alg.cra_list),
47 .cra_u = { .digest = { 47 .cra_u = { .digest = {
48 .dia_digestsize = SHA512_DIGEST_SIZE, 48 .dia_digestsize = SHA512_DIGEST_SIZE,
49 .dia_init = sha512_init, 49 .dia_init = sha512_init,
@@ -51,21 +51,64 @@ static struct crypto_alg alg = {
51 .dia_final = s390_sha_final } } 51 .dia_final = s390_sha_final } }
52}; 52};
53 53
54MODULE_ALIAS("sha512");
55
56static void sha384_init(struct crypto_tfm *tfm)
57{
58 struct s390_sha_ctx *ctx = crypto_tfm_ctx(tfm);
59
60 *(__u64 *)&ctx->state[0] = 0xcbbb9d5dc1059ed8ULL;
61 *(__u64 *)&ctx->state[2] = 0x629a292a367cd507ULL;
62 *(__u64 *)&ctx->state[4] = 0x9159015a3070dd17ULL;
63 *(__u64 *)&ctx->state[6] = 0x152fecd8f70e5939ULL;
64 *(__u64 *)&ctx->state[8] = 0x67332667ffc00b31ULL;
65 *(__u64 *)&ctx->state[10] = 0x8eb44a8768581511ULL;
66 *(__u64 *)&ctx->state[12] = 0xdb0c2e0d64f98fa7ULL;
67 *(__u64 *)&ctx->state[14] = 0x47b5481dbefa4fa4ULL;
68 ctx->count = 0;
69 ctx->func = KIMD_SHA_512;
70}
71
72static struct crypto_alg sha384_alg = {
73 .cra_name = "sha384",
74 .cra_driver_name = "sha384-s390",
75 .cra_priority = CRYPT_S390_PRIORITY,
76 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
77 .cra_blocksize = SHA384_BLOCK_SIZE,
78 .cra_ctxsize = sizeof(struct s390_sha_ctx),
79 .cra_module = THIS_MODULE,
80 .cra_list = LIST_HEAD_INIT(sha384_alg.cra_list),
81 .cra_u = { .digest = {
82 .dia_digestsize = SHA384_DIGEST_SIZE,
83 .dia_init = sha384_init,
84 .dia_update = s390_sha_update,
85 .dia_final = s390_sha_final } }
86};
87
88MODULE_ALIAS("sha384");
89
54static int __init init(void) 90static int __init init(void)
55{ 91{
92 int ret;
93
56 if (!crypt_s390_func_available(KIMD_SHA_512)) 94 if (!crypt_s390_func_available(KIMD_SHA_512))
57 return -EOPNOTSUPP; 95 return -EOPNOTSUPP;
58 return crypto_register_alg(&alg); 96 if ((ret = crypto_register_alg(&sha512_alg)) < 0)
97 goto out;
98 if ((ret = crypto_register_alg(&sha384_alg)) < 0)
99 crypto_unregister_alg(&sha512_alg);
100out:
101 return ret;
59} 102}
60 103
61static void __exit fini(void) 104static void __exit fini(void)
62{ 105{
63 crypto_unregister_alg(&alg); 106 crypto_unregister_alg(&sha512_alg);
107 crypto_unregister_alg(&sha384_alg);
64} 108}
65 109
66module_init(init); 110module_init(init);
67module_exit(fini); 111module_exit(fini);
68 112
69MODULE_ALIAS("sha512");
70MODULE_LICENSE("GPL"); 113MODULE_LICENSE("GPL");
71MODULE_DESCRIPTION("SHA512 Secure Hash Algorithm"); 114MODULE_DESCRIPTION("SHA512 and SHA-384 Secure Hash Algorithm");
diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig
index ea7b19047270..e15dbc61f20f 100644
--- a/drivers/crypto/Kconfig
+++ b/drivers/crypto/Kconfig
@@ -102,7 +102,7 @@ config CRYPTO_SHA256_S390
102 security against collision attacks. 102 security against collision attacks.
103 103
104config CRYPTO_SHA512_S390 104config CRYPTO_SHA512_S390
105 tristate "SHA512 digest algorithm" 105 tristate "SHA384 and SHA512 digest algorithm"
106 depends on S390 106 depends on S390
107 select CRYPTO_ALGAPI 107 select CRYPTO_ALGAPI
108 help 108 help
@@ -110,7 +110,9 @@ config CRYPTO_SHA512_S390
110 SHA512 secure hash standard. 110 SHA512 secure hash standard.
111 111
112 This version of SHA implements a 512 bit hash with 256 bits of 112 This version of SHA implements a 512 bit hash with 256 bits of
113 security against collision attacks. 113 security against collision attacks. The code also includes SHA-384,
114 a 384 bit hash with 192 bits of security against collision attacks.
115
114 116
115config CRYPTO_DES_S390 117config CRYPTO_DES_S390
116 tristate "DES and Triple DES cipher algorithms" 118 tristate "DES and Triple DES cipher algorithms"