aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/s390/crypto/sha1_s390.c14
-rw-r--r--arch/s390/crypto/sha256_s390.c20
-rw-r--r--crypto/sha1_generic.c8
-rw-r--r--crypto/sha256_generic.c31
-rw-r--r--crypto/sha512.c63
-rw-r--r--drivers/crypto/padlock-sha.c36
-rw-r--r--include/crypto/sha.h53
7 files changed, 116 insertions, 109 deletions
diff --git a/arch/s390/crypto/sha1_s390.c b/arch/s390/crypto/sha1_s390.c
index 8ebd3cd6bd1f..5a834f6578ab 100644
--- a/arch/s390/crypto/sha1_s390.c
+++ b/arch/s390/crypto/sha1_s390.c
@@ -26,12 +26,10 @@
26#include <linux/init.h> 26#include <linux/init.h>
27#include <linux/module.h> 27#include <linux/module.h>
28#include <linux/crypto.h> 28#include <linux/crypto.h>
29#include <crypto/sha.h>
29 30
30#include "crypt_s390.h" 31#include "crypt_s390.h"
31 32
32#define SHA1_DIGEST_SIZE 20
33#define SHA1_BLOCK_SIZE 64
34
35struct s390_sha1_ctx { 33struct s390_sha1_ctx {
36 u64 count; /* message length */ 34 u64 count; /* message length */
37 u32 state[5]; 35 u32 state[5];
@@ -42,11 +40,11 @@ static void sha1_init(struct crypto_tfm *tfm)
42{ 40{
43 struct s390_sha1_ctx *sctx = crypto_tfm_ctx(tfm); 41 struct s390_sha1_ctx *sctx = crypto_tfm_ctx(tfm);
44 42
45 sctx->state[0] = 0x67452301; 43 sctx->state[0] = SHA1_H0;
46 sctx->state[1] = 0xEFCDAB89; 44 sctx->state[1] = SHA1_H1;
47 sctx->state[2] = 0x98BADCFE; 45 sctx->state[2] = SHA1_H2;
48 sctx->state[3] = 0x10325476; 46 sctx->state[3] = SHA1_H3;
49 sctx->state[4] = 0xC3D2E1F0; 47 sctx->state[4] = SHA1_H4;
50 sctx->count = 0; 48 sctx->count = 0;
51} 49}
52 50
diff --git a/arch/s390/crypto/sha256_s390.c b/arch/s390/crypto/sha256_s390.c
index c728bd0ae1ed..ccf8633c4f65 100644
--- a/arch/s390/crypto/sha256_s390.c
+++ b/arch/s390/crypto/sha256_s390.c
@@ -19,12 +19,10 @@
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/crypto.h> 21#include <linux/crypto.h>
22#include <crypto/sha.h>
22 23
23#include "crypt_s390.h" 24#include "crypt_s390.h"
24 25
25#define SHA256_DIGEST_SIZE 32
26#define SHA256_BLOCK_SIZE 64
27
28struct s390_sha256_ctx { 26struct s390_sha256_ctx {
29 u64 count; /* message length */ 27 u64 count; /* message length */
30 u32 state[8]; 28 u32 state[8];
@@ -35,14 +33,14 @@ static void sha256_init(struct crypto_tfm *tfm)
35{ 33{
36 struct s390_sha256_ctx *sctx = crypto_tfm_ctx(tfm); 34 struct s390_sha256_ctx *sctx = crypto_tfm_ctx(tfm);
37 35
38 sctx->state[0] = 0x6a09e667; 36 sctx->state[0] = SHA256_H0;
39 sctx->state[1] = 0xbb67ae85; 37 sctx->state[1] = SHA256_H1;
40 sctx->state[2] = 0x3c6ef372; 38 sctx->state[2] = SHA256_H2;
41 sctx->state[3] = 0xa54ff53a; 39 sctx->state[3] = SHA256_H3;
42 sctx->state[4] = 0x510e527f; 40 sctx->state[4] = SHA256_H4;
43 sctx->state[5] = 0x9b05688c; 41 sctx->state[5] = SHA256_H5;
44 sctx->state[6] = 0x1f83d9ab; 42 sctx->state[6] = SHA256_H6;
45 sctx->state[7] = 0x5be0cd19; 43 sctx->state[7] = SHA256_H7;
46 sctx->count = 0; 44 sctx->count = 0;
47} 45}
48 46
diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
index 70364dd5c45a..48a3c3e0bf5f 100644
--- a/crypto/sha1_generic.c
+++ b/crypto/sha1_generic.c
@@ -22,12 +22,10 @@
22#include <linux/crypto.h> 22#include <linux/crypto.h>
23#include <linux/cryptohash.h> 23#include <linux/cryptohash.h>
24#include <linux/types.h> 24#include <linux/types.h>
25#include <crypto/sha.h>
25#include <asm/scatterlist.h> 26#include <asm/scatterlist.h>
26#include <asm/byteorder.h> 27#include <asm/byteorder.h>
27 28
28#define SHA1_DIGEST_SIZE 20
29#define SHA1_HMAC_BLOCK_SIZE 64
30
31struct sha1_ctx { 29struct sha1_ctx {
32 u64 count; 30 u64 count;
33 u32 state[5]; 31 u32 state[5];
@@ -39,7 +37,7 @@ static void sha1_init(struct crypto_tfm *tfm)
39 struct sha1_ctx *sctx = crypto_tfm_ctx(tfm); 37 struct sha1_ctx *sctx = crypto_tfm_ctx(tfm);
40 static const struct sha1_ctx initstate = { 38 static const struct sha1_ctx initstate = {
41 0, 39 0,
42 { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 }, 40 { SHA1_H0, SHA1_H1, SHA1_H2, SHA1_H3, SHA1_H4 },
43 { 0, } 41 { 0, }
44 }; 42 };
45 43
@@ -111,7 +109,7 @@ static struct crypto_alg alg = {
111 .cra_name = "sha1", 109 .cra_name = "sha1",
112 .cra_driver_name= "sha1-generic", 110 .cra_driver_name= "sha1-generic",
113 .cra_flags = CRYPTO_ALG_TYPE_DIGEST, 111 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
114 .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, 112 .cra_blocksize = SHA1_BLOCK_SIZE,
115 .cra_ctxsize = sizeof(struct sha1_ctx), 113 .cra_ctxsize = sizeof(struct sha1_ctx),
116 .cra_module = THIS_MODULE, 114 .cra_module = THIS_MODULE,
117 .cra_alignmask = 3, 115 .cra_alignmask = 3,
diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c
index 74bf2f95f4e5..5f4332edcf6b 100644
--- a/crypto/sha256_generic.c
+++ b/crypto/sha256_generic.c
@@ -21,12 +21,10 @@
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/crypto.h> 22#include <linux/crypto.h>
23#include <linux/types.h> 23#include <linux/types.h>
24#include <crypto/sha.h>
24#include <asm/scatterlist.h> 25#include <asm/scatterlist.h>
25#include <asm/byteorder.h> 26#include <asm/byteorder.h>
26 27
27#define SHA256_DIGEST_SIZE 32
28#define SHA256_HMAC_BLOCK_SIZE 64
29
30struct sha256_ctx { 28struct sha256_ctx {
31 u32 count[2]; 29 u32 count[2];
32 u32 state[8]; 30 u32 state[8];
@@ -48,15 +46,6 @@ static inline u32 Maj(u32 x, u32 y, u32 z)
48#define s0(x) (ror32(x, 7) ^ ror32(x,18) ^ (x >> 3)) 46#define s0(x) (ror32(x, 7) ^ ror32(x,18) ^ (x >> 3))
49#define s1(x) (ror32(x,17) ^ ror32(x,19) ^ (x >> 10)) 47#define s1(x) (ror32(x,17) ^ ror32(x,19) ^ (x >> 10))
50 48
51#define H0 0x6a09e667
52#define H1 0xbb67ae85
53#define H2 0x3c6ef372
54#define H3 0xa54ff53a
55#define H4 0x510e527f
56#define H5 0x9b05688c
57#define H6 0x1f83d9ab
58#define H7 0x5be0cd19
59
60static inline void LOAD_OP(int I, u32 *W, const u8 *input) 49static inline void LOAD_OP(int I, u32 *W, const u8 *input)
61{ 50{
62 W[I] = __be32_to_cpu( ((__be32*)(input))[I] ); 51 W[I] = __be32_to_cpu( ((__be32*)(input))[I] );
@@ -233,14 +222,14 @@ static void sha256_transform(u32 *state, const u8 *input)
233static void sha256_init(struct crypto_tfm *tfm) 222static void sha256_init(struct crypto_tfm *tfm)
234{ 223{
235 struct sha256_ctx *sctx = crypto_tfm_ctx(tfm); 224 struct sha256_ctx *sctx = crypto_tfm_ctx(tfm);
236 sctx->state[0] = H0; 225 sctx->state[0] = SHA256_H0;
237 sctx->state[1] = H1; 226 sctx->state[1] = SHA256_H1;
238 sctx->state[2] = H2; 227 sctx->state[2] = SHA256_H2;
239 sctx->state[3] = H3; 228 sctx->state[3] = SHA256_H3;
240 sctx->state[4] = H4; 229 sctx->state[4] = SHA256_H4;
241 sctx->state[5] = H5; 230 sctx->state[5] = SHA256_H5;
242 sctx->state[6] = H6; 231 sctx->state[6] = SHA256_H6;
243 sctx->state[7] = H7; 232 sctx->state[7] = SHA256_H7;
244 sctx->count[0] = sctx->count[1] = 0; 233 sctx->count[0] = sctx->count[1] = 0;
245} 234}
246 235
@@ -311,7 +300,7 @@ static struct crypto_alg alg = {
311 .cra_name = "sha256", 300 .cra_name = "sha256",
312 .cra_driver_name= "sha256-generic", 301 .cra_driver_name= "sha256-generic",
313 .cra_flags = CRYPTO_ALG_TYPE_DIGEST, 302 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
314 .cra_blocksize = SHA256_HMAC_BLOCK_SIZE, 303 .cra_blocksize = SHA256_BLOCK_SIZE,
315 .cra_ctxsize = sizeof(struct sha256_ctx), 304 .cra_ctxsize = sizeof(struct sha256_ctx),
316 .cra_module = THIS_MODULE, 305 .cra_module = THIS_MODULE,
317 .cra_alignmask = 3, 306 .cra_alignmask = 3,
diff --git a/crypto/sha512.c b/crypto/sha512.c
index 15eab9db9be4..e736596ca574 100644
--- a/crypto/sha512.c
+++ b/crypto/sha512.c
@@ -13,20 +13,15 @@
13 13
14#include <linux/kernel.h> 14#include <linux/kernel.h>
15#include <linux/module.h> 15#include <linux/module.h>
16
17#include <linux/mm.h> 16#include <linux/mm.h>
18#include <linux/init.h> 17#include <linux/init.h>
19#include <linux/crypto.h> 18#include <linux/crypto.h>
20#include <linux/types.h> 19#include <linux/types.h>
20#include <crypto/sha.h>
21 21
22#include <asm/scatterlist.h> 22#include <asm/scatterlist.h>
23#include <asm/byteorder.h> 23#include <asm/byteorder.h>
24 24
25#define SHA384_DIGEST_SIZE 48
26#define SHA512_DIGEST_SIZE 64
27#define SHA384_HMAC_BLOCK_SIZE 128
28#define SHA512_HMAC_BLOCK_SIZE 128
29
30struct sha512_ctx { 25struct sha512_ctx {
31 u64 state[8]; 26 u64 state[8];
32 u32 count[4]; 27 u32 count[4];
@@ -84,26 +79,6 @@ static const u64 sha512_K[80] = {
84#define s0(x) (RORu64(x, 1) ^ RORu64(x, 8) ^ (x >> 7)) 79#define s0(x) (RORu64(x, 1) ^ RORu64(x, 8) ^ (x >> 7))
85#define s1(x) (RORu64(x,19) ^ RORu64(x,61) ^ (x >> 6)) 80#define s1(x) (RORu64(x,19) ^ RORu64(x,61) ^ (x >> 6))
86 81
87/* H* initial state for SHA-512 */
88#define H0 0x6a09e667f3bcc908ULL
89#define H1 0xbb67ae8584caa73bULL
90#define H2 0x3c6ef372fe94f82bULL
91#define H3 0xa54ff53a5f1d36f1ULL
92#define H4 0x510e527fade682d1ULL
93#define H5 0x9b05688c2b3e6c1fULL
94#define H6 0x1f83d9abfb41bd6bULL
95#define H7 0x5be0cd19137e2179ULL
96
97/* H'* initial state for SHA-384 */
98#define HP0 0xcbbb9d5dc1059ed8ULL
99#define HP1 0x629a292a367cd507ULL
100#define HP2 0x9159015a3070dd17ULL
101#define HP3 0x152fecd8f70e5939ULL
102#define HP4 0x67332667ffc00b31ULL
103#define HP5 0x8eb44a8768581511ULL
104#define HP6 0xdb0c2e0d64f98fa7ULL
105#define HP7 0x47b5481dbefa4fa4ULL
106
107static inline void LOAD_OP(int I, u64 *W, const u8 *input) 82static inline void LOAD_OP(int I, u64 *W, const u8 *input)
108{ 83{
109 W[I] = __be64_to_cpu( ((__be64*)(input))[I] ); 84 W[I] = __be64_to_cpu( ((__be64*)(input))[I] );
@@ -164,14 +139,14 @@ static void
164sha512_init(struct crypto_tfm *tfm) 139sha512_init(struct crypto_tfm *tfm)
165{ 140{
166 struct sha512_ctx *sctx = crypto_tfm_ctx(tfm); 141 struct sha512_ctx *sctx = crypto_tfm_ctx(tfm);
167 sctx->state[0] = H0; 142 sctx->state[0] = SHA512_H0;
168 sctx->state[1] = H1; 143 sctx->state[1] = SHA512_H1;
169 sctx->state[2] = H2; 144 sctx->state[2] = SHA512_H2;
170 sctx->state[3] = H3; 145 sctx->state[3] = SHA512_H3;
171 sctx->state[4] = H4; 146 sctx->state[4] = SHA512_H4;
172 sctx->state[5] = H5; 147 sctx->state[5] = SHA512_H5;
173 sctx->state[6] = H6; 148 sctx->state[6] = SHA512_H6;
174 sctx->state[7] = H7; 149 sctx->state[7] = SHA512_H7;
175 sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0; 150 sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
176} 151}
177 152
@@ -179,14 +154,14 @@ static void
179sha384_init(struct crypto_tfm *tfm) 154sha384_init(struct crypto_tfm *tfm)
180{ 155{
181 struct sha512_ctx *sctx = crypto_tfm_ctx(tfm); 156 struct sha512_ctx *sctx = crypto_tfm_ctx(tfm);
182 sctx->state[0] = HP0; 157 sctx->state[0] = SHA384_H0;
183 sctx->state[1] = HP1; 158 sctx->state[1] = SHA384_H1;
184 sctx->state[2] = HP2; 159 sctx->state[2] = SHA384_H2;
185 sctx->state[3] = HP3; 160 sctx->state[3] = SHA384_H3;
186 sctx->state[4] = HP4; 161 sctx->state[4] = SHA384_H4;
187 sctx->state[5] = HP5; 162 sctx->state[5] = SHA384_H5;
188 sctx->state[6] = HP6; 163 sctx->state[6] = SHA384_H6;
189 sctx->state[7] = HP7; 164 sctx->state[7] = SHA384_H7;
190 sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0; 165 sctx->count[0] = sctx->count[1] = sctx->count[2] = sctx->count[3] = 0;
191} 166}
192 167
@@ -275,7 +250,7 @@ static void sha384_final(struct crypto_tfm *tfm, u8 *hash)
275static struct crypto_alg sha512 = { 250static struct crypto_alg sha512 = {
276 .cra_name = "sha512", 251 .cra_name = "sha512",
277 .cra_flags = CRYPTO_ALG_TYPE_DIGEST, 252 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
278 .cra_blocksize = SHA512_HMAC_BLOCK_SIZE, 253 .cra_blocksize = SHA512_BLOCK_SIZE,
279 .cra_ctxsize = sizeof(struct sha512_ctx), 254 .cra_ctxsize = sizeof(struct sha512_ctx),
280 .cra_module = THIS_MODULE, 255 .cra_module = THIS_MODULE,
281 .cra_alignmask = 3, 256 .cra_alignmask = 3,
@@ -291,7 +266,7 @@ static struct crypto_alg sha512 = {
291static struct crypto_alg sha384 = { 266static struct crypto_alg sha384 = {
292 .cra_name = "sha384", 267 .cra_name = "sha384",
293 .cra_flags = CRYPTO_ALG_TYPE_DIGEST, 268 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
294 .cra_blocksize = SHA384_HMAC_BLOCK_SIZE, 269 .cra_blocksize = SHA384_BLOCK_SIZE,
295 .cra_ctxsize = sizeof(struct sha512_ctx), 270 .cra_ctxsize = sizeof(struct sha512_ctx),
296 .cra_alignmask = 3, 271 .cra_alignmask = 3,
297 .cra_module = THIS_MODULE, 272 .cra_module = THIS_MODULE,
diff --git a/drivers/crypto/padlock-sha.c b/drivers/crypto/padlock-sha.c
index f3857bbbfae3..4e8de162fc12 100644
--- a/drivers/crypto/padlock-sha.c
+++ b/drivers/crypto/padlock-sha.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <crypto/algapi.h> 15#include <crypto/algapi.h>
16#include <crypto/sha.h>
16#include <linux/err.h> 17#include <linux/err.h>
17#include <linux/module.h> 18#include <linux/module.h>
18#include <linux/init.h> 19#include <linux/init.h>
@@ -24,12 +25,7 @@
24#include "padlock.h" 25#include "padlock.h"
25 26
26#define SHA1_DEFAULT_FALLBACK "sha1-generic" 27#define SHA1_DEFAULT_FALLBACK "sha1-generic"
27#define SHA1_DIGEST_SIZE 20
28#define SHA1_HMAC_BLOCK_SIZE 64
29
30#define SHA256_DEFAULT_FALLBACK "sha256-generic" 28#define SHA256_DEFAULT_FALLBACK "sha256-generic"
31#define SHA256_DIGEST_SIZE 32
32#define SHA256_HMAC_BLOCK_SIZE 64
33 29
34struct padlock_sha_ctx { 30struct padlock_sha_ctx {
35 char *data; 31 char *data;
@@ -107,11 +103,11 @@ static void padlock_do_sha1(const char *in, char *out, int count)
107 char buf[128+16]; 103 char buf[128+16];
108 char *result = NEAREST_ALIGNED(buf); 104 char *result = NEAREST_ALIGNED(buf);
109 105
110 ((uint32_t *)result)[0] = 0x67452301; 106 ((uint32_t *)result)[0] = SHA1_H0;
111 ((uint32_t *)result)[1] = 0xEFCDAB89; 107 ((uint32_t *)result)[1] = SHA1_H1;
112 ((uint32_t *)result)[2] = 0x98BADCFE; 108 ((uint32_t *)result)[2] = SHA1_H2;
113 ((uint32_t *)result)[3] = 0x10325476; 109 ((uint32_t *)result)[3] = SHA1_H3;
114 ((uint32_t *)result)[4] = 0xC3D2E1F0; 110 ((uint32_t *)result)[4] = SHA1_H4;
115 111
116 asm volatile (".byte 0xf3,0x0f,0xa6,0xc8" /* rep xsha1 */ 112 asm volatile (".byte 0xf3,0x0f,0xa6,0xc8" /* rep xsha1 */
117 : "+S"(in), "+D"(result) 113 : "+S"(in), "+D"(result)
@@ -128,14 +124,14 @@ static void padlock_do_sha256(const char *in, char *out, int count)
128 char buf[128+16]; 124 char buf[128+16];
129 char *result = NEAREST_ALIGNED(buf); 125 char *result = NEAREST_ALIGNED(buf);
130 126
131 ((uint32_t *)result)[0] = 0x6A09E667; 127 ((uint32_t *)result)[0] = SHA256_H0;
132 ((uint32_t *)result)[1] = 0xBB67AE85; 128 ((uint32_t *)result)[1] = SHA256_H1;
133 ((uint32_t *)result)[2] = 0x3C6EF372; 129 ((uint32_t *)result)[2] = SHA256_H2;
134 ((uint32_t *)result)[3] = 0xA54FF53A; 130 ((uint32_t *)result)[3] = SHA256_H3;
135 ((uint32_t *)result)[4] = 0x510E527F; 131 ((uint32_t *)result)[4] = SHA256_H4;
136 ((uint32_t *)result)[5] = 0x9B05688C; 132 ((uint32_t *)result)[5] = SHA256_H5;
137 ((uint32_t *)result)[6] = 0x1F83D9AB; 133 ((uint32_t *)result)[6] = SHA256_H6;
138 ((uint32_t *)result)[7] = 0x5BE0CD19; 134 ((uint32_t *)result)[7] = SHA256_H7;
139 135
140 asm volatile (".byte 0xf3,0x0f,0xa6,0xd0" /* rep xsha256 */ 136 asm volatile (".byte 0xf3,0x0f,0xa6,0xd0" /* rep xsha256 */
141 : "+S"(in), "+D"(result) 137 : "+S"(in), "+D"(result)
@@ -215,7 +211,7 @@ static struct crypto_alg sha1_alg = {
215 .cra_priority = PADLOCK_CRA_PRIORITY, 211 .cra_priority = PADLOCK_CRA_PRIORITY,
216 .cra_flags = CRYPTO_ALG_TYPE_DIGEST | 212 .cra_flags = CRYPTO_ALG_TYPE_DIGEST |
217 CRYPTO_ALG_NEED_FALLBACK, 213 CRYPTO_ALG_NEED_FALLBACK,
218 .cra_blocksize = SHA1_HMAC_BLOCK_SIZE, 214 .cra_blocksize = SHA1_BLOCK_SIZE,
219 .cra_ctxsize = sizeof(struct padlock_sha_ctx), 215 .cra_ctxsize = sizeof(struct padlock_sha_ctx),
220 .cra_module = THIS_MODULE, 216 .cra_module = THIS_MODULE,
221 .cra_list = LIST_HEAD_INIT(sha1_alg.cra_list), 217 .cra_list = LIST_HEAD_INIT(sha1_alg.cra_list),
@@ -237,7 +233,7 @@ static struct crypto_alg sha256_alg = {
237 .cra_priority = PADLOCK_CRA_PRIORITY, 233 .cra_priority = PADLOCK_CRA_PRIORITY,
238 .cra_flags = CRYPTO_ALG_TYPE_DIGEST | 234 .cra_flags = CRYPTO_ALG_TYPE_DIGEST |
239 CRYPTO_ALG_NEED_FALLBACK, 235 CRYPTO_ALG_NEED_FALLBACK,
240 .cra_blocksize = SHA256_HMAC_BLOCK_SIZE, 236 .cra_blocksize = SHA256_BLOCK_SIZE,
241 .cra_ctxsize = sizeof(struct padlock_sha_ctx), 237 .cra_ctxsize = sizeof(struct padlock_sha_ctx),
242 .cra_module = THIS_MODULE, 238 .cra_module = THIS_MODULE,
243 .cra_list = LIST_HEAD_INIT(sha256_alg.cra_list), 239 .cra_list = LIST_HEAD_INIT(sha256_alg.cra_list),
diff --git a/include/crypto/sha.h b/include/crypto/sha.h
new file mode 100644
index 000000000000..0686e1f7a24b
--- /dev/null
+++ b/include/crypto/sha.h
@@ -0,0 +1,53 @@
1/*
2 * Common values for SHA algorithms
3 */
4
5#ifndef _CRYPTO_SHA_H
6#define _CRYPTO_SHA_H
7
8#define SHA1_DIGEST_SIZE 20
9#define SHA1_BLOCK_SIZE 64
10
11#define SHA256_DIGEST_SIZE 32
12#define SHA256_BLOCK_SIZE 64
13
14#define SHA384_DIGEST_SIZE 48
15#define SHA384_BLOCK_SIZE 128
16
17#define SHA512_DIGEST_SIZE 64
18#define SHA512_BLOCK_SIZE 128
19
20#define SHA1_H0 0x67452301UL
21#define SHA1_H1 0xefcdab89UL
22#define SHA1_H2 0x98badcfeUL
23#define SHA1_H3 0x10325476UL
24#define SHA1_H4 0xc3d2e1f0UL
25
26#define SHA256_H0 0x6a09e667UL
27#define SHA256_H1 0xbb67ae85UL
28#define SHA256_H2 0x3c6ef372UL
29#define SHA256_H3 0xa54ff53aUL
30#define SHA256_H4 0x510e527fUL
31#define SHA256_H5 0x9b05688cUL
32#define SHA256_H6 0x1f83d9abUL
33#define SHA256_H7 0x5be0cd19UL
34
35#define SHA384_H0 0xcbbb9d5dc1059ed8ULL
36#define SHA384_H1 0x629a292a367cd507ULL
37#define SHA384_H2 0x9159015a3070dd17ULL
38#define SHA384_H3 0x152fecd8f70e5939ULL
39#define SHA384_H4 0x67332667ffc00b31ULL
40#define SHA384_H5 0x8eb44a8768581511ULL
41#define SHA384_H6 0xdb0c2e0d64f98fa7ULL
42#define SHA384_H7 0x47b5481dbefa4fa4ULL
43
44#define SHA512_H0 0x6a09e667f3bcc908ULL
45#define SHA512_H1 0xbb67ae8584caa73bULL
46#define SHA512_H2 0x3c6ef372fe94f82bULL
47#define SHA512_H3 0xa54ff53a5f1d36f1ULL
48#define SHA512_H4 0x510e527fade682d1ULL
49#define SHA512_H5 0x9b05688c2b3e6c1fULL
50#define SHA512_H6 0x1f83d9abfb41bd6bULL
51#define SHA512_H7 0x5be0cd19137e2179ULL
52
53#endif