aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Lynch <jonathan.lynch@intel.com>2007-11-10 07:08:25 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2008-01-10 16:16:12 -0500
commitcd12fb906d2591e80da9edcbd4794b9b916d7489 (patch)
tree312f7ff32b70a1c093fd3d45e6f2a0715008f22b
parentcd7c3bfe54270f41ac52be6b725a7194d99175b4 (diff)
[CRYPTO] sha256-generic: Extend sha256_generic.c to support SHA-224
Resubmitting this patch which extends sha256_generic.c to support SHA-224 as described in FIPS 180-2 and RFC 3874. HMAC-SHA-224 as described in RFC4231 is then supported through the hmac interface. Patch includes test vectors for SHA-224 and HMAC-SHA-224. SHA-224 chould be chosen as a hash algorithm when 112 bits of security strength is required. Patch generated against the 2.6.24-rc1 kernel and tested against 2.6.24-rc1-git14 which includes fix for scatter gather implementation for HMAC. Signed-off-by: Jonathan Lynch <jonathan.lynch@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/Kconfig5
-rw-r--r--crypto/sha256_generic.c72
-rw-r--r--crypto/tcrypt.c22
-rw-r--r--crypto/tcrypt.h142
-rw-r--r--include/crypto/sha.h12
5 files changed, 241 insertions, 12 deletions
diff --git a/crypto/Kconfig b/crypto/Kconfig
index cf115b14079e..7758454b9f17 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -91,7 +91,7 @@ config CRYPTO_SHA1
91 SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2). 91 SHA-1 secure hash standard (FIPS 180-1/DFIPS 180-2).
92 92
93config CRYPTO_SHA256 93config CRYPTO_SHA256
94 tristate "SHA256 digest algorithm" 94 tristate "SHA224 and SHA256 digest algorithm"
95 select CRYPTO_ALGAPI 95 select CRYPTO_ALGAPI
96 help 96 help
97 SHA256 secure hash standard (DFIPS 180-2). 97 SHA256 secure hash standard (DFIPS 180-2).
@@ -99,6 +99,9 @@ config CRYPTO_SHA256
99 This version of SHA implements a 256 bit hash with 128 bits of 99 This version of SHA implements a 256 bit hash with 128 bits of
100 security against collision attacks. 100 security against collision attacks.
101 101
102 This code also includes SHA-224, a 224 bit hash with 112 bits
103 of security against collision attacks.
104
102config CRYPTO_SHA512 105config CRYPTO_SHA512
103 tristate "SHA384 and SHA512 digest algorithms" 106 tristate "SHA384 and SHA512 digest algorithms"
104 select CRYPTO_ALGAPI 107 select CRYPTO_ALGAPI
diff --git a/crypto/sha256_generic.c b/crypto/sha256_generic.c
index fd3918be58b5..3cc93fd61043 100644
--- a/crypto/sha256_generic.c
+++ b/crypto/sha256_generic.c
@@ -9,6 +9,7 @@
9 * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com> 9 * Copyright (c) Jean-Luc Cooke <jlcooke@certainkey.com>
10 * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk> 10 * Copyright (c) Andrew McDonald <andrew@mcdonald.org.uk>
11 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au> 11 * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
12 * SHA224 Support Copyright 2007 Intel Corporation <jonathan.lynch@intel.com>
12 * 13 *
13 * This program is free software; you can redistribute it and/or modify it 14 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free 15 * under the terms of the GNU General Public License as published by the Free
@@ -218,6 +219,22 @@ static void sha256_transform(u32 *state, const u8 *input)
218 memset(W, 0, 64 * sizeof(u32)); 219 memset(W, 0, 64 * sizeof(u32));
219} 220}
220 221
222
223static void sha224_init(struct crypto_tfm *tfm)
224{
225 struct sha256_ctx *sctx = crypto_tfm_ctx(tfm);
226 sctx->state[0] = SHA224_H0;
227 sctx->state[1] = SHA224_H1;
228 sctx->state[2] = SHA224_H2;
229 sctx->state[3] = SHA224_H3;
230 sctx->state[4] = SHA224_H4;
231 sctx->state[5] = SHA224_H5;
232 sctx->state[6] = SHA224_H6;
233 sctx->state[7] = SHA224_H7;
234 sctx->count[0] = 0;
235 sctx->count[1] = 0;
236}
237
221static void sha256_init(struct crypto_tfm *tfm) 238static void sha256_init(struct crypto_tfm *tfm)
222{ 239{
223 struct sha256_ctx *sctx = crypto_tfm_ctx(tfm); 240 struct sha256_ctx *sctx = crypto_tfm_ctx(tfm);
@@ -294,8 +311,17 @@ static void sha256_final(struct crypto_tfm *tfm, u8 *out)
294 memset(sctx, 0, sizeof(*sctx)); 311 memset(sctx, 0, sizeof(*sctx));
295} 312}
296 313
314static void sha224_final(struct crypto_tfm *tfm, u8 *hash)
315{
316 u8 D[SHA256_DIGEST_SIZE];
317
318 sha256_final(tfm, D);
319
320 memcpy(hash, D, SHA224_DIGEST_SIZE);
321 memset(D, 0, SHA256_DIGEST_SIZE);
322}
297 323
298static struct crypto_alg alg = { 324static struct crypto_alg sha256 = {
299 .cra_name = "sha256", 325 .cra_name = "sha256",
300 .cra_driver_name= "sha256-generic", 326 .cra_driver_name= "sha256-generic",
301 .cra_flags = CRYPTO_ALG_TYPE_DIGEST, 327 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
@@ -303,28 +329,58 @@ static struct crypto_alg alg = {
303 .cra_ctxsize = sizeof(struct sha256_ctx), 329 .cra_ctxsize = sizeof(struct sha256_ctx),
304 .cra_module = THIS_MODULE, 330 .cra_module = THIS_MODULE,
305 .cra_alignmask = 3, 331 .cra_alignmask = 3,
306 .cra_list = LIST_HEAD_INIT(alg.cra_list), 332 .cra_list = LIST_HEAD_INIT(sha256.cra_list),
307 .cra_u = { .digest = { 333 .cra_u = { .digest = {
308 .dia_digestsize = SHA256_DIGEST_SIZE, 334 .dia_digestsize = SHA256_DIGEST_SIZE,
309 .dia_init = sha256_init, 335 .dia_init = sha256_init,
310 .dia_update = sha256_update, 336 .dia_update = sha256_update,
311 .dia_final = sha256_final } } 337 .dia_final = sha256_final } }
338};
339
340static struct crypto_alg sha224 = {
341 .cra_name = "sha224",
342 .cra_driver_name = "sha224-generic",
343 .cra_flags = CRYPTO_ALG_TYPE_DIGEST,
344 .cra_blocksize = SHA224_BLOCK_SIZE,
345 .cra_ctxsize = sizeof(struct sha256_ctx),
346 .cra_module = THIS_MODULE,
347 .cra_alignmask = 3,
348 .cra_list = LIST_HEAD_INIT(sha224.cra_list),
349 .cra_u = { .digest = {
350 .dia_digestsize = SHA224_DIGEST_SIZE,
351 .dia_init = sha224_init,
352 .dia_update = sha256_update,
353 .dia_final = sha224_final } }
312}; 354};
313 355
314static int __init init(void) 356static int __init init(void)
315{ 357{
316 return crypto_register_alg(&alg); 358 int ret = 0;
359
360 ret = crypto_register_alg(&sha224);
361
362 if (ret < 0)
363 return ret;
364
365 ret = crypto_register_alg(&sha256);
366
367 if (ret < 0)
368 crypto_unregister_alg(&sha224);
369
370 return ret;
317} 371}
318 372
319static void __exit fini(void) 373static void __exit fini(void)
320{ 374{
321 crypto_unregister_alg(&alg); 375 crypto_unregister_alg(&sha224);
376 crypto_unregister_alg(&sha256);
322} 377}
323 378
324module_init(init); 379module_init(init);
325module_exit(fini); 380module_exit(fini);
326 381
327MODULE_LICENSE("GPL"); 382MODULE_LICENSE("GPL");
328MODULE_DESCRIPTION("SHA256 Secure Hash Algorithm"); 383MODULE_DESCRIPTION("SHA-224 and SHA-256 Secure Hash Algorithm");
329 384
385MODULE_ALIAS("sha224");
330MODULE_ALIAS("sha256"); 386MODULE_ALIAS("sha256");
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index aa84bc4f2313..4d364ccacbb2 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -12,6 +12,7 @@
12 * Software Foundation; either version 2 of the License, or (at your option) 12 * Software Foundation; either version 2 of the License, or (at your option)
13 * any later version. 13 * any later version.
14 * 14 *
15 * 2007-11-06 Added SHA-224 and SHA-224-HMAC tests
15 * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests 16 * 2006-12-07 Added SHA384 HMAC and SHA512 HMAC tests
16 * 2004-08-09 Added cipher speed tests (Reyk Floeter <reyk@vantronix.net>) 17 * 2004-08-09 Added cipher speed tests (Reyk Floeter <reyk@vantronix.net>)
17 * 2003-09-14 Rewritten by Kartikey Mahendra Bhatt 18 * 2003-09-14 Rewritten by Kartikey Mahendra Bhatt
@@ -74,8 +75,9 @@ static char *xbuf;
74static char *tvmem; 75static char *tvmem;
75 76
76static char *check[] = { 77static char *check[] = {
77 "des", "md5", "des3_ede", "rot13", "sha1", "sha256", "blowfish", 78 "des", "md5", "des3_ede", "rot13", "sha1", "sha224", "sha256",
78 "twofish", "serpent", "sha384", "sha512", "md4", "aes", "cast6", 79 "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes",
80 "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
79 "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", 81 "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea",
80 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", 82 "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt",
81 "camellia", "seed", NULL 83 "camellia", "seed", NULL
@@ -918,6 +920,8 @@ static void do_test(void)
918 920
919 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS); 921 test_hash("md4", md4_tv_template, MD4_TEST_VECTORS);
920 922
923 test_hash("sha224", sha224_tv_template, SHA224_TEST_VECTORS);
924
921 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS); 925 test_hash("sha256", sha256_tv_template, SHA256_TEST_VECTORS);
922 926
923 //BLOWFISH 927 //BLOWFISH
@@ -1067,6 +1071,8 @@ static void do_test(void)
1067 HMAC_MD5_TEST_VECTORS); 1071 HMAC_MD5_TEST_VECTORS);
1068 test_hash("hmac(sha1)", hmac_sha1_tv_template, 1072 test_hash("hmac(sha1)", hmac_sha1_tv_template,
1069 HMAC_SHA1_TEST_VECTORS); 1073 HMAC_SHA1_TEST_VECTORS);
1074 test_hash("hmac(sha224)", hmac_sha224_tv_template,
1075 HMAC_SHA224_TEST_VECTORS);
1070 test_hash("hmac(sha256)", hmac_sha256_tv_template, 1076 test_hash("hmac(sha256)", hmac_sha256_tv_template,
1071 HMAC_SHA256_TEST_VECTORS); 1077 HMAC_SHA256_TEST_VECTORS);
1072 test_hash("hmac(sha384)", hmac_sha384_tv_template, 1078 test_hash("hmac(sha384)", hmac_sha384_tv_template,
@@ -1299,6 +1305,9 @@ static void do_test(void)
1299 camellia_cbc_dec_tv_template, 1305 camellia_cbc_dec_tv_template,
1300 CAMELLIA_CBC_DEC_TEST_VECTORS); 1306 CAMELLIA_CBC_DEC_TEST_VECTORS);
1301 break; 1307 break;
1308 case 33:
1309 test_hash("sha224", sha224_tv_template, SHA224_TEST_VECTORS);
1310 break;
1302 1311
1303 case 100: 1312 case 100:
1304 test_hash("hmac(md5)", hmac_md5_tv_template, 1313 test_hash("hmac(md5)", hmac_md5_tv_template,
@@ -1324,7 +1333,10 @@ static void do_test(void)
1324 test_hash("hmac(sha512)", hmac_sha512_tv_template, 1333 test_hash("hmac(sha512)", hmac_sha512_tv_template,
1325 HMAC_SHA512_TEST_VECTORS); 1334 HMAC_SHA512_TEST_VECTORS);
1326 break; 1335 break;
1327 1336 case 105:
1337 test_hash("hmac(sha224)", hmac_sha224_tv_template,
1338 HMAC_SHA224_TEST_VECTORS);
1339 break;
1328 1340
1329 case 200: 1341 case 200:
1330 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0, 1342 test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
@@ -1459,6 +1471,10 @@ static void do_test(void)
1459 test_hash_speed("tgr192", sec, generic_hash_speed_template); 1471 test_hash_speed("tgr192", sec, generic_hash_speed_template);
1460 if (mode > 300 && mode < 400) break; 1472 if (mode > 300 && mode < 400) break;
1461 1473
1474 case 313:
1475 test_hash_speed("sha224", sec, generic_hash_speed_template);
1476 if (mode > 300 && mode < 400) break;
1477
1462 case 399: 1478 case 399:
1463 break; 1479 break;
1464 1480
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h
index f7f9b2379270..b91585ea1362 100644
--- a/crypto/tcrypt.h
+++ b/crypto/tcrypt.h
@@ -173,6 +173,33 @@ static struct hash_testvec sha1_tv_template[] = {
173 } 173 }
174}; 174};
175 175
176
177/*
178 * SHA224 test vectors from from FIPS PUB 180-2
179 */
180#define SHA224_TEST_VECTORS 2
181
182static struct hash_testvec sha224_tv_template[] = {
183 {
184 .plaintext = "abc",
185 .psize = 3,
186 .digest = { 0x23, 0x09, 0x7D, 0x22, 0x34, 0x05, 0xD8, 0x22,
187 0x86, 0x42, 0xA4, 0x77, 0xBD, 0xA2, 0x55, 0xB3,
188 0x2A, 0xAD, 0xBC, 0xE4, 0xBD, 0xA0, 0xB3, 0xF7,
189 0xE3, 0x6C, 0x9D, 0xA7},
190 }, {
191 .plaintext =
192 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
193 .psize = 56,
194 .digest = { 0x75, 0x38, 0x8B, 0x16, 0x51, 0x27, 0x76, 0xCC,
195 0x5D, 0xBA, 0x5D, 0xA1, 0xFD, 0x89, 0x01, 0x50,
196 0xB0, 0xC6, 0x45, 0x5C, 0xB4, 0xF5, 0x8B, 0x19,
197 0x52, 0x52, 0x25, 0x25 },
198 .np = 2,
199 .tap = { 28, 28 }
200 }
201};
202
176/* 203/*
177 * SHA256 test vectors from from NIST 204 * SHA256 test vectors from from NIST
178 */ 205 */
@@ -817,6 +844,121 @@ static struct hash_testvec hmac_sha1_tv_template[] = {
817 }, 844 },
818}; 845};
819 846
847
848/*
849 * SHA224 HMAC test vectors from RFC4231
850 */
851#define HMAC_SHA224_TEST_VECTORS 4
852
853static struct hash_testvec hmac_sha224_tv_template[] = {
854 {
855 .key = { 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
856 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
857 0x0b, 0x0b, 0x0b, 0x0b },
858 .ksize = 20,
859 /* ("Hi There") */
860 .plaintext = { 0x48, 0x69, 0x20, 0x54, 0x68, 0x65, 0x72, 0x65 },
861 .psize = 8,
862 .digest = { 0x89, 0x6f, 0xb1, 0x12, 0x8a, 0xbb, 0xdf, 0x19,
863 0x68, 0x32, 0x10, 0x7c, 0xd4, 0x9d, 0xf3, 0x3f,
864 0x47, 0xb4, 0xb1, 0x16, 0x99, 0x12, 0xba, 0x4f,
865 0x53, 0x68, 0x4b, 0x22},
866 }, {
867 .key = { 0x4a, 0x65, 0x66, 0x65 }, /* ("Jefe") */
868 .ksize = 4,
869 /* ("what do ya want for nothing?") */
870 .plaintext = { 0x77, 0x68, 0x61, 0x74, 0x20, 0x64, 0x6f, 0x20,
871 0x79, 0x61, 0x20, 0x77, 0x61, 0x6e, 0x74, 0x20,
872 0x66, 0x6f, 0x72, 0x20, 0x6e, 0x6f, 0x74, 0x68,
873 0x69, 0x6e, 0x67, 0x3f },
874 .psize = 28,
875 .digest = { 0xa3, 0x0e, 0x01, 0x09, 0x8b, 0xc6, 0xdb, 0xbf,
876 0x45, 0x69, 0x0f, 0x3a, 0x7e, 0x9e, 0x6d, 0x0f,
877 0x8b, 0xbe, 0xa2, 0xa3, 0x9e, 0x61, 0x48, 0x00,
878 0x8f, 0xd0, 0x5e, 0x44 },
879 .np = 4,
880 .tap = { 7, 7, 7, 7 }
881 }, {
882 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
883 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
884 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
885 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
886 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
887 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
888 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
889 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
890 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
891 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
892 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
893 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
894 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
895 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
896 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
897 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
898 0xaa, 0xaa, 0xaa },
899 .ksize = 131,
900 /* ("Test Using Larger Than Block-Size Key - Hash Key First") */
901 .plaintext = { 0x54, 0x65, 0x73, 0x74, 0x20, 0x55, 0x73, 0x69,
902 0x6e, 0x67, 0x20, 0x4c, 0x61, 0x72, 0x67, 0x65,
903 0x72, 0x20, 0x54, 0x68, 0x61, 0x6e, 0x20, 0x42,
904 0x6c, 0x6f, 0x63, 0x6b, 0x2d, 0x53, 0x69, 0x7a,
905 0x65, 0x20, 0x4b, 0x65, 0x79, 0x20, 0x2d, 0x20,
906 0x48, 0x61, 0x73, 0x68, 0x20, 0x4b, 0x65, 0x79,
907 0x20, 0x46, 0x69, 0x72, 0x73, 0x74 },
908 .psize = 54,
909 .digest = { 0x95, 0xe9, 0xa0, 0xdb, 0x96, 0x20, 0x95, 0xad,
910 0xae, 0xbe, 0x9b, 0x2d, 0x6f, 0x0d, 0xbc, 0xe2,
911 0xd4, 0x99, 0xf1, 0x12, 0xf2, 0xd2, 0xb7, 0x27,
912 0x3f, 0xa6, 0x87, 0x0e },
913 }, {
914 .key = { 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
915 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
916 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
917 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
918 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
919 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
920 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
921 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
922 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
923 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
924 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
925 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
926 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
927 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
928 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
929 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
930 0xaa, 0xaa, 0xaa },
931 .ksize = 131,
932 /* ("This is a test using a larger than block-size key and a")
933 (" larger than block-size data. The key needs to be")
934 (" hashed before being used by the HMAC algorithm.") */
935 .plaintext = { 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
936 0x61, 0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x75,
937 0x73, 0x69, 0x6e, 0x67, 0x20, 0x61, 0x20, 0x6c,
938 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74, 0x68,
939 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63, 0x6b,
940 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x6b, 0x65,
941 0x79, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x61, 0x20,
942 0x6c, 0x61, 0x72, 0x67, 0x65, 0x72, 0x20, 0x74,
943 0x68, 0x61, 0x6e, 0x20, 0x62, 0x6c, 0x6f, 0x63,
944 0x6b, 0x2d, 0x73, 0x69, 0x7a, 0x65, 0x20, 0x64,
945 0x61, 0x74, 0x61, 0x2e, 0x20, 0x54, 0x68, 0x65,
946 0x20, 0x6b, 0x65, 0x79, 0x20, 0x6e, 0x65, 0x65,
947 0x64, 0x73, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65,
948 0x20, 0x68, 0x61, 0x73, 0x68, 0x65, 0x64, 0x20,
949 0x62, 0x65, 0x66, 0x6f, 0x72, 0x65, 0x20, 0x62,
950 0x65, 0x69, 0x6e, 0x67, 0x20, 0x75, 0x73, 0x65,
951 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, 0x68, 0x65,
952 0x20, 0x48, 0x4d, 0x41, 0x43, 0x20, 0x61, 0x6c,
953 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d, 0x2e },
954 .psize = 152,
955 .digest = { 0x3a, 0x85, 0x41, 0x66, 0xac, 0x5d, 0x9f, 0x02,
956 0x3f, 0x54, 0xd5, 0x17, 0xd0, 0xb3, 0x9d, 0xbd,
957 0x94, 0x67, 0x70, 0xdb, 0x9c, 0x2b, 0x95, 0xc9,
958 0xf6, 0xf5, 0x65, 0xd1 },
959 },
960};
961
820/* 962/*
821 * HMAC-SHA256 test vectors from 963 * HMAC-SHA256 test vectors from
822 * draft-ietf-ipsec-ciph-sha-256-01.txt 964 * draft-ietf-ipsec-ciph-sha-256-01.txt
diff --git a/include/crypto/sha.h b/include/crypto/sha.h
index 0686e1f7a24b..c0ccc2b1a2d8 100644
--- a/include/crypto/sha.h
+++ b/include/crypto/sha.h
@@ -8,6 +8,9 @@
8#define SHA1_DIGEST_SIZE 20 8#define SHA1_DIGEST_SIZE 20
9#define SHA1_BLOCK_SIZE 64 9#define SHA1_BLOCK_SIZE 64
10 10
11#define SHA224_DIGEST_SIZE 28
12#define SHA224_BLOCK_SIZE 64
13
11#define SHA256_DIGEST_SIZE 32 14#define SHA256_DIGEST_SIZE 32
12#define SHA256_BLOCK_SIZE 64 15#define SHA256_BLOCK_SIZE 64
13 16
@@ -23,6 +26,15 @@
23#define SHA1_H3 0x10325476UL 26#define SHA1_H3 0x10325476UL
24#define SHA1_H4 0xc3d2e1f0UL 27#define SHA1_H4 0xc3d2e1f0UL
25 28
29#define SHA224_H0 0xc1059ed8UL
30#define SHA224_H1 0x367cd507UL
31#define SHA224_H2 0x3070dd17UL
32#define SHA224_H3 0xf70e5939UL
33#define SHA224_H4 0xffc00b31UL
34#define SHA224_H5 0x68581511UL
35#define SHA224_H6 0x64f98fa7UL
36#define SHA224_H7 0xbefa4fa4UL
37
26#define SHA256_H0 0x6a09e667UL 38#define SHA256_H0 0x6a09e667UL
27#define SHA256_H1 0xbb67ae85UL 39#define SHA256_H1 0xbb67ae85UL
28#define SHA256_H2 0x3c6ef372UL 40#define SHA256_H2 0x3c6ef372UL