1 /*****************************************************************************
2 Copyright (c) 2017-2018, Intel Corporation
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright notice,
8 this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of Intel Corporation nor the names of its contributors
13 may be used to endorse or promote products derived from this software
14 without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *****************************************************************************/
34 #include <intel-ipsec-mb.h>
36 #include "gcm_ctr_vectors_test.h"
39 #define DIM(x) (sizeof(x) / sizeof(x[0]))
42 int des_test(const enum arch_type arch
, struct MB_MGR
*mb_mgr
);
45 const uint8_t *K
; /* key */
46 const uint8_t *IV
; /* initialization vector */
47 const uint8_t *P
; /* plain text */
48 uint64_t Plen
; /* plain text length */
49 const uint8_t *C
; /* cipher text - same length as plain text */
53 const uint8_t *K1
; /* key */
54 const uint8_t *K2
; /* key */
55 const uint8_t *K3
; /* key */
56 const uint8_t *IV
; /* initialization vector */
57 const uint8_t *P
; /* plain text */
58 uint64_t Plen
; /* plain text length */
59 const uint8_t *C
; /* cipher text - same length as plain text */
62 /* CM-SP-SECv3.1-I07-170111 I.7 */
63 static const uint8_t K1
[] = {
64 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
66 static const uint8_t IV1
[] = {
67 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
69 static const uint8_t P1
[] = {
70 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
71 0x08, 0x09, 0x0a, 0x0b, 0x88, 0x41, 0x65, 0x06
73 static const uint8_t C1
[] = {
74 0x0d, 0xda, 0x5a, 0xcb, 0xd0, 0x5e, 0x55, 0x67,
75 0x9f, 0x04, 0xd1, 0xb6, 0x41, 0x3d, 0x4e, 0xed
78 static const uint8_t K2
[] = {
79 0x3b, 0x38, 0x98, 0x37, 0x15, 0x20, 0xf7, 0x5e
81 static const uint8_t IV2
[] = {
82 0x02, 0xa8, 0x11, 0x77, 0x4d, 0xcd, 0xe1, 0x3b
84 static const uint8_t P2
[] = {
85 0x05, 0xef, 0xf7, 0x00, 0xe9, 0xa1, 0x3a, 0xe5,
86 0xca, 0x0b, 0xcb, 0xd0, 0x48, 0x47, 0x64, 0xbd,
87 0x1f, 0x23, 0x1e, 0xa8, 0x1c, 0x7b, 0x64, 0xc5,
88 0x14, 0x73, 0x5a, 0xc5, 0x5e, 0x4b, 0x79, 0x63,
89 0x3b, 0x70, 0x64, 0x24, 0x11, 0x9e, 0x09, 0xdc,
90 0xaa, 0xd4, 0xac, 0xf2, 0x1b, 0x10, 0xaf, 0x3b,
91 0x33, 0xcd, 0xe3, 0x50, 0x48, 0x47, 0x15, 0x5c,
92 0xbb, 0x6f, 0x22, 0x19, 0xba, 0x9b, 0x7d, 0xf5
95 static const uint8_t C2
[] = {
96 0xf3, 0x31, 0x8d, 0x01, 0x19, 0x4d, 0xa8, 0x00,
97 0xa4, 0x2c, 0x10, 0xb5, 0x33, 0xd6, 0xbc, 0x11,
98 0x97, 0x59, 0x2d, 0xcc, 0x9b, 0x5d, 0x35, 0x9a,
99 0xc3, 0x04, 0x5d, 0x07, 0x4c, 0x86, 0xbf, 0x72,
100 0xe5, 0x1a, 0x72, 0x25, 0x82, 0x22, 0x54, 0x03,
101 0xde, 0x8b, 0x7a, 0x58, 0x5c, 0x6c, 0x28, 0xdf,
102 0x41, 0x0e, 0x38, 0xd6, 0x2a, 0x86, 0xe3, 0x4f,
103 0xa2, 0x7c, 0x22, 0x39, 0x60, 0x06, 0x03, 0x6f
106 static struct des_vector vectors
[] = {
107 {K1
, IV1
, P1
, sizeof(P1
), C1
},
108 {K2
, IV2
, P2
, sizeof(P2
), C2
},
111 /* CM-SP-SECv3.1-I07-170111 I.7 */
112 static const uint8_t DK1
[] = {
113 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
115 static const uint8_t DIV1
[] = {
116 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
118 static const uint8_t DP1
[] = {
119 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
120 0x08, 0x09, 0x0a, 0x0b, 0x88, 0x41, 0x65, 0x06
122 static const uint8_t DC1
[] = {
123 0x0d, 0xda, 0x5a, 0xcb, 0xd0, 0x5e, 0x55, 0x67,
124 0x9f, 0x04, 0xd1, 0xb6, 0x41, 0x3d, 0x4e, 0xed
127 static const uint8_t DK2
[] = {
128 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
130 static const uint8_t DIV2
[] = {
131 0x81, 0x0e, 0x52, 0x8e, 0x1c, 0x5f, 0xda, 0x1a
133 static const uint8_t DP2
[] = {
134 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
135 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x91,
138 static const uint8_t DC2
[] = {
139 0x0d, 0xda, 0x5a, 0xcb, 0xd0, 0x5e, 0x55, 0x67,
140 0x51, 0x47, 0x46, 0x86, 0x8a, 0x71, 0xe5, 0x77,
144 static const uint8_t DK3
[] = {
145 0xe6, 0x60, 0x0f, 0xd8, 0x85, 0x2e, 0xf5, 0xab
147 static const uint8_t DIV3
[] = {
148 0x51, 0x47, 0x46, 0x86, 0x8a, 0x71, 0xe5, 0x77
150 static const uint8_t DP3
[] = {
153 static const uint8_t DC3
[] = {
158 static struct des_vector docsis_vectors
[] = {
159 {DK1
, DIV1
, DP1
, sizeof(DP1
), DC1
},
160 {DK2
, DIV2
, DP2
, sizeof(DP2
), DC2
},
161 {DK3
, DIV3
, DP3
, sizeof(DP3
), DC3
},
164 /* 3DES vectors - 2x and 3x keys */
166 static const uint8_t D3K1_1
[] = {
167 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
170 static const uint8_t D3K2_1
[] = {
171 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
174 static const uint8_t D3K3_1
[] = {
175 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
178 static const uint8_t D3IV_1
[] = {
179 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
183 static const uint8_t D3PT_1
[] = {
184 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
187 static const uint8_t D3CT_1
[] = {
188 0xdf, 0x0b, 0x6c, 0x9c, 0x31, 0xcd, 0x0c, 0xe4
193 static const uint8_t D3K1_2
[] = {
194 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
197 static const uint8_t D3K2_2
[] = {
198 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
201 static const uint8_t D3K3_2
[] = {
202 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
205 static const uint8_t D3IV_2
[] = {
206 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
209 static const uint8_t D3PT_2
[] = {
210 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
211 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
214 static const uint8_t D3CT_2
[] = {
215 0xdd, 0xad, 0xa1, 0x61, 0xe8, 0xd7, 0x96, 0x73,
216 0xed, 0x75, 0x32, 0xe5, 0x92, 0x23, 0xcd, 0x0d
219 #define D3PT_LEN_2 16
221 static const uint8_t D3K1_3
[] = {
222 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
225 static const uint8_t D3K2_3
[] = {
226 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
229 static const uint8_t D3K3_3
[] = {
230 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
233 static const uint8_t D3IV_3
[] = {
234 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
237 static const uint8_t D3PT_3
[] = {
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
241 static const uint8_t D3CT_3
[] = {
242 0x58, 0xed, 0x24, 0x8f, 0x77, 0xf6, 0xb1, 0x9e
247 static const uint8_t D3K1_4
[] = {
248 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
251 static const uint8_t D3K2_4
[] = {
252 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
255 static const uint8_t D3K3_4
[] = {
256 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
259 static const uint8_t D3IV_4
[] = {
260 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07
263 static const uint8_t D3PT_4
[] = {
264 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
265 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
268 static const uint8_t D3CT_4
[] = {
269 0x89, 0x4b, 0xc3, 0x08, 0x54, 0x26, 0xa4, 0x41,
270 0xf2, 0x7f, 0x73, 0xae, 0x26, 0xab, 0xbf, 0x74
273 #define D3PT_LEN_4 16
275 static struct des3_vector des3_vectors
[] = {
276 { D3K1_1
, D3K2_1
, D3K3_1
, D3IV_1
, D3PT_1
, D3PT_LEN_1
, D3CT_1
},
277 { D3K1_2
, D3K2_2
, D3K3_2
, D3IV_2
, D3PT_2
, D3PT_LEN_2
, D3CT_2
},
278 { D3K1_3
, D3K2_3
, D3K3_3
, D3IV_3
, D3PT_3
, D3PT_LEN_3
, D3CT_3
},
279 { D3K1_4
, D3K2_4
, D3K3_4
, D3IV_4
, D3PT_4
, D3PT_LEN_4
, D3CT_4
},
283 test_des_many(struct MB_MGR
*mb_mgr
,
288 const uint8_t *in_text
,
289 const uint8_t *out_text
,
293 JOB_CIPHER_MODE cipher
,
297 const void *ks_ptr
[3]; /* 3DES */
298 struct JOB_AES_HMAC
*job
;
300 uint8_t **targets
= malloc(num_jobs
* sizeof(void *));
301 int i
, jobs_rx
= 0, ret
= -1;
303 assert(targets
!= NULL
);
305 memset(padding
, -1, sizeof(padding
));
307 for (i
= 0; i
< num_jobs
; i
++) {
308 targets
[i
] = malloc(text_len
+ (sizeof(padding
) * 2));
309 memset(targets
[i
], -1, text_len
+ (sizeof(padding
) * 2));
311 /* copy input text to the allocated buffer */
312 memcpy(targets
[i
] + sizeof(padding
), in_text
, text_len
);
316 /* Used in 3DES only */
321 /* flush the scheduler */
322 while ((job
= IMB_FLUSH_JOB(mb_mgr
)) != NULL
)
325 for (i
= 0; i
< num_jobs
; i
++) {
326 job
= IMB_GET_NEXT_JOB(mb_mgr
);
327 job
->cipher_direction
= dir
;
328 job
->chain_order
= order
;
330 job
->dst
= targets
[i
] + sizeof(padding
);
333 job
->dst
= targets
[i
] + sizeof(padding
);
334 job
->src
= targets
[i
] + sizeof(padding
);
336 job
->cipher_mode
= cipher
;
337 if (cipher
== DES3
) {
338 job
->aes_enc_key_expanded
= (const void *) ks_ptr
;
339 job
->aes_dec_key_expanded
= (const void *) ks_ptr
;
340 job
->aes_key_len_in_bytes
= 24; /* 3x keys only */
342 job
->aes_enc_key_expanded
= ks
;
343 job
->aes_dec_key_expanded
= ks
;
344 job
->aes_key_len_in_bytes
= 8;
347 job
->iv_len_in_bytes
= 8;
348 job
->cipher_start_src_offset_in_bytes
= 0;
349 job
->msg_len_to_cipher_in_bytes
= text_len
;
350 job
->user_data
= (void *)((uint64_t)i
);
352 job
->hash_alg
= NULL_HASH
;
354 job
= IMB_SUBMIT_JOB(mb_mgr
);
356 const int num
= (const int)((uint64_t)job
->user_data
);
359 if (job
->status
!= STS_COMPLETED
) {
360 printf("%d error status:%d, job %d",
361 __LINE__
, job
->status
, num
);
364 if (memcmp(out_text
, targets
[num
] + sizeof(padding
),
366 printf("%d mismatched\n", num
);
369 if (memcmp(padding
, targets
[num
], sizeof(padding
))) {
370 printf("%d overwrite head\n", num
);
374 targets
[num
] + sizeof(padding
) + text_len
,
376 printf("%d overwrite tail\n", num
);
382 while ((job
= IMB_FLUSH_JOB(mb_mgr
)) != NULL
) {
383 const int num
= (const int)((uint64_t)job
->user_data
);
386 if (job
->status
!= STS_COMPLETED
) {
387 printf("%d Error status:%d, job %d",
388 __LINE__
, job
->status
, num
);
391 if (memcmp(out_text
, targets
[num
] + sizeof(padding
),
393 printf("%d mismatched\n", num
);
396 if (memcmp(padding
, targets
[num
], sizeof(padding
))) {
397 printf("%d overwrite head\n", num
);
400 if (memcmp(padding
, targets
[num
] + sizeof(padding
) + text_len
,
402 printf("%d overwrite tail\n", num
);
407 if (jobs_rx
!= num_jobs
) {
408 printf("Expected %d jobs, received %d\n", num_jobs
, jobs_rx
);
414 while ((job
= IMB_FLUSH_JOB(mb_mgr
)) != NULL
)
417 for (i
= 0; i
< num_jobs
; i
++)
424 test_des_one(struct MB_MGR
*mb_mgr
,
425 const enum arch_type arch
,
430 const uint8_t *in_text
,
431 const uint8_t *out_text
,
435 JOB_CIPHER_MODE cipher
,
438 const void *ks_ptr
[3]; /* 3DES */
439 struct JOB_AES_HMAC
*job
;
441 uint8_t *target
= malloc(text_len
+ (sizeof(padding
) * 2));
444 assert(target
!= NULL
);
446 memset(target
, -1, text_len
+ (sizeof(padding
) * 2));
447 memset(padding
, -1, sizeof(padding
));
450 /* copy input text to the allocated buffer */
451 memcpy(target
+ sizeof(padding
), in_text
, text_len
);
454 /* Used in 3DES only */
459 while ((job
= IMB_FLUSH_JOB(mb_mgr
)) != NULL
)
462 job
= IMB_GET_NEXT_JOB(mb_mgr
);
463 job
->cipher_direction
= dir
;
464 job
->chain_order
= order
;
466 job
->dst
= target
+ sizeof(padding
);
469 job
->dst
= target
+ sizeof(padding
);
470 job
->src
= target
+ sizeof(padding
);
472 job
->cipher_mode
= cipher
;
473 if (cipher
== DES3
) {
474 job
->aes_enc_key_expanded
= (const void *) ks_ptr
;
475 job
->aes_dec_key_expanded
= (const void *) ks_ptr
;
476 job
->aes_key_len_in_bytes
= 24;
478 job
->aes_enc_key_expanded
= ks
;
479 job
->aes_dec_key_expanded
= ks
;
480 job
->aes_key_len_in_bytes
= 8;
483 job
->iv_len_in_bytes
= 8;
484 job
->cipher_start_src_offset_in_bytes
= 0;
485 job
->msg_len_to_cipher_in_bytes
= text_len
;
487 job
->hash_alg
= NULL_HASH
;
489 if (arch
== ARCH_AVX512
) {
490 job
= IMB_SUBMIT_JOB(mb_mgr
);
492 printf("%d Unexpected return from submit_job\n",
496 job
= IMB_FLUSH_JOB(mb_mgr
);
498 printf("%d Unexpected null return from flush_job\n",
503 job
= IMB_SUBMIT_JOB(mb_mgr
);
505 printf("%d Unexpected null return from submit_job\n",
510 if (job
->status
!= STS_COMPLETED
) {
511 printf("%d Error status:%d", __LINE__
, job
->status
);
514 if (memcmp(out_text
, target
+ sizeof(padding
), text_len
)) {
515 printf("mismatched\n");
518 if (memcmp(padding
, target
, sizeof(padding
))) {
519 printf("overwrite head\n");
522 if (memcmp(padding
, target
+ sizeof(padding
) + text_len
,
524 printf("overwrite tail\n");
529 while ((job
= IMB_FLUSH_JOB(mb_mgr
)) != NULL
)
537 test_des(struct MB_MGR
*mb_mgr
,
538 const enum arch_type arch
,
543 const uint8_t *in_text
,
544 const uint8_t *out_text
,
548 JOB_CIPHER_MODE cipher
,
553 if (cipher
== DES3
) {
554 if (ks2
== NULL
&& ks3
== NULL
) {
555 ret
|= test_des_one(mb_mgr
, arch
, ks
, ks
, ks
, iv
,
556 in_text
, out_text
, text_len
, dir
,
557 order
, cipher
, in_place
);
558 ret
|= test_des_many(mb_mgr
, ks
, ks
, ks
, iv
, in_text
,
559 out_text
, text_len
, dir
, order
,
560 cipher
, in_place
, 32);
562 ret
|= test_des_one(mb_mgr
, arch
, ks
, ks2
, ks3
, iv
,
563 in_text
, out_text
, text_len
, dir
,
564 order
, cipher
, in_place
);
565 ret
|= test_des_many(mb_mgr
, ks
, ks2
, ks3
, iv
, in_text
,
566 out_text
, text_len
, dir
, order
,
567 cipher
, in_place
, 32);
570 ret
|= test_des_one(mb_mgr
, arch
, ks
, NULL
, NULL
, iv
, in_text
,
571 out_text
, text_len
, dir
, order
, cipher
,
573 ret
|= test_des_many(mb_mgr
, ks
, NULL
, NULL
, iv
, in_text
,
574 out_text
, text_len
, dir
, order
, cipher
,
581 test_des_vectors(struct MB_MGR
*mb_mgr
, const enum arch_type arch
,
583 const struct des_vector
*vec_tab
, const char *banner
,
584 const JOB_CIPHER_MODE cipher
)
586 int vect
, errors
= 0;
589 printf("%s:\n", banner
);
590 for (vect
= 0; vect
< vec_cnt
; vect
++) {
592 printf("Standard vector %d/%d PTLen:%d\n",
594 (int) vec_tab
[vect
].Plen
);
598 des_key_schedule(ks
, vec_tab
[vect
].K
);
600 if (test_des(mb_mgr
, arch
, ks
, NULL
, NULL
,
602 vec_tab
[vect
].P
, vec_tab
[vect
].C
,
603 (unsigned) vec_tab
[vect
].Plen
,
604 ENCRYPT
, CIPHER_HASH
, cipher
, 0)) {
605 printf("error #%d encrypt\n", vect
+ 1);
609 if (test_des(mb_mgr
, arch
, ks
, NULL
, NULL
,
611 vec_tab
[vect
].C
, vec_tab
[vect
].P
,
612 (unsigned) vec_tab
[vect
].Plen
,
613 DECRYPT
, HASH_CIPHER
, cipher
, 0)) {
614 printf("error #%d decrypt\n", vect
+ 1);
618 if (test_des(mb_mgr
, arch
, ks
, NULL
, NULL
,
620 vec_tab
[vect
].P
, vec_tab
[vect
].C
,
621 (unsigned) vec_tab
[vect
].Plen
,
622 ENCRYPT
, CIPHER_HASH
, cipher
, 1)) {
623 printf("error #%d encrypt in-place\n", vect
+ 1);
627 if (test_des(mb_mgr
, arch
, ks
, NULL
, NULL
,
629 vec_tab
[vect
].C
, vec_tab
[vect
].P
,
630 (unsigned) vec_tab
[vect
].Plen
,
631 DECRYPT
, HASH_CIPHER
, cipher
, 1)) {
632 printf("error #%d decrypt in-place\n", vect
+ 1);
641 test_des3_vectors(struct MB_MGR
*mb_mgr
, const enum arch_type arch
,
643 const struct des3_vector
*vec_tab
, const char *banner
)
645 int vect
, errors
= 0;
650 printf("%s:\n", banner
);
651 for (vect
= 0; vect
< vec_cnt
; vect
++) {
653 printf("Standard vector %d/%d PTLen:%d\n",
655 (int) vec_tab
[vect
].Plen
);
659 des_key_schedule(ks1
, vec_tab
[vect
].K1
);
660 des_key_schedule(ks2
, vec_tab
[vect
].K2
);
661 des_key_schedule(ks3
, vec_tab
[vect
].K3
);
663 if (test_des(mb_mgr
, arch
, ks1
, ks2
, ks3
,
665 vec_tab
[vect
].P
, vec_tab
[vect
].C
,
666 (unsigned) vec_tab
[vect
].Plen
,
667 ENCRYPT
, CIPHER_HASH
, DES3
, 0)) {
668 printf("error #%d encrypt\n", vect
+ 1);
672 if (test_des(mb_mgr
, arch
, ks1
, ks2
, ks3
,
674 vec_tab
[vect
].C
, vec_tab
[vect
].P
,
675 (unsigned) vec_tab
[vect
].Plen
,
676 DECRYPT
, HASH_CIPHER
, DES3
, 0)) {
677 printf("error #%d decrypt\n", vect
+ 1);
681 if (test_des(mb_mgr
, arch
, ks1
, ks2
, ks3
,
683 vec_tab
[vect
].P
, vec_tab
[vect
].C
,
684 (unsigned) vec_tab
[vect
].Plen
,
685 ENCRYPT
, CIPHER_HASH
, DES3
, 1)) {
686 printf("error #%d encrypt in-place\n", vect
+ 1);
690 if (test_des(mb_mgr
, arch
, ks1
, ks2
, ks3
,
692 vec_tab
[vect
].C
, vec_tab
[vect
].P
,
693 (unsigned) vec_tab
[vect
].Plen
,
694 DECRYPT
, HASH_CIPHER
, DES3
, 1)) {
695 printf("error #%d decrypt in-place\n", vect
+ 1);
704 des_test(const enum arch_type arch
,
705 struct MB_MGR
*mb_mgr
)
709 errors
= test_des_vectors(mb_mgr
, arch
, DIM(vectors
), vectors
,
710 "DES standard test vectors", DES
);
712 errors
+= test_des_vectors(mb_mgr
, arch
, DIM(docsis_vectors
),
714 "DOCSIS DES standard test vectors",
717 errors
+= test_des_vectors(mb_mgr
, arch
, DIM(vectors
), vectors
,
718 "3DES (single key) standard test vectors",
721 errors
+= test_des3_vectors(mb_mgr
, arch
, DIM(des3_vectors
),
723 "3DES (multiple keys) test vectors");