diff options
author | Jan Glauber <jang@de.ibm.com> | 2007-10-09 10:43:13 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:55:50 -0400 |
commit | 5265eeb2b036835021591173ac64e624baaff55c (patch) | |
tree | 0263f8e8db4ead27b6e02f3200e3a1305bbf2080 /drivers/crypto | |
parent | ad5d27899fdbe7a66e57fdf1af883dbd7ff88dac (diff) |
[CRYPTO] sha: Add header file for SHA definitions
There are currently several SHA implementations that all define their own
initialization vectors and size values. Since this values are idential
move them to a header file under include/crypto.
Signed-off-by: Jan Glauber <jang@de.ibm.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/padlock-sha.c | 36 |
1 files changed, 16 insertions, 20 deletions
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 | ||
34 | struct padlock_sha_ctx { | 30 | struct 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), |