summaryrefslogtreecommitdiffstats
path: root/src/spdk/intel-ipsec-mb/LibTestApp/hmac_md5_test.c
blob: ede7fe22c35e78f9b0d893a251a7baf186880a23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
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
/*****************************************************************************
 Copyright (c) 2018, Intel Corporation

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:

     * Redistributions of source code must retain the above copyright notice,
       this list of conditions and the following disclaimer.
     * Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
     * Neither the name of Intel Corporation nor the names of its contributors
       may be used to endorse or promote products derived from this software
       without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/

#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include <intel-ipsec-mb.h>
#include "gcm_ctr_vectors_test.h"
#include "utils.h"

int hmac_md5_test(const enum arch_type arch, struct MB_MGR *mb_mgr);

#define block_size    64
#define digest_size   16
#define digest96_size 12

/*
 * Test vectors from https://tools.ietf.org/html/rfc2202
 */

/*
 * 2.  Test Case 1
 *
 *    Key =          0x0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b
 *
 *    Key length =   16
 *
 *    Data =         "Hi There"
 *
 *    Data length =  8
 *
 *    Digest =       0x9294727a3638bb1c13f48ef8158bfc9d
 *
 *    Digest96 =     0x9294727a3638bb1c13f48ef8
 */
#define test_case1      "1"
#define test_case_l1    "1_long"
#define key_len1        16
#define data_len1       8
#define digest_len1     digest96_size
#define digest_len_l1   digest_size
static const uint8_t key1[key_len1] = {
        0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
        0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
};
static const char data1[] = "Hi There";
static const uint8_t digest1[digest_len_l1] = {
        0x92, 0x94, 0x72, 0x7a, 0x36, 0x38, 0xbb, 0x1c,
        0x13, 0xf4, 0x8e, 0xf8, 0x15, 0x8b, 0xfc, 0x9d
};

/*
 * 2.  Test Case 2
 *
 *    Key =          "Jefe"
 *
 *    Key length =   4
 *
 *    Data =         "what do ya want for nothing?"
 *
 *    Data length =  28
 *
 *    Digest =       0x750c783e6ab0b503eaa86e310a5db738
 *
 *    Digest96 =     0x750c783e6ab0b503eaa86e31
 */
#define test_case2    "2"
#define test_case_l2  "2_long"
#define key_len2      4
#define data_len2     28
#define digest_len2   digest96_size
#define digest_len_l2 digest_size
static const char key2[] = "Jefe";
static const char data2[] = "what do ya want for nothing?";
static const uint8_t digest2[digest_len_l2] = {
        0x75, 0x0c, 0x78, 0x3e, 0x6a, 0xb0, 0xb5, 0x03,
        0xea, 0xa8, 0x6e, 0x31, 0x0a, 0x5d, 0xb7, 0x38
};

/*
 * 2.  Test Case 3
 *
 *    Key =          0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 *
 *    Key length =   16
 *
 *    Data =         0xdd (repeated 50 times)
 *
 *    Data length =  50
 *
 *    Digest =       0x56be34521d144c88dbb8c733f0e8b3f6
 *
 *    Digest96 =     0x56be34521d144c88dbb8c733
 */
#define test_case3    "3"
#define test_case_l3  "3_long"
#define key_len3      16
#define data_len3     50
#define digest_len3   digest96_size
#define digest_len_l3 digest_size
static const uint8_t key3[key_len3] = {
        0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
        0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
};
static const uint8_t data3[data_len3] = {
        0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
        0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
        0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
        0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
        0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
        0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd, 0xdd,
        0xdd, 0xdd
};
static const uint8_t digest3[digest_len_l3] = {
        0x56, 0xbe, 0x34, 0x52, 0x1d, 0x14, 0x4c, 0x88,
        0xdb, 0xb8, 0xc7, 0x33, 0xf0, 0xe8, 0xb3, 0xf6
};

/*
 * 2.  Test Case 4
 *
 *    Key =          0x0102030405060708090a0b0c0d0e0f10111213141516171819
 *
 *    Key length =   25
 *
 *    Data =         0xcd (repeated 50 times)
 *
 *    Data length =  50
 *
 *    Digest =       0x697eaf0aca3a3aea3a75164746ffaa79
 *
 *    Digest96 =     0x697eaf0aca3a3aea3a751647
 */
#define test_case4    "4"
#define test_case_l4  "4_long"
#define key_len4      25
#define data_len4     50
#define digest_len4   digest96_size
#define digest_len_l4 digest_size
static const uint8_t key4[key_len4] = {
        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
        0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
        0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18,
        0x19
};
static const uint8_t data4[data_len4] = {
        0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
        0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
        0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
        0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
        0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
        0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd, 0xcd,
        0xcd, 0xcd
};
static const uint8_t digest4[digest_len_l4] = {
        0x69, 0x7e, 0xaf, 0x0a, 0xca, 0x3a, 0x3a, 0xea,
        0x3a, 0x75, 0x16, 0x47, 0x46, 0xff, 0xaa, 0x79
};

/*
 * 2.  Test Case 5
 *
 *    Key =          0x0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c
 *
 *    Key length =   16
 *
 *    Data =         "Test With Truncation"
 *
 *    Data length =  20
 *
 *    Digest =       0x56461ef2342edc00f9bab995690efd4c
 *
 *    Digest96 =     0x56461ef2342edc00f9bab995
 */
#define test_case5    "5"
#define test_case_l5  "5_long"
#define key_len5      16
#define data_len5     20
#define digest_len5   digest96_size
#define digest_len_l5 digest_size
static const uint8_t key5[key_len5] = {
        0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
        0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
};
static const char data5[] = "Test With Truncation";
static const uint8_t digest5[digest_len_l5] = {
        0x56, 0x46, 0x1e, 0xf2, 0x34, 0x2e, 0xdc, 0x00,
        0xf9, 0xba, 0xb9, 0x95, 0x69, 0x0e, 0xfd, 0x4c
};

/*
 * 2.  Test Case 6
 *
 *    Key =          0xaa (repeated 80 times)
 *
 *    Key length =   80
 *
 *    Data =         "Test Using Larger Than Block-Size Key - Hash Key First"
 *
 *    Data length =  54
 *
 *    Digest =       0x6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd
 *
 *    Digest96 =     0x6b1ab7fe4bd7bf8f0b62e6ce
 */
/* #define test_case6  "6" */
/* #define key_len6    80 */
/* #define data_len6   54 */
/* #define digest_len6 digest96_size */
/* static const uint8_t key6[key_len6] = { */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa */
/* }; */
/* static const char data6[] = "Test Using Larger Than Block-Size " */
/*         "Key - Hash Key First"; */
/* static const uint8_t digest6[digest_len6] = { */
/*         0x6b, 0x1a, 0xb7, 0xfe, 0x4b, 0xd7, 0xbf, 0x8f, */
/*         0x0b, 0x62, 0xe6, 0xce */
/* }; */

/*
 * 2.  Test Case 7
 *
 *    Key =          0xaa (repeated 80 times)
 *
 *    Key length =   80
 *
 *    Data =         "Test Using Larger Than Block-Size Key and Larger"
 *
 *    Data length =  73
 *
 *    Digest =       0x6f630fad67cda0ee1fb1f562db3aa53e
 *
 *    Digest96 =     0x6f630fad67cda0ee1fb1f562
 */
/* #define test_case7  "7" */
/* #define key_len7    80 */
/* #define data_len7   73 */
/* #define digest_len7 digest96_size */
/* static const uint8_t key7[key_len7] = { */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, */
/*         0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa */
/* }; */
/* static const char data7[] = "Test Using Larger Than Block-Size " */
/*         "Key and Larger Than One Block-Size Data"; */
/* static const uint8_t digest7[digest_len7] = { */
/*         0x6f, 0x63, 0x0f, 0xad, 0x67, 0xcd, 0xa0, 0xee, */
/*         0x1f, 0xb1, 0xf5, 0x62 */
/* }; */

#define HMAC_MD5_TEST_VEC(num)                                          \
        { test_case##num,                                               \
                        (const uint8_t *) key##num, key_len##num,       \
                        (const uint8_t *) data##num, data_len##num,     \
                        (const uint8_t *) digest##num, digest_len##num }
#define HMAC_MD5_TEST_VEC_LONG(num)                                     \
        { test_case_l##num,                                             \
                        (const uint8_t *) key##num, key_len##num,       \
                        (const uint8_t *) data##num, data_len##num,     \
                        (const uint8_t *) digest##num, digest_len_l##num }

static const struct hmac_md5_rfc2202_vector {
        const char *test_case;
        const uint8_t *key;
        size_t key_len;
        const uint8_t *data;
        size_t data_len;
        const uint8_t *digest;
        size_t digest_len;
} hmac_md5_vectors[] = {
        HMAC_MD5_TEST_VEC(1),
        HMAC_MD5_TEST_VEC(2),
        HMAC_MD5_TEST_VEC(3),
        HMAC_MD5_TEST_VEC(4),
        HMAC_MD5_TEST_VEC(5),
        /* HMAC_MD5_TEST_VEC(6), */
        /* HMAC_MD5_TEST_VEC(7), */
        HMAC_MD5_TEST_VEC_LONG(1),
        HMAC_MD5_TEST_VEC_LONG(2),
        HMAC_MD5_TEST_VEC_LONG(3),
        HMAC_MD5_TEST_VEC_LONG(4),
        HMAC_MD5_TEST_VEC_LONG(5),
};

static int
hmac_md5_job_ok(const struct hmac_md5_rfc2202_vector *vec,
                 const struct JOB_AES_HMAC *job,
                 const uint8_t *auth,
                 const uint8_t *padding,
                 const size_t sizeof_padding)
{
        if (job->status != STS_COMPLETED) {
                printf("line:%d job error status:%d ", __LINE__, job->status);
                return 0;
        }

        /* hash checks */
        if (memcmp(padding, &auth[sizeof_padding + vec->digest_len],
                   sizeof_padding)) {
                printf("hash overwrite tail\n");
                hexdump(stderr, "Target",
                        &auth[sizeof_padding + vec->digest_len],
                        sizeof_padding);
                return 0;
        }

        if (memcmp(padding, &auth[0], sizeof_padding)) {
                printf("hash overwrite head\n");
                hexdump(stderr, "Target", &auth[0], sizeof_padding);
                return 0;
        }

        if (memcmp(vec->digest, &auth[sizeof_padding],
                   vec->digest_len)) {
                printf("hash mismatched\n");
                hexdump(stderr, "Received", &auth[sizeof_padding],
                        vec->digest_len);
                hexdump(stderr, "Expected", vec->digest,
                        vec->digest_len);
                return 0;
        }
        return 1;
}

static int
test_hmac_md5(struct MB_MGR *mb_mgr,
               const struct hmac_md5_rfc2202_vector *vec,
               const int num_jobs)
{
        struct JOB_AES_HMAC *job;
        uint8_t padding[16];
        uint8_t **auths = malloc(num_jobs * sizeof(void *));
        int i = 0, jobs_rx = 0, ret = -1;
        uint8_t key[block_size];
        uint8_t buf[block_size];
        DECLARE_ALIGNED(uint8_t ipad_hash[digest_size], 16);
        DECLARE_ALIGNED(uint8_t opad_hash[digest_size], 16);
        int key_len = 0;

        if (auths == NULL) {
		fprintf(stderr, "Can't allocate buffer memory\n");
		goto end2;
        }

        memset(padding, -1, sizeof(padding));
        memset(auths, 0, num_jobs * sizeof(void *));

        for (i = 0; i < num_jobs; i++) {
                const size_t alloc_len =
                        vec->digest_len + (sizeof(padding) * 2);

                auths[i] = malloc(alloc_len);
                if (auths[i] == NULL) {
                        fprintf(stderr, "Can't allocate buffer memory\n");
                        goto end;
                }
                memset(auths[i], -1, alloc_len);
        }

        /* prepare the key */
        memset(key, 0, sizeof(key));
        if (vec->key_len <= block_size) {
                memcpy(key, vec->key, vec->key_len);
                key_len = (int) vec->key_len;
        } else {
                printf("Key length longer than block size is not supported "
                       "by MD5\n");
                ret = 0;
                goto end;
        }

        /* compute ipad hash */
        memset(buf, 0x36, sizeof(buf));
        for (i = 0; i < key_len; i++)
                buf[i] ^= key[i];
        IMB_MD5_ONE_BLOCK(mb_mgr, buf, ipad_hash);

        /* compute opad hash */
        memset(buf, 0x5c, sizeof(buf));
        for (i = 0; i < key_len; i++)
                buf[i] ^= key[i];
        IMB_MD5_ONE_BLOCK(mb_mgr, buf, opad_hash);

        /* empty the manager */
        while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
                ;

        for (i = 0; i < num_jobs; i++) {
                job = IMB_GET_NEXT_JOB(mb_mgr);
                job->aes_enc_key_expanded = NULL;
                job->aes_dec_key_expanded = NULL;
                job->cipher_direction = ENCRYPT;
                job->chain_order = HASH_CIPHER;
                job->dst = NULL;
                job->aes_key_len_in_bytes = 0;
                job->auth_tag_output = auths[i] + sizeof(padding);
                job->auth_tag_output_len_in_bytes = vec->digest_len;
                job->iv = NULL;
                job->iv_len_in_bytes = 0;
                job->src = vec->data;
                job->cipher_start_src_offset_in_bytes = 0;
                job->msg_len_to_cipher_in_bytes = 0;
                job->hash_start_src_offset_in_bytes = 0;
                job->msg_len_to_hash_in_bytes = vec->data_len;
                job->u.HMAC._hashed_auth_key_xor_ipad = ipad_hash;
                job->u.HMAC._hashed_auth_key_xor_opad = opad_hash;
                job->cipher_mode = NULL_CIPHER;
                job->hash_alg = MD5;

                job->user_data = auths[i];

                job = IMB_SUBMIT_JOB(mb_mgr);
                if (job) {
                        jobs_rx++;
                        /*
                         * HMAC-MD5 requires 8 submissions to get one back
                         */
                        if (num_jobs < 8) {
                                printf("%d Unexpected return from submit_job\n",
                                       __LINE__);
                                goto end;
                        }
                        if (!hmac_md5_job_ok(vec, job, job->user_data,
                                              padding, sizeof(padding)))
                                goto end;
                }
        }

        while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL) {
                jobs_rx++;
                if (!hmac_md5_job_ok(vec, job, job->user_data,
                                      padding, sizeof(padding)))
                        goto end;
        }

        if (jobs_rx != num_jobs) {
                printf("Expected %d jobs, received %d\n", num_jobs, jobs_rx);
                goto end;
        }
        ret = 0;

 end:
        /* empty the manager before next tests */
        while ((job = IMB_FLUSH_JOB(mb_mgr)) != NULL)
                ;

        for (i = 0; i < num_jobs; i++) {
                if (auths[i] != NULL)
                        free(auths[i]);
        }

 end2:
        if (auths != NULL)
                free(auths);

        return ret;
}

static int
test_hmac_md5_std_vectors(struct MB_MGR *mb_mgr, const int num_jobs)
{
	const int vectors_cnt =
                sizeof(hmac_md5_vectors) / sizeof(hmac_md5_vectors[0]);
	int vect;
	int errors = 0;

	printf("HMAC-MD5 standard test vectors (N jobs = %d):\n", num_jobs);
	for (vect = 1; vect <= vectors_cnt; vect++) {
                const int idx = vect - 1;
#ifdef DEBUG
		printf("[%d/%d] RFC2202 Test Case %s key_len:%d data_len:%d "
                       "digest_len:%d\n",
                       vect, vectors_cnt,
                       hmac_md5_vectors[idx].test_case,
                       (int) hmac_md5_vectors[idx].key_len,
                       (int) hmac_md5_vectors[idx].data_len,
                       (int) hmac_md5_vectors[idx].digest_len);
#else
		printf(".");
#endif

                if (test_hmac_md5(mb_mgr, &hmac_md5_vectors[idx], num_jobs)) {
                        printf("error #%d\n", vect);
                        errors++;
                }
	}
	printf("\n");
	return errors;
}

int
hmac_md5_test(const enum arch_type arch,
               struct MB_MGR *mb_mgr)
{
        int errors = 0;

        (void) arch; /* unused */

        errors += test_hmac_md5_std_vectors(mb_mgr, 1);
        errors += test_hmac_md5_std_vectors(mb_mgr, 3);
        errors += test_hmac_md5_std_vectors(mb_mgr, 4);
        errors += test_hmac_md5_std_vectors(mb_mgr, 5);
        errors += test_hmac_md5_std_vectors(mb_mgr, 7);
        errors += test_hmac_md5_std_vectors(mb_mgr, 8);
        errors += test_hmac_md5_std_vectors(mb_mgr, 9);
        errors += test_hmac_md5_std_vectors(mb_mgr, 15);
        errors += test_hmac_md5_std_vectors(mb_mgr, 16);
        errors += test_hmac_md5_std_vectors(mb_mgr, 17);

	if (0 == errors)
		printf("...Pass\n");
	else
		printf("...Fail\n");

	return errors;
}