hmac-test.c 28.8 KB
Newer Older
Niels Möller's avatar
Niels Möller committed
1
2
3
#include "testutils.h"
#include "hmac.h"

Niels Möller's avatar
Niels Möller committed
4
/* KEY and MSG are supposed to expand to length, data */ 
5
6
7
8
9
10
11
#define HMAC_TEST(alg, length, key, msg, mac) do {		\
  hmac_##alg##_set_key(&alg, key);				\
  hmac_##alg##_update(&alg, msg);				\
  digest[length] = 17;						\
  hmac_##alg##_digest(&alg, length, digest);			\
  ASSERT(MEMEQ (length, digest, mac));				\
  ASSERT(digest[length] == 17);					\
Niels Möller's avatar
Niels Möller committed
12
13
} while (0)

Niels Möller's avatar
Niels Möller committed
14
15
16
17
18
int
test_main(void)
{
  struct hmac_md5_ctx md5;
  struct hmac_sha1_ctx sha1;
19
  struct hmac_sha224_ctx sha224;
Niels Möller's avatar
Niels Möller committed
20
  struct hmac_sha256_ctx sha256;
21
  struct hmac_sha384_ctx sha384;
22
  struct hmac_sha512_ctx sha512;
Niels Möller's avatar
Niels Möller committed
23

24
  /* sha512's digests are longest */
25
  uint8_t digest[SHA512_DIGEST_SIZE+1];
Niels Möller's avatar
Niels Möller committed
26
27

  memset(digest, 0, sizeof(digest));
28

Niels Möller's avatar
Niels Möller committed
29
  /* Test vectors for md5, from RFC-2202 */
30
31

  /* md5 - 1 */
Niels Möller's avatar
Niels Möller committed
32
33
34
35
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b 0b0b0b0b0b0b0b0b"),
	    LDATA("Hi There"),
	    H("9294727a3638bb1c 13f48ef8158bfc9d"));
Niels Möller's avatar
Niels Möller committed
36
37


38
  /* md5 - 2 */
Niels Möller's avatar
Niels Möller committed
39
40
41
42
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("Jefe"),
	    LDATA("what do ya want for nothing?"),
	    H("750c783e6ab0b503 eaa86e310a5db738"));	    
Niels Möller's avatar
Niels Möller committed
43

44
  /* md5 - 3 */
Niels Möller's avatar
Niels Möller committed
45
46
47
48
49
50
51
52
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    HL("dddddddddddddddd dddddddddddddddd"
	       "dddddddddddddddd dddddddddddddddd"
	       "dddddddddddddddd dddddddddddddddd"
	       "dddd"),
	    H("56be34521d144c88 dbb8c733f0e8b3f6"));
  
53
  /* md5 - 4 */
Niels Möller's avatar
Niels Möller committed
54
55
56
57
58
59
60
61
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    HL("0102030405060708 090a0b0c0d0e0f10" 
	       "1112131415161718 19"),
	    HL("cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcd"),
	    H("697eaf0aca3a3aea 3a75164746ffaa79"));
Niels Möller's avatar
Niels Möller committed
62

63
  /* md5 - 5 */
64
65
66
67
  HMAC_TEST(md5, 12,
	    HL("0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c"),
	    LDATA("Test With Truncation"),
	    H("56461ef2342edc00 f9bab995"));
Niels Möller's avatar
Niels Möller committed
68

69
  /* md5 - 6 */
Niels Möller's avatar
Niels Möller committed
70
71
72
73
74
75
76
77
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key - Hash Key First"),
	    H("6b1ab7fe4bd7bf8f 0b62e6ce61b9d0cd"));
Niels Möller's avatar
Niels Möller committed
78

79
  /* md5 - 7 */
Niels Möller's avatar
Niels Möller committed
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key and Larger "
		  "Than One Block-Size Data"),
	    H("6f630fad67cda0ee 1fb1f562db3aa53e"));

  /* Additional test vectors, from Daniel Kahn Gillmor */
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA(""),
	    H("e84db42a188813f30a15e611d64c7869"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("a"),
	    H("123662062e67c2aab371cc49db0df134"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("38"),
	    H("0a46cc10a49d4b7025c040c597bf5d76"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abc"),
	    H("d1f4d89f0e8b2b6ed0623c99ec298310"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("message digest"),
	    H("1627207b9bed5009a4f6e9ca8d2ca01e"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abcdefghijklmnopqrstuvwxyz"),
	    H("922aae6ab3b3a29202e21ce5f916ae9a"));

  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
	    H("ede9cb83679ba82d88fbeae865b3f8fc"));

  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("12345678901234567890123456789012345678901234567890123456789012345678901234567890"),
	    H("939dd45512ee3a594b6654f6b8de27f7"));
  
131
132
133
  /* Test vectors for sha1, from RFC-2202 */

  /* sha1 - 1 */
Niels Möller's avatar
Niels Möller committed
134
135
136
137
  HMAC_TEST(sha1, SHA1_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b 0b0b0b0b0b0b0b0b 0b0b0b0b"),
	    LDATA("Hi There"),
	    H("b617318655057264 e28bc0b6fb378c8e f146be00"));
138
139

  /* sha1 - 2 */
Niels Möller's avatar
Niels Möller committed
140
141
142
143
  HMAC_TEST(sha1, SHA1_DIGEST_SIZE,
	    LDATA("Jefe"),
	    LDATA("what do ya want for nothing?"),
	    H("effcdf6ae5eb2fa2 d27416d5f184df9c 259a7c79"));
144
145

  /* sha1 - 3 */
Niels Möller's avatar
Niels Möller committed
146
147
148
149
150
151
152
  HMAC_TEST(sha1, SHA1_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaa"),
	    HL("dddddddddddddddd dddddddddddddddd"
	       "dddddddddddddddd dddddddddddddddd"
	       "dddddddddddddddd dddddddddddddddd"
	       "dddd"),
	    H("125d7342b9ac11cd 91a39af48aa17b4f 63f175d3"));
153

154
  /* sha1 - 4 */
Niels Möller's avatar
Niels Möller committed
155
156
157
158
159
160
161
162
  HMAC_TEST(sha1, SHA1_DIGEST_SIZE,
	    HL("0102030405060708 090a0b0c0d0e0f10" 
	       "1112131415161718 19"),
	    HL("cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcd"),
	    H("4c9007f4026250c6 bc8414f9bf50c86c 2d7235da"));
163
164

  /* sha1 - 5 */
165
166
167
168
  HMAC_TEST(sha1, 12,
	    HL("0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c 0c0c0c0c"),
	    LDATA("Test With Truncation"),
	    H("4c1a03424b55e07f e7f27be1"));
169
170

  /* sha1 - 6 */
Niels Möller's avatar
Niels Möller committed
171
172
173
174
175
176
177
178
  HMAC_TEST(sha1, SHA1_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key - Hash Key First"),
	    H("aa4ae5e15272d00e 95705637ce8a3b55 ed402112"));
179
180

  /* sha1 - 7 */
Niels Möller's avatar
Niels Möller committed
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
  HMAC_TEST(sha1, SHA1_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key and Larger "
		  "Than One Block-Size Data"),
	    H("e8e99d0f45237d78 6d6bbaa7965c7808 bbff1a91"));

  /* Additional test vectors, from Daniel Kahn Gillmor */
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA(""),
	    H("e84db42a188813f30a15e611d64c7869"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("a"),
	    H("123662062e67c2aab371cc49db0df134"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("38"),
	    H("0a46cc10a49d4b7025c040c597bf5d76"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abc"),
	    H("d1f4d89f0e8b2b6ed0623c99ec298310"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("message digest"),
	    H("1627207b9bed5009a4f6e9ca8d2ca01e"));
  
  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abcdefghijklmnopqrstuvwxyz"),
	    H("922aae6ab3b3a29202e21ce5f916ae9a"));

  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
	    H("ede9cb83679ba82d88fbeae865b3f8fc"));

  HMAC_TEST(md5, MD5_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("12345678901234567890123456789012345678901234567890123456789012345678901234567890"),
	    H("939dd45512ee3a594b6654f6b8de27f7"));
231

232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
  /* Test vectors for sha224, from RFC 4231 */
  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
	       "0b0b0b0b"),
	    LDATA("Hi There"),
	    H("896fb1128abbdf196832107cd49df33f"
	      "47b4b1169912ba4f53684b22"));

  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("Jefe"),
	    LDATA("what do ya want for nothing?"),
	    H("a30e01098bc6dbbf45690f3a7e9e6d0f"
	      "8bbea2a39e6148008fd05e44"));

  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaa"),
	    HL("dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddd"),
	    H("7fb3cb3588c6c1f6ffa9694d7d6ad264"
	      "9365b0c1f65d69d1ec8333ea"));

  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    HL("0102030405060708090a0b0c0d0e0f10"
	       "111213141516171819"),
	    HL("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcd"),
	    H("6c11506874013cac6a2abc1bb382627c"
	      "ec6a90d86efc012de7afec5a"));

  HMAC_TEST(sha224, 16,
	    HL("0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c 0c0c0c0c"),
	    LDATA("Test With Truncation"),
	    H("0e2aea68a90c8d37c988bcdb9fca6fa8"));

  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key - Hash Key First"),
	    H("95e9a0db962095adaebe9b2d6f0dbce2"
	      "d499f112f2d2b7273fa6870e"));

  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("This is a test using a larger than block-size ke"
		  "y and a larger than block-size data. The key nee"
		  "ds to be hashed before being used by the HMAC al"
		  "gorithm."),
	    H("3a854166ac5d9f023f54d517d0b39dbd"
	      "946770db9c2b95c9f6f565d1"));

  /* Additional test vectors, from Daniel Kahn Gillmor */
  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA(""),
	    H("d12a49ae38177ffeaa548b2148bb5238"
	      "60849772d9391e675b103d89"));
  
  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("a"),
	    H("b04ff8522f904f553970bfa8ad3f0086"
	      "bce1e8580affd8a12c94e31a"));
  
  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("38"),
	    H("afcfb5511f710334f9350f57faec3c08"
	      "764b4bd126a6840f4347f116"));
  
  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abc"),
	    H("9df9907af127900c909376893565c6cf"
	      "2d7db244fdc4277da1e0b679"));
  
  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("message digest"),
	    H("254ebf6b8ddd7a3271b3d9aca1699b0c"
	      "0bfb7df61e8a114922c88d27"));
  
  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abcdefghijklmnopqrstuvwxyz"),
	    H("6ec5bffba5880c3234a6cf257816e4d5"
	      "35ab178a7f12929769e378fb"));

  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
	    H("5f768179dbb29ca722875d0f461a2e2f"
	      "597d0210340a84df1a8e9c63"));

  HMAC_TEST(sha224, SHA224_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("12345678901234567890123456789012345678901234567890123456789012345678901234567890"),
	    H("c7667b0d7e56b2b4f6fcc1d8da9e22da"
	      "a1556f44c47132a87303c6a2"));

  /* Test vectors for sha256, from RFC 4231 */
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
	       "0b0b0b0b"),
	    LDATA("Hi There"),
	    H("b0344c61d8db38535ca8afceaf0bf12b"
	      "881dc200c9833da726e9376c2e32cff7"));

  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("Jefe"),
	    LDATA("what do ya want for nothing?"),
	    H("5bdcc146bf60754e6a042426089575c7"
	      "5a003f089d2739839dec58b964ec3843"));

  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaa"),
	    HL("dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddd"),
	    H("773ea91e36800e46854db8ebd09181a7"
	      "2959098b3ef8c122d9635514ced565fe"));

  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("0102030405060708090a0b0c0d0e0f10"
	       "111213141516171819"),
	    HL("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcd"),
	    H("82558a389a443c0ea4cc819899f2083a"
	      "85f0faa3e578f8077a2e3ff46729665b"));

  HMAC_TEST(sha256, 16,
	    HL("0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c 0c0c0c0c"),
	    LDATA("Test With Truncation"),
	    H("a3b6167473100ee06e0c796c2955552b"));

  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key - Hash Key First"),
	    H("60e431591ee0b67f0d8a26aacbf5b77f"
	      "8e0bc6213728c5140546040f0ee37f54"));

  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("This is a test using a larger than block-size ke"
		  "y and a larger than block-size data. The key nee"
		  "ds to be hashed before being used by the HMAC al"
		  "gorithm."),
	    H("9b09ffa71b942fcb27635fbcd5b0e944"
	      "bfdc63644f0713938a7f51535c3a35e2"));

  /* Additional test vectors for sha256, from
     draft-ietf-ipsec-ciph-sha-256-01.txt */
423
424

  /* Test Case #1: HMAC-SHA-256 with 3-byte input and 32-byte key */
425
426
427
428
429
430
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("0102030405060708 090a0b0c0d0e0f10"
	       "1112131415161718 191a1b1c1d1e1f20"),
	    LDATA("abc"),
	    H("a21b1f5d4cf4f73a 4dd939750f7a066a"
		 "7f98cc131cb16a66 92759021cfab8181"));
431
432

  /* Test Case #2: HMAC-SHA-256 with 56-byte input and 32-byte key */
433
434
435
436
437
438
439
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("0102030405060708 090a0b0c0d0e0f10"
	       "1112131415161718 191a1b1c1d1e1f20"),
	    LDATA("abcdbcdecdefdefgefghfghighijhijk"
		  "ijkljklmklmnlmnomnopnopq"),
	    H("104fdc1257328f08 184ba73131c53cae"
		 "e698e36119421149 ea8c712456697d30"));
440
441
442

  /* Test Case #3: HMAC-SHA-256 with 112-byte (multi-block) input
     and 32-byte key */
443
444
445
446
447
448
449
450
451
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("0102030405060708 090a0b0c0d0e0f10"
	       "1112131415161718 191a1b1c1d1e1f20"),
	    LDATA("abcdbcdecdefdefgefghfghighijhijk"
		  "ijkljklmklmnlmnomnopnopqabcdbcde"
		  "cdefdefgefghfghighijhijkijkljklm"
		  "klmnlmnomnopnopq"),
	    H("470305fc7e40fe34 d3eeb3e773d95aab"
	      "73acf0fd060447a5 eb4595bf33a9d1a3"));
452
453

  /* Test Case #4:  HMAC-SHA-256 with 8-byte input and 32-byte key */
454
455
456
457
458
459
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b 0b0b0b0b0b0b0b0b"
	       "0b0b0b0b0b0b0b0b 0b0b0b0b0b0b0b0b"),
	    LDATA("Hi There"),
	    H("198a607eb44bfbc6 9903a0f1cf2bbdc5"
	      "ba0aa3f3d9ae3c1c 7a3b1696a0b68cf7"));
460
461

  /* Test Case #6: HMAC-SHA-256 with 50-byte input and 32-byte key */
462
463
464
465
466
467
468
469
470
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    HL("dddddddddddddddd dddddddddddddddd"
	       "dddddddddddddddd dddddddddddddddd"
	       "dddddddddddddddd dddddddddddddddd"
	       "dddd"),
	    H("cdcb1220d1ecccea 91e53aba3092f962"
	      "e549fe6ce9ed7fdc 43191fbde45c30b0"));
471
472

  /* Test Case #7: HMAC-SHA-256 with 50-byte input and 37-byte key */
473
474
475
476
477
478
479
480
481
482
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("0102030405060708 090a0b0c0d0e0f10"
	       "1112131415161718 191a1b1c1d1e1f20"
	       "2122232425"),
	    HL("cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcd cdcdcdcdcdcdcdcd"
	       "cdcd"),
	    H("d4633c17f6fb8d74 4c66dee0f8f07455"
	      "6ec4af55ef079985 41468eb49bd2e917"));
483
484

  /* Test Case #8: HMAC-SHA-256 with 20-byte input and 32-byte key */
485
486
487
488
489
  HMAC_TEST(sha256, 16,
	    HL("0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c"
	       "0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c"),
	    LDATA("Test With Truncation"),
	    H("7546af01841fc09b 1ab9c3749a5f1c17"));
490
491

  /* Test Case #9: HMAC-SHA-256 with 54-byte input and 80-byte key */
492
493
494
495
496
497
498
499
500
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key - Hash Key First"),
	    H("6953025ed96f0c09 f80a96f78e6538db"
	      "e2e7b820e3dd970e 7ddd39091b32352f"));
501
502
503

  /* Test Case #10: HMAC-SHA-256 with 73-byte (multi-block) input
     and 80-byte key */
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"),
	    H("6355ac22e890d0a3 c8481a5ca4825bc8"
	      "84d3e7a1ff98a2fc 2ac7d8e064c3b2e6"));

  /* Additional test vectors, from Daniel Kahn Gillmor */
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA(""),
	    H("5c780648c90d121c50091c3a0c3afc1f"
	      "4ab847528005d99d9821ad3f341b651a"));
  
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("a"),
	    H("6142364c0646b0cfe426866f21d613e0"
	      "55a136a7d9b45d85685e080a09cec463"));
  
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("38"),
	    H("e49aa7839977e130ad87b63da9d4eb7b"
	      "263cd5a27c54a7604b6044eb35901171"));
  
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abc"),
	    H("e5ef49f545c7af933a9d18c7c562bc91"
	      "08583fd5cf00d9e0db351d6d8f8e41bc"));
  
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("message digest"),
	    H("373b04877180fea27a41a8fb8f88201c"
	      "a6268411ee3c80b01a424483eb9156e1"));
  
  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abcdefghijklmnopqrstuvwxyz"),
	    H("eb5945d56eefbdb41602946ea6448d53"
	      "86b08d7d801a87f439fab52f8bb9736e"));

  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
	    H("3798f363c57afa6edaffe39016ca7bad"
	      "efd1e670afb0e3987194307dec3197db"));

  HMAC_TEST(sha256, SHA256_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("12345678901234567890123456789012345678901234567890123456789012345678901234567890"),
	    H("c89a7039a62985ff813fe4509b918a43"
	      "6d7b1ffd8778e2c24dec464849fb6128"));

  /* Test vectors for sha384, from RFC 4231 */
  HMAC_TEST(sha384, SHA384_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
	       "0b0b0b0b"),
	    LDATA("Hi There"),
	    H("afd03944d84895626b0825f4ab46907f"
	      "15f9dadbe4101ec682aa034c7cebc59c"
	      "faea9ea9076ede7f4af152e8b2fa9cb6"));

  HMAC_TEST(sha384, SHA384_DIGEST_SIZE,
	    LDATA("Jefe"),
	    LDATA("what do ya want for nothing?"),
	    H("af45d2e376484031617f78d2b58a6b1b"
	      "9c7ef464f5a01b47e42ec3736322445e"
	      "8e2240ca5e69e2c78b3239ecfab21649"));

  HMAC_TEST(sha384, SHA384_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaa"),
	    HL("dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddd"),
	    H("88062608d3e6ad8a0aa2ace014c8a86f"
	      "0aa635d947ac9febe83ef4e55966144b"
	      "2a5ab39dc13814b94e3ab6e101a34f27"));

  HMAC_TEST(sha384, SHA384_DIGEST_SIZE,
	    HL("0102030405060708090a0b0c0d0e0f10"
	       "111213141516171819"),
	    HL("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcd"),
	    H("3e8a69b7783c25851933ab6290af6ca7"
	      "7a9981480850009cc5577c6e1f573b4e"
	      "6801dd23c4a7d679ccf8a386c674cffb"));

  HMAC_TEST(sha384, 16,
	    HL("0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c 0c0c0c0c"),
	    LDATA("Test With Truncation"),
	    H("3abf34c3503b2a23a46efc619baef897"));

  HMAC_TEST(sha384, SHA384_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key - Hash Key First"),
	    H("4ece084485813e9088d2c63a041bc5b4"
	      "4f9ef1012a2b588f3cd11f05033ac4c6"
	      "0c2ef6ab4030fe8296248df163f44952"));

  HMAC_TEST(sha384, SHA384_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("This is a test using a larger than block-size ke"
		  "y and a larger than block-size data. The key nee"
		  "ds to be hashed before being used by the HMAC al"
		  "gorithm."),
	    H("6617178e941f020d351e2f254e8fd32c"
	      "602420feb0b8fb9adccebb82461e99c5"
	      "a678cc31e799176d3860e6110c46523e"));

  /* Test vectors for sha512, from RFC 4231 */
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
	       "0b0b0b0b"),
	    LDATA("Hi There"),
	    H("87aa7cdea5ef619d4ff0b4241a1d6cb0"
	      "2379f4e2ce4ec2787ad0b30545e17cde"
	      "daa833b7d6b8a702038b274eaea3f4e4"
	      "be9d914eeb61f1702e696c203a126854"));

  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("Jefe"),
	    LDATA("what do ya want for nothing?"),
	    H("164b7a7bfcf819e2e395fbe73b56e0a3"
	      "87bd64222e831fd610270cd7ea250554"
	      "9758bf75c05a994a6d034f65f8f0e6fd"
	      "caeab1a34d4a6b4b636e070a38bce737"));

  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaa"),
	    HL("dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddd"),
	    H("fa73b0089d56a284efb0f0756c890be9"
	      "b1b5dbdd8ee81a3655f83e33b2279d39"
	      "bf3e848279a722c806b485a47e67c807"
	      "b946a337bee8942674278859e13292fb"));

  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    HL("0102030405060708090a0b0c0d0e0f10"
	       "111213141516171819"),
	    HL("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
	       "cdcd"),
	    H("b0ba465637458c6990e5a8c5f61d4af7"
	      "e576d97ff94b872de76f8050361ee3db"
	      "a91ca5c11aa25eb4d679275cc5788063"
	      "a5f19741120c4f2de2adebeb10a298dd"));

  HMAC_TEST(sha512, 16,
	    HL("0c0c0c0c0c0c0c0c 0c0c0c0c0c0c0c0c 0c0c0c0c"),
	    LDATA("Test With Truncation"),
	    H("415fad6271580a531d4179bc891d87a6"));

  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("Test Using Larger Than Block-Size Key - Hash Key First"),
	    H("80b24263c7c1a3ebb71493c1dd7be8b4"
	      "9b46d1f41b4aeec1121b013783f8f352"
	      "6b56d037e05f2598bd0fd2215d6a1e52"
	      "95e64f73f63f0aec8b915a985d786598"));

  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaa"),
	    LDATA("This is a test using a larger than block-size ke"
		  "y and a larger than block-size data. The key nee"
		  "ds to be hashed before being used by the HMAC al"
		  "gorithm."),
	    H("e37b6a775dc87dbaa4dfa9f96e5e3ffd"
	      "debd71f8867289865df5a32d20cdc944"
	      "b6022cac3c4982b10d5eeb55c3e4de15"
	      "134676fb6de0446065c97440fa8c6a58"));

  /* Additional test vectors, from Daniel Kahn Gillmor */
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA(""),
	    H("34316413c2d6940572d0bbbf099d529d"
	      "148b424533cf562bc1b365f530e21a31"
	      "799fc51cef78060cc6f448a8e5d780c2"
	      "6cdf20d4c3e6f27fe5ef576bbd05e855"));
  
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("a"),
	    H("cf1948507378bc3ab58cb6ec87f4d456"
	      "b90d3298395c29873f1ded1e111b50fe"
	      "c336ed24684bf19716efc309212f37aa"
	      "715cfb9ecccf3af13691ded167b4b336"));
  
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("38"),
	    H("b8201784216ce01b83cdd282616c6e89"
	      "644c6dfd1269ed8580bbc39b92add364"
	      "c2b2a2018cffb1915e8625e473b67d0f"
	      "e54a50e475dfa0e2b1a97bac1383792c"));
  
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abc"),
	    H("f097ee08b8c44e847a384f9fd645e35e"
	      "4816baa9791ba39d3dc611210500b044"
	      "873ee296bf1047dc06daa201a5767192"
	      "5b73b4ea59c60114881c8287d0699c83"));
  
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("message digest"),
	    H("921a441a884b83c76a8526da8e60d60d"
	      "17ded4eee5c29375e0d93717669a4c3e"
	      "eba7473e95f7c1a2a85afc24a0adbc4d"
	      "6c2bdd6ca6cab8b18d19f82d4a6c51bc"));
  
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("abcdefghijklmnopqrstuvwxyz"),
	    H("640054c96f35815095617d0a8c956066"
	      "1a6ff46bfb39110333b2c52c8866abfb"
	      "59d9152c9b0948c1ed65c3fd72a8fb82"
	      "190acc8830770afe5b0c5b6414c75a77"));

  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"),
	    H("835a4f5b3750b4c1fccfa88da2f746a4"
	      "900160c9f18964309bb736c13b59491b"
	      "8e32d37b724cc5aebb0f554c6338a3b5"
	      "94c4ba26862b2dadb59b7ede1d08d53e"));

  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("monkey monkey monkey monkey"),
	    LDATA("12345678901234567890123456789012345678901234567890123456789012345678901234567890"),
	    H("fdf83dc879e3476c8e8aceff2bf6fece"
	      "2e4f39c7e1a167845465bb549dfa5ffe"
	      "997e6c7cf3720eae51ed2b00ad2a8225"
	      "375092290edfa9d48ec7e4bc8e276088"));

  /* Additional test vectors, from
     draft-kelly-ipsec-ciph-sha2-01.txt */
788
789

  /* Test case AUTH512-1: */
790
791
792
793
794
795
796
797
798
799
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    HL("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
	       "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
	       "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"
	       "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"),
	    LDATA("Hi There"),
	    H("637edc6e01dce7e6742a99451aae82df"
	      "23da3e92439e590e43e761b33e910fb8"
	      "ac2878ebd5803f6f0b61dbce5e251ff8"
	      "789a4722c1be65aea45fd464e89f8f5b"));
800
801

  /* Test case AUTH512-2: */
802
803
804
805
806
807
808
809
810
811
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    LDATA("JefeJefeJefeJefe"
		  "JefeJefeJefeJefe"
		  "JefeJefeJefeJefe"
		  "JefeJefeJefeJefe"),	    
	    LDATA("what do ya want for nothing?"),
	    H("cb370917ae8a7ce28cfd1d8f4705d614"
	      "1c173b2a9362c15df235dfb251b15454"
	      "6aa334ae9fb9afc2184932d8695e397b"
	      "fa0ffb93466cfcceaae38c833b7dba38"));
812
813

  /* Test case AUTH512-3: */
814
815
816
817
818
819
820
821
822
823
824
825
826
  HMAC_TEST(sha512, SHA512_DIGEST_SIZE,
	    HL("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
	       "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
	    HL("dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddddddddddddddddddddddddddddddd"
	       "dddd"),
	    H("2ee7acd783624ca9398710f3ee05ae41"
	      "b9f9b0510c87e49e586cc9bf961733d8"
	      "623c7b55cebefccf02d5581acc1c9d5f"
	      "b1ff68a1de45509fbe4da9a433922655"));
827
828

  /* Test case AUTH512-3 from same document seems broken. */
Niels Möller's avatar
Niels Möller committed
829
  
Niels Möller's avatar
Niels Möller committed
830
831
  SUCCESS();
}