1 /* Copyright (c) 2018 The Johns Hopkins University/Applied Physics Laboratory
4 * This file is dual licensed under the terms of the Apache 2.0 License and
5 * the BSD 3-Clause License. See the LICENSE file in the root of this
6 * repository for more information.
15 #define TEST_PASSED(A, B) \
18 printf("PASS - %s\n", (B)); \
19 (A)->tests_passed++; \
23 #define TEST_FAILED(A, B, C) \
26 printf("FAIL - %s @ L%d\n", (B), (C)); \
27 (A)->tests_failed++; \
31 #define TRACK_TEST(A) ((A)->test_count++)
34 typedef struct test_tracker
43 report_encoding_test_result(
46 const uint8
*expected
,
47 const uint8
*observed
,
53 for(size_t i
= 0; i
< ctx
->size
; i
++)
55 if(expected
[i
] != observed
[i
])
57 printf("FAIL - %s\n", function
);
58 printf("- byte mismatch at: %zu (exp: %X, obs: %X)\n",
59 i
, expected
[i
], observed
[i
]);
60 for(size_t j
= 0; j
< ctx
->size
; j
++)
62 printf("- %zu: %X - %X\n", j
, expected
[j
], observed
[j
]);
64 tracker
->tests_failed
++;
69 TEST_PASSED(tracker
, function
);
73 printf("FAIL - %s\n", function
);
74 if(result
== KMIP_ERROR_BUFFER_FULL
)
76 printf("- context buffer is full\n");
78 kmip_print_stack_trace(ctx
);
79 tracker
->tests_failed
++;
85 report_decoding_test_result(
96 TEST_PASSED(tracker
, function
);
100 printf("FAIL - %s\n", function
);
101 printf("- compared objects are not identical\n");
102 tracker
->tests_failed
++;
108 printf("FAIL - %s\n", function
);
109 if(result
== KMIP_ERROR_BUFFER_FULL
)
111 printf("- context buffer is underfull\n");
113 kmip_print_stack_trace(ctx
);
114 tracker
->tests_failed
++;
120 report_result(TestTracker
*tracker
, int observed
, int expected
, const char *function
)
122 if(observed
== expected
)
124 TEST_PASSED(tracker
, function
);
128 printf("FAIL - %s\n", function
);
129 tracker
->tests_failed
++;
135 test_linked_list_push(TestTracker
*tracker
)
139 LinkedList list
= {0};
141 LinkedListItem a
= {0};
142 LinkedListItem b
= {0};
143 LinkedListItem c
= {0};
145 if(list
.head
!= NULL
|| list
.tail
!= NULL
|| list
.size
!= 0)
147 TEST_FAILED(tracker
, __func__
, __LINE__
);
150 kmip_linked_list_push(&list
, &a
);
152 if(list
.head
!= &a
|| list
.tail
!= &a
|| list
.size
!= 1)
154 TEST_FAILED(tracker
, __func__
, __LINE__
);
157 kmip_linked_list_push(&list
, &b
);
159 if(list
.head
!= &b
|| list
.tail
!= &a
|| list
.size
!= 2)
161 TEST_FAILED(tracker
, __func__
, __LINE__
);
164 kmip_linked_list_push(&list
, &c
);
166 if(list
.head
!= &c
|| list
.tail
!= &a
|| list
.size
!= 3)
168 TEST_FAILED(tracker
, __func__
, __LINE__
);
171 LinkedListItem
*curr
= list
.head
;
172 if(curr
!= &c
|| curr
->next
!= &b
|| curr
->prev
!= NULL
)
174 TEST_FAILED(tracker
, __func__
, __LINE__
);
177 if(curr
!= &b
|| curr
->next
!= &a
|| curr
->prev
!= &c
)
179 TEST_FAILED(tracker
, __func__
, __LINE__
);
182 if(curr
!= &a
|| curr
->next
!= NULL
|| curr
->prev
!= &b
)
184 TEST_FAILED(tracker
, __func__
, __LINE__
);
187 TEST_PASSED(tracker
, __func__
);
191 test_linked_list_pop(TestTracker
*tracker
)
195 LinkedList list
= {0};
197 if(list
.head
!= NULL
|| list
.tail
!= NULL
|| list
.size
!= 0)
199 TEST_FAILED(tracker
, __func__
, __LINE__
);
202 LinkedListItem
*item
= kmip_linked_list_pop(&list
);
204 if(item
!= NULL
|| list
.head
!= NULL
|| list
.tail
!= NULL
|| list
.size
!= 0)
206 TEST_FAILED(tracker
, __func__
, __LINE__
);
209 LinkedListItem a
= {0};
210 LinkedListItem b
= {0};
211 LinkedListItem c
= {0};
224 item
= kmip_linked_list_pop(&list
);
226 if(item
!= &a
|| list
.head
!= &b
|| list
.tail
!= &c
|| list
.size
!= 2)
228 TEST_FAILED(tracker
, __func__
, __LINE__
);
231 item
= kmip_linked_list_pop(&list
);
233 if(item
!= &b
|| list
.head
!= &c
|| list
.tail
!= &c
|| list
.size
!= 1)
235 TEST_FAILED(tracker
, __func__
, __LINE__
);
238 item
= kmip_linked_list_pop(&list
);
240 if(item
!= &c
|| list
.head
!= NULL
|| list
.tail
!= NULL
|| list
.size
!= 0)
242 TEST_FAILED(tracker
, __func__
, __LINE__
);
245 TEST_PASSED(tracker
, __func__
);
249 test_linked_list_enqueue(TestTracker
*tracker
)
253 LinkedList list
= {0};
255 LinkedListItem a
= {0};
256 LinkedListItem b
= {0};
257 LinkedListItem c
= {0};
259 if(list
.head
!= NULL
|| list
.tail
!= NULL
|| list
.size
!= 0)
261 TEST_FAILED(tracker
, __func__
, __LINE__
);
264 kmip_linked_list_enqueue(&list
, &a
);
266 if(list
.head
!= &a
|| list
.tail
!= &a
|| list
.size
!= 1)
268 TEST_FAILED(tracker
, __func__
, __LINE__
);
271 kmip_linked_list_enqueue(&list
, &b
);
273 if(list
.head
!= &a
|| list
.tail
!= &b
|| list
.size
!= 2)
275 TEST_FAILED(tracker
, __func__
, __LINE__
);
278 kmip_linked_list_enqueue(&list
, &c
);
280 if(list
.head
!= &a
|| list
.tail
!= &c
|| list
.size
!= 3)
282 TEST_FAILED(tracker
, __func__
, __LINE__
);
285 LinkedListItem
*curr
= list
.head
;
286 if(curr
!= &a
|| curr
->next
!= &b
|| curr
->prev
!= NULL
)
288 TEST_FAILED(tracker
, __func__
, __LINE__
);
291 if(curr
!= &b
|| curr
->next
!= &c
|| curr
->prev
!= &a
)
293 TEST_FAILED(tracker
, __func__
, __LINE__
);
296 if(curr
!= &c
|| curr
->next
!= NULL
|| curr
->prev
!= &b
)
298 TEST_FAILED(tracker
, __func__
, __LINE__
);
301 TEST_PASSED(tracker
, __func__
);
305 test_buffer_full_and_resize(TestTracker
*tracker
)
309 uint8 expected
[40] = {
310 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
311 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
312 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
313 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
317 uint8 too_small
[30] = {0};
318 uint8 large_enough
[40] = {0};
319 struct kmip ctx
= {0};
320 kmip_init(&ctx
, too_small
, ARRAY_LENGTH(too_small
), KMIP_1_0
);
322 struct protocol_version pv
= {0};
326 int result
= kmip_encode_protocol_version(&ctx
, &pv
);
328 if(result
== KMIP_ERROR_BUFFER_FULL
)
331 kmip_set_buffer(&ctx
, large_enough
, ARRAY_LENGTH(large_enough
));
333 result
= kmip_encode_protocol_version(&ctx
, &pv
);
334 result
= report_encoding_test_result(
348 printf("FAIL - %s\n", __func__
);
349 printf("- expected buffer full\n");
352 tracker
->tests_failed
++;
358 test_is_tag_next(TestTracker
*tracker
)
362 uint8 encoding
[3] = {0x42, 0x00, 0x08};
364 struct kmip ctx
= {0};
365 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
367 uint8
*before
= ctx
.index
;
370 if(kmip_is_tag_next(&ctx
, KMIP_TAG_ATTRIBUTE
) == KMIP_FALSE
)
372 printf("FAIL - %s\n", __func__
);
373 printf("- expected tag is not next\n");
374 tracker
->tests_failed
++;
378 uint8
*after
= ctx
.index
;
382 printf("FAIL - %s\n", __func__
);
383 printf("- tag checking modifies context buffer index\n");
384 tracker
->tests_failed
++;
392 printf("PASS - %s\n", __func__
);
393 tracker
->tests_passed
++;
400 test_get_num_items_next(TestTracker
*tracker
)
404 uint8 encoding
[168] = {
405 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
406 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
407 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
408 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
409 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
410 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
411 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
412 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
413 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
414 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
415 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
416 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
417 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
418 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
419 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
420 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
421 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
422 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
423 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
424 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
425 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
428 struct kmip ctx
= {0};
429 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
431 uint8
*before
= ctx
.index
;
435 count
= kmip_get_num_items_next(&ctx
, KMIP_TAG_ATTRIBUTE
);
438 printf("FAIL - %s\n", __func__
);
439 printf("- expected item count not found (exp. 3, obs. %d)\n",
441 tracker
->tests_failed
++;
445 uint8
*after
= ctx
.index
;
449 printf("FAIL - %s\n", __func__
);
450 printf("- item count checking modifies context buffer index\n");
451 tracker
->tests_failed
++;
459 printf("PASS - %s\n", __func__
);
460 tracker
->tests_passed
++;
467 test_get_num_items_next_with_partial_item(TestTracker
*tracker
)
471 uint8 encoding
[136] = {
472 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
473 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
474 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
475 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
476 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
477 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
478 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
479 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
480 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
481 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
482 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
483 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
484 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
485 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
486 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
487 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
488 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72
491 struct kmip ctx
= {0};
492 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
494 uint8
*before
= ctx
.index
;
498 count
= kmip_get_num_items_next(&ctx
, KMIP_TAG_ATTRIBUTE
);
501 printf("FAIL - %s\n", __func__
);
502 printf("- expected item count not found (exp. 2, obs. %d)\n",
504 tracker
->tests_failed
++;
508 uint8
*after
= ctx
.index
;
512 printf("FAIL - %s\n", __func__
);
513 printf("- item count checking modifies context buffer index\n");
514 tracker
->tests_failed
++;
522 printf("PASS - %s\n", __func__
);
523 tracker
->tests_passed
++;
530 test_get_num_items_next_with_mismatch_item(TestTracker
*tracker
)
534 uint8 encoding
[80] = {
535 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
536 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
537 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
538 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
539 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
540 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
541 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
542 0x42, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x30,
543 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
544 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72
547 struct kmip ctx
= {0};
548 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
550 uint8
*before
= ctx
.index
;
554 count
= kmip_get_num_items_next(&ctx
, KMIP_TAG_ATTRIBUTE
);
557 printf("FAIL - %s\n", __func__
);
558 printf("- expected item count not found (exp. 1, obs. %d)\n",
560 tracker
->tests_failed
++;
564 uint8
*after
= ctx
.index
;
568 printf("FAIL - %s\n", __func__
);
569 printf("- item count checking modifies context buffer index\n");
570 tracker
->tests_failed
++;
578 printf("PASS - %s\n", __func__
);
579 tracker
->tests_passed
++;
586 test_get_num_items_next_with_no_matches(TestTracker
*tracker
)
590 uint8 encoding
[80] = {
591 0x42, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x30,
592 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
593 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
594 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
595 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
596 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
597 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
598 0x42, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 0x30,
599 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
600 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72
603 struct kmip ctx
= {0};
604 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
606 uint8
*before
= ctx
.index
;
610 count
= kmip_get_num_items_next(&ctx
, KMIP_TAG_ATTRIBUTE
);
613 printf("FAIL - %s\n", __func__
);
614 printf("- expected item count not found (exp. 0, obs. %d)\n",
616 tracker
->tests_failed
++;
620 uint8
*after
= ctx
.index
;
624 printf("FAIL - %s\n", __func__
);
625 printf("- item count checking modifies context buffer index\n");
626 tracker
->tests_failed
++;
634 printf("PASS - %s\n", __func__
);
635 tracker
->tests_passed
++;
642 test_get_num_items_next_with_non_structures(TestTracker
*tracker
)
646 uint8 encoding
[144] = {
647 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x26,
648 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
649 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
650 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
651 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
652 0x65, 0x39, 0x38, 0x61, 0x11, 0x11, 0x00, 0x00,
653 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x25,
654 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
655 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
656 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
657 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
658 0x65, 0x39, 0x38, 0x61, 0x11, 0x00, 0x00, 0x00,
659 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
660 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
661 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
662 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
663 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
664 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00
667 struct kmip ctx
= {0};
668 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
670 uint8
*before
= ctx
.index
;
674 count
= kmip_get_num_items_next(&ctx
, KMIP_TAG_UNIQUE_IDENTIFIER
);
677 printf("FAIL - %s\n", __func__
);
678 printf("- expected item count not found (exp. 3, obs. %d)\n",
680 tracker
->tests_failed
++;
684 uint8
*after
= ctx
.index
;
688 printf("FAIL - %s\n", __func__
);
689 printf("- item count checking modifies context buffer index\n");
690 tracker
->tests_failed
++;
698 printf("PASS - %s\n", __func__
);
699 tracker
->tests_passed
++;
706 test_buffer_bytes_left(TestTracker
*tracker
)
711 uint8 b
[3] = {0x42, 0x00, 0x08};
712 uint8 c
[5] = {0x42, 0x00, 0x53, 0x01, 0x00};
715 kmip_init(&ctx
, a
, ARRAY_LENGTH(a
), KMIP_1_0
);
717 if(BUFFER_BYTES_LEFT(&ctx
) != 1)
720 TEST_FAILED(tracker
, __func__
, __LINE__
);
724 kmip_init(&ctx
, b
, ARRAY_LENGTH(b
), KMIP_1_0
);
726 if(BUFFER_BYTES_LEFT(&ctx
) != 3)
729 TEST_FAILED(tracker
, __func__
, __LINE__
);
733 kmip_init(&ctx
, c
, ARRAY_LENGTH(c
), KMIP_1_0
);
735 if(BUFFER_BYTES_LEFT(&ctx
) != 5)
738 TEST_FAILED(tracker
, __func__
, __LINE__
);
743 TEST_PASSED(tracker
, __func__
);
747 test_get_num_attributes_next(TestTracker
*tracker
)
751 /* Need to build an encoding with one of each type of support
752 attribute. Verify that this function returns the correct
755 Need to build an encoding with bad attribute length? Handle
758 TEST_FAILED(tracker
, __func__
, __LINE__
);
762 test_peek_tag(TestTracker
*tracker
)
766 /* Build an encoding with an arbitrary tag value. Verify that this
767 function reads and returns this tag value without changing the
771 uint8 underfull_encoding
[1] = {0x42};
772 uint8 full_encoding
[3] = {0x42, 0x00, 0x08};
773 uint8 overfull_encoding
[5] = {0x42, 0x00, 0x53, 0x01, 0x00};
776 uint8
*prev_buffer
= NULL
;
777 uint8
*prev_index
= NULL
;
778 size_t prev_size
= 0;
780 kmip_init(&ctx
, underfull_encoding
, ARRAY_LENGTH(underfull_encoding
), KMIP_1_0
);
782 prev_buffer
= ctx
.buffer
;
783 prev_index
= ctx
.index
;
784 prev_size
= ctx
.size
;
785 tag
= kmip_peek_tag(&ctx
);
786 if(tag
!= 0 || ctx
.buffer
!= prev_buffer
|| ctx
.index
!= prev_index
|| ctx
.size
!= prev_size
)
788 TEST_FAILED(tracker
, __func__
, __LINE__
);
792 kmip_init(&ctx
, full_encoding
, ARRAY_LENGTH(full_encoding
), KMIP_1_0
);
794 prev_buffer
= ctx
.buffer
;
795 prev_index
= ctx
.index
;
796 prev_size
= ctx
.size
;
797 tag
= kmip_peek_tag(&ctx
);
798 if(tag
!= KMIP_TAG_ATTRIBUTE
|| ctx
.buffer
!= prev_buffer
|| ctx
.index
!= prev_index
|| ctx
.size
!= prev_size
)
800 TEST_FAILED(tracker
, __func__
, __LINE__
);
804 kmip_init(&ctx
, overfull_encoding
, ARRAY_LENGTH(overfull_encoding
), KMIP_1_0
);
806 prev_buffer
= ctx
.buffer
;
807 prev_index
= ctx
.index
;
808 prev_size
= ctx
.size
;
809 tag
= kmip_peek_tag(&ctx
);
810 if(tag
!= KMIP_TAG_NAME
|| ctx
.buffer
!= prev_buffer
|| ctx
.index
!= prev_index
|| ctx
.size
!= prev_size
)
812 TEST_FAILED(tracker
, __func__
, __LINE__
);
817 TEST_PASSED(tracker
, __func__
);
821 test_is_attribute_tag(TestTracker
*tracker
)
825 if(!kmip_is_attribute_tag(KMIP_TAG_UNIQUE_IDENTIFIER
))
827 TEST_FAILED(tracker
, __func__
, __LINE__
);
829 if(!kmip_is_attribute_tag(KMIP_TAG_NAME
))
831 TEST_FAILED(tracker
, __func__
, __LINE__
);
833 if(!kmip_is_attribute_tag(KMIP_TAG_OBJECT_TYPE
))
835 TEST_FAILED(tracker
, __func__
, __LINE__
);
837 if(!kmip_is_attribute_tag(KMIP_TAG_CRYPTOGRAPHIC_ALGORITHM
))
839 TEST_FAILED(tracker
, __func__
, __LINE__
);
841 if(!kmip_is_attribute_tag(KMIP_TAG_CRYPTOGRAPHIC_LENGTH
))
843 TEST_FAILED(tracker
, __func__
, __LINE__
);
845 if(!kmip_is_attribute_tag(KMIP_TAG_CRYPTOGRAPHIC_PARAMETERS
))
847 TEST_FAILED(tracker
, __func__
, __LINE__
);
849 if(!kmip_is_attribute_tag(KMIP_TAG_CRYPTOGRAPHIC_DOMAIN_PARAMETERS
))
851 TEST_FAILED(tracker
, __func__
, __LINE__
);
853 if(!kmip_is_attribute_tag(KMIP_TAG_CERTIFICATE_TYPE
))
855 TEST_FAILED(tracker
, __func__
, __LINE__
);
857 if(!kmip_is_attribute_tag(KMIP_TAG_CERTIFICATE_LENGTH
))
859 TEST_FAILED(tracker
, __func__
, __LINE__
);
861 if(!kmip_is_attribute_tag(KMIP_TAG_X509_CERTIFICATE_IDENTIFIER
))
863 TEST_FAILED(tracker
, __func__
, __LINE__
);
865 if(!kmip_is_attribute_tag(KMIP_TAG_X509_CERTIFICATE_SUBJECT
))
867 TEST_FAILED(tracker
, __func__
, __LINE__
);
869 if(!kmip_is_attribute_tag(KMIP_TAG_X509_CERTIFICATE_ISSUER
))
871 TEST_FAILED(tracker
, __func__
, __LINE__
);
873 if(!kmip_is_attribute_tag(KMIP_TAG_CERTIFICATE_IDENTIFIER
))
875 TEST_FAILED(tracker
, __func__
, __LINE__
);
877 if(!kmip_is_attribute_tag(KMIP_TAG_CERTIFICATE_SUBJECT
))
879 TEST_FAILED(tracker
, __func__
, __LINE__
);
881 if(!kmip_is_attribute_tag(KMIP_TAG_CERTIFICATE_ISSUER
))
883 TEST_FAILED(tracker
, __func__
, __LINE__
);
885 if(!kmip_is_attribute_tag(KMIP_TAG_DIGITAL_SIGNATURE_ALGORITHM
))
887 TEST_FAILED(tracker
, __func__
, __LINE__
);
889 if(!kmip_is_attribute_tag(KMIP_TAG_DIGEST
))
891 TEST_FAILED(tracker
, __func__
, __LINE__
);
893 if(!kmip_is_attribute_tag(KMIP_TAG_OPERATION_POLICY_NAME
))
895 TEST_FAILED(tracker
, __func__
, __LINE__
);
897 if(!kmip_is_attribute_tag(KMIP_TAG_CRYPTOGRAPHIC_USAGE_MASK
))
899 TEST_FAILED(tracker
, __func__
, __LINE__
);
901 if(!kmip_is_attribute_tag(KMIP_TAG_LEASE_TIME
))
903 TEST_FAILED(tracker
, __func__
, __LINE__
);
905 if(!kmip_is_attribute_tag(KMIP_TAG_USAGE_LIMITS
))
907 TEST_FAILED(tracker
, __func__
, __LINE__
);
909 if(!kmip_is_attribute_tag(KMIP_TAG_STATE
))
911 TEST_FAILED(tracker
, __func__
, __LINE__
);
913 if(!kmip_is_attribute_tag(KMIP_TAG_INITIAL_DATE
))
915 TEST_FAILED(tracker
, __func__
, __LINE__
);
917 if(!kmip_is_attribute_tag(KMIP_TAG_ACTIVATION_DATE
))
919 TEST_FAILED(tracker
, __func__
, __LINE__
);
921 if(!kmip_is_attribute_tag(KMIP_TAG_PROCESS_START_DATE
))
923 TEST_FAILED(tracker
, __func__
, __LINE__
);
925 if(!kmip_is_attribute_tag(KMIP_TAG_PROTECT_STOP_DATE
))
927 TEST_FAILED(tracker
, __func__
, __LINE__
);
929 if(!kmip_is_attribute_tag(KMIP_TAG_DEACTIVATION_DATE
))
931 TEST_FAILED(tracker
, __func__
, __LINE__
);
933 if(!kmip_is_attribute_tag(KMIP_TAG_DESTROY_DATE
))
935 TEST_FAILED(tracker
, __func__
, __LINE__
);
937 if(!kmip_is_attribute_tag(KMIP_TAG_COMPROMISE_OCCURRENCE_DATE
))
939 TEST_FAILED(tracker
, __func__
, __LINE__
);
941 if(!kmip_is_attribute_tag(KMIP_TAG_COMPROMISE_DATE
))
943 TEST_FAILED(tracker
, __func__
, __LINE__
);
945 if(!kmip_is_attribute_tag(KMIP_TAG_REVOCATION_REASON
))
947 TEST_FAILED(tracker
, __func__
, __LINE__
);
949 if(!kmip_is_attribute_tag(KMIP_TAG_ARCHIVE_DATE
))
951 TEST_FAILED(tracker
, __func__
, __LINE__
);
953 if(!kmip_is_attribute_tag(KMIP_TAG_OBJECT_GROUP
))
955 TEST_FAILED(tracker
, __func__
, __LINE__
);
957 if(!kmip_is_attribute_tag(KMIP_TAG_FRESH
))
959 TEST_FAILED(tracker
, __func__
, __LINE__
);
961 if(!kmip_is_attribute_tag(KMIP_TAG_LINK
))
963 TEST_FAILED(tracker
, __func__
, __LINE__
);
965 if(!kmip_is_attribute_tag(KMIP_TAG_APPLICATION_SPECIFIC_INFORMATION
))
967 TEST_FAILED(tracker
, __func__
, __LINE__
);
969 if(!kmip_is_attribute_tag(KMIP_TAG_CONTACT_INFORMATION
))
971 TEST_FAILED(tracker
, __func__
, __LINE__
);
973 if(!kmip_is_attribute_tag(KMIP_TAG_LAST_CHANGE_DATE
))
975 TEST_FAILED(tracker
, __func__
, __LINE__
);
977 if(!kmip_is_attribute_tag(KMIP_TAG_ALTERNATIVE_NAME
))
979 TEST_FAILED(tracker
, __func__
, __LINE__
);
981 if(!kmip_is_attribute_tag(KMIP_TAG_KEY_VALUE_PRESENT
))
983 TEST_FAILED(tracker
, __func__
, __LINE__
);
985 if(!kmip_is_attribute_tag(KMIP_TAG_KEY_VALUE_LOCATION
))
987 TEST_FAILED(tracker
, __func__
, __LINE__
);
989 if(!kmip_is_attribute_tag(KMIP_TAG_ORIGINAL_CREATION_DATE
))
991 TEST_FAILED(tracker
, __func__
, __LINE__
);
993 if(!kmip_is_attribute_tag(KMIP_TAG_RANDOM_NUMBER_GENERATOR
))
995 TEST_FAILED(tracker
, __func__
, __LINE__
);
997 if(!kmip_is_attribute_tag(KMIP_TAG_PKCS_12_FRIENDLY_NAME
))
999 TEST_FAILED(tracker
, __func__
, __LINE__
);
1001 if(!kmip_is_attribute_tag(KMIP_TAG_DESCRIPTION
))
1003 TEST_FAILED(tracker
, __func__
, __LINE__
);
1005 if(!kmip_is_attribute_tag(KMIP_TAG_COMMENT
))
1007 TEST_FAILED(tracker
, __func__
, __LINE__
);
1009 if(!kmip_is_attribute_tag(KMIP_TAG_SENSITIVE
))
1011 TEST_FAILED(tracker
, __func__
, __LINE__
);
1013 if(!kmip_is_attribute_tag(KMIP_TAG_ALWAYS_SENSITIVE
))
1015 TEST_FAILED(tracker
, __func__
, __LINE__
);
1017 if(!kmip_is_attribute_tag(KMIP_TAG_EXTRACTABLE
))
1019 TEST_FAILED(tracker
, __func__
, __LINE__
);
1021 if(!kmip_is_attribute_tag(KMIP_TAG_NEVER_EXTRACTABLE
))
1023 TEST_FAILED(tracker
, __func__
, __LINE__
);
1025 if(!kmip_is_attribute_tag(KMIP_TAG_KEY_FORMAT_TYPE
))
1027 TEST_FAILED(tracker
, __func__
, __LINE__
);
1030 if(kmip_is_attribute_tag(KMIP_TAG_REQUEST_MESSAGE
))
1032 TEST_FAILED(tracker
, __func__
, __LINE__
);
1035 TEST_PASSED(tracker
, __func__
);
1039 test_get_enum_string_index(TestTracker
*tracker
)
1041 TRACK_TEST(tracker
);
1043 if(kmip_get_enum_string_index(KMIP_TAG_UNIQUE_IDENTIFIER
) != 0)
1045 TEST_FAILED(tracker
, __func__
, __LINE__
);
1048 if(kmip_get_enum_string_index(KMIP_TAG_NAME
) != 1)
1050 TEST_FAILED(tracker
, __func__
, __LINE__
);
1053 if(kmip_get_enum_string_index(KMIP_TAG_OBJECT_TYPE
) != 2)
1055 TEST_FAILED(tracker
, __func__
, __LINE__
);
1058 if(kmip_get_enum_string_index(KMIP_TAG_CRYPTOGRAPHIC_ALGORITHM
) != 3)
1060 TEST_FAILED(tracker
, __func__
, __LINE__
);
1063 if(kmip_get_enum_string_index(KMIP_TAG_CRYPTOGRAPHIC_LENGTH
) != 4)
1065 TEST_FAILED(tracker
, __func__
, __LINE__
);
1068 if(kmip_get_enum_string_index(KMIP_TAG_CRYPTOGRAPHIC_PARAMETERS
) != 5)
1070 TEST_FAILED(tracker
, __func__
, __LINE__
);
1073 if(kmip_get_enum_string_index(KMIP_TAG_CRYPTOGRAPHIC_DOMAIN_PARAMETERS
) != 6)
1075 TEST_FAILED(tracker
, __func__
, __LINE__
);
1078 if(kmip_get_enum_string_index(KMIP_TAG_CERTIFICATE_TYPE
) != 7)
1080 TEST_FAILED(tracker
, __func__
, __LINE__
);
1083 if(kmip_get_enum_string_index(KMIP_TAG_CERTIFICATE_LENGTH
) != 8)
1085 TEST_FAILED(tracker
, __func__
, __LINE__
);
1088 if(kmip_get_enum_string_index(KMIP_TAG_X509_CERTIFICATE_IDENTIFIER
) != 9)
1090 TEST_FAILED(tracker
, __func__
, __LINE__
);
1093 if(kmip_get_enum_string_index(KMIP_TAG_X509_CERTIFICATE_SUBJECT
) != 10)
1095 TEST_FAILED(tracker
, __func__
, __LINE__
);
1098 if(kmip_get_enum_string_index(KMIP_TAG_X509_CERTIFICATE_ISSUER
) != 11)
1100 TEST_FAILED(tracker
, __func__
, __LINE__
);
1103 if(kmip_get_enum_string_index(KMIP_TAG_CERTIFICATE_IDENTIFIER
) != 12)
1105 TEST_FAILED(tracker
, __func__
, __LINE__
);
1108 if(kmip_get_enum_string_index(KMIP_TAG_CERTIFICATE_SUBJECT
) != 13)
1110 TEST_FAILED(tracker
, __func__
, __LINE__
);
1113 if(kmip_get_enum_string_index(KMIP_TAG_CERTIFICATE_ISSUER
) != 14)
1115 TEST_FAILED(tracker
, __func__
, __LINE__
);
1118 if(kmip_get_enum_string_index(KMIP_TAG_DIGITAL_SIGNATURE_ALGORITHM
) != 15)
1120 TEST_FAILED(tracker
, __func__
, __LINE__
);
1123 if(kmip_get_enum_string_index(KMIP_TAG_DIGEST
) != 16)
1125 TEST_FAILED(tracker
, __func__
, __LINE__
);
1128 if(kmip_get_enum_string_index(KMIP_TAG_OPERATION_POLICY_NAME
) != 17)
1130 TEST_FAILED(tracker
, __func__
, __LINE__
);
1133 if(kmip_get_enum_string_index(KMIP_TAG_CRYPTOGRAPHIC_USAGE_MASK
) != 18)
1135 TEST_FAILED(tracker
, __func__
, __LINE__
);
1138 if(kmip_get_enum_string_index(KMIP_TAG_LEASE_TIME
) != 19)
1140 TEST_FAILED(tracker
, __func__
, __LINE__
);
1143 if(kmip_get_enum_string_index(KMIP_TAG_USAGE_LIMITS
) != 20)
1145 TEST_FAILED(tracker
, __func__
, __LINE__
);
1148 if(kmip_get_enum_string_index(KMIP_TAG_STATE
) != 21)
1150 TEST_FAILED(tracker
, __func__
, __LINE__
);
1153 if(kmip_get_enum_string_index(KMIP_TAG_INITIAL_DATE
) != 22)
1155 TEST_FAILED(tracker
, __func__
, __LINE__
);
1158 if(kmip_get_enum_string_index(KMIP_TAG_ACTIVATION_DATE
) != 23)
1160 TEST_FAILED(tracker
, __func__
, __LINE__
);
1163 if(kmip_get_enum_string_index(KMIP_TAG_PROCESS_START_DATE
) != 24)
1165 TEST_FAILED(tracker
, __func__
, __LINE__
);
1168 if(kmip_get_enum_string_index(KMIP_TAG_PROTECT_STOP_DATE
) != 25)
1170 TEST_FAILED(tracker
, __func__
, __LINE__
);
1173 if(kmip_get_enum_string_index(KMIP_TAG_DEACTIVATION_DATE
) != 26)
1175 TEST_FAILED(tracker
, __func__
, __LINE__
);
1178 if(kmip_get_enum_string_index(KMIP_TAG_DESTROY_DATE
) != 27)
1180 TEST_FAILED(tracker
, __func__
, __LINE__
);
1183 if(kmip_get_enum_string_index(KMIP_TAG_COMPROMISE_OCCURRENCE_DATE
) != 28)
1185 TEST_FAILED(tracker
, __func__
, __LINE__
);
1188 if(kmip_get_enum_string_index(KMIP_TAG_COMPROMISE_DATE
) != 29)
1190 TEST_FAILED(tracker
, __func__
, __LINE__
);
1193 if(kmip_get_enum_string_index(KMIP_TAG_REVOCATION_REASON
) != 30)
1195 TEST_FAILED(tracker
, __func__
, __LINE__
);
1198 if(kmip_get_enum_string_index(KMIP_TAG_ARCHIVE_DATE
) != 31)
1200 TEST_FAILED(tracker
, __func__
, __LINE__
);
1203 if(kmip_get_enum_string_index(KMIP_TAG_OBJECT_GROUP
) != 32)
1205 TEST_FAILED(tracker
, __func__
, __LINE__
);
1208 if(kmip_get_enum_string_index(KMIP_TAG_FRESH
) != 33)
1210 TEST_FAILED(tracker
, __func__
, __LINE__
);
1213 if(kmip_get_enum_string_index(KMIP_TAG_LINK
) != 34)
1215 TEST_FAILED(tracker
, __func__
, __LINE__
);
1218 if(kmip_get_enum_string_index(KMIP_TAG_APPLICATION_SPECIFIC_INFORMATION
) != 35)
1220 TEST_FAILED(tracker
, __func__
, __LINE__
);
1223 if(kmip_get_enum_string_index(KMIP_TAG_CONTACT_INFORMATION
) != 36)
1225 TEST_FAILED(tracker
, __func__
, __LINE__
);
1228 if(kmip_get_enum_string_index(KMIP_TAG_LAST_CHANGE_DATE
) != 37)
1230 TEST_FAILED(tracker
, __func__
, __LINE__
);
1233 if(kmip_get_enum_string_index(KMIP_TAG_ALTERNATIVE_NAME
) != 38)
1235 TEST_FAILED(tracker
, __func__
, __LINE__
);
1238 if(kmip_get_enum_string_index(KMIP_TAG_KEY_VALUE_PRESENT
) != 39)
1240 TEST_FAILED(tracker
, __func__
, __LINE__
);
1243 if(kmip_get_enum_string_index(KMIP_TAG_KEY_VALUE_LOCATION
) != 40)
1245 TEST_FAILED(tracker
, __func__
, __LINE__
);
1248 if(kmip_get_enum_string_index(KMIP_TAG_ORIGINAL_CREATION_DATE
) != 41)
1250 TEST_FAILED(tracker
, __func__
, __LINE__
);
1253 if(kmip_get_enum_string_index(KMIP_TAG_RANDOM_NUMBER_GENERATOR
) != 42)
1255 TEST_FAILED(tracker
, __func__
, __LINE__
);
1258 if(kmip_get_enum_string_index(KMIP_TAG_PKCS_12_FRIENDLY_NAME
) != 43)
1260 TEST_FAILED(tracker
, __func__
, __LINE__
);
1263 if(kmip_get_enum_string_index(KMIP_TAG_DESCRIPTION
) != 44)
1265 TEST_FAILED(tracker
, __func__
, __LINE__
);
1268 if(kmip_get_enum_string_index(KMIP_TAG_COMMENT
) != 45)
1270 TEST_FAILED(tracker
, __func__
, __LINE__
);
1273 if(kmip_get_enum_string_index(KMIP_TAG_SENSITIVE
) != 46)
1275 TEST_FAILED(tracker
, __func__
, __LINE__
);
1278 if(kmip_get_enum_string_index(KMIP_TAG_ALWAYS_SENSITIVE
) != 47)
1280 TEST_FAILED(tracker
, __func__
, __LINE__
);
1283 if(kmip_get_enum_string_index(KMIP_TAG_EXTRACTABLE
) != 48)
1285 TEST_FAILED(tracker
, __func__
, __LINE__
);
1288 if(kmip_get_enum_string_index(KMIP_TAG_NEVER_EXTRACTABLE
) != 49)
1290 TEST_FAILED(tracker
, __func__
, __LINE__
);
1293 if(kmip_get_enum_string_index(KMIP_TAG_KEY_FORMAT_TYPE
) != 50)
1295 TEST_FAILED(tracker
, __func__
, __LINE__
);
1298 if(kmip_get_enum_string_index(-1) != 51)
1300 TEST_FAILED(tracker
, __func__
, __LINE__
);
1303 TEST_PASSED(tracker
, __func__
);
1307 test_check_enum_value_protection_storage_masks(TestTracker
*tracker
)
1309 TRACK_TEST(tracker
);
1311 enum kmip_version v
= KMIP_2_0
;
1312 enum tag t
= KMIP_TAG_PROTECTION_STORAGE_MASK
;
1314 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_SOFTWARE
) != KMIP_OK
)
1316 TEST_FAILED(tracker
, __func__
, __LINE__
);
1319 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_HARDWARE
) != KMIP_OK
)
1321 TEST_FAILED(tracker
, __func__
, __LINE__
);
1324 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_ON_PROCESSOR
) != KMIP_OK
)
1326 TEST_FAILED(tracker
, __func__
, __LINE__
);
1329 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_ON_SYSTEM
) != KMIP_OK
)
1331 TEST_FAILED(tracker
, __func__
, __LINE__
);
1334 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OFF_SYSTEM
) != KMIP_OK
)
1336 TEST_FAILED(tracker
, __func__
, __LINE__
);
1339 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_HYPERVISOR
) != KMIP_OK
)
1341 TEST_FAILED(tracker
, __func__
, __LINE__
);
1344 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OPERATING_SYSTEM
) != KMIP_OK
)
1346 TEST_FAILED(tracker
, __func__
, __LINE__
);
1349 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_CONTAINER
) != KMIP_OK
)
1351 TEST_FAILED(tracker
, __func__
, __LINE__
);
1354 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_ON_PREMISES
) != KMIP_OK
)
1356 TEST_FAILED(tracker
, __func__
, __LINE__
);
1359 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OFF_PREMISES
) != KMIP_OK
)
1361 TEST_FAILED(tracker
, __func__
, __LINE__
);
1364 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_SELF_MANAGED
) != KMIP_OK
)
1366 TEST_FAILED(tracker
, __func__
, __LINE__
);
1369 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OUTSOURCED
) != KMIP_OK
)
1371 TEST_FAILED(tracker
, __func__
, __LINE__
);
1374 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_VALIDATED
) != KMIP_OK
)
1376 TEST_FAILED(tracker
, __func__
, __LINE__
);
1379 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_SAME_JURISDICTION
) != KMIP_OK
)
1381 TEST_FAILED(tracker
, __func__
, __LINE__
);
1386 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_SOFTWARE
) != KMIP_INVALID_FOR_VERSION
)
1388 TEST_FAILED(tracker
, __func__
, __LINE__
);
1391 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_HARDWARE
) != KMIP_INVALID_FOR_VERSION
)
1393 TEST_FAILED(tracker
, __func__
, __LINE__
);
1396 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_ON_PROCESSOR
) != KMIP_INVALID_FOR_VERSION
)
1398 TEST_FAILED(tracker
, __func__
, __LINE__
);
1401 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_ON_SYSTEM
) != KMIP_INVALID_FOR_VERSION
)
1403 TEST_FAILED(tracker
, __func__
, __LINE__
);
1406 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OFF_SYSTEM
) != KMIP_INVALID_FOR_VERSION
)
1408 TEST_FAILED(tracker
, __func__
, __LINE__
);
1411 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_HYPERVISOR
) != KMIP_INVALID_FOR_VERSION
)
1413 TEST_FAILED(tracker
, __func__
, __LINE__
);
1416 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OPERATING_SYSTEM
) != KMIP_INVALID_FOR_VERSION
)
1418 TEST_FAILED(tracker
, __func__
, __LINE__
);
1421 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_CONTAINER
) != KMIP_INVALID_FOR_VERSION
)
1423 TEST_FAILED(tracker
, __func__
, __LINE__
);
1426 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_ON_PREMISES
) != KMIP_INVALID_FOR_VERSION
)
1428 TEST_FAILED(tracker
, __func__
, __LINE__
);
1431 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OFF_PREMISES
) != KMIP_INVALID_FOR_VERSION
)
1433 TEST_FAILED(tracker
, __func__
, __LINE__
);
1436 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_SELF_MANAGED
) != KMIP_INVALID_FOR_VERSION
)
1438 TEST_FAILED(tracker
, __func__
, __LINE__
);
1441 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_OUTSOURCED
) != KMIP_INVALID_FOR_VERSION
)
1443 TEST_FAILED(tracker
, __func__
, __LINE__
);
1446 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_VALIDATED
) != KMIP_INVALID_FOR_VERSION
)
1448 TEST_FAILED(tracker
, __func__
, __LINE__
);
1451 if(kmip_check_enum_value(v
, t
, KMIP_PROTECT_SAME_JURISDICTION
) != KMIP_INVALID_FOR_VERSION
)
1453 TEST_FAILED(tracker
, __func__
, __LINE__
);
1456 if(kmip_check_enum_value(v
, t
, -1) != KMIP_ENUM_MISMATCH
)
1458 TEST_FAILED(tracker
, __func__
, __LINE__
);
1461 TEST_PASSED(tracker
, __func__
);
1465 test_init_protocol_version(TestTracker
*tracker
)
1467 TRACK_TEST(tracker
);
1469 kmip_init_protocol_version(NULL
, KMIP_1_0
);
1471 ProtocolVersion pv
= {0};
1474 TEST_FAILED(tracker
, __func__
, __LINE__
);
1476 TEST_FAILED(tracker
, __func__
, __LINE__
);
1478 kmip_init_protocol_version(&pv
, KMIP_1_0
);
1481 TEST_FAILED(tracker
, __func__
, __LINE__
);
1483 TEST_FAILED(tracker
, __func__
, __LINE__
);
1485 kmip_init_protocol_version(&pv
, KMIP_1_1
);
1488 TEST_FAILED(tracker
, __func__
, __LINE__
);
1490 TEST_FAILED(tracker
, __func__
, __LINE__
);
1492 kmip_init_protocol_version(&pv
, KMIP_1_2
);
1495 TEST_FAILED(tracker
, __func__
, __LINE__
);
1497 TEST_FAILED(tracker
, __func__
, __LINE__
);
1499 kmip_init_protocol_version(&pv
, KMIP_1_3
);
1502 TEST_FAILED(tracker
, __func__
, __LINE__
);
1504 TEST_FAILED(tracker
, __func__
, __LINE__
);
1506 kmip_init_protocol_version(&pv
, KMIP_1_4
);
1509 TEST_FAILED(tracker
, __func__
, __LINE__
);
1511 TEST_FAILED(tracker
, __func__
, __LINE__
);
1513 kmip_init_protocol_version(&pv
, KMIP_2_0
);
1516 TEST_FAILED(tracker
, __func__
, __LINE__
);
1518 TEST_FAILED(tracker
, __func__
, __LINE__
);
1520 TEST_PASSED(tracker
, __func__
);
1524 test_init_request_batch_item(TestTracker
*tracker
)
1526 TRACK_TEST(tracker
);
1528 kmip_init_request_batch_item(NULL
);
1530 RequestBatchItem rbi
= {0};
1532 if(rbi
.operation
!= 0)
1533 TEST_FAILED(tracker
, __func__
, __LINE__
);
1534 if(rbi
.unique_batch_item_id
!= NULL
)
1535 TEST_FAILED(tracker
, __func__
, __LINE__
);
1536 if(rbi
.request_payload
!= NULL
)
1537 TEST_FAILED(tracker
, __func__
, __LINE__
);
1538 if(rbi
.ephemeral
!= 0)
1539 TEST_FAILED(tracker
, __func__
, __LINE__
);
1541 kmip_init_request_batch_item(&rbi
);
1543 if(rbi
.operation
!= 0)
1544 TEST_FAILED(tracker
, __func__
, __LINE__
);
1545 if(rbi
.unique_batch_item_id
!= NULL
)
1546 TEST_FAILED(tracker
, __func__
, __LINE__
);
1547 if(rbi
.request_payload
!= NULL
)
1548 TEST_FAILED(tracker
, __func__
, __LINE__
);
1549 if(rbi
.ephemeral
!= KMIP_UNSET
)
1550 TEST_FAILED(tracker
, __func__
, __LINE__
);
1552 TEST_PASSED(tracker
, __func__
);
1556 test_print_attributes(TestTracker
*tracker
)
1558 TRACK_TEST(tracker
);
1560 /* For now this will probably be left as a placeholder for a
1561 future test. Ideally the print functions would output to
1562 an arbitrary buffer so that we can verify that they are
1563 correctly displaying structure content and formatting.
1564 Since they currently use printf directly, this may be hard
1565 to do in the short term.
1567 TEST_FAILED(tracker
, __func__
, __LINE__
);
1571 test_free_attributes(TestTracker
*tracker
)
1573 TRACK_TEST(tracker
);
1575 /* Build a dynamically allocated Attributes structure. Free it
1576 with this function. Verify that all internal pointers and
1577 fields are correctly nullified.
1579 Ideally, hook into the free function managed by the context
1580 and use that hook to verify that the correct free calls are
1581 made on the internal Attributes structure pointers. This
1582 may require more infrastructure work than currently exists.
1584 TEST_FAILED(tracker
, __func__
, __LINE__
);
1588 test_compare_attributes(TestTracker
*tracker
)
1590 TRACK_TEST(tracker
);
1592 /* Build two separate identical Attributes structures. Compare
1593 them with this function and confirm they match.
1595 Build two separate different Attributes structures. Compare
1596 them with this function and confirm they do not match. This
1597 may require multiple rounds, changing different parts of the
1598 underlying Attributes structure. It may make more sense to
1599 split this into multiple test functions.
1601 TEST_FAILED(tracker
, __func__
, __LINE__
);
1605 test_deep_copy_int32(TestTracker
*tracker
)
1607 TRACK_TEST(tracker
);
1609 int32 expected
= 42;
1610 int32
*observed
= NULL
;
1612 observed
= kmip_deep_copy_int32(NULL
, NULL
);
1613 if(observed
!= NULL
)
1614 TEST_FAILED(tracker
, __func__
, __LINE__
);
1617 kmip_init(&ctx
, NULL
, 0, KMIP_1_0
);
1619 observed
= kmip_deep_copy_int32(&ctx
, NULL
);
1620 if(observed
!= NULL
)
1623 TEST_FAILED(tracker
, __func__
, __LINE__
);
1626 observed
= kmip_deep_copy_int32(&ctx
, &expected
);
1627 if(observed
== NULL
)
1630 TEST_FAILED(tracker
, __func__
, __LINE__
);
1632 if(*observed
!= expected
)
1634 kmip_print_integer(expected
);
1635 kmip_print_integer(*observed
);
1636 ctx
.free_func(ctx
.state
, observed
);
1638 TEST_FAILED(tracker
, __func__
, __LINE__
);
1641 ctx
.free_func(ctx
.state
, observed
);
1644 TEST_PASSED(tracker
, __func__
);
1648 test_deep_copy_text_string(TestTracker
*tracker
)
1650 TRACK_TEST(tracker
);
1652 TextString expected
= {0};
1653 expected
.value
= "example";
1655 TextString
*observed
= NULL
;
1657 observed
= kmip_deep_copy_text_string(NULL
, NULL
);
1658 if(observed
!= NULL
)
1659 TEST_FAILED(tracker
, __func__
, __LINE__
);
1662 kmip_init(&ctx
, NULL
, 0, KMIP_1_0
);
1664 observed
= kmip_deep_copy_text_string(&ctx
, NULL
);
1665 if(observed
!= NULL
)
1668 TEST_FAILED(tracker
, __func__
, __LINE__
);
1671 observed
= kmip_deep_copy_text_string(&ctx
, &expected
);
1672 if(observed
== NULL
)
1675 TEST_FAILED(tracker
, __func__
, __LINE__
);
1677 if(!kmip_compare_text_string(&expected
, observed
))
1679 kmip_print_text_string(1, "Name Value", &expected
);
1680 kmip_print_text_string(1, "Name Value", observed
);
1681 kmip_free_text_string(&ctx
, observed
);
1682 ctx
.free_func(ctx
.state
, observed
);
1684 TEST_FAILED(tracker
, __func__
, __LINE__
);
1687 kmip_free_text_string(&ctx
, observed
);
1688 ctx
.free_func(ctx
.state
, observed
);
1691 TEST_PASSED(tracker
, __func__
);
1695 test_deep_copy_name(TestTracker
*tracker
)
1697 TRACK_TEST(tracker
);
1699 TextString value
= {0};
1700 value
.value
= "example";
1702 Name expected
= {0};
1703 expected
.value
= &value
;
1704 expected
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
1705 Name
*observed
= NULL
;
1707 observed
= kmip_deep_copy_name(NULL
, NULL
);
1708 if(observed
!= NULL
)
1709 TEST_FAILED(tracker
, __func__
, __LINE__
);
1712 kmip_init(&ctx
, NULL
, 0, KMIP_1_0
);
1714 observed
= kmip_deep_copy_name(&ctx
, NULL
);
1715 if(observed
!= NULL
)
1718 TEST_FAILED(tracker
, __func__
, __LINE__
);
1721 observed
= kmip_deep_copy_name(&ctx
, &expected
);
1722 if(observed
== NULL
)
1725 TEST_FAILED(tracker
, __func__
, __LINE__
);
1727 if(!kmip_compare_name(&expected
, observed
))
1729 kmip_print_name(1, &expected
);
1730 kmip_print_name(1, observed
);
1731 kmip_free_name(&ctx
, observed
);
1732 ctx
.free_func(ctx
.state
, observed
);
1734 TEST_FAILED(tracker
, __func__
, __LINE__
);
1737 kmip_free_name(&ctx
, observed
);
1738 ctx
.free_func(ctx
.state
, observed
);
1741 TEST_PASSED(tracker
, __func__
);
1745 test_deep_copy_attribute(TestTracker
*tracker
)
1747 TRACK_TEST(tracker
);
1749 Attribute expected
= {0};
1750 kmip_init_attribute(&expected
);
1751 Attribute
*observed
= NULL
;
1753 observed
= kmip_deep_copy_attribute(NULL
, NULL
);
1754 if(observed
!= NULL
)
1755 TEST_FAILED(tracker
, __func__
, __LINE__
);
1758 kmip_init(&ctx
, NULL
, 0, KMIP_1_0
);
1760 observed
= kmip_deep_copy_attribute(&ctx
, NULL
);
1761 if(observed
!= NULL
)
1764 TEST_FAILED(tracker
, __func__
, __LINE__
);
1767 /* Test deep copying an "empty" attribute. */
1768 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1769 if(observed
== NULL
)
1772 TEST_FAILED(tracker
, __func__
, __LINE__
);
1774 if(!kmip_compare_attribute(&expected
, observed
))
1776 kmip_print_attribute(1, &expected
);
1777 kmip_print_attribute(1, observed
);
1778 kmip_free_attribute(&ctx
, observed
);
1779 ctx
.free_func(ctx
.state
, observed
);
1781 TEST_FAILED(tracker
, __func__
, __LINE__
);
1784 kmip_free_attribute(&ctx
, observed
);
1785 ctx
.free_func(ctx
.state
, observed
);
1787 /* Test deep copying a Unique Identifier attribute. */
1788 TextString uuid
= {0};
1789 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
1791 expected
.type
= KMIP_ATTR_UNIQUE_IDENTIFIER
;
1792 expected
.value
= &uuid
;
1794 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1795 if(observed
== NULL
)
1798 TEST_FAILED(tracker
, __func__
, __LINE__
);
1800 if(!kmip_compare_attribute(&expected
, observed
))
1802 kmip_print_attribute(1, &expected
);
1803 kmip_print_attribute(1, observed
);
1804 kmip_free_attribute(&ctx
, observed
);
1805 ctx
.free_func(ctx
.state
, observed
);
1807 TEST_FAILED(tracker
, __func__
, __LINE__
);
1810 kmip_free_attribute(&ctx
, observed
);
1811 ctx
.free_func(ctx
.state
, observed
);
1813 /* Test deep copying an Operation Policy Name attribute. */
1814 TextString policy
= {0};
1815 policy
.value
= "default";
1817 expected
.type
= KMIP_ATTR_OPERATION_POLICY_NAME
;
1818 expected
.value
= &policy
;
1820 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1821 if(observed
== NULL
)
1824 TEST_FAILED(tracker
, __func__
, __LINE__
);
1826 if(!kmip_compare_attribute(&expected
, observed
))
1828 kmip_print_attribute(1, &expected
);
1829 kmip_print_attribute(1, observed
);
1830 kmip_free_attribute(&ctx
, observed
);
1831 ctx
.free_func(ctx
.state
, observed
);
1833 TEST_FAILED(tracker
, __func__
, __LINE__
);
1836 kmip_free_attribute(&ctx
, observed
);
1837 ctx
.free_func(ctx
.state
, observed
);
1839 /* Test deep copying a Name attribute. */
1840 TextString name_value
= {0};
1841 name_value
.value
= "example";
1842 name_value
.size
= 7;
1844 name
.value
= &name_value
;
1845 name
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
1846 expected
.type
= KMIP_ATTR_NAME
;
1847 expected
.value
= &name
;
1849 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1850 if(observed
== NULL
)
1853 TEST_FAILED(tracker
, __func__
, __LINE__
);
1855 if(!kmip_compare_attribute(&expected
, observed
))
1857 kmip_print_attribute(1, &expected
);
1858 kmip_print_attribute(1, observed
);
1859 kmip_free_attribute(&ctx
, observed
);
1860 ctx
.free_func(ctx
.state
, observed
);
1862 TEST_FAILED(tracker
, __func__
, __LINE__
);
1865 kmip_free_attribute(&ctx
, observed
);
1866 ctx
.free_func(ctx
.state
, observed
);
1868 /* Test deep copying an Object Type attribute. */
1869 enum object_type object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
1870 expected
.type
= KMIP_ATTR_OBJECT_TYPE
;
1871 expected
.value
= &object_type
;
1873 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1874 if(observed
== NULL
)
1877 TEST_FAILED(tracker
, __func__
, __LINE__
);
1879 if(!kmip_compare_attribute(&expected
, observed
))
1881 kmip_print_attribute(1, &expected
);
1882 kmip_print_attribute(1, observed
);
1883 kmip_free_attribute(&ctx
, observed
);
1884 ctx
.free_func(ctx
.state
, observed
);
1886 TEST_FAILED(tracker
, __func__
, __LINE__
);
1889 kmip_free_attribute(&ctx
, observed
);
1890 ctx
.free_func(ctx
.state
, observed
);
1892 /* Test deep copying a Cryptographic Algorithm attribute. */
1893 enum cryptographic_algorithm cryptographic_algorithm
= KMIP_CRYPTOALG_AES
;
1894 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
1895 expected
.value
= &cryptographic_algorithm
;
1897 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1898 if(observed
== NULL
)
1901 TEST_FAILED(tracker
, __func__
, __LINE__
);
1903 if(!kmip_compare_attribute(&expected
, observed
))
1905 kmip_print_attribute(1, &expected
);
1906 kmip_print_attribute(1, observed
);
1907 kmip_free_attribute(&ctx
, observed
);
1908 ctx
.free_func(ctx
.state
, observed
);
1910 TEST_FAILED(tracker
, __func__
, __LINE__
);
1913 kmip_free_attribute(&ctx
, observed
);
1914 ctx
.free_func(ctx
.state
, observed
);
1916 /* Test deep copying a Cryptographic Length attribute. */
1917 int32 cryptographic_length
= 256;
1918 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
1919 expected
.value
= &cryptographic_length
;
1921 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1922 if(observed
== NULL
)
1925 TEST_FAILED(tracker
, __func__
, __LINE__
);
1927 if(!kmip_compare_attribute(&expected
, observed
))
1929 kmip_print_attribute(1, &expected
);
1930 kmip_print_attribute(1, observed
);
1931 kmip_free_attribute(&ctx
, observed
);
1932 ctx
.free_func(ctx
.state
, observed
);
1934 TEST_FAILED(tracker
, __func__
, __LINE__
);
1937 kmip_free_attribute(&ctx
, observed
);
1938 ctx
.free_func(ctx
.state
, observed
);
1940 /* Test deep copying a Cryptographic Usage Mask attribute. */
1941 int32 cryptographic_usage_mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
1942 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
1943 expected
.value
= &cryptographic_usage_mask
;
1945 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1946 if(observed
== NULL
)
1949 TEST_FAILED(tracker
, __func__
, __LINE__
);
1951 if(!kmip_compare_attribute(&expected
, observed
))
1953 kmip_print_attribute(1, &expected
);
1954 kmip_print_attribute(1, observed
);
1955 kmip_free_attribute(&ctx
, observed
);
1956 ctx
.free_func(ctx
.state
, observed
);
1958 TEST_FAILED(tracker
, __func__
, __LINE__
);
1961 kmip_free_attribute(&ctx
, observed
);
1962 ctx
.free_func(ctx
.state
, observed
);
1964 /* Test deep copying a State attribute. */
1965 enum state state
= KMIP_STATE_ACTIVE
;
1966 expected
.type
= KMIP_ATTR_STATE
;
1967 expected
.value
= &state
;
1969 observed
= kmip_deep_copy_attribute(&ctx
, &expected
);
1970 if(observed
== NULL
)
1973 TEST_FAILED(tracker
, __func__
, __LINE__
);
1975 if(!kmip_compare_attribute(&expected
, observed
))
1977 kmip_print_attribute(1, &expected
);
1978 kmip_print_attribute(1, observed
);
1979 kmip_free_attribute(&ctx
, observed
);
1980 ctx
.free_func(ctx
.state
, observed
);
1982 TEST_FAILED(tracker
, __func__
, __LINE__
);
1985 kmip_free_attribute(&ctx
, observed
);
1986 ctx
.free_func(ctx
.state
, observed
);
1989 TEST_PASSED(tracker
, __func__
);
1993 test_decode_int8_be(TestTracker
*tracker
)
1995 TRACK_TEST(tracker
);
1997 uint8 encoding
[1] = {0x42};
1999 struct kmip ctx
= {0};
2000 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2004 int result
= kmip_decode_int8_be(&ctx
, &value
);
2005 result
= report_decoding_test_result(
2016 test_decode_int32_be(TestTracker
*tracker
)
2018 TRACK_TEST(tracker
);
2020 uint8 encoding
[4] = {0x11, 0x22, 0x33, 0x44};
2022 struct kmip ctx
= {0};
2023 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2025 int32 expected
= 0x11223344;
2028 int result
= kmip_decode_int32_be(&ctx
, &observed
);
2029 result
= report_decoding_test_result(
2032 observed
== expected
,
2040 test_decode_int64_be(TestTracker
*tracker
)
2042 TRACK_TEST(tracker
);
2044 uint8 encoding
[8] = {
2045 0x01, 0xB6, 0x9B, 0x4B, 0xA5, 0x74, 0x92, 0x00
2048 struct kmip ctx
= {0};
2049 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2051 int64 expected
= 0x01B69B4BA5749200;
2054 int result
= kmip_decode_int64_be(&ctx
, &observed
);
2055 result
= report_decoding_test_result(
2058 observed
== expected
,
2066 test_encode_integer(TestTracker
*tracker
)
2068 TRACK_TEST(tracker
);
2070 uint8 expected
[16] = {
2071 0x42, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04,
2072 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00
2075 uint8 observed
[16] = {0};
2076 struct kmip ctx
= {0};
2077 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2079 int result
= kmip_encode_integer(&ctx
, KMIP_TAG_DEFAULT
, 8);
2080 result
= report_encoding_test_result(
2092 test_decode_integer(TestTracker
*tracker
)
2094 TRACK_TEST(tracker
);
2096 uint8 encoding
[16] = {
2097 0x42, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04,
2098 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00
2101 struct kmip ctx
= {0};
2102 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2107 int result
= kmip_decode_integer(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2108 result
= report_decoding_test_result(
2111 observed
== expected
,
2119 test_encode_long(TestTracker
*tracker
)
2121 TRACK_TEST(tracker
);
2123 uint8 expected
[16] = {
2124 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08,
2125 0x01, 0xB6, 0x9B, 0x4B, 0xA5, 0x74, 0x92, 0x00
2128 uint8 observed
[16] = {0};
2129 struct kmip ctx
= {0};
2130 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2132 int result
= kmip_encode_long(&ctx
, KMIP_TAG_DEFAULT
, 123456789000000000);
2133 result
= report_encoding_test_result(
2145 test_decode_long(TestTracker
*tracker
)
2147 TRACK_TEST(tracker
);
2149 uint8 encoding
[16] = {
2150 0x42, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08,
2151 0x01, 0xB6, 0x9B, 0x4B, 0xA5, 0x74, 0x92, 0x00
2154 struct kmip ctx
= {0};
2155 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2157 int64 expected
= 0x01B69B4BA5749200;
2160 int result
= kmip_decode_long(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2161 result
= report_decoding_test_result(
2164 observed
== expected
,
2172 test_encode_enum(TestTracker
*tracker
)
2174 TRACK_TEST(tracker
);
2176 uint8 expected
[16] = {
2177 0x42, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04,
2178 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
2181 uint8 observed
[16] = {0};
2182 struct kmip ctx
= {0};
2183 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2185 int result
= kmip_encode_enum(&ctx
, KMIP_TAG_DEFAULT
, KMIP_CRYPTOALG_AES
);
2186 result
= report_encoding_test_result(
2198 test_decode_enum(TestTracker
*tracker
)
2200 TRACK_TEST(tracker
);
2202 uint8 encoding
[16] = {
2203 0x42, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04,
2204 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
2207 struct kmip ctx
= {0};
2208 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2210 enum cryptographic_algorithm expected
= KMIP_CRYPTOALG_AES
;
2211 enum cryptographic_algorithm observed
= 0;
2213 int result
= kmip_decode_enum(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2214 result
= report_decoding_test_result(
2217 observed
== expected
,
2225 test_encode_bool(TestTracker
*tracker
)
2227 TRACK_TEST(tracker
);
2229 uint8 expected
[16] = {
2230 0x42, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08,
2231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
2234 uint8 observed
[16] = {0};
2235 struct kmip ctx
= {0};
2236 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2238 int result
= kmip_encode_bool(&ctx
, KMIP_TAG_DEFAULT
, KMIP_TRUE
);
2239 result
= report_encoding_test_result(
2251 test_decode_bool(TestTracker
*tracker
)
2253 TRACK_TEST(tracker
);
2255 uint8 encoding
[16] = {
2256 0x42, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x08,
2257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
2260 struct kmip ctx
= {0};
2261 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2263 bool32 expected
= KMIP_TRUE
;
2264 bool32 observed
= 0;
2266 int result
= kmip_decode_bool(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2267 result
= report_decoding_test_result(
2270 observed
== expected
,
2278 test_encode_text_string(TestTracker
*tracker
)
2280 TRACK_TEST(tracker
);
2282 uint8 expected
[24] = {
2283 0x42, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0B,
2284 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F,
2285 0x72, 0x6C, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00
2288 uint8 observed
[24] = {0};
2289 struct kmip ctx
= {0};
2290 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2292 struct text_string example
= {0};
2293 example
.value
= "Hello World";
2296 int result
= kmip_encode_text_string(&ctx
, KMIP_TAG_DEFAULT
, &example
);
2297 result
= report_encoding_test_result(
2309 test_decode_text_string(TestTracker
*tracker
)
2311 TRACK_TEST(tracker
);
2313 uint8 encoding
[24] = {
2314 0x42, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0B,
2315 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x57, 0x6F,
2316 0x72, 0x6C, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00
2319 struct kmip ctx
= {0};
2320 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2322 struct text_string expected
= {0};
2323 expected
.value
= "Hello World";
2325 struct text_string observed
= {0};
2327 int result
= kmip_decode_text_string(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2328 result
= report_decoding_test_result(
2331 kmip_compare_text_string(&expected
, &observed
),
2334 kmip_free_text_string(&ctx
, &observed
);
2340 test_encode_byte_string(TestTracker
*tracker
)
2342 TRACK_TEST(tracker
);
2344 uint8 expected
[16] = {
2345 0x42, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03,
2346 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
2349 uint8 observed
[16] = {0};
2350 struct kmip ctx
= {0};
2351 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2352 uint8 str
[3] = {0x01, 0x02, 0x03};
2354 struct byte_string example
= {0};
2355 example
.value
= str
;
2358 int result
= kmip_encode_byte_string(&ctx
, KMIP_TAG_DEFAULT
, &example
);
2359 result
= report_encoding_test_result(
2371 test_decode_byte_string(TestTracker
*tracker
)
2373 TRACK_TEST(tracker
);
2375 uint8 encoding
[16] = {
2376 0x42, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03,
2377 0x01, 0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00
2380 struct kmip ctx
= {0};
2381 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2383 uint8 str
[3] = {0x01, 0x02, 0x03};
2385 struct byte_string expected
= {0};
2386 expected
.value
= str
;
2388 struct byte_string observed
= {0};
2390 int result
= kmip_decode_byte_string(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2391 result
= report_decoding_test_result(
2394 kmip_compare_byte_string(&expected
, &observed
),
2397 kmip_free_byte_string(&ctx
, &observed
);
2403 test_encode_date_time(TestTracker
*tracker
)
2405 TRACK_TEST(tracker
);
2407 uint8 expected
[16] = {
2408 0x42, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08,
2409 0x00, 0x00, 0x00, 0x00, 0x47, 0xDA, 0x67, 0xF8
2412 uint8 observed
[16] = {0};
2413 struct kmip ctx
= {0};
2414 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2416 int result
= kmip_encode_date_time(&ctx
, KMIP_TAG_DEFAULT
, 1205495800);
2417 result
= report_encoding_test_result(
2429 test_decode_date_time(TestTracker
*tracker
)
2431 TRACK_TEST(tracker
);
2433 uint8 encoding
[16] = {
2434 0x42, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x08,
2435 0x00, 0x00, 0x00, 0x00, 0x47, 0xDA, 0x67, 0xF8
2438 struct kmip ctx
= {0};
2439 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2441 uint64 expected
= 1205495800;
2442 uint64 observed
= 0;
2444 int result
= kmip_decode_date_time(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2445 result
= report_decoding_test_result(
2448 observed
== expected
,
2456 test_encode_interval(TestTracker
*tracker
)
2458 TRACK_TEST(tracker
);
2460 uint8 expected
[16] = {
2461 0x42, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x04,
2462 0x00, 0x0D, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00
2465 uint8 observed
[16] = {0};
2466 struct kmip ctx
= {0};
2467 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2469 int result
= kmip_encode_interval(&ctx
, KMIP_TAG_DEFAULT
, 864000);
2470 result
= report_encoding_test_result(
2482 test_decode_interval(TestTracker
*tracker
)
2484 TRACK_TEST(tracker
);
2486 uint8 encoding
[16] = {
2487 0x42, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x04,
2488 0x00, 0x0D, 0x2F, 0x00, 0x00, 0x00, 0x00, 0x00
2491 struct kmip ctx
= {0};
2492 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2494 uint32 expected
= 864000;
2495 uint32 observed
= 0;
2497 int result
= kmip_decode_interval(&ctx
, KMIP_TAG_DEFAULT
, &observed
);
2498 result
= report_decoding_test_result(
2501 observed
== expected
,
2509 test_encode_name(TestTracker
*tracker
)
2511 TRACK_TEST(tracker
);
2513 uint8 expected
[48] = {
2514 0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28,
2515 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
2516 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
2517 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2518 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
2519 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
2522 uint8 observed
[48] = {0};
2523 struct kmip ctx
= {0};
2524 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2526 struct text_string value
= {0};
2527 value
.value
= "Template1";
2530 struct name n
= {0};
2532 n
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
2534 int result
= kmip_encode_name(&ctx
, &n
);
2535 result
= report_encoding_test_result(
2547 test_decode_name(TestTracker
*tracker
)
2549 TRACK_TEST(tracker
);
2551 uint8 encoding
[48] = {
2552 0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28,
2553 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
2554 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
2555 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2556 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
2557 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
2560 struct kmip ctx
= {0};
2561 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2563 struct text_string value
= {0};
2564 value
.value
= "Template1";
2567 struct name expected
= {0};
2568 expected
.value
= &value
;
2569 expected
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
2570 struct name observed
= {0};
2572 int result
= kmip_decode_name(&ctx
, &observed
);
2573 result
= report_decoding_test_result(
2576 kmip_compare_name(&expected
, &observed
),
2579 kmip_free_name(&ctx
, &observed
);
2585 test_encode_protection_storage_masks(TestTracker
*tracker
)
2587 TRACK_TEST(tracker
);
2589 /* This encoding matches the following set of values:
2590 * Protection Storage Masks
2591 * Protection Storage Mask
2606 * Protection Storage Mask
2610 uint8 expected
[40] = {
2611 0x42, 0x01, 0x5F, 0x01, 0x00, 0x00, 0x00, 0x20,
2612 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
2613 0x00, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x00, 0x00,
2614 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
2615 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
2618 uint8 observed
[40] = {0};
2620 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
2622 LinkedList list
= {0};
2623 LinkedListItem item_1
= {0};
2624 int32 mask_1
= 0x3FFF;
2625 item_1
.data
= &mask_1
;
2627 LinkedListItem item_2
= {0};
2628 int32 mask_2
= 0x0003;
2629 item_2
.data
= &mask_2
;
2631 kmip_linked_list_enqueue(&list
, &item_1
);
2632 kmip_linked_list_enqueue(&list
, &item_2
);
2634 ProtectionStorageMasks psm
= {0};
2637 int result
= kmip_encode_protection_storage_masks(&ctx
, &psm
);
2638 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
2646 test_decode_protection_storage_masks(TestTracker
*tracker
)
2648 TRACK_TEST(tracker
);
2650 /* This encoding matches the following set of values:
2651 * Protection Storage Masks
2652 * Protection Storage Mask
2667 * Protection Storage Mask
2671 uint8 encoding
[40] = {
2672 0x42, 0x01, 0x5F, 0x01, 0x00, 0x00, 0x00, 0x20,
2673 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
2674 0x00, 0x00, 0x3F, 0xFF, 0x00, 0x00, 0x00, 0x00,
2675 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
2676 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
2680 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
2682 LinkedList list
= {0};
2683 LinkedListItem item_1
= {0};
2684 int32 mask_1
= 0x3FFF;
2685 item_1
.data
= &mask_1
;
2687 LinkedListItem item_2
= {0};
2688 int32 mask_2
= 0x0003;
2689 item_2
.data
= &mask_2
;
2691 kmip_linked_list_enqueue(&list
, &item_1
);
2692 kmip_linked_list_enqueue(&list
, &item_2
);
2694 ProtectionStorageMasks expected
= {0};
2695 expected
.masks
= &list
;
2697 ProtectionStorageMasks observed
= {0};
2698 int result
= kmip_decode_protection_storage_masks(&ctx
, &observed
);
2699 int comparison
= kmip_compare_protection_storage_masks(&expected
, &observed
);
2702 kmip_print_protection_storage_masks(1, &expected
);
2703 kmip_print_protection_storage_masks(1, &observed
);
2705 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
2707 kmip_free_protection_storage_masks(&ctx
, &observed
);
2714 test_encode_attribute_unique_identifier(TestTracker
*tracker
)
2716 TRACK_TEST(tracker
);
2718 uint8 expected
[88] = {
2719 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x50,
2720 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x11,
2721 0x55, 0x6E, 0x69, 0x71, 0x75, 0x65, 0x20, 0x49,
2722 0x64, 0x65, 0x6E, 0x74, 0x69, 0x66, 0x69, 0x65,
2723 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2724 0x42, 0x00, 0x0B, 0x07, 0x00, 0x00, 0x00, 0x24,
2725 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
2726 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
2727 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
2728 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
2729 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
2732 uint8 observed
[88] = {0};
2733 struct kmip ctx
= {0};
2734 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2736 struct text_string uuid
= {0};
2737 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
2740 struct attribute attr
= {0};
2741 kmip_init_attribute(&attr
);
2743 attr
.type
= KMIP_ATTR_UNIQUE_IDENTIFIER
;
2746 int result
= kmip_encode_attribute(&ctx
, &attr
);
2747 result
= report_encoding_test_result(
2759 test_decode_attribute_unique_identifier(TestTracker
*tracker
)
2761 TRACK_TEST(tracker
);
2763 uint8 encoding
[88] = {
2764 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x50,
2765 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x11,
2766 0x55, 0x6E, 0x69, 0x71, 0x75, 0x65, 0x20, 0x49,
2767 0x64, 0x65, 0x6E, 0x74, 0x69, 0x66, 0x69, 0x65,
2768 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2769 0x42, 0x00, 0x0B, 0x07, 0x00, 0x00, 0x00, 0x24,
2770 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
2771 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
2772 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
2773 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
2774 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
2777 struct kmip ctx
= {0};
2778 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2780 struct text_string uuid
= {0};
2781 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
2784 struct attribute expected
= {0};
2785 kmip_init_attribute(&expected
);
2786 expected
.type
= KMIP_ATTR_UNIQUE_IDENTIFIER
;
2787 expected
.value
= &uuid
;
2788 struct attribute observed
= {0};
2789 kmip_init_attribute(&observed
);
2791 int result
= kmip_decode_attribute(&ctx
, &observed
);
2792 result
= report_decoding_test_result(
2795 kmip_compare_attribute(&expected
, &observed
),
2798 kmip_free_attribute(&ctx
, &observed
);
2804 test_encode_attribute_name(TestTracker
*tracker
)
2806 TRACK_TEST(tracker
);
2808 uint8 expected
[72] = {
2809 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x40,
2810 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x04,
2811 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x00,
2812 0x42, 0x00, 0x0B, 0x01, 0x00, 0x00, 0x00, 0x28,
2813 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
2814 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
2815 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2816 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
2817 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
2820 uint8 observed
[72] = {0};
2821 struct kmip ctx
= {0};
2822 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2824 struct text_string value
= {0};
2825 value
.value
= "Template1";
2828 struct name n
= {0};
2830 n
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
2832 struct attribute attr
= {0};
2833 kmip_init_attribute(&attr
);
2835 attr
.type
= KMIP_ATTR_NAME
;
2838 int result
= kmip_encode_attribute(&ctx
, &attr
);
2839 result
= report_encoding_test_result(
2851 test_decode_attribute_name(TestTracker
*tracker
)
2853 TRACK_TEST(tracker
);
2855 uint8 encoding
[72] = {
2856 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x40,
2857 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x04,
2858 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x00,
2859 0x42, 0x00, 0x0B, 0x01, 0x00, 0x00, 0x00, 0x28,
2860 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
2861 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
2862 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2863 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
2864 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
2867 struct kmip ctx
= {0};
2868 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2870 struct text_string value
= {0};
2871 value
.value
= "Template1";
2874 struct name n
= {0};
2876 n
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
2878 struct attribute expected
= {0};
2879 kmip_init_attribute(&expected
);
2880 expected
.type
= KMIP_ATTR_NAME
;
2881 expected
.value
= &n
;
2882 struct attribute observed
= {0};
2883 kmip_init_attribute(&observed
);
2885 int result
= kmip_decode_attribute(&ctx
, &observed
);
2886 result
= report_decoding_test_result(
2889 kmip_compare_attribute(&expected
, &observed
),
2892 kmip_free_attribute(&ctx
, &observed
);
2898 test_encode_attribute_object_type(TestTracker
*tracker
)
2900 TRACK_TEST(tracker
);
2902 uint8 expected
[48] = {
2903 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x28,
2904 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x0B,
2905 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x20, 0x54,
2906 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
2907 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
2908 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
2911 uint8 observed
[48] = {0};
2912 struct kmip ctx
= {0};
2913 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2915 enum object_type t
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
2916 struct attribute attr
= {0};
2917 kmip_init_attribute(&attr
);
2919 attr
.type
= KMIP_ATTR_OBJECT_TYPE
;
2922 int result
= kmip_encode_attribute(&ctx
, &attr
);
2923 result
= report_encoding_test_result(
2935 test_decode_attribute_object_type(TestTracker
*tracker
)
2937 TRACK_TEST(tracker
);
2939 uint8 encoding
[48] = {
2940 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x28,
2941 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x0B,
2942 0x4F, 0x62, 0x6A, 0x65, 0x63, 0x74, 0x20, 0x54,
2943 0x79, 0x70, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00,
2944 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
2945 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
2948 struct kmip ctx
= {0};
2949 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
2951 enum object_type t
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
2952 struct attribute expected
= {0};
2953 kmip_init_attribute(&expected
);
2954 expected
.type
= KMIP_ATTR_OBJECT_TYPE
;
2955 expected
.value
= &t
;
2956 struct attribute observed
= {0};
2957 kmip_init_attribute(&observed
);
2959 int result
= kmip_decode_attribute(&ctx
, &observed
);
2960 result
= report_decoding_test_result(
2963 kmip_compare_attribute(&expected
, &observed
),
2966 kmip_free_attribute(&ctx
, &observed
);
2972 test_encode_attribute_cryptographic_algorithm(TestTracker
*tracker
)
2974 TRACK_TEST(tracker
);
2976 uint8 expected
[56] = {
2977 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
2978 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
2979 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
2980 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
2981 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
2982 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
2983 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
2986 uint8 observed
[56] = {0};
2987 struct kmip ctx
= {0};
2988 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
2990 enum cryptographic_algorithm a
= KMIP_CRYPTOALG_AES
;
2991 struct attribute attr
= {0};
2992 kmip_init_attribute(&attr
);
2994 attr
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
2997 int result
= kmip_encode_attribute(&ctx
, &attr
);
2998 result
= report_encoding_test_result(
3010 test_decode_attribute_cryptographic_algorithm(TestTracker
*tracker
)
3012 TRACK_TEST(tracker
);
3014 uint8 encoding
[56] = {
3015 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
3016 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
3017 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
3018 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
3019 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
3020 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
3021 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
3024 struct kmip ctx
= {0};
3025 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3027 enum cryptographic_algorithm a
= KMIP_CRYPTOALG_AES
;
3028 struct attribute expected
= {0};
3029 kmip_init_attribute(&expected
);
3030 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
3031 expected
.value
= &a
;
3032 struct attribute observed
= {0};
3033 kmip_init_attribute(&observed
);
3035 int result
= kmip_decode_attribute(&ctx
, &observed
);
3036 result
= report_decoding_test_result(
3039 kmip_compare_attribute(&expected
, &observed
),
3042 kmip_free_attribute(&ctx
, &observed
);
3048 test_encode_attribute_cryptographic_length(TestTracker
*tracker
)
3050 TRACK_TEST(tracker
);
3052 uint8 expected
[56] = {
3053 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
3054 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
3055 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
3056 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
3057 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
3058 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
3059 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
3062 uint8 observed
[56] = {0};
3063 struct kmip ctx
= {0};
3064 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3067 struct attribute attr
= {0};
3068 kmip_init_attribute(&attr
);
3070 attr
.type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
3071 attr
.value
= &length
;
3073 int result
= kmip_encode_attribute(&ctx
, &attr
);
3074 result
= report_encoding_test_result(
3086 test_decode_attribute_cryptographic_length(TestTracker
*tracker
)
3088 TRACK_TEST(tracker
);
3090 uint8 encoding
[56] = {
3091 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
3092 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
3093 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
3094 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
3095 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
3096 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
3097 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
3100 struct kmip ctx
= {0};
3101 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3104 struct attribute expected
= {0};
3105 kmip_init_attribute(&expected
);
3106 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
3107 expected
.value
= &length
;
3108 struct attribute observed
= {0};
3109 kmip_init_attribute(&observed
);
3111 int result
= kmip_decode_attribute(&ctx
, &observed
);
3112 result
= report_decoding_test_result(
3115 kmip_compare_attribute(&expected
, &observed
),
3118 kmip_free_attribute(&ctx
, &observed
);
3124 test_encode_attribute_operation_policy_name(TestTracker
*tracker
)
3126 TRACK_TEST(tracker
);
3128 uint8 expected
[56] = {
3129 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
3130 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x15,
3131 0x4F, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6F,
3132 0x6E, 0x20, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79,
3133 0x20, 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00,
3134 0x42, 0x00, 0x0B, 0x07, 0x00, 0x00, 0x00, 0x07,
3135 0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74, 0x00
3138 uint8 observed
[56] = {0};
3139 struct kmip ctx
= {0};
3140 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3142 struct text_string policy
= {0};
3143 policy
.value
= "default";
3146 struct attribute attr
= {0};
3147 kmip_init_attribute(&attr
);
3149 attr
.type
= KMIP_ATTR_OPERATION_POLICY_NAME
;
3150 attr
.value
= &policy
;
3152 int result
= kmip_encode_attribute(&ctx
, &attr
);
3153 result
= report_encoding_test_result(
3165 test_decode_attribute_operation_policy_name(TestTracker
*tracker
)
3167 TRACK_TEST(tracker
);
3169 uint8 encoding
[56] = {
3170 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
3171 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x15,
3172 0x4F, 0x70, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6F,
3173 0x6E, 0x20, 0x50, 0x6F, 0x6C, 0x69, 0x63, 0x79,
3174 0x20, 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00,
3175 0x42, 0x00, 0x0B, 0x07, 0x00, 0x00, 0x00, 0x07,
3176 0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74, 0x00
3179 struct kmip ctx
= {0};
3180 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3182 struct text_string policy
= {0};
3183 policy
.value
= "default";
3186 struct attribute expected
= {0};
3187 kmip_init_attribute(&expected
);
3188 expected
.type
= KMIP_ATTR_OPERATION_POLICY_NAME
;
3189 expected
.value
= &policy
;
3190 struct attribute observed
= {0};
3191 kmip_init_attribute(&observed
);
3193 int result
= kmip_decode_attribute(&ctx
, &observed
);
3194 result
= report_decoding_test_result(
3197 kmip_compare_attribute(&expected
, &observed
),
3200 kmip_free_attribute(&ctx
, &observed
);
3206 test_encode_attribute_cryptographic_usage_mask(TestTracker
*tracker
)
3208 TRACK_TEST(tracker
);
3210 uint8 expected
[56] = {
3211 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
3212 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
3213 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
3214 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
3215 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
3216 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
3217 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
3220 uint8 observed
[56] = {0};
3221 struct kmip ctx
= {0};
3222 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3224 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
3225 struct attribute attr
= {0};
3226 kmip_init_attribute(&attr
);
3228 attr
.type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
3231 int result
= kmip_encode_attribute(&ctx
, &attr
);
3232 result
= report_encoding_test_result(
3244 test_decode_attribute_cryptographic_usage_mask(TestTracker
*tracker
)
3246 TRACK_TEST(tracker
);
3248 uint8 encoding
[56] = {
3249 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
3250 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
3251 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
3252 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
3253 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
3254 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
3255 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
3258 struct kmip ctx
= {0};
3259 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3261 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
3262 struct attribute expected
= {0};
3263 kmip_init_attribute(&expected
);
3264 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
3265 expected
.value
= &mask
;
3266 struct attribute observed
= {0};
3267 kmip_init_attribute(&observed
);
3269 int result
= kmip_decode_attribute(&ctx
, &observed
);
3270 result
= report_decoding_test_result(
3273 kmip_compare_attribute(&expected
, &observed
),
3276 kmip_free_attribute(&ctx
, &observed
);
3282 test_encode_attribute_state(TestTracker
*tracker
)
3284 TRACK_TEST(tracker
);
3286 uint8 expected
[40] = {
3287 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x20,
3288 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x05,
3289 0x53, 0x74, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00,
3290 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
3291 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
3294 uint8 observed
[40] = {0};
3295 struct kmip ctx
= {0};
3296 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3298 enum state s
= KMIP_STATE_PRE_ACTIVE
;
3299 struct attribute attr
= {0};
3300 kmip_init_attribute(&attr
);
3302 attr
.type
= KMIP_ATTR_STATE
;
3305 int result
= kmip_encode_attribute(&ctx
, &attr
);
3306 result
= report_encoding_test_result(
3318 test_decode_attribute_state(TestTracker
*tracker
)
3320 TRACK_TEST(tracker
);
3322 uint8 encoding
[40] = {
3323 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x20,
3324 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x05,
3325 0x53, 0x74, 0x61, 0x74, 0x65, 0x00, 0x00, 0x00,
3326 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
3327 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
3330 struct kmip ctx
= {0};
3331 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3333 enum state s
= KMIP_STATE_PRE_ACTIVE
;
3334 struct attribute expected
= {0};
3335 kmip_init_attribute(&expected
);
3336 expected
.type
= KMIP_ATTR_STATE
;
3337 expected
.value
= &s
;
3338 struct attribute observed
= {0};
3339 kmip_init_attribute(&observed
);
3341 int result
= kmip_decode_attribute(&ctx
, &observed
);
3342 result
= report_decoding_test_result(
3345 kmip_compare_attribute(&expected
, &observed
),
3348 kmip_free_attribute(&ctx
, &observed
);
3354 test_encode_protocol_version(TestTracker
*tracker
)
3356 TRACK_TEST(tracker
);
3358 uint8 expected
[40] = {
3359 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
3360 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
3361 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3362 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
3363 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3366 uint8 observed
[40] = {0};
3367 struct kmip ctx
= {0};
3368 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3370 struct protocol_version pv
= {0};
3374 int result
= kmip_encode_protocol_version(&ctx
, &pv
);
3375 result
= report_encoding_test_result(
3387 test_decode_protocol_version(TestTracker
*tracker
)
3389 TRACK_TEST(tracker
);
3391 uint8 encoding
[40] = {
3392 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
3393 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
3394 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3395 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
3396 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
3399 struct kmip ctx
= {0};
3400 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3402 struct protocol_version expected
= {0};
3405 struct protocol_version observed
= {0};
3407 int result
= kmip_decode_protocol_version(&ctx
, &observed
);
3408 result
= report_decoding_test_result(
3411 kmip_compare_protocol_version(&expected
, &observed
),
3419 test_encode_cryptographic_parameters(TestTracker
*tracker
)
3421 TRACK_TEST(tracker
);
3423 uint8 expected
[72] = {
3424 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x40,
3425 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3426 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3427 0x42, 0x00, 0x5F, 0x05, 0x00, 0x00, 0x00, 0x04,
3428 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
3429 0x42, 0x00, 0x38, 0x05, 0x00, 0x00, 0x00, 0x04,
3430 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
3431 0x42, 0x00, 0x83, 0x05, 0x00, 0x00, 0x00, 0x04,
3432 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00
3435 uint8 observed
[72] = {0};
3436 struct kmip ctx
= {0};
3437 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3439 struct cryptographic_parameters cp
= {0};
3440 cp
.block_cipher_mode
= KMIP_BLOCK_CBC
;
3441 cp
.padding_method
= KMIP_PAD_PKCS5
;
3442 cp
.hashing_algorithm
= KMIP_HASH_SHA1
;
3443 cp
.key_role_type
= KMIP_ROLE_KEK
;
3445 int result
= kmip_encode_cryptographic_parameters(&ctx
, &cp
);
3446 result
= report_encoding_test_result(
3458 test_decode_cryptographic_parameters(TestTracker
*tracker
)
3460 TRACK_TEST(tracker
);
3462 uint8 encoding
[72] = {
3463 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x40,
3464 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3465 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3466 0x42, 0x00, 0x5F, 0x05, 0x00, 0x00, 0x00, 0x04,
3467 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
3468 0x42, 0x00, 0x38, 0x05, 0x00, 0x00, 0x00, 0x04,
3469 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
3470 0x42, 0x00, 0x83, 0x05, 0x00, 0x00, 0x00, 0x04,
3471 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00
3474 struct kmip ctx
= {0};
3475 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3477 struct cryptographic_parameters expected
= {0};
3478 kmip_init_cryptographic_parameters(&expected
);
3479 expected
.block_cipher_mode
= KMIP_BLOCK_CBC
;
3480 expected
.padding_method
= KMIP_PAD_PKCS5
;
3481 expected
.hashing_algorithm
= KMIP_HASH_SHA1
;
3482 expected
.key_role_type
= KMIP_ROLE_KEK
;
3483 struct cryptographic_parameters observed
= {0};
3484 kmip_init_cryptographic_parameters(&observed
);
3486 int result
= kmip_decode_cryptographic_parameters(&ctx
, &observed
);
3487 result
= report_decoding_test_result(
3490 kmip_compare_cryptographic_parameters(&expected
, &observed
),
3493 kmip_free_cryptographic_parameters(&ctx
, &observed
);
3499 test_encode_encryption_key_information(TestTracker
*tracker
)
3501 TRACK_TEST(tracker
);
3503 uint8 expected
[80] = {
3504 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
3505 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
3506 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
3507 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
3508 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
3509 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
3510 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
3511 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
3512 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3513 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
3516 uint8 observed
[80] = {0};
3517 struct kmip ctx
= {0};
3518 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3520 struct text_string uuid
= {0};
3521 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
3524 struct cryptographic_parameters cp
= {0};
3525 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
3527 struct encryption_key_information eki
= {0};
3528 eki
.unique_identifier
= &uuid
;
3529 eki
.cryptographic_parameters
= &cp
;
3531 int result
= kmip_encode_encryption_key_information(&ctx
, &eki
);
3532 result
= report_encoding_test_result(
3544 test_decode_encryption_key_information(TestTracker
*tracker
)
3546 TRACK_TEST(tracker
);
3548 uint8 encoding
[80] = {
3549 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
3550 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
3551 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
3552 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
3553 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
3554 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
3555 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
3556 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
3557 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3558 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
3561 struct kmip ctx
= {0};
3562 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3564 struct text_string uuid
= {0};
3565 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
3568 struct cryptographic_parameters cp
= {0};
3569 kmip_init_cryptographic_parameters(&cp
);
3571 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
3573 struct encryption_key_information expected
= {0};
3574 expected
.unique_identifier
= &uuid
;
3575 expected
.cryptographic_parameters
= &cp
;
3577 struct encryption_key_information observed
= {0};
3579 int result
= kmip_decode_encryption_key_information(&ctx
, &observed
);
3580 result
= report_decoding_test_result(
3583 kmip_compare_encryption_key_information(&expected
, &observed
),
3586 kmip_free_encryption_key_information(&ctx
, &observed
);
3592 test_encode_mac_signature_key_information(TestTracker
*tracker
)
3594 TRACK_TEST(tracker
);
3596 uint8 expected
[80] = {
3597 0x42, 0x00, 0x4E, 0x01, 0x00, 0x00, 0x00, 0x48,
3598 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
3599 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
3600 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
3601 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
3602 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
3603 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
3604 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
3605 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3606 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
3609 uint8 observed
[80] = {0};
3610 struct kmip ctx
= {0};
3611 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3613 struct text_string uuid
= {0};
3614 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
3617 struct cryptographic_parameters cp
= {0};
3618 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
3620 struct mac_signature_key_information mski
= {0};
3621 mski
.unique_identifier
= &uuid
;
3622 mski
.cryptographic_parameters
= &cp
;
3624 int result
= kmip_encode_mac_signature_key_information(&ctx
, &mski
);
3625 result
= report_encoding_test_result(
3637 test_decode_mac_signature_key_information(TestTracker
*tracker
)
3639 TRACK_TEST(tracker
);
3641 uint8 encoding
[80] = {
3642 0x42, 0x00, 0x4E, 0x01, 0x00, 0x00, 0x00, 0x48,
3643 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
3644 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
3645 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
3646 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
3647 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
3648 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
3649 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
3650 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3651 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
3654 struct kmip ctx
= {0};
3655 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3657 struct text_string uuid
= {0};
3658 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
3661 struct cryptographic_parameters cp
= {0};
3662 kmip_init_cryptographic_parameters(&cp
);
3664 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
3666 struct mac_signature_key_information expected
= {0};
3667 expected
.unique_identifier
= &uuid
;
3668 expected
.cryptographic_parameters
= &cp
;
3670 struct mac_signature_key_information observed
= {0};
3672 int result
= kmip_decode_mac_signature_key_information(&ctx
, &observed
);
3673 result
= report_decoding_test_result(
3676 kmip_compare_mac_signature_key_information(&expected
, &observed
),
3679 kmip_free_mac_signature_key_information(&ctx
, &observed
);
3685 test_encode_key_wrapping_data(TestTracker
*tracker
)
3687 TRACK_TEST(tracker
);
3689 uint8 expected
[104] = {
3690 0x42, 0x00, 0x46, 0x01, 0x00, 0x00, 0x00, 0x60,
3691 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
3692 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3693 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
3694 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
3695 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
3696 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
3697 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
3698 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
3699 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
3700 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
3701 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3702 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
3705 uint8 observed
[104] = {0};
3706 struct kmip ctx
= {0};
3707 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3709 struct text_string uuid
= {0};
3710 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
3713 struct cryptographic_parameters cp
= {0};
3714 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
3716 struct encryption_key_information eki
= {0};
3717 eki
.unique_identifier
= &uuid
;
3718 eki
.cryptographic_parameters
= &cp
;
3720 struct key_wrapping_data kwd
= {0};
3721 kwd
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
3722 kwd
.encryption_key_info
= &eki
;
3724 int result
= kmip_encode_key_wrapping_data(&ctx
, &kwd
);
3725 result
= report_encoding_test_result(
3737 test_decode_key_wrapping_data(TestTracker
*tracker
)
3739 TRACK_TEST(tracker
);
3741 uint8 encoding
[104] = {
3742 0x42, 0x00, 0x46, 0x01, 0x00, 0x00, 0x00, 0x60,
3743 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
3744 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
3745 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
3746 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
3747 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
3748 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
3749 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
3750 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
3751 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
3752 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
3753 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
3754 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
3757 struct kmip ctx
= {0};
3758 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3760 struct text_string uuid
= {0};
3761 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
3764 struct cryptographic_parameters cp
= {0};
3765 kmip_init_cryptographic_parameters(&cp
);
3767 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
3769 struct encryption_key_information eki
= {0};
3770 eki
.unique_identifier
= &uuid
;
3771 eki
.cryptographic_parameters
= &cp
;
3773 struct key_wrapping_data expected
= {0};
3774 expected
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
3775 expected
.encryption_key_info
= &eki
;
3777 struct key_wrapping_data observed
= {0};
3779 int result
= kmip_decode_key_wrapping_data(&ctx
, &observed
);
3780 result
= report_decoding_test_result(
3783 kmip_compare_key_wrapping_data(&expected
, &observed
),
3786 kmip_free_key_wrapping_data(&ctx
, &observed
);
3792 test_encode_key_material_byte_string(TestTracker
*tracker
)
3794 TRACK_TEST(tracker
);
3796 uint8 expected
[24] = {
3797 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
3798 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3799 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
3802 uint8 observed
[24] = {0};
3803 struct kmip ctx
= {0};
3804 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3807 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3808 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
3810 struct byte_string key
= {0};
3812 key
.size
= ARRAY_LENGTH(value
);
3814 int result
= kmip_encode_key_material(&ctx
, KMIP_KEYFORMAT_RAW
, &key
);
3815 result
= report_encoding_test_result(
3827 test_decode_key_material_byte_string(TestTracker
*tracker
)
3829 TRACK_TEST(tracker
);
3831 uint8 encoding
[24] = {
3832 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
3833 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3834 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
3837 struct kmip ctx
= {0};
3838 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3841 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
3842 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
3844 struct byte_string expected
= {0};
3845 expected
.value
= value
;
3846 expected
.size
= ARRAY_LENGTH(value
);
3848 struct byte_string
*expected_ptr
= &expected
;
3849 struct byte_string
*observed_ptr
= NULL
;
3851 int result
= kmip_decode_key_material(
3854 (void**)&observed_ptr
);
3855 result
= report_decoding_test_result(
3858 kmip_compare_key_material(KMIP_KEYFORMAT_RAW
, (void**)&expected_ptr
, (void**)&observed_ptr
),
3861 kmip_free_key_material(&ctx
, KMIP_KEYFORMAT_RAW
, (void**)&observed_ptr
);
3867 test_encode_key_material_transparent_symmetric_key(TestTracker
*tracker
)
3869 TRACK_TEST(tracker
);
3871 uint8 expected
[48] = {
3872 0x42, 0x00, 0x43, 0x01, 0x00, 0x00, 0x00, 0x28,
3873 0x42, 0x00, 0x3F, 0x08, 0x00, 0x00, 0x00, 0x20,
3874 0x00, 0x00, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33,
3875 0x44, 0x44, 0x55, 0x55, 0x66, 0x66, 0x77, 0x77,
3876 0x88, 0x88, 0x99, 0x99, 0xAA, 0xAA, 0xBB, 0xBB,
3877 0xCC, 0xCC, 0xDD, 0xDD, 0xEE, 0xEE, 0xFF, 0xFF
3880 uint8 observed
[48] = {0};
3881 struct kmip ctx
= {0};
3882 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3885 0x00, 0x00, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33,
3886 0x44, 0x44, 0x55, 0x55, 0x66, 0x66, 0x77, 0x77,
3887 0x88, 0x88, 0x99, 0x99, 0xAA, 0xAA, 0xBB, 0xBB,
3888 0xCC, 0xCC, 0xDD, 0xDD, 0xEE, 0xEE, 0xFF, 0xFF
3890 struct byte_string key
= {0};
3892 key
.size
= ARRAY_LENGTH(value
);
3893 struct transparent_symmetric_key tsk
= {0};
3896 int result
= kmip_encode_key_material(&ctx
, KMIP_KEYFORMAT_TRANS_SYMMETRIC_KEY
, &tsk
);
3897 result
= report_encoding_test_result(
3909 test_decode_key_material_transparent_symmetric_key(TestTracker
*tracker
)
3911 TRACK_TEST(tracker
);
3913 uint8 encoding
[48] = {
3914 0x42, 0x00, 0x43, 0x01, 0x00, 0x00, 0x00, 0x28,
3915 0x42, 0x00, 0x3F, 0x08, 0x00, 0x00, 0x00, 0x20,
3916 0x00, 0x00, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33,
3917 0x44, 0x44, 0x55, 0x55, 0x66, 0x66, 0x77, 0x77,
3918 0x88, 0x88, 0x99, 0x99, 0xAA, 0xAA, 0xBB, 0xBB,
3919 0xCC, 0xCC, 0xDD, 0xDD, 0xEE, 0xEE, 0xFF, 0xFF
3922 struct kmip ctx
= {0};
3923 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
3926 0x00, 0x00, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33,
3927 0x44, 0x44, 0x55, 0x55, 0x66, 0x66, 0x77, 0x77,
3928 0x88, 0x88, 0x99, 0x99, 0xAA, 0xAA, 0xBB, 0xBB,
3929 0xCC, 0xCC, 0xDD, 0xDD, 0xEE, 0xEE, 0xFF, 0xFF
3931 struct byte_string key
= {0};
3933 key
.size
= ARRAY_LENGTH(value
);
3934 struct transparent_symmetric_key expected
= {0};
3935 expected
.key
= &key
;
3937 struct transparent_symmetric_key
*expected_ptr
= &expected
;
3938 struct transparent_symmetric_key
*observed_ptr
= NULL
;
3940 int result
= kmip_decode_key_material(
3942 KMIP_KEYFORMAT_TRANS_SYMMETRIC_KEY
,
3943 (void**)&observed_ptr
);
3944 result
= report_decoding_test_result(
3947 kmip_compare_key_material(KMIP_KEYFORMAT_TRANS_SYMMETRIC_KEY
, (void**)&expected_ptr
, (void**)&observed_ptr
),
3950 kmip_free_key_material(
3952 KMIP_KEYFORMAT_TRANS_SYMMETRIC_KEY
,
3953 (void**)&observed_ptr
);
3959 test_encode_key_value(TestTracker
*tracker
)
3961 TRACK_TEST(tracker
);
3963 uint8 expected
[32] = {
3964 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x18,
3965 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
3966 0xD3, 0x51, 0x91, 0x0F, 0x1D, 0x79, 0x34, 0xD6,
3967 0xE2, 0xAE, 0x17, 0x57, 0x65, 0x64, 0xE2, 0xBC
3970 uint8 observed
[32] = {0};
3971 struct kmip ctx
= {0};
3972 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
3975 0xD3, 0x51, 0x91, 0x0F, 0x1D, 0x79, 0x34, 0xD6,
3976 0xE2, 0xAE, 0x17, 0x57, 0x65, 0x64, 0xE2, 0xBC
3978 struct byte_string key
= {0};
3980 key
.size
= ARRAY_LENGTH(value
);
3982 struct key_value kv
= {0};
3983 kv
.key_material
= &key
;
3985 int result
= kmip_encode_key_value(&ctx
, KMIP_KEYFORMAT_RAW
, &kv
);
3986 result
= report_encoding_test_result(
3998 test_decode_key_value(TestTracker
*tracker
)
4000 TRACK_TEST(tracker
);
4002 uint8 encoding
[32] = {
4003 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x18,
4004 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
4005 0xD3, 0x51, 0x91, 0x0F, 0x1D, 0x79, 0x34, 0xD6,
4006 0xE2, 0xAE, 0x17, 0x57, 0x65, 0x64, 0xE2, 0xBC
4009 struct kmip ctx
= {0};
4010 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
4013 0xD3, 0x51, 0x91, 0x0F, 0x1D, 0x79, 0x34, 0xD6,
4014 0xE2, 0xAE, 0x17, 0x57, 0x65, 0x64, 0xE2, 0xBC
4016 struct byte_string key
= {0};
4018 key
.size
= ARRAY_LENGTH(value
);
4020 struct key_value expected
= {0};
4021 expected
.key_material
= &key
;
4022 struct key_value observed
= {0};
4024 int result
= kmip_decode_key_value(&ctx
, KMIP_KEYFORMAT_RAW
, &observed
);
4025 result
= report_decoding_test_result(
4028 kmip_compare_key_value(KMIP_KEYFORMAT_RAW
, &expected
, &observed
),
4031 kmip_free_key_value(&ctx
, KMIP_KEYFORMAT_RAW
, &observed
);
4037 test_encode_key_value_with_attributes(TestTracker
*tracker
)
4039 TRACK_TEST(tracker
);
4041 uint8 expected
[144] = {
4042 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x88,
4043 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
4044 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4045 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
4046 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
4047 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
4048 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
4049 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
4050 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
4051 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
4052 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4053 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
4054 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
4055 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
4056 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
4057 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
4058 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
4059 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
4062 uint8 observed
[144] = {0};
4063 struct kmip ctx
= {0};
4064 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
4067 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4068 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
4070 struct byte_string key
= {0};
4072 key
.size
= ARRAY_LENGTH(value
);
4074 struct attribute attributes
[2] = {0};
4075 for(int i
= 0; i
< 2; i
++)
4077 kmip_init_attribute(&attributes
[i
]);
4080 enum cryptographic_algorithm ca
= KMIP_CRYPTOALG_AES
;
4082 attributes
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
4083 attributes
[0].value
= &ca
;
4084 attributes
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
4085 attributes
[1].value
= &length
;
4087 struct key_value kv
= {0};
4088 kv
.key_material
= &key
;
4089 kv
.attributes
= attributes
;
4090 kv
.attribute_count
= ARRAY_LENGTH(attributes
);
4092 int result
= kmip_encode_key_value(&ctx
, KMIP_KEYFORMAT_RAW
, &kv
);
4093 result
= report_encoding_test_result(
4105 test_decode_key_value_with_attributes(TestTracker
*tracker
)
4107 TRACK_TEST(tracker
);
4109 uint8 encoding
[144] = {
4110 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x88,
4111 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
4112 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4113 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
4114 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
4115 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
4116 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
4117 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
4118 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
4119 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
4120 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4121 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
4122 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
4123 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
4124 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
4125 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
4126 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
4127 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
4130 struct kmip ctx
= {0};
4131 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
4134 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4135 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
4137 struct byte_string key
= {0};
4139 key
.size
= ARRAY_LENGTH(value
);
4141 struct attribute attributes
[2] = {0};
4142 for(size_t i
= 0; i
< 2; i
++)
4144 kmip_init_attribute(&attributes
[i
]);
4147 enum cryptographic_algorithm ca
= KMIP_CRYPTOALG_AES
;
4149 attributes
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
4150 attributes
[0].value
= &ca
;
4151 attributes
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
4152 attributes
[1].value
= &length
;
4154 struct key_value expected
= {0};
4155 expected
.key_material
= &key
;
4156 expected
.attributes
= attributes
;
4157 expected
.attribute_count
= ARRAY_LENGTH(attributes
);
4158 struct key_value observed
= {0};
4160 int result
= kmip_decode_key_value(&ctx
, KMIP_KEYFORMAT_RAW
, &observed
);
4161 result
= report_decoding_test_result(
4164 kmip_compare_key_value(KMIP_KEYFORMAT_RAW
, &expected
, &observed
),
4167 kmip_free_key_value(&ctx
, KMIP_KEYFORMAT_RAW
, &observed
);
4173 test_encode_key_block_key_value_byte_string(TestTracker
*tracker
)
4175 TRACK_TEST(tracker
);
4177 uint8 expected
[192] = {
4178 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0xB8,
4179 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4180 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4181 0x42, 0x00, 0x45, 0x08, 0x00, 0x00, 0x00, 0x18,
4182 0x1F, 0xA6, 0x8B, 0x0A, 0x81, 0x12, 0xB4, 0x47,
4183 0xAE, 0xF3, 0x4B, 0xD8, 0xFB, 0x5A, 0x7B, 0x82,
4184 0x9D, 0x3E, 0x86, 0x23, 0x71, 0xD2, 0xCF, 0xE5,
4185 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4186 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4187 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4188 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
4189 0x42, 0x00, 0x46, 0x01, 0x00, 0x00, 0x00, 0x60,
4190 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
4191 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4192 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
4193 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
4194 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
4195 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
4196 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
4197 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
4198 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
4199 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
4200 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
4201 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
4204 uint8 observed
[192] = {0};
4205 struct kmip ctx
= {0};
4206 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
4209 0x1F, 0xA6, 0x8B, 0x0A, 0x81, 0x12, 0xB4, 0x47,
4210 0xAE, 0xF3, 0x4B, 0xD8, 0xFB, 0x5A, 0x7B, 0x82,
4211 0x9D, 0x3E, 0x86, 0x23, 0x71, 0xD2, 0xCF, 0xE5
4213 struct byte_string key
= {0};
4215 key
.size
= ARRAY_LENGTH(value
);
4217 struct text_string uuid
= {0};
4218 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
4221 struct cryptographic_parameters cp
= {0};
4222 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
4224 struct encryption_key_information eki
= {0};
4225 eki
.unique_identifier
= &uuid
;
4226 eki
.cryptographic_parameters
= &cp
;
4228 struct key_wrapping_data kwd
= {0};
4229 kwd
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
4230 kwd
.encryption_key_info
= &eki
;
4232 struct key_block kb
= {0};
4233 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
4234 kb
.key_value
= &key
;
4235 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_AES
;
4236 kb
.cryptographic_length
= 128;
4237 kb
.key_wrapping_data
= &kwd
;
4239 int result
= kmip_encode_key_block(&ctx
, &kb
);
4240 result
= report_encoding_test_result(
4252 test_decode_key_block_key_value_byte_string(TestTracker
*tracker
)
4254 TRACK_TEST(tracker
);
4256 uint8 encoding
[192] = {
4257 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0xB8,
4258 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4259 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4260 0x42, 0x00, 0x45, 0x08, 0x00, 0x00, 0x00, 0x18,
4261 0x1F, 0xA6, 0x8B, 0x0A, 0x81, 0x12, 0xB4, 0x47,
4262 0xAE, 0xF3, 0x4B, 0xD8, 0xFB, 0x5A, 0x7B, 0x82,
4263 0x9D, 0x3E, 0x86, 0x23, 0x71, 0xD2, 0xCF, 0xE5,
4264 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4265 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4266 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4267 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
4268 0x42, 0x00, 0x46, 0x01, 0x00, 0x00, 0x00, 0x60,
4269 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
4270 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4271 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
4272 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
4273 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
4274 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
4275 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
4276 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
4277 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
4278 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
4279 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
4280 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
4283 struct kmip ctx
= {0};
4284 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
4287 0x1F, 0xA6, 0x8B, 0x0A, 0x81, 0x12, 0xB4, 0x47,
4288 0xAE, 0xF3, 0x4B, 0xD8, 0xFB, 0x5A, 0x7B, 0x82,
4289 0x9D, 0x3E, 0x86, 0x23, 0x71, 0xD2, 0xCF, 0xE5
4291 struct byte_string key
= {0};
4293 key
.size
= ARRAY_LENGTH(value
);
4295 struct text_string uuid
= {0};
4296 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
4299 struct cryptographic_parameters cp
= {0};
4300 kmip_init_cryptographic_parameters(&cp
);
4302 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
4304 struct encryption_key_information eki
= {0};
4305 eki
.unique_identifier
= &uuid
;
4306 eki
.cryptographic_parameters
= &cp
;
4308 struct key_wrapping_data kwd
= {0};
4309 kwd
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
4310 kwd
.encryption_key_info
= &eki
;
4312 struct key_block expected
= {0};
4313 kmip_init_key_block(&expected
);
4315 expected
.key_format_type
= KMIP_KEYFORMAT_RAW
;
4316 expected
.key_value
= &key
;
4317 expected
.key_value_type
= KMIP_TYPE_BYTE_STRING
;
4318 expected
.cryptographic_algorithm
= KMIP_CRYPTOALG_AES
;
4319 expected
.cryptographic_length
= 128;
4320 expected
.key_wrapping_data
= &kwd
;
4322 struct key_block observed
= {0};
4323 kmip_init_key_block(&observed
);
4325 int result
= kmip_decode_key_block(&ctx
, &observed
);
4326 result
= report_decoding_test_result(
4329 kmip_compare_key_block(&expected
, &observed
),
4332 kmip_free_key_block(&ctx
, &observed
);
4338 test_encode_key_block_key_value_structure(TestTracker
*tracker
)
4340 TRACK_TEST(tracker
);
4342 uint8 expected
[88] = {
4343 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x50,
4344 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4345 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4346 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x18,
4347 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
4348 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4349 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
4350 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4351 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4352 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4353 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
4356 uint8 observed
[88] = {0};
4357 struct kmip ctx
= {0};
4358 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
4361 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4362 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
4364 struct byte_string key
= {0};
4366 key
.size
= ARRAY_LENGTH(value
);
4368 struct key_value kv
= {0};
4369 kv
.key_material
= &key
;
4371 struct key_block kb
= {0};
4372 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
4374 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_AES
;
4375 kb
.cryptographic_length
= 128;
4377 int result
= kmip_encode_key_block(&ctx
, &kb
);
4378 result
= report_encoding_test_result(
4390 test_decode_key_block_key_value_structure(TestTracker
*tracker
)
4392 TRACK_TEST(tracker
);
4394 uint8 encoding
[88] = {
4395 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x50,
4396 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4397 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4398 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x18,
4399 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
4400 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4401 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
4402 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4403 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4404 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4405 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
4408 struct kmip ctx
= {0};
4409 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
4412 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
4413 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF
4415 struct byte_string key
= {0};
4417 key
.size
= ARRAY_LENGTH(value
);
4419 struct key_value kv
= {0};
4420 kv
.key_material
= &key
;
4422 struct key_block expected
= {0};
4423 kmip_init_key_block(&expected
);
4425 expected
.key_format_type
= KMIP_KEYFORMAT_RAW
;
4426 expected
.key_value
= &kv
;
4427 expected
.key_value_type
= KMIP_TYPE_STRUCTURE
;
4428 expected
.cryptographic_algorithm
= KMIP_CRYPTOALG_AES
;
4429 expected
.cryptographic_length
= 128;
4431 struct key_block observed
= {0};
4432 kmip_init_key_block(&observed
);
4434 int result
= kmip_decode_key_block(&ctx
, &observed
);
4435 result
= report_decoding_test_result(
4438 kmip_compare_key_block(&expected
, &observed
),
4441 kmip_free_key_block(&ctx
, &observed
);
4447 test_encode_symmetric_key(TestTracker
*tracker
)
4449 TRACK_TEST(tracker
);
4451 uint8 expected
[96] = {
4452 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x58,
4453 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x50,
4454 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4455 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4456 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x18,
4457 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
4458 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4459 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
4460 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4461 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4462 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4463 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
4466 uint8 observed
[96] = {0};
4467 struct kmip ctx
= {0};
4468 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
4471 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4472 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
4474 struct byte_string key
= {0};
4476 key
.size
= ARRAY_LENGTH(value
);
4478 struct key_value kv
= {0};
4479 kv
.key_material
= &key
;
4481 struct key_block kb
= {0};
4482 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
4484 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_AES
;
4485 kb
.cryptographic_length
= 128;
4487 struct symmetric_key sk
= {0};
4490 int result
= kmip_encode_symmetric_key(&ctx
, &sk
);
4491 result
= report_encoding_test_result(
4503 test_decode_symmetric_key(TestTracker
*tracker
)
4505 TRACK_TEST(tracker
);
4507 uint8 encoding
[96] = {
4508 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x58,
4509 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x50,
4510 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4511 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
4512 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x18,
4513 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x10,
4514 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4515 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
4516 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4517 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4518 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4519 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
4522 struct kmip ctx
= {0};
4523 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
4526 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
4527 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
4529 struct byte_string key
= {0};
4531 key
.size
= ARRAY_LENGTH(value
);
4533 struct key_value kv
= {0};
4534 kv
.key_material
= &key
;
4536 struct key_block kb
= {0};
4537 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
4539 kb
.key_value_type
= KMIP_TYPE_STRUCTURE
;
4540 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_AES
;
4541 kb
.cryptographic_length
= 128;
4543 struct symmetric_key expected
= {0};
4544 expected
.key_block
= &kb
;
4546 struct symmetric_key observed
= {0};
4548 int result
= kmip_decode_symmetric_key(&ctx
, &observed
);
4549 result
= report_decoding_test_result(
4552 kmip_compare_symmetric_key(&expected
, &observed
),
4555 kmip_free_symmetric_key(&ctx
, &observed
);
4561 test_encode_public_key(TestTracker
*tracker
)
4563 TRACK_TEST(tracker
);
4565 uint8 expected
[248] = {
4566 0x42, 0x00, 0x6D, 0x01, 0x00, 0x00, 0x00, 0xF0,
4567 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0xE8,
4568 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4569 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
4570 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0xB0,
4571 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0xA2,
4572 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A,
4573 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01,
4574 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81,
4575 0x89, 0x02, 0x81, 0x81, 0x00, 0x93, 0x04, 0x51,
4576 0xC9, 0xEC, 0xD9, 0x4F, 0x5B, 0xB9, 0xDA, 0x17,
4577 0xDD, 0x09, 0x38, 0x1B, 0xD2, 0x3B, 0xE4, 0x3E,
4578 0xCA, 0x8C, 0x75, 0x39, 0xF3, 0x01, 0xFC, 0x8A,
4579 0x8C, 0xD5, 0xD5, 0x27, 0x4C, 0x3E, 0x76, 0x99,
4580 0xDB, 0xDC, 0x71, 0x1C, 0x97, 0xA7, 0xAA, 0x91,
4581 0xE2, 0xC5, 0x0A, 0x82, 0xBD, 0x0B, 0x10, 0x34,
4582 0xF0, 0xDF, 0x49, 0x3D, 0xEC, 0x16, 0x36, 0x24,
4583 0x27, 0xE5, 0x8A, 0xCC, 0xE7, 0xF6, 0xCE, 0x0F,
4584 0x9B, 0xCC, 0x61, 0x7B, 0xBD, 0x8C, 0x90, 0xD0,
4585 0x09, 0x4A, 0x27, 0x03, 0xBA, 0x0D, 0x09, 0xEB,
4586 0x19, 0xD1, 0x00, 0x5F, 0x2F, 0xB2, 0x65, 0x52,
4587 0x6A, 0xAC, 0x75, 0xAF, 0x32, 0xF8, 0xBC, 0x78,
4588 0x2C, 0xDE, 0xD2, 0xA5, 0x7F, 0x81, 0x1E, 0x03,
4589 0xEA, 0xF6, 0x7A, 0x94, 0x4D, 0xE5, 0xE7, 0x84,
4590 0x13, 0xDC, 0xA8, 0xF2, 0x32, 0xD0, 0x74, 0xE6,
4591 0xDC, 0xEA, 0x4C, 0xEC, 0x9F, 0x02, 0x03, 0x01,
4592 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4593 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4594 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
4595 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4596 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00
4599 uint8 observed
[248] = {0};
4600 struct kmip ctx
= {0};
4601 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
4603 uint8 value
[162] = {
4604 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A,
4605 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01,
4606 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81,
4607 0x89, 0x02, 0x81, 0x81, 0x00, 0x93, 0x04, 0x51,
4608 0xC9, 0xEC, 0xD9, 0x4F, 0x5B, 0xB9, 0xDA, 0x17,
4609 0xDD, 0x09, 0x38, 0x1B, 0xD2, 0x3B, 0xE4, 0x3E,
4610 0xCA, 0x8C, 0x75, 0x39, 0xF3, 0x01, 0xFC, 0x8A,
4611 0x8C, 0xD5, 0xD5, 0x27, 0x4C, 0x3E, 0x76, 0x99,
4612 0xDB, 0xDC, 0x71, 0x1C, 0x97, 0xA7, 0xAA, 0x91,
4613 0xE2, 0xC5, 0x0A, 0x82, 0xBD, 0x0B, 0x10, 0x34,
4614 0xF0, 0xDF, 0x49, 0x3D, 0xEC, 0x16, 0x36, 0x24,
4615 0x27, 0xE5, 0x8A, 0xCC, 0xE7, 0xF6, 0xCE, 0x0F,
4616 0x9B, 0xCC, 0x61, 0x7B, 0xBD, 0x8C, 0x90, 0xD0,
4617 0x09, 0x4A, 0x27, 0x03, 0xBA, 0x0D, 0x09, 0xEB,
4618 0x19, 0xD1, 0x00, 0x5F, 0x2F, 0xB2, 0x65, 0x52,
4619 0x6A, 0xAC, 0x75, 0xAF, 0x32, 0xF8, 0xBC, 0x78,
4620 0x2C, 0xDE, 0xD2, 0xA5, 0x7F, 0x81, 0x1E, 0x03,
4621 0xEA, 0xF6, 0x7A, 0x94, 0x4D, 0xE5, 0xE7, 0x84,
4622 0x13, 0xDC, 0xA8, 0xF2, 0x32, 0xD0, 0x74, 0xE6,
4623 0xDC, 0xEA, 0x4C, 0xEC, 0x9F, 0x02, 0x03, 0x01,
4626 struct byte_string key
= {0};
4628 key
.size
= ARRAY_LENGTH(value
);
4630 struct key_value kv
= {0};
4631 kv
.key_material
= &key
;
4633 struct key_block kb
= {0};
4634 kb
.key_format_type
= KMIP_KEYFORMAT_X509
;
4636 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
4637 kb
.cryptographic_length
= 1024;
4639 struct public_key pk
= {0};
4642 int result
= kmip_encode_public_key(&ctx
, &pk
);
4643 result
= report_encoding_test_result(
4655 test_decode_public_key(TestTracker
*tracker
)
4657 TRACK_TEST(tracker
);
4659 uint8 encoding
[248] = {
4660 0x42, 0x00, 0x6D, 0x01, 0x00, 0x00, 0x00, 0xF0,
4661 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0xE8,
4662 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4663 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
4664 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0xB0,
4665 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0xA2,
4666 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A,
4667 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01,
4668 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81,
4669 0x89, 0x02, 0x81, 0x81, 0x00, 0x93, 0x04, 0x51,
4670 0xC9, 0xEC, 0xD9, 0x4F, 0x5B, 0xB9, 0xDA, 0x17,
4671 0xDD, 0x09, 0x38, 0x1B, 0xD2, 0x3B, 0xE4, 0x3E,
4672 0xCA, 0x8C, 0x75, 0x39, 0xF3, 0x01, 0xFC, 0x8A,
4673 0x8C, 0xD5, 0xD5, 0x27, 0x4C, 0x3E, 0x76, 0x99,
4674 0xDB, 0xDC, 0x71, 0x1C, 0x97, 0xA7, 0xAA, 0x91,
4675 0xE2, 0xC5, 0x0A, 0x82, 0xBD, 0x0B, 0x10, 0x34,
4676 0xF0, 0xDF, 0x49, 0x3D, 0xEC, 0x16, 0x36, 0x24,
4677 0x27, 0xE5, 0x8A, 0xCC, 0xE7, 0xF6, 0xCE, 0x0F,
4678 0x9B, 0xCC, 0x61, 0x7B, 0xBD, 0x8C, 0x90, 0xD0,
4679 0x09, 0x4A, 0x27, 0x03, 0xBA, 0x0D, 0x09, 0xEB,
4680 0x19, 0xD1, 0x00, 0x5F, 0x2F, 0xB2, 0x65, 0x52,
4681 0x6A, 0xAC, 0x75, 0xAF, 0x32, 0xF8, 0xBC, 0x78,
4682 0x2C, 0xDE, 0xD2, 0xA5, 0x7F, 0x81, 0x1E, 0x03,
4683 0xEA, 0xF6, 0x7A, 0x94, 0x4D, 0xE5, 0xE7, 0x84,
4684 0x13, 0xDC, 0xA8, 0xF2, 0x32, 0xD0, 0x74, 0xE6,
4685 0xDC, 0xEA, 0x4C, 0xEC, 0x9F, 0x02, 0x03, 0x01,
4686 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4687 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4688 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
4689 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4690 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00
4693 struct kmip ctx
= {0};
4694 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
4696 uint8 value
[162] = {
4697 0x30, 0x81, 0x9F, 0x30, 0x0D, 0x06, 0x09, 0x2A,
4698 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x01, 0x01,
4699 0x05, 0x00, 0x03, 0x81, 0x8D, 0x00, 0x30, 0x81,
4700 0x89, 0x02, 0x81, 0x81, 0x00, 0x93, 0x04, 0x51,
4701 0xC9, 0xEC, 0xD9, 0x4F, 0x5B, 0xB9, 0xDA, 0x17,
4702 0xDD, 0x09, 0x38, 0x1B, 0xD2, 0x3B, 0xE4, 0x3E,
4703 0xCA, 0x8C, 0x75, 0x39, 0xF3, 0x01, 0xFC, 0x8A,
4704 0x8C, 0xD5, 0xD5, 0x27, 0x4C, 0x3E, 0x76, 0x99,
4705 0xDB, 0xDC, 0x71, 0x1C, 0x97, 0xA7, 0xAA, 0x91,
4706 0xE2, 0xC5, 0x0A, 0x82, 0xBD, 0x0B, 0x10, 0x34,
4707 0xF0, 0xDF, 0x49, 0x3D, 0xEC, 0x16, 0x36, 0x24,
4708 0x27, 0xE5, 0x8A, 0xCC, 0xE7, 0xF6, 0xCE, 0x0F,
4709 0x9B, 0xCC, 0x61, 0x7B, 0xBD, 0x8C, 0x90, 0xD0,
4710 0x09, 0x4A, 0x27, 0x03, 0xBA, 0x0D, 0x09, 0xEB,
4711 0x19, 0xD1, 0x00, 0x5F, 0x2F, 0xB2, 0x65, 0x52,
4712 0x6A, 0xAC, 0x75, 0xAF, 0x32, 0xF8, 0xBC, 0x78,
4713 0x2C, 0xDE, 0xD2, 0xA5, 0x7F, 0x81, 0x1E, 0x03,
4714 0xEA, 0xF6, 0x7A, 0x94, 0x4D, 0xE5, 0xE7, 0x84,
4715 0x13, 0xDC, 0xA8, 0xF2, 0x32, 0xD0, 0x74, 0xE6,
4716 0xDC, 0xEA, 0x4C, 0xEC, 0x9F, 0x02, 0x03, 0x01,
4719 struct byte_string key
= {0};
4721 key
.size
= ARRAY_LENGTH(value
);
4723 struct key_value kv
= {0};
4724 kv
.key_material
= &key
;
4726 struct key_block kb
= {0};
4727 kb
.key_format_type
= KMIP_KEYFORMAT_X509
;
4729 kb
.key_value_type
= KMIP_TYPE_STRUCTURE
;
4730 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
4731 kb
.cryptographic_length
= 1024;
4733 struct public_key expected
= {0};
4734 expected
.key_block
= &kb
;
4736 struct public_key observed
= {0};
4738 int result
= kmip_decode_public_key(&ctx
, &observed
);
4739 result
= report_decoding_test_result(
4742 kmip_compare_public_key(&expected
, &observed
),
4745 kmip_free_public_key(&ctx
, &observed
);
4751 test_encode_private_key(TestTracker
*tracker
)
4753 TRACK_TEST(tracker
);
4755 uint8 expected
[1280] = {
4756 0x42, 0x00, 0x64, 0x01, 0x00, 0x00, 0x04, 0xF8,
4757 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x04, 0xF0,
4758 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
4759 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
4760 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x04, 0xB8,
4761 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x04, 0xA9,
4762 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02,
4763 0x82, 0x01, 0x01, 0x00, 0xAB, 0x7F, 0x16, 0x1C,
4764 0x00, 0x42, 0x49, 0x6C, 0xCD, 0x6C, 0x6D, 0x4D,
4765 0xAD, 0xB9, 0x19, 0x97, 0x34, 0x35, 0x35, 0x77,
4766 0x76, 0x00, 0x3A, 0xCF, 0x54, 0xB7, 0xAF, 0x1E,
4767 0x44, 0x0A, 0xFB, 0x80, 0xB6, 0x4A, 0x87, 0x55,
4768 0xF8, 0x00, 0x2C, 0xFE, 0xBA, 0x6B, 0x18, 0x45,
4769 0x40, 0xA2, 0xD6, 0x60, 0x86, 0xD7, 0x46, 0x48,
4770 0x34, 0x6D, 0x75, 0xB8, 0xD7, 0x18, 0x12, 0xB2,
4771 0x05, 0x38, 0x7C, 0x0F, 0x65, 0x83, 0xBC, 0x4D,
4772 0x7D, 0xC7, 0xEC, 0x11, 0x4F, 0x3B, 0x17, 0x6B,
4773 0x79, 0x57, 0xC4, 0x22, 0xE7, 0xD0, 0x3F, 0xC6,
4774 0x26, 0x7F, 0xA2, 0xA6, 0xF8, 0x9B, 0x9B, 0xEE,
4775 0x9E, 0x60, 0xA1, 0xD7, 0xC2, 0xD8, 0x33, 0xE5,
4776 0xA5, 0xF4, 0xBB, 0x0B, 0x14, 0x34, 0xF4, 0xE7,
4777 0x95, 0xA4, 0x11, 0x00, 0xF8, 0xAA, 0x21, 0x49,
4778 0x00, 0xDF, 0x8B, 0x65, 0x08, 0x9F, 0x98, 0x13,
4779 0x5B, 0x1C, 0x67, 0xB7, 0x01, 0x67, 0x5A, 0xBD,
4780 0xBC, 0x7D, 0x57, 0x21, 0xAA, 0xC9, 0xD1, 0x4A,
4781 0x7F, 0x08, 0x1F, 0xCE, 0xC8, 0x0B, 0x64, 0xE8,
4782 0xA0, 0xEC, 0xC8, 0x29, 0x53, 0x53, 0xC7, 0x95,
4783 0x32, 0x8A, 0xBF, 0x70, 0xE1, 0xB4, 0x2E, 0x7B,
4784 0xB8, 0xB7, 0xF4, 0xE8, 0xAC, 0x8C, 0x81, 0x0C,
4785 0xDB, 0x66, 0xE3, 0xD2, 0x11, 0x26, 0xEB, 0xA8,
4786 0xDA, 0x7D, 0x0C, 0xA3, 0x41, 0x42, 0xCB, 0x76,
4787 0xF9, 0x1F, 0x01, 0x3D, 0xA8, 0x09, 0xE9, 0xC1,
4788 0xB7, 0xAE, 0x64, 0xC5, 0x41, 0x30, 0xFB, 0xC2,
4789 0x1D, 0x80, 0xE9, 0xC2, 0xCB, 0x06, 0xC5, 0xC8,
4790 0xD7, 0xCC, 0xE8, 0x94, 0x6A, 0x9A, 0xC9, 0x9B,
4791 0x1C, 0x28, 0x15, 0xC3, 0x61, 0x2A, 0x29, 0xA8,
4792 0x2D, 0x73, 0xA1, 0xF9, 0x93, 0x74, 0xFE, 0x30,
4793 0xE5, 0x49, 0x51, 0x66, 0x2A, 0x6E, 0xDA, 0x29,
4794 0xC6, 0xFC, 0x41, 0x13, 0x35, 0xD5, 0xDC, 0x74,
4795 0x26, 0xB0, 0xF6, 0x05, 0x02, 0x03, 0x01, 0x00,
4796 0x01, 0x02, 0x82, 0x01, 0x00, 0x3B, 0x12, 0x45,
4797 0x5D, 0x53, 0xC1, 0x81, 0x65, 0x16, 0xC5, 0x18,
4798 0x49, 0x3F, 0x63, 0x98, 0xAA, 0xFA, 0x72, 0xB1,
4799 0x7D, 0xFA, 0x89, 0x4D, 0xB8, 0x88, 0xA7, 0xD4,
4800 0x8C, 0x0A, 0x47, 0xF6, 0x25, 0x79, 0xA4, 0xE6,
4801 0x44, 0xF8, 0x6D, 0xA7, 0x11, 0xFE, 0xC8, 0x50,
4802 0xCD, 0xD9, 0xDB, 0xBD, 0x17, 0xF6, 0x9A, 0x44,
4803 0x3D, 0x2E, 0xC1, 0xDD, 0x60, 0xD3, 0xC6, 0x18,
4804 0xFA, 0x74, 0xCD, 0xE5, 0xFD, 0xAF, 0xAB, 0xD6,
4805 0xBA, 0xA2, 0x6E, 0xB0, 0xA3, 0xAD, 0xB4, 0xDE,
4806 0xF6, 0x48, 0x0F, 0xB1, 0x21, 0x8C, 0xD3, 0xB0,
4807 0x83, 0xE2, 0x52, 0xE8, 0x85, 0xB6, 0xF0, 0x72,
4808 0x9F, 0x98, 0xB2, 0x14, 0x4D, 0x2B, 0x72, 0x29,
4809 0x3E, 0x1B, 0x11, 0xD7, 0x33, 0x93, 0xBC, 0x41,
4810 0xF7, 0x5B, 0x15, 0xEE, 0x3D, 0x75, 0x69, 0xB4,
4811 0x99, 0x5E, 0xD1, 0xA1, 0x44, 0x25, 0xDA, 0x43,
4812 0x19, 0xB7, 0xB2, 0x6B, 0x0E, 0x8F, 0xEF, 0x17,
4813 0xC3, 0x75, 0x42, 0xAE, 0x5C, 0x6D, 0x58, 0x49,
4814 0xF8, 0x72, 0x09, 0x56, 0x7F, 0x39, 0x25, 0xA4,
4815 0x7B, 0x01, 0x6D, 0x56, 0x48, 0x59, 0x71, 0x7B,
4816 0xC5, 0x7F, 0xCB, 0x45, 0x22, 0xD0, 0xAA, 0x49,
4817 0xCE, 0x81, 0x6E, 0x5B, 0xE7, 0xB3, 0x08, 0x81,
4818 0x93, 0x23, 0x6E, 0xC9, 0xEF, 0xFF, 0x14, 0x08,
4819 0x58, 0x04, 0x5B, 0x73, 0xC5, 0xD7, 0x9B, 0xAF,
4820 0x38, 0xF7, 0xC6, 0x7F, 0x04, 0xC5, 0xDC, 0xF0,
4821 0xE3, 0x80, 0x6A, 0xD9, 0x82, 0xD1, 0x25, 0x90,
4822 0x58, 0xC3, 0x47, 0x3E, 0x84, 0x71, 0x79, 0xA8,
4823 0x78, 0xF2, 0xC6, 0xB3, 0xBD, 0x96, 0x8F, 0xB9,
4824 0x9E, 0xA4, 0x6E, 0x91, 0x85, 0x89, 0x2F, 0x36,
4825 0x76, 0xE7, 0x89, 0x65, 0xC2, 0xAE, 0xD4, 0x87,
4826 0x7B, 0xA3, 0x91, 0x7D, 0xF0, 0x7C, 0x5E, 0x92,
4827 0x74, 0x74, 0xF1, 0x9E, 0x76, 0x4B, 0xA6, 0x1D,
4828 0xC3, 0x8D, 0x63, 0xBF, 0x29, 0x02, 0x81, 0x81,
4829 0x00, 0xD5, 0xC6, 0x9C, 0x8C, 0x3C, 0xDC, 0x24,
4830 0x64, 0x74, 0x4A, 0x79, 0x37, 0x13, 0xDA, 0xFB,
4831 0x9F, 0x1D, 0xBC, 0x79, 0x9F, 0xF9, 0x64, 0x23,
4832 0xFE, 0xCD, 0x3C, 0xBA, 0x79, 0x42, 0x86, 0xBC,
4833 0xE9, 0x20, 0xF4, 0xB5, 0xC1, 0x83, 0xF9, 0x9E,
4834 0xE9, 0x02, 0x8D, 0xB6, 0x21, 0x2C, 0x62, 0x77,
4835 0xC4, 0xC8, 0x29, 0x7F, 0xCF, 0xBC, 0xE7, 0xF7,
4836 0xC2, 0x4C, 0xA4, 0xC5, 0x1F, 0xC7, 0x18, 0x2F,
4837 0xB8, 0xF4, 0x01, 0x9F, 0xB1, 0xD5, 0x65, 0x96,
4838 0x74, 0xC5, 0xCB, 0xE6, 0xD5, 0xFA, 0x99, 0x20,
4839 0x51, 0x34, 0x17, 0x60, 0xCD, 0x00, 0x73, 0x57,
4840 0x29, 0xA0, 0x70, 0xA9, 0xE5, 0x4D, 0x34, 0x2B,
4841 0xEB, 0xA8, 0xEF, 0x47, 0xEE, 0x82, 0xD3, 0xA0,
4842 0x1B, 0x04, 0xCE, 0xC4, 0xA0, 0x0D, 0x4D, 0xDB,
4843 0x41, 0xE3, 0x51, 0x16, 0xFC, 0x22, 0x1E, 0x85,
4844 0x4B, 0x43, 0xA6, 0x96, 0xC0, 0xE6, 0x41, 0x9B,
4845 0x1B, 0x02, 0x81, 0x81, 0x00, 0xCD, 0x5E, 0xA7,
4846 0x70, 0x27, 0x89, 0x06, 0x4B, 0x67, 0x35, 0x40,
4847 0xCB, 0xFF, 0x09, 0x35, 0x6A, 0xD8, 0x0B, 0xC3,
4848 0xD5, 0x92, 0x81, 0x2E, 0xBA, 0x47, 0x61, 0x0B,
4849 0x9F, 0xAC, 0x6A, 0xEC, 0xEF, 0xE2, 0x2A, 0xCA,
4850 0xE4, 0x38, 0x45, 0x9C, 0xDA, 0x74, 0xE5, 0x96,
4851 0x53, 0xD8, 0x8C, 0x04, 0x18, 0x9D, 0x34, 0x39,
4852 0x9B, 0xF5, 0xB1, 0x4B, 0x92, 0x0E, 0x34, 0xEF,
4853 0x38, 0xA7, 0xD0, 0x9F, 0xE6, 0x95, 0x93, 0x39,
4854 0x6E, 0x8F, 0xE7, 0x35, 0xE6, 0xF0, 0xA6, 0xAE,
4855 0x49, 0x90, 0x40, 0x10, 0x41, 0xD8, 0xA4, 0x06,
4856 0xB6, 0xFD, 0x86, 0xA1, 0x16, 0x1E, 0x45, 0xF9,
4857 0x5A, 0x3E, 0xAA, 0x5C, 0x10, 0x12, 0xE6, 0x66,
4858 0x2E, 0x44, 0xF1, 0x5F, 0x33, 0x5A, 0xC9, 0x71,
4859 0xE1, 0x76, 0x6B, 0x2B, 0xB9, 0xC9, 0x85, 0x10,
4860 0x99, 0x74, 0x14, 0x1B, 0x44, 0xD3, 0x7E, 0x1E,
4861 0x31, 0x98, 0x20, 0xA5, 0x5F, 0x02, 0x81, 0x81,
4862 0x00, 0xB2, 0x87, 0x12, 0x37, 0xBF, 0x9F, 0xAD,
4863 0x38, 0xC3, 0x31, 0x6A, 0xB7, 0x87, 0x7A, 0x6A,
4864 0x86, 0x80, 0x63, 0xE5, 0x42, 0xA7, 0x18, 0x6D,
4865 0x43, 0x1E, 0x8D, 0x27, 0xC1, 0x9A, 0xC0, 0x41,
4866 0x45, 0x84, 0x03, 0x39, 0x42, 0xE9, 0xFF, 0x6E,
4867 0x29, 0x73, 0xBB, 0x7B, 0x2D, 0x8B, 0x0E, 0x94,
4868 0xAD, 0x1E, 0xE8, 0x21, 0x58, 0x10, 0x8F, 0xBC,
4869 0x86, 0x64, 0x51, 0x7A, 0x5A, 0x46, 0x7F, 0xB9,
4870 0x63, 0x01, 0x4B, 0xD5, 0xDC, 0xC2, 0xB4, 0xFB,
4871 0x08, 0x7C, 0x23, 0x03, 0x9D, 0x11, 0x92, 0x0D,
4872 0xBE, 0x22, 0xFD, 0x9F, 0x16, 0xB4, 0xD8, 0x9E,
4873 0x23, 0x22, 0x5C, 0xD4, 0x55, 0xAD, 0xBA, 0xF3,
4874 0x2E, 0xF4, 0x3F, 0x18, 0x58, 0x64, 0xA3, 0x6D,
4875 0x63, 0x03, 0x09, 0xD6, 0x85, 0x3F, 0x77, 0x14,
4876 0xB3, 0x9A, 0xAE, 0x1E, 0xBE, 0xE3, 0x93, 0x8F,
4877 0x87, 0xC2, 0x70, 0x7E, 0x17, 0x8C, 0x73, 0x9F,
4878 0x9F, 0x02, 0x81, 0x81, 0x00, 0x96, 0x90, 0xBE,
4879 0xD1, 0x4B, 0x2A, 0xFA, 0xA2, 0x6D, 0x98, 0x6D,
4880 0x59, 0x22, 0x31, 0xEE, 0x27, 0xD7, 0x1D, 0x49,
4881 0x06, 0x5B, 0xD2, 0xBA, 0x1F, 0x78, 0x15, 0x7E,
4882 0x20, 0x22, 0x98, 0x81, 0xFD, 0x9D, 0x23, 0x22,
4883 0x7D, 0x0F, 0x84, 0x79, 0xEA, 0xEF, 0xA9, 0x22,
4884 0xFD, 0x75, 0xD5, 0xB1, 0x6B, 0x1A, 0x56, 0x1F,
4885 0xA6, 0x68, 0x0B, 0x04, 0x0C, 0xA0, 0xBD, 0xCE,
4886 0x65, 0x0B, 0x23, 0xB9, 0x17, 0xA4, 0xB1, 0xBB,
4887 0x79, 0x83, 0xA7, 0x4F, 0xAD, 0x70, 0xE1, 0xC3,
4888 0x05, 0xCB, 0xEC, 0x2B, 0xFF, 0x1A, 0x85, 0xA7,
4889 0x26, 0xA1, 0xD9, 0x02, 0x60, 0xE4, 0xF1, 0x08,
4890 0x4F, 0x51, 0x82, 0x34, 0xDC, 0xD3, 0xFE, 0x77,
4891 0x0B, 0x95, 0x20, 0x21, 0x5B, 0xD5, 0x43, 0xBB,
4892 0x6A, 0x41, 0x17, 0x71, 0x87, 0x54, 0x67, 0x6A,
4893 0x34, 0x17, 0x16, 0x66, 0xA7, 0x9F, 0x26, 0xE7,
4894 0x9C, 0x14, 0x9C, 0x5A, 0xA1, 0x02, 0x81, 0x81,
4895 0x00, 0xA0, 0xC9, 0x85, 0xA0, 0xA0, 0xA7, 0x91,
4896 0xA6, 0x59, 0xF9, 0x97, 0x31, 0x13, 0x4C, 0x44,
4897 0xF3, 0x7B, 0x2E, 0x52, 0x0A, 0x2C, 0xEA, 0x35,
4898 0x80, 0x0A, 0xD2, 0x72, 0x41, 0xED, 0x36, 0x0D,
4899 0xFD, 0xE6, 0xE8, 0xCA, 0x61, 0x4F, 0x12, 0x04,
4900 0x7F, 0xD0, 0x8B, 0x76, 0xAC, 0x4D, 0x13, 0xC0,
4901 0x56, 0xA0, 0x69, 0x9E, 0x2F, 0x98, 0xA1, 0xCA,
4902 0xC9, 0x10, 0x11, 0x29, 0x4D, 0x71, 0x20, 0x8F,
4903 0x4A, 0xBA, 0xB3, 0x3B, 0xA8, 0x7A, 0xA0, 0x51,
4904 0x7F, 0x41, 0x5B, 0xAC, 0xA8, 0x8D, 0x6B, 0xAC,
4905 0x00, 0x60, 0x88, 0xFA, 0x60, 0x1D, 0x34, 0x94,
4906 0x17, 0xE1, 0xF0, 0xC9, 0xB2, 0x3A, 0xFF, 0xA4,
4907 0xD4, 0x96, 0x61, 0x8D, 0xBC, 0x02, 0x49, 0x86,
4908 0xED, 0x69, 0x0B, 0xBB, 0x7B, 0x02, 0x57, 0x68,
4909 0xFF, 0x9D, 0xF8, 0xAC, 0x15, 0x41, 0x6F, 0x48,
4910 0x9F, 0x81, 0x29, 0xC3, 0x23, 0x41, 0xA8, 0xB4,
4911 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4912 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
4913 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
4914 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
4915 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00
4918 uint8 observed
[1280] = {0};
4919 struct kmip ctx
= {0};
4920 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
4922 uint8 value
[1193] = {
4923 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02,
4924 0x82, 0x01, 0x01, 0x00, 0xAB, 0x7F, 0x16, 0x1C,
4925 0x00, 0x42, 0x49, 0x6C, 0xCD, 0x6C, 0x6D, 0x4D,
4926 0xAD, 0xB9, 0x19, 0x97, 0x34, 0x35, 0x35, 0x77,
4927 0x76, 0x00, 0x3A, 0xCF, 0x54, 0xB7, 0xAF, 0x1E,
4928 0x44, 0x0A, 0xFB, 0x80, 0xB6, 0x4A, 0x87, 0x55,
4929 0xF8, 0x00, 0x2C, 0xFE, 0xBA, 0x6B, 0x18, 0x45,
4930 0x40, 0xA2, 0xD6, 0x60, 0x86, 0xD7, 0x46, 0x48,
4931 0x34, 0x6D, 0x75, 0xB8, 0xD7, 0x18, 0x12, 0xB2,
4932 0x05, 0x38, 0x7C, 0x0F, 0x65, 0x83, 0xBC, 0x4D,
4933 0x7D, 0xC7, 0xEC, 0x11, 0x4F, 0x3B, 0x17, 0x6B,
4934 0x79, 0x57, 0xC4, 0x22, 0xE7, 0xD0, 0x3F, 0xC6,
4935 0x26, 0x7F, 0xA2, 0xA6, 0xF8, 0x9B, 0x9B, 0xEE,
4936 0x9E, 0x60, 0xA1, 0xD7, 0xC2, 0xD8, 0x33, 0xE5,
4937 0xA5, 0xF4, 0xBB, 0x0B, 0x14, 0x34, 0xF4, 0xE7,
4938 0x95, 0xA4, 0x11, 0x00, 0xF8, 0xAA, 0x21, 0x49,
4939 0x00, 0xDF, 0x8B, 0x65, 0x08, 0x9F, 0x98, 0x13,
4940 0x5B, 0x1C, 0x67, 0xB7, 0x01, 0x67, 0x5A, 0xBD,
4941 0xBC, 0x7D, 0x57, 0x21, 0xAA, 0xC9, 0xD1, 0x4A,
4942 0x7F, 0x08, 0x1F, 0xCE, 0xC8, 0x0B, 0x64, 0xE8,
4943 0xA0, 0xEC, 0xC8, 0x29, 0x53, 0x53, 0xC7, 0x95,
4944 0x32, 0x8A, 0xBF, 0x70, 0xE1, 0xB4, 0x2E, 0x7B,
4945 0xB8, 0xB7, 0xF4, 0xE8, 0xAC, 0x8C, 0x81, 0x0C,
4946 0xDB, 0x66, 0xE3, 0xD2, 0x11, 0x26, 0xEB, 0xA8,
4947 0xDA, 0x7D, 0x0C, 0xA3, 0x41, 0x42, 0xCB, 0x76,
4948 0xF9, 0x1F, 0x01, 0x3D, 0xA8, 0x09, 0xE9, 0xC1,
4949 0xB7, 0xAE, 0x64, 0xC5, 0x41, 0x30, 0xFB, 0xC2,
4950 0x1D, 0x80, 0xE9, 0xC2, 0xCB, 0x06, 0xC5, 0xC8,
4951 0xD7, 0xCC, 0xE8, 0x94, 0x6A, 0x9A, 0xC9, 0x9B,
4952 0x1C, 0x28, 0x15, 0xC3, 0x61, 0x2A, 0x29, 0xA8,
4953 0x2D, 0x73, 0xA1, 0xF9, 0x93, 0x74, 0xFE, 0x30,
4954 0xE5, 0x49, 0x51, 0x66, 0x2A, 0x6E, 0xDA, 0x29,
4955 0xC6, 0xFC, 0x41, 0x13, 0x35, 0xD5, 0xDC, 0x74,
4956 0x26, 0xB0, 0xF6, 0x05, 0x02, 0x03, 0x01, 0x00,
4957 0x01, 0x02, 0x82, 0x01, 0x00, 0x3B, 0x12, 0x45,
4958 0x5D, 0x53, 0xC1, 0x81, 0x65, 0x16, 0xC5, 0x18,
4959 0x49, 0x3F, 0x63, 0x98, 0xAA, 0xFA, 0x72, 0xB1,
4960 0x7D, 0xFA, 0x89, 0x4D, 0xB8, 0x88, 0xA7, 0xD4,
4961 0x8C, 0x0A, 0x47, 0xF6, 0x25, 0x79, 0xA4, 0xE6,
4962 0x44, 0xF8, 0x6D, 0xA7, 0x11, 0xFE, 0xC8, 0x50,
4963 0xCD, 0xD9, 0xDB, 0xBD, 0x17, 0xF6, 0x9A, 0x44,
4964 0x3D, 0x2E, 0xC1, 0xDD, 0x60, 0xD3, 0xC6, 0x18,
4965 0xFA, 0x74, 0xCD, 0xE5, 0xFD, 0xAF, 0xAB, 0xD6,
4966 0xBA, 0xA2, 0x6E, 0xB0, 0xA3, 0xAD, 0xB4, 0xDE,
4967 0xF6, 0x48, 0x0F, 0xB1, 0x21, 0x8C, 0xD3, 0xB0,
4968 0x83, 0xE2, 0x52, 0xE8, 0x85, 0xB6, 0xF0, 0x72,
4969 0x9F, 0x98, 0xB2, 0x14, 0x4D, 0x2B, 0x72, 0x29,
4970 0x3E, 0x1B, 0x11, 0xD7, 0x33, 0x93, 0xBC, 0x41,
4971 0xF7, 0x5B, 0x15, 0xEE, 0x3D, 0x75, 0x69, 0xB4,
4972 0x99, 0x5E, 0xD1, 0xA1, 0x44, 0x25, 0xDA, 0x43,
4973 0x19, 0xB7, 0xB2, 0x6B, 0x0E, 0x8F, 0xEF, 0x17,
4974 0xC3, 0x75, 0x42, 0xAE, 0x5C, 0x6D, 0x58, 0x49,
4975 0xF8, 0x72, 0x09, 0x56, 0x7F, 0x39, 0x25, 0xA4,
4976 0x7B, 0x01, 0x6D, 0x56, 0x48, 0x59, 0x71, 0x7B,
4977 0xC5, 0x7F, 0xCB, 0x45, 0x22, 0xD0, 0xAA, 0x49,
4978 0xCE, 0x81, 0x6E, 0x5B, 0xE7, 0xB3, 0x08, 0x81,
4979 0x93, 0x23, 0x6E, 0xC9, 0xEF, 0xFF, 0x14, 0x08,
4980 0x58, 0x04, 0x5B, 0x73, 0xC5, 0xD7, 0x9B, 0xAF,
4981 0x38, 0xF7, 0xC6, 0x7F, 0x04, 0xC5, 0xDC, 0xF0,
4982 0xE3, 0x80, 0x6A, 0xD9, 0x82, 0xD1, 0x25, 0x90,
4983 0x58, 0xC3, 0x47, 0x3E, 0x84, 0x71, 0x79, 0xA8,
4984 0x78, 0xF2, 0xC6, 0xB3, 0xBD, 0x96, 0x8F, 0xB9,
4985 0x9E, 0xA4, 0x6E, 0x91, 0x85, 0x89, 0x2F, 0x36,
4986 0x76, 0xE7, 0x89, 0x65, 0xC2, 0xAE, 0xD4, 0x87,
4987 0x7B, 0xA3, 0x91, 0x7D, 0xF0, 0x7C, 0x5E, 0x92,
4988 0x74, 0x74, 0xF1, 0x9E, 0x76, 0x4B, 0xA6, 0x1D,
4989 0xC3, 0x8D, 0x63, 0xBF, 0x29, 0x02, 0x81, 0x81,
4990 0x00, 0xD5, 0xC6, 0x9C, 0x8C, 0x3C, 0xDC, 0x24,
4991 0x64, 0x74, 0x4A, 0x79, 0x37, 0x13, 0xDA, 0xFB,
4992 0x9F, 0x1D, 0xBC, 0x79, 0x9F, 0xF9, 0x64, 0x23,
4993 0xFE, 0xCD, 0x3C, 0xBA, 0x79, 0x42, 0x86, 0xBC,
4994 0xE9, 0x20, 0xF4, 0xB5, 0xC1, 0x83, 0xF9, 0x9E,
4995 0xE9, 0x02, 0x8D, 0xB6, 0x21, 0x2C, 0x62, 0x77,
4996 0xC4, 0xC8, 0x29, 0x7F, 0xCF, 0xBC, 0xE7, 0xF7,
4997 0xC2, 0x4C, 0xA4, 0xC5, 0x1F, 0xC7, 0x18, 0x2F,
4998 0xB8, 0xF4, 0x01, 0x9F, 0xB1, 0xD5, 0x65, 0x96,
4999 0x74, 0xC5, 0xCB, 0xE6, 0xD5, 0xFA, 0x99, 0x20,
5000 0x51, 0x34, 0x17, 0x60, 0xCD, 0x00, 0x73, 0x57,
5001 0x29, 0xA0, 0x70, 0xA9, 0xE5, 0x4D, 0x34, 0x2B,
5002 0xEB, 0xA8, 0xEF, 0x47, 0xEE, 0x82, 0xD3, 0xA0,
5003 0x1B, 0x04, 0xCE, 0xC4, 0xA0, 0x0D, 0x4D, 0xDB,
5004 0x41, 0xE3, 0x51, 0x16, 0xFC, 0x22, 0x1E, 0x85,
5005 0x4B, 0x43, 0xA6, 0x96, 0xC0, 0xE6, 0x41, 0x9B,
5006 0x1B, 0x02, 0x81, 0x81, 0x00, 0xCD, 0x5E, 0xA7,
5007 0x70, 0x27, 0x89, 0x06, 0x4B, 0x67, 0x35, 0x40,
5008 0xCB, 0xFF, 0x09, 0x35, 0x6A, 0xD8, 0x0B, 0xC3,
5009 0xD5, 0x92, 0x81, 0x2E, 0xBA, 0x47, 0x61, 0x0B,
5010 0x9F, 0xAC, 0x6A, 0xEC, 0xEF, 0xE2, 0x2A, 0xCA,
5011 0xE4, 0x38, 0x45, 0x9C, 0xDA, 0x74, 0xE5, 0x96,
5012 0x53, 0xD8, 0x8C, 0x04, 0x18, 0x9D, 0x34, 0x39,
5013 0x9B, 0xF5, 0xB1, 0x4B, 0x92, 0x0E, 0x34, 0xEF,
5014 0x38, 0xA7, 0xD0, 0x9F, 0xE6, 0x95, 0x93, 0x39,
5015 0x6E, 0x8F, 0xE7, 0x35, 0xE6, 0xF0, 0xA6, 0xAE,
5016 0x49, 0x90, 0x40, 0x10, 0x41, 0xD8, 0xA4, 0x06,
5017 0xB6, 0xFD, 0x86, 0xA1, 0x16, 0x1E, 0x45, 0xF9,
5018 0x5A, 0x3E, 0xAA, 0x5C, 0x10, 0x12, 0xE6, 0x66,
5019 0x2E, 0x44, 0xF1, 0x5F, 0x33, 0x5A, 0xC9, 0x71,
5020 0xE1, 0x76, 0x6B, 0x2B, 0xB9, 0xC9, 0x85, 0x10,
5021 0x99, 0x74, 0x14, 0x1B, 0x44, 0xD3, 0x7E, 0x1E,
5022 0x31, 0x98, 0x20, 0xA5, 0x5F, 0x02, 0x81, 0x81,
5023 0x00, 0xB2, 0x87, 0x12, 0x37, 0xBF, 0x9F, 0xAD,
5024 0x38, 0xC3, 0x31, 0x6A, 0xB7, 0x87, 0x7A, 0x6A,
5025 0x86, 0x80, 0x63, 0xE5, 0x42, 0xA7, 0x18, 0x6D,
5026 0x43, 0x1E, 0x8D, 0x27, 0xC1, 0x9A, 0xC0, 0x41,
5027 0x45, 0x84, 0x03, 0x39, 0x42, 0xE9, 0xFF, 0x6E,
5028 0x29, 0x73, 0xBB, 0x7B, 0x2D, 0x8B, 0x0E, 0x94,
5029 0xAD, 0x1E, 0xE8, 0x21, 0x58, 0x10, 0x8F, 0xBC,
5030 0x86, 0x64, 0x51, 0x7A, 0x5A, 0x46, 0x7F, 0xB9,
5031 0x63, 0x01, 0x4B, 0xD5, 0xDC, 0xC2, 0xB4, 0xFB,
5032 0x08, 0x7C, 0x23, 0x03, 0x9D, 0x11, 0x92, 0x0D,
5033 0xBE, 0x22, 0xFD, 0x9F, 0x16, 0xB4, 0xD8, 0x9E,
5034 0x23, 0x22, 0x5C, 0xD4, 0x55, 0xAD, 0xBA, 0xF3,
5035 0x2E, 0xF4, 0x3F, 0x18, 0x58, 0x64, 0xA3, 0x6D,
5036 0x63, 0x03, 0x09, 0xD6, 0x85, 0x3F, 0x77, 0x14,
5037 0xB3, 0x9A, 0xAE, 0x1E, 0xBE, 0xE3, 0x93, 0x8F,
5038 0x87, 0xC2, 0x70, 0x7E, 0x17, 0x8C, 0x73, 0x9F,
5039 0x9F, 0x02, 0x81, 0x81, 0x00, 0x96, 0x90, 0xBE,
5040 0xD1, 0x4B, 0x2A, 0xFA, 0xA2, 0x6D, 0x98, 0x6D,
5041 0x59, 0x22, 0x31, 0xEE, 0x27, 0xD7, 0x1D, 0x49,
5042 0x06, 0x5B, 0xD2, 0xBA, 0x1F, 0x78, 0x15, 0x7E,
5043 0x20, 0x22, 0x98, 0x81, 0xFD, 0x9D, 0x23, 0x22,
5044 0x7D, 0x0F, 0x84, 0x79, 0xEA, 0xEF, 0xA9, 0x22,
5045 0xFD, 0x75, 0xD5, 0xB1, 0x6B, 0x1A, 0x56, 0x1F,
5046 0xA6, 0x68, 0x0B, 0x04, 0x0C, 0xA0, 0xBD, 0xCE,
5047 0x65, 0x0B, 0x23, 0xB9, 0x17, 0xA4, 0xB1, 0xBB,
5048 0x79, 0x83, 0xA7, 0x4F, 0xAD, 0x70, 0xE1, 0xC3,
5049 0x05, 0xCB, 0xEC, 0x2B, 0xFF, 0x1A, 0x85, 0xA7,
5050 0x26, 0xA1, 0xD9, 0x02, 0x60, 0xE4, 0xF1, 0x08,
5051 0x4F, 0x51, 0x82, 0x34, 0xDC, 0xD3, 0xFE, 0x77,
5052 0x0B, 0x95, 0x20, 0x21, 0x5B, 0xD5, 0x43, 0xBB,
5053 0x6A, 0x41, 0x17, 0x71, 0x87, 0x54, 0x67, 0x6A,
5054 0x34, 0x17, 0x16, 0x66, 0xA7, 0x9F, 0x26, 0xE7,
5055 0x9C, 0x14, 0x9C, 0x5A, 0xA1, 0x02, 0x81, 0x81,
5056 0x00, 0xA0, 0xC9, 0x85, 0xA0, 0xA0, 0xA7, 0x91,
5057 0xA6, 0x59, 0xF9, 0x97, 0x31, 0x13, 0x4C, 0x44,
5058 0xF3, 0x7B, 0x2E, 0x52, 0x0A, 0x2C, 0xEA, 0x35,
5059 0x80, 0x0A, 0xD2, 0x72, 0x41, 0xED, 0x36, 0x0D,
5060 0xFD, 0xE6, 0xE8, 0xCA, 0x61, 0x4F, 0x12, 0x04,
5061 0x7F, 0xD0, 0x8B, 0x76, 0xAC, 0x4D, 0x13, 0xC0,
5062 0x56, 0xA0, 0x69, 0x9E, 0x2F, 0x98, 0xA1, 0xCA,
5063 0xC9, 0x10, 0x11, 0x29, 0x4D, 0x71, 0x20, 0x8F,
5064 0x4A, 0xBA, 0xB3, 0x3B, 0xA8, 0x7A, 0xA0, 0x51,
5065 0x7F, 0x41, 0x5B, 0xAC, 0xA8, 0x8D, 0x6B, 0xAC,
5066 0x00, 0x60, 0x88, 0xFA, 0x60, 0x1D, 0x34, 0x94,
5067 0x17, 0xE1, 0xF0, 0xC9, 0xB2, 0x3A, 0xFF, 0xA4,
5068 0xD4, 0x96, 0x61, 0x8D, 0xBC, 0x02, 0x49, 0x86,
5069 0xED, 0x69, 0x0B, 0xBB, 0x7B, 0x02, 0x57, 0x68,
5070 0xFF, 0x9D, 0xF8, 0xAC, 0x15, 0x41, 0x6F, 0x48,
5071 0x9F, 0x81, 0x29, 0xC3, 0x23, 0x41, 0xA8, 0xB4,
5074 struct byte_string key
= {0};
5076 key
.size
= ARRAY_LENGTH(value
);
5078 struct key_value kv
= {0};
5079 kv
.key_material
= &key
;
5081 struct key_block kb
= {0};
5082 kb
.key_format_type
= KMIP_KEYFORMAT_PKCS1
;
5084 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
5085 kb
.cryptographic_length
= 2048;
5087 struct private_key pk
= {0};
5090 int result
= kmip_encode_private_key(&ctx
, &pk
);
5091 result
= report_encoding_test_result(
5103 test_decode_private_key(TestTracker
*tracker
)
5105 TRACK_TEST(tracker
);
5107 uint8 encoding
[1280] = {
5108 0x42, 0x00, 0x64, 0x01, 0x00, 0x00, 0x04, 0xF8,
5109 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x04, 0xF0,
5110 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
5111 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
5112 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x04, 0xB8,
5113 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x04, 0xA9,
5114 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02,
5115 0x82, 0x01, 0x01, 0x00, 0xAB, 0x7F, 0x16, 0x1C,
5116 0x00, 0x42, 0x49, 0x6C, 0xCD, 0x6C, 0x6D, 0x4D,
5117 0xAD, 0xB9, 0x19, 0x97, 0x34, 0x35, 0x35, 0x77,
5118 0x76, 0x00, 0x3A, 0xCF, 0x54, 0xB7, 0xAF, 0x1E,
5119 0x44, 0x0A, 0xFB, 0x80, 0xB6, 0x4A, 0x87, 0x55,
5120 0xF8, 0x00, 0x2C, 0xFE, 0xBA, 0x6B, 0x18, 0x45,
5121 0x40, 0xA2, 0xD6, 0x60, 0x86, 0xD7, 0x46, 0x48,
5122 0x34, 0x6D, 0x75, 0xB8, 0xD7, 0x18, 0x12, 0xB2,
5123 0x05, 0x38, 0x7C, 0x0F, 0x65, 0x83, 0xBC, 0x4D,
5124 0x7D, 0xC7, 0xEC, 0x11, 0x4F, 0x3B, 0x17, 0x6B,
5125 0x79, 0x57, 0xC4, 0x22, 0xE7, 0xD0, 0x3F, 0xC6,
5126 0x26, 0x7F, 0xA2, 0xA6, 0xF8, 0x9B, 0x9B, 0xEE,
5127 0x9E, 0x60, 0xA1, 0xD7, 0xC2, 0xD8, 0x33, 0xE5,
5128 0xA5, 0xF4, 0xBB, 0x0B, 0x14, 0x34, 0xF4, 0xE7,
5129 0x95, 0xA4, 0x11, 0x00, 0xF8, 0xAA, 0x21, 0x49,
5130 0x00, 0xDF, 0x8B, 0x65, 0x08, 0x9F, 0x98, 0x13,
5131 0x5B, 0x1C, 0x67, 0xB7, 0x01, 0x67, 0x5A, 0xBD,
5132 0xBC, 0x7D, 0x57, 0x21, 0xAA, 0xC9, 0xD1, 0x4A,
5133 0x7F, 0x08, 0x1F, 0xCE, 0xC8, 0x0B, 0x64, 0xE8,
5134 0xA0, 0xEC, 0xC8, 0x29, 0x53, 0x53, 0xC7, 0x95,
5135 0x32, 0x8A, 0xBF, 0x70, 0xE1, 0xB4, 0x2E, 0x7B,
5136 0xB8, 0xB7, 0xF4, 0xE8, 0xAC, 0x8C, 0x81, 0x0C,
5137 0xDB, 0x66, 0xE3, 0xD2, 0x11, 0x26, 0xEB, 0xA8,
5138 0xDA, 0x7D, 0x0C, 0xA3, 0x41, 0x42, 0xCB, 0x76,
5139 0xF9, 0x1F, 0x01, 0x3D, 0xA8, 0x09, 0xE9, 0xC1,
5140 0xB7, 0xAE, 0x64, 0xC5, 0x41, 0x30, 0xFB, 0xC2,
5141 0x1D, 0x80, 0xE9, 0xC2, 0xCB, 0x06, 0xC5, 0xC8,
5142 0xD7, 0xCC, 0xE8, 0x94, 0x6A, 0x9A, 0xC9, 0x9B,
5143 0x1C, 0x28, 0x15, 0xC3, 0x61, 0x2A, 0x29, 0xA8,
5144 0x2D, 0x73, 0xA1, 0xF9, 0x93, 0x74, 0xFE, 0x30,
5145 0xE5, 0x49, 0x51, 0x66, 0x2A, 0x6E, 0xDA, 0x29,
5146 0xC6, 0xFC, 0x41, 0x13, 0x35, 0xD5, 0xDC, 0x74,
5147 0x26, 0xB0, 0xF6, 0x05, 0x02, 0x03, 0x01, 0x00,
5148 0x01, 0x02, 0x82, 0x01, 0x00, 0x3B, 0x12, 0x45,
5149 0x5D, 0x53, 0xC1, 0x81, 0x65, 0x16, 0xC5, 0x18,
5150 0x49, 0x3F, 0x63, 0x98, 0xAA, 0xFA, 0x72, 0xB1,
5151 0x7D, 0xFA, 0x89, 0x4D, 0xB8, 0x88, 0xA7, 0xD4,
5152 0x8C, 0x0A, 0x47, 0xF6, 0x25, 0x79, 0xA4, 0xE6,
5153 0x44, 0xF8, 0x6D, 0xA7, 0x11, 0xFE, 0xC8, 0x50,
5154 0xCD, 0xD9, 0xDB, 0xBD, 0x17, 0xF6, 0x9A, 0x44,
5155 0x3D, 0x2E, 0xC1, 0xDD, 0x60, 0xD3, 0xC6, 0x18,
5156 0xFA, 0x74, 0xCD, 0xE5, 0xFD, 0xAF, 0xAB, 0xD6,
5157 0xBA, 0xA2, 0x6E, 0xB0, 0xA3, 0xAD, 0xB4, 0xDE,
5158 0xF6, 0x48, 0x0F, 0xB1, 0x21, 0x8C, 0xD3, 0xB0,
5159 0x83, 0xE2, 0x52, 0xE8, 0x85, 0xB6, 0xF0, 0x72,
5160 0x9F, 0x98, 0xB2, 0x14, 0x4D, 0x2B, 0x72, 0x29,
5161 0x3E, 0x1B, 0x11, 0xD7, 0x33, 0x93, 0xBC, 0x41,
5162 0xF7, 0x5B, 0x15, 0xEE, 0x3D, 0x75, 0x69, 0xB4,
5163 0x99, 0x5E, 0xD1, 0xA1, 0x44, 0x25, 0xDA, 0x43,
5164 0x19, 0xB7, 0xB2, 0x6B, 0x0E, 0x8F, 0xEF, 0x17,
5165 0xC3, 0x75, 0x42, 0xAE, 0x5C, 0x6D, 0x58, 0x49,
5166 0xF8, 0x72, 0x09, 0x56, 0x7F, 0x39, 0x25, 0xA4,
5167 0x7B, 0x01, 0x6D, 0x56, 0x48, 0x59, 0x71, 0x7B,
5168 0xC5, 0x7F, 0xCB, 0x45, 0x22, 0xD0, 0xAA, 0x49,
5169 0xCE, 0x81, 0x6E, 0x5B, 0xE7, 0xB3, 0x08, 0x81,
5170 0x93, 0x23, 0x6E, 0xC9, 0xEF, 0xFF, 0x14, 0x08,
5171 0x58, 0x04, 0x5B, 0x73, 0xC5, 0xD7, 0x9B, 0xAF,
5172 0x38, 0xF7, 0xC6, 0x7F, 0x04, 0xC5, 0xDC, 0xF0,
5173 0xE3, 0x80, 0x6A, 0xD9, 0x82, 0xD1, 0x25, 0x90,
5174 0x58, 0xC3, 0x47, 0x3E, 0x84, 0x71, 0x79, 0xA8,
5175 0x78, 0xF2, 0xC6, 0xB3, 0xBD, 0x96, 0x8F, 0xB9,
5176 0x9E, 0xA4, 0x6E, 0x91, 0x85, 0x89, 0x2F, 0x36,
5177 0x76, 0xE7, 0x89, 0x65, 0xC2, 0xAE, 0xD4, 0x87,
5178 0x7B, 0xA3, 0x91, 0x7D, 0xF0, 0x7C, 0x5E, 0x92,
5179 0x74, 0x74, 0xF1, 0x9E, 0x76, 0x4B, 0xA6, 0x1D,
5180 0xC3, 0x8D, 0x63, 0xBF, 0x29, 0x02, 0x81, 0x81,
5181 0x00, 0xD5, 0xC6, 0x9C, 0x8C, 0x3C, 0xDC, 0x24,
5182 0x64, 0x74, 0x4A, 0x79, 0x37, 0x13, 0xDA, 0xFB,
5183 0x9F, 0x1D, 0xBC, 0x79, 0x9F, 0xF9, 0x64, 0x23,
5184 0xFE, 0xCD, 0x3C, 0xBA, 0x79, 0x42, 0x86, 0xBC,
5185 0xE9, 0x20, 0xF4, 0xB5, 0xC1, 0x83, 0xF9, 0x9E,
5186 0xE9, 0x02, 0x8D, 0xB6, 0x21, 0x2C, 0x62, 0x77,
5187 0xC4, 0xC8, 0x29, 0x7F, 0xCF, 0xBC, 0xE7, 0xF7,
5188 0xC2, 0x4C, 0xA4, 0xC5, 0x1F, 0xC7, 0x18, 0x2F,
5189 0xB8, 0xF4, 0x01, 0x9F, 0xB1, 0xD5, 0x65, 0x96,
5190 0x74, 0xC5, 0xCB, 0xE6, 0xD5, 0xFA, 0x99, 0x20,
5191 0x51, 0x34, 0x17, 0x60, 0xCD, 0x00, 0x73, 0x57,
5192 0x29, 0xA0, 0x70, 0xA9, 0xE5, 0x4D, 0x34, 0x2B,
5193 0xEB, 0xA8, 0xEF, 0x47, 0xEE, 0x82, 0xD3, 0xA0,
5194 0x1B, 0x04, 0xCE, 0xC4, 0xA0, 0x0D, 0x4D, 0xDB,
5195 0x41, 0xE3, 0x51, 0x16, 0xFC, 0x22, 0x1E, 0x85,
5196 0x4B, 0x43, 0xA6, 0x96, 0xC0, 0xE6, 0x41, 0x9B,
5197 0x1B, 0x02, 0x81, 0x81, 0x00, 0xCD, 0x5E, 0xA7,
5198 0x70, 0x27, 0x89, 0x06, 0x4B, 0x67, 0x35, 0x40,
5199 0xCB, 0xFF, 0x09, 0x35, 0x6A, 0xD8, 0x0B, 0xC3,
5200 0xD5, 0x92, 0x81, 0x2E, 0xBA, 0x47, 0x61, 0x0B,
5201 0x9F, 0xAC, 0x6A, 0xEC, 0xEF, 0xE2, 0x2A, 0xCA,
5202 0xE4, 0x38, 0x45, 0x9C, 0xDA, 0x74, 0xE5, 0x96,
5203 0x53, 0xD8, 0x8C, 0x04, 0x18, 0x9D, 0x34, 0x39,
5204 0x9B, 0xF5, 0xB1, 0x4B, 0x92, 0x0E, 0x34, 0xEF,
5205 0x38, 0xA7, 0xD0, 0x9F, 0xE6, 0x95, 0x93, 0x39,
5206 0x6E, 0x8F, 0xE7, 0x35, 0xE6, 0xF0, 0xA6, 0xAE,
5207 0x49, 0x90, 0x40, 0x10, 0x41, 0xD8, 0xA4, 0x06,
5208 0xB6, 0xFD, 0x86, 0xA1, 0x16, 0x1E, 0x45, 0xF9,
5209 0x5A, 0x3E, 0xAA, 0x5C, 0x10, 0x12, 0xE6, 0x66,
5210 0x2E, 0x44, 0xF1, 0x5F, 0x33, 0x5A, 0xC9, 0x71,
5211 0xE1, 0x76, 0x6B, 0x2B, 0xB9, 0xC9, 0x85, 0x10,
5212 0x99, 0x74, 0x14, 0x1B, 0x44, 0xD3, 0x7E, 0x1E,
5213 0x31, 0x98, 0x20, 0xA5, 0x5F, 0x02, 0x81, 0x81,
5214 0x00, 0xB2, 0x87, 0x12, 0x37, 0xBF, 0x9F, 0xAD,
5215 0x38, 0xC3, 0x31, 0x6A, 0xB7, 0x87, 0x7A, 0x6A,
5216 0x86, 0x80, 0x63, 0xE5, 0x42, 0xA7, 0x18, 0x6D,
5217 0x43, 0x1E, 0x8D, 0x27, 0xC1, 0x9A, 0xC0, 0x41,
5218 0x45, 0x84, 0x03, 0x39, 0x42, 0xE9, 0xFF, 0x6E,
5219 0x29, 0x73, 0xBB, 0x7B, 0x2D, 0x8B, 0x0E, 0x94,
5220 0xAD, 0x1E, 0xE8, 0x21, 0x58, 0x10, 0x8F, 0xBC,
5221 0x86, 0x64, 0x51, 0x7A, 0x5A, 0x46, 0x7F, 0xB9,
5222 0x63, 0x01, 0x4B, 0xD5, 0xDC, 0xC2, 0xB4, 0xFB,
5223 0x08, 0x7C, 0x23, 0x03, 0x9D, 0x11, 0x92, 0x0D,
5224 0xBE, 0x22, 0xFD, 0x9F, 0x16, 0xB4, 0xD8, 0x9E,
5225 0x23, 0x22, 0x5C, 0xD4, 0x55, 0xAD, 0xBA, 0xF3,
5226 0x2E, 0xF4, 0x3F, 0x18, 0x58, 0x64, 0xA3, 0x6D,
5227 0x63, 0x03, 0x09, 0xD6, 0x85, 0x3F, 0x77, 0x14,
5228 0xB3, 0x9A, 0xAE, 0x1E, 0xBE, 0xE3, 0x93, 0x8F,
5229 0x87, 0xC2, 0x70, 0x7E, 0x17, 0x8C, 0x73, 0x9F,
5230 0x9F, 0x02, 0x81, 0x81, 0x00, 0x96, 0x90, 0xBE,
5231 0xD1, 0x4B, 0x2A, 0xFA, 0xA2, 0x6D, 0x98, 0x6D,
5232 0x59, 0x22, 0x31, 0xEE, 0x27, 0xD7, 0x1D, 0x49,
5233 0x06, 0x5B, 0xD2, 0xBA, 0x1F, 0x78, 0x15, 0x7E,
5234 0x20, 0x22, 0x98, 0x81, 0xFD, 0x9D, 0x23, 0x22,
5235 0x7D, 0x0F, 0x84, 0x79, 0xEA, 0xEF, 0xA9, 0x22,
5236 0xFD, 0x75, 0xD5, 0xB1, 0x6B, 0x1A, 0x56, 0x1F,
5237 0xA6, 0x68, 0x0B, 0x04, 0x0C, 0xA0, 0xBD, 0xCE,
5238 0x65, 0x0B, 0x23, 0xB9, 0x17, 0xA4, 0xB1, 0xBB,
5239 0x79, 0x83, 0xA7, 0x4F, 0xAD, 0x70, 0xE1, 0xC3,
5240 0x05, 0xCB, 0xEC, 0x2B, 0xFF, 0x1A, 0x85, 0xA7,
5241 0x26, 0xA1, 0xD9, 0x02, 0x60, 0xE4, 0xF1, 0x08,
5242 0x4F, 0x51, 0x82, 0x34, 0xDC, 0xD3, 0xFE, 0x77,
5243 0x0B, 0x95, 0x20, 0x21, 0x5B, 0xD5, 0x43, 0xBB,
5244 0x6A, 0x41, 0x17, 0x71, 0x87, 0x54, 0x67, 0x6A,
5245 0x34, 0x17, 0x16, 0x66, 0xA7, 0x9F, 0x26, 0xE7,
5246 0x9C, 0x14, 0x9C, 0x5A, 0xA1, 0x02, 0x81, 0x81,
5247 0x00, 0xA0, 0xC9, 0x85, 0xA0, 0xA0, 0xA7, 0x91,
5248 0xA6, 0x59, 0xF9, 0x97, 0x31, 0x13, 0x4C, 0x44,
5249 0xF3, 0x7B, 0x2E, 0x52, 0x0A, 0x2C, 0xEA, 0x35,
5250 0x80, 0x0A, 0xD2, 0x72, 0x41, 0xED, 0x36, 0x0D,
5251 0xFD, 0xE6, 0xE8, 0xCA, 0x61, 0x4F, 0x12, 0x04,
5252 0x7F, 0xD0, 0x8B, 0x76, 0xAC, 0x4D, 0x13, 0xC0,
5253 0x56, 0xA0, 0x69, 0x9E, 0x2F, 0x98, 0xA1, 0xCA,
5254 0xC9, 0x10, 0x11, 0x29, 0x4D, 0x71, 0x20, 0x8F,
5255 0x4A, 0xBA, 0xB3, 0x3B, 0xA8, 0x7A, 0xA0, 0x51,
5256 0x7F, 0x41, 0x5B, 0xAC, 0xA8, 0x8D, 0x6B, 0xAC,
5257 0x00, 0x60, 0x88, 0xFA, 0x60, 0x1D, 0x34, 0x94,
5258 0x17, 0xE1, 0xF0, 0xC9, 0xB2, 0x3A, 0xFF, 0xA4,
5259 0xD4, 0x96, 0x61, 0x8D, 0xBC, 0x02, 0x49, 0x86,
5260 0xED, 0x69, 0x0B, 0xBB, 0x7B, 0x02, 0x57, 0x68,
5261 0xFF, 0x9D, 0xF8, 0xAC, 0x15, 0x41, 0x6F, 0x48,
5262 0x9F, 0x81, 0x29, 0xC3, 0x23, 0x41, 0xA8, 0xB4,
5263 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5264 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
5265 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
5266 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
5267 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00
5270 struct kmip ctx
= {0};
5271 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
5273 uint8 value
[1193] = {
5274 0x30, 0x82, 0x04, 0xA5, 0x02, 0x01, 0x00, 0x02,
5275 0x82, 0x01, 0x01, 0x00, 0xAB, 0x7F, 0x16, 0x1C,
5276 0x00, 0x42, 0x49, 0x6C, 0xCD, 0x6C, 0x6D, 0x4D,
5277 0xAD, 0xB9, 0x19, 0x97, 0x34, 0x35, 0x35, 0x77,
5278 0x76, 0x00, 0x3A, 0xCF, 0x54, 0xB7, 0xAF, 0x1E,
5279 0x44, 0x0A, 0xFB, 0x80, 0xB6, 0x4A, 0x87, 0x55,
5280 0xF8, 0x00, 0x2C, 0xFE, 0xBA, 0x6B, 0x18, 0x45,
5281 0x40, 0xA2, 0xD6, 0x60, 0x86, 0xD7, 0x46, 0x48,
5282 0x34, 0x6D, 0x75, 0xB8, 0xD7, 0x18, 0x12, 0xB2,
5283 0x05, 0x38, 0x7C, 0x0F, 0x65, 0x83, 0xBC, 0x4D,
5284 0x7D, 0xC7, 0xEC, 0x11, 0x4F, 0x3B, 0x17, 0x6B,
5285 0x79, 0x57, 0xC4, 0x22, 0xE7, 0xD0, 0x3F, 0xC6,
5286 0x26, 0x7F, 0xA2, 0xA6, 0xF8, 0x9B, 0x9B, 0xEE,
5287 0x9E, 0x60, 0xA1, 0xD7, 0xC2, 0xD8, 0x33, 0xE5,
5288 0xA5, 0xF4, 0xBB, 0x0B, 0x14, 0x34, 0xF4, 0xE7,
5289 0x95, 0xA4, 0x11, 0x00, 0xF8, 0xAA, 0x21, 0x49,
5290 0x00, 0xDF, 0x8B, 0x65, 0x08, 0x9F, 0x98, 0x13,
5291 0x5B, 0x1C, 0x67, 0xB7, 0x01, 0x67, 0x5A, 0xBD,
5292 0xBC, 0x7D, 0x57, 0x21, 0xAA, 0xC9, 0xD1, 0x4A,
5293 0x7F, 0x08, 0x1F, 0xCE, 0xC8, 0x0B, 0x64, 0xE8,
5294 0xA0, 0xEC, 0xC8, 0x29, 0x53, 0x53, 0xC7, 0x95,
5295 0x32, 0x8A, 0xBF, 0x70, 0xE1, 0xB4, 0x2E, 0x7B,
5296 0xB8, 0xB7, 0xF4, 0xE8, 0xAC, 0x8C, 0x81, 0x0C,
5297 0xDB, 0x66, 0xE3, 0xD2, 0x11, 0x26, 0xEB, 0xA8,
5298 0xDA, 0x7D, 0x0C, 0xA3, 0x41, 0x42, 0xCB, 0x76,
5299 0xF9, 0x1F, 0x01, 0x3D, 0xA8, 0x09, 0xE9, 0xC1,
5300 0xB7, 0xAE, 0x64, 0xC5, 0x41, 0x30, 0xFB, 0xC2,
5301 0x1D, 0x80, 0xE9, 0xC2, 0xCB, 0x06, 0xC5, 0xC8,
5302 0xD7, 0xCC, 0xE8, 0x94, 0x6A, 0x9A, 0xC9, 0x9B,
5303 0x1C, 0x28, 0x15, 0xC3, 0x61, 0x2A, 0x29, 0xA8,
5304 0x2D, 0x73, 0xA1, 0xF9, 0x93, 0x74, 0xFE, 0x30,
5305 0xE5, 0x49, 0x51, 0x66, 0x2A, 0x6E, 0xDA, 0x29,
5306 0xC6, 0xFC, 0x41, 0x13, 0x35, 0xD5, 0xDC, 0x74,
5307 0x26, 0xB0, 0xF6, 0x05, 0x02, 0x03, 0x01, 0x00,
5308 0x01, 0x02, 0x82, 0x01, 0x00, 0x3B, 0x12, 0x45,
5309 0x5D, 0x53, 0xC1, 0x81, 0x65, 0x16, 0xC5, 0x18,
5310 0x49, 0x3F, 0x63, 0x98, 0xAA, 0xFA, 0x72, 0xB1,
5311 0x7D, 0xFA, 0x89, 0x4D, 0xB8, 0x88, 0xA7, 0xD4,
5312 0x8C, 0x0A, 0x47, 0xF6, 0x25, 0x79, 0xA4, 0xE6,
5313 0x44, 0xF8, 0x6D, 0xA7, 0x11, 0xFE, 0xC8, 0x50,
5314 0xCD, 0xD9, 0xDB, 0xBD, 0x17, 0xF6, 0x9A, 0x44,
5315 0x3D, 0x2E, 0xC1, 0xDD, 0x60, 0xD3, 0xC6, 0x18,
5316 0xFA, 0x74, 0xCD, 0xE5, 0xFD, 0xAF, 0xAB, 0xD6,
5317 0xBA, 0xA2, 0x6E, 0xB0, 0xA3, 0xAD, 0xB4, 0xDE,
5318 0xF6, 0x48, 0x0F, 0xB1, 0x21, 0x8C, 0xD3, 0xB0,
5319 0x83, 0xE2, 0x52, 0xE8, 0x85, 0xB6, 0xF0, 0x72,
5320 0x9F, 0x98, 0xB2, 0x14, 0x4D, 0x2B, 0x72, 0x29,
5321 0x3E, 0x1B, 0x11, 0xD7, 0x33, 0x93, 0xBC, 0x41,
5322 0xF7, 0x5B, 0x15, 0xEE, 0x3D, 0x75, 0x69, 0xB4,
5323 0x99, 0x5E, 0xD1, 0xA1, 0x44, 0x25, 0xDA, 0x43,
5324 0x19, 0xB7, 0xB2, 0x6B, 0x0E, 0x8F, 0xEF, 0x17,
5325 0xC3, 0x75, 0x42, 0xAE, 0x5C, 0x6D, 0x58, 0x49,
5326 0xF8, 0x72, 0x09, 0x56, 0x7F, 0x39, 0x25, 0xA4,
5327 0x7B, 0x01, 0x6D, 0x56, 0x48, 0x59, 0x71, 0x7B,
5328 0xC5, 0x7F, 0xCB, 0x45, 0x22, 0xD0, 0xAA, 0x49,
5329 0xCE, 0x81, 0x6E, 0x5B, 0xE7, 0xB3, 0x08, 0x81,
5330 0x93, 0x23, 0x6E, 0xC9, 0xEF, 0xFF, 0x14, 0x08,
5331 0x58, 0x04, 0x5B, 0x73, 0xC5, 0xD7, 0x9B, 0xAF,
5332 0x38, 0xF7, 0xC6, 0x7F, 0x04, 0xC5, 0xDC, 0xF0,
5333 0xE3, 0x80, 0x6A, 0xD9, 0x82, 0xD1, 0x25, 0x90,
5334 0x58, 0xC3, 0x47, 0x3E, 0x84, 0x71, 0x79, 0xA8,
5335 0x78, 0xF2, 0xC6, 0xB3, 0xBD, 0x96, 0x8F, 0xB9,
5336 0x9E, 0xA4, 0x6E, 0x91, 0x85, 0x89, 0x2F, 0x36,
5337 0x76, 0xE7, 0x89, 0x65, 0xC2, 0xAE, 0xD4, 0x87,
5338 0x7B, 0xA3, 0x91, 0x7D, 0xF0, 0x7C, 0x5E, 0x92,
5339 0x74, 0x74, 0xF1, 0x9E, 0x76, 0x4B, 0xA6, 0x1D,
5340 0xC3, 0x8D, 0x63, 0xBF, 0x29, 0x02, 0x81, 0x81,
5341 0x00, 0xD5, 0xC6, 0x9C, 0x8C, 0x3C, 0xDC, 0x24,
5342 0x64, 0x74, 0x4A, 0x79, 0x37, 0x13, 0xDA, 0xFB,
5343 0x9F, 0x1D, 0xBC, 0x79, 0x9F, 0xF9, 0x64, 0x23,
5344 0xFE, 0xCD, 0x3C, 0xBA, 0x79, 0x42, 0x86, 0xBC,
5345 0xE9, 0x20, 0xF4, 0xB5, 0xC1, 0x83, 0xF9, 0x9E,
5346 0xE9, 0x02, 0x8D, 0xB6, 0x21, 0x2C, 0x62, 0x77,
5347 0xC4, 0xC8, 0x29, 0x7F, 0xCF, 0xBC, 0xE7, 0xF7,
5348 0xC2, 0x4C, 0xA4, 0xC5, 0x1F, 0xC7, 0x18, 0x2F,
5349 0xB8, 0xF4, 0x01, 0x9F, 0xB1, 0xD5, 0x65, 0x96,
5350 0x74, 0xC5, 0xCB, 0xE6, 0xD5, 0xFA, 0x99, 0x20,
5351 0x51, 0x34, 0x17, 0x60, 0xCD, 0x00, 0x73, 0x57,
5352 0x29, 0xA0, 0x70, 0xA9, 0xE5, 0x4D, 0x34, 0x2B,
5353 0xEB, 0xA8, 0xEF, 0x47, 0xEE, 0x82, 0xD3, 0xA0,
5354 0x1B, 0x04, 0xCE, 0xC4, 0xA0, 0x0D, 0x4D, 0xDB,
5355 0x41, 0xE3, 0x51, 0x16, 0xFC, 0x22, 0x1E, 0x85,
5356 0x4B, 0x43, 0xA6, 0x96, 0xC0, 0xE6, 0x41, 0x9B,
5357 0x1B, 0x02, 0x81, 0x81, 0x00, 0xCD, 0x5E, 0xA7,
5358 0x70, 0x27, 0x89, 0x06, 0x4B, 0x67, 0x35, 0x40,
5359 0xCB, 0xFF, 0x09, 0x35, 0x6A, 0xD8, 0x0B, 0xC3,
5360 0xD5, 0x92, 0x81, 0x2E, 0xBA, 0x47, 0x61, 0x0B,
5361 0x9F, 0xAC, 0x6A, 0xEC, 0xEF, 0xE2, 0x2A, 0xCA,
5362 0xE4, 0x38, 0x45, 0x9C, 0xDA, 0x74, 0xE5, 0x96,
5363 0x53, 0xD8, 0x8C, 0x04, 0x18, 0x9D, 0x34, 0x39,
5364 0x9B, 0xF5, 0xB1, 0x4B, 0x92, 0x0E, 0x34, 0xEF,
5365 0x38, 0xA7, 0xD0, 0x9F, 0xE6, 0x95, 0x93, 0x39,
5366 0x6E, 0x8F, 0xE7, 0x35, 0xE6, 0xF0, 0xA6, 0xAE,
5367 0x49, 0x90, 0x40, 0x10, 0x41, 0xD8, 0xA4, 0x06,
5368 0xB6, 0xFD, 0x86, 0xA1, 0x16, 0x1E, 0x45, 0xF9,
5369 0x5A, 0x3E, 0xAA, 0x5C, 0x10, 0x12, 0xE6, 0x66,
5370 0x2E, 0x44, 0xF1, 0x5F, 0x33, 0x5A, 0xC9, 0x71,
5371 0xE1, 0x76, 0x6B, 0x2B, 0xB9, 0xC9, 0x85, 0x10,
5372 0x99, 0x74, 0x14, 0x1B, 0x44, 0xD3, 0x7E, 0x1E,
5373 0x31, 0x98, 0x20, 0xA5, 0x5F, 0x02, 0x81, 0x81,
5374 0x00, 0xB2, 0x87, 0x12, 0x37, 0xBF, 0x9F, 0xAD,
5375 0x38, 0xC3, 0x31, 0x6A, 0xB7, 0x87, 0x7A, 0x6A,
5376 0x86, 0x80, 0x63, 0xE5, 0x42, 0xA7, 0x18, 0x6D,
5377 0x43, 0x1E, 0x8D, 0x27, 0xC1, 0x9A, 0xC0, 0x41,
5378 0x45, 0x84, 0x03, 0x39, 0x42, 0xE9, 0xFF, 0x6E,
5379 0x29, 0x73, 0xBB, 0x7B, 0x2D, 0x8B, 0x0E, 0x94,
5380 0xAD, 0x1E, 0xE8, 0x21, 0x58, 0x10, 0x8F, 0xBC,
5381 0x86, 0x64, 0x51, 0x7A, 0x5A, 0x46, 0x7F, 0xB9,
5382 0x63, 0x01, 0x4B, 0xD5, 0xDC, 0xC2, 0xB4, 0xFB,
5383 0x08, 0x7C, 0x23, 0x03, 0x9D, 0x11, 0x92, 0x0D,
5384 0xBE, 0x22, 0xFD, 0x9F, 0x16, 0xB4, 0xD8, 0x9E,
5385 0x23, 0x22, 0x5C, 0xD4, 0x55, 0xAD, 0xBA, 0xF3,
5386 0x2E, 0xF4, 0x3F, 0x18, 0x58, 0x64, 0xA3, 0x6D,
5387 0x63, 0x03, 0x09, 0xD6, 0x85, 0x3F, 0x77, 0x14,
5388 0xB3, 0x9A, 0xAE, 0x1E, 0xBE, 0xE3, 0x93, 0x8F,
5389 0x87, 0xC2, 0x70, 0x7E, 0x17, 0x8C, 0x73, 0x9F,
5390 0x9F, 0x02, 0x81, 0x81, 0x00, 0x96, 0x90, 0xBE,
5391 0xD1, 0x4B, 0x2A, 0xFA, 0xA2, 0x6D, 0x98, 0x6D,
5392 0x59, 0x22, 0x31, 0xEE, 0x27, 0xD7, 0x1D, 0x49,
5393 0x06, 0x5B, 0xD2, 0xBA, 0x1F, 0x78, 0x15, 0x7E,
5394 0x20, 0x22, 0x98, 0x81, 0xFD, 0x9D, 0x23, 0x22,
5395 0x7D, 0x0F, 0x84, 0x79, 0xEA, 0xEF, 0xA9, 0x22,
5396 0xFD, 0x75, 0xD5, 0xB1, 0x6B, 0x1A, 0x56, 0x1F,
5397 0xA6, 0x68, 0x0B, 0x04, 0x0C, 0xA0, 0xBD, 0xCE,
5398 0x65, 0x0B, 0x23, 0xB9, 0x17, 0xA4, 0xB1, 0xBB,
5399 0x79, 0x83, 0xA7, 0x4F, 0xAD, 0x70, 0xE1, 0xC3,
5400 0x05, 0xCB, 0xEC, 0x2B, 0xFF, 0x1A, 0x85, 0xA7,
5401 0x26, 0xA1, 0xD9, 0x02, 0x60, 0xE4, 0xF1, 0x08,
5402 0x4F, 0x51, 0x82, 0x34, 0xDC, 0xD3, 0xFE, 0x77,
5403 0x0B, 0x95, 0x20, 0x21, 0x5B, 0xD5, 0x43, 0xBB,
5404 0x6A, 0x41, 0x17, 0x71, 0x87, 0x54, 0x67, 0x6A,
5405 0x34, 0x17, 0x16, 0x66, 0xA7, 0x9F, 0x26, 0xE7,
5406 0x9C, 0x14, 0x9C, 0x5A, 0xA1, 0x02, 0x81, 0x81,
5407 0x00, 0xA0, 0xC9, 0x85, 0xA0, 0xA0, 0xA7, 0x91,
5408 0xA6, 0x59, 0xF9, 0x97, 0x31, 0x13, 0x4C, 0x44,
5409 0xF3, 0x7B, 0x2E, 0x52, 0x0A, 0x2C, 0xEA, 0x35,
5410 0x80, 0x0A, 0xD2, 0x72, 0x41, 0xED, 0x36, 0x0D,
5411 0xFD, 0xE6, 0xE8, 0xCA, 0x61, 0x4F, 0x12, 0x04,
5412 0x7F, 0xD0, 0x8B, 0x76, 0xAC, 0x4D, 0x13, 0xC0,
5413 0x56, 0xA0, 0x69, 0x9E, 0x2F, 0x98, 0xA1, 0xCA,
5414 0xC9, 0x10, 0x11, 0x29, 0x4D, 0x71, 0x20, 0x8F,
5415 0x4A, 0xBA, 0xB3, 0x3B, 0xA8, 0x7A, 0xA0, 0x51,
5416 0x7F, 0x41, 0x5B, 0xAC, 0xA8, 0x8D, 0x6B, 0xAC,
5417 0x00, 0x60, 0x88, 0xFA, 0x60, 0x1D, 0x34, 0x94,
5418 0x17, 0xE1, 0xF0, 0xC9, 0xB2, 0x3A, 0xFF, 0xA4,
5419 0xD4, 0x96, 0x61, 0x8D, 0xBC, 0x02, 0x49, 0x86,
5420 0xED, 0x69, 0x0B, 0xBB, 0x7B, 0x02, 0x57, 0x68,
5421 0xFF, 0x9D, 0xF8, 0xAC, 0x15, 0x41, 0x6F, 0x48,
5422 0x9F, 0x81, 0x29, 0xC3, 0x23, 0x41, 0xA8, 0xB4,
5425 struct byte_string key
= {0};
5427 key
.size
= ARRAY_LENGTH(value
);
5429 struct key_value kv
= {0};
5430 kv
.key_material
= &key
;
5432 struct key_block kb
= {0};
5433 kb
.key_format_type
= KMIP_KEYFORMAT_PKCS1
;
5435 kb
.key_value_type
= KMIP_TYPE_STRUCTURE
;
5436 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
5437 kb
.cryptographic_length
= 2048;
5439 struct private_key expected
= {0};
5440 expected
.key_block
= &kb
;
5442 struct private_key observed
= {0};
5444 int result
= kmip_decode_private_key(&ctx
, &observed
);
5445 result
= report_decoding_test_result(
5448 kmip_compare_private_key(&expected
, &observed
),
5451 kmip_free_private_key(&ctx
, &observed
);
5457 test_encode_key_wrapping_specification(TestTracker
*tracker
)
5459 TRACK_TEST(tracker
);
5461 uint8 expected
[136] = {
5462 0x42, 0x00, 0x47, 0x01, 0x00, 0x00, 0x00, 0x80,
5463 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
5464 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
5465 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
5466 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
5467 0x66, 0x34, 0x62, 0x32, 0x62, 0x34, 0x63, 0x33,
5468 0x2D, 0x34, 0x63, 0x31, 0x39, 0x2D, 0x34, 0x65,
5469 0x63, 0x66, 0x2D, 0x38, 0x32, 0x37, 0x61, 0x2D,
5470 0x30, 0x31, 0x31, 0x63, 0x61, 0x36, 0x30, 0x35,
5471 0x37, 0x64, 0x33, 0x65, 0x00, 0x00, 0x00, 0x00,
5472 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
5473 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
5474 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00,
5475 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
5476 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5477 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
5478 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B
5481 uint8 observed
[136] = {0};
5482 struct kmip ctx
= {0};
5483 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
5485 struct text_string uuid
= {0};
5486 uuid
.value
= "f4b2b4c3-4c19-4ecf-827a-011ca6057d3e";
5489 struct cryptographic_parameters cp
= {0};
5490 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
5492 struct encryption_key_information eki
= {0};
5493 eki
.unique_identifier
= &uuid
;
5494 eki
.cryptographic_parameters
= &cp
;
5496 struct text_string attribute_name
= {0};
5497 attribute_name
.value
= "Cryptographic Usage Mask";
5498 attribute_name
.size
= 24;
5500 struct key_wrapping_specification kws
= {0};
5501 kws
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
5502 kws
.encryption_key_info
= &eki
;
5503 kws
.attribute_names
= &attribute_name
;
5504 kws
.attribute_name_count
= 1;
5506 int result
= kmip_encode_key_wrapping_specification(&ctx
, &kws
);
5507 result
= report_encoding_test_result(
5519 test_decode_key_wrapping_specification(TestTracker
*tracker
)
5521 TRACK_TEST(tracker
);
5523 uint8 encoding
[136] = {
5524 0x42, 0x00, 0x47, 0x01, 0x00, 0x00, 0x00, 0x80,
5525 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
5526 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
5527 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
5528 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
5529 0x66, 0x34, 0x62, 0x32, 0x62, 0x34, 0x63, 0x33,
5530 0x2D, 0x34, 0x63, 0x31, 0x39, 0x2D, 0x34, 0x65,
5531 0x63, 0x66, 0x2D, 0x38, 0x32, 0x37, 0x61, 0x2D,
5532 0x30, 0x31, 0x31, 0x63, 0x61, 0x36, 0x30, 0x35,
5533 0x37, 0x64, 0x33, 0x65, 0x00, 0x00, 0x00, 0x00,
5534 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
5535 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
5536 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00,
5537 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
5538 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5539 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
5540 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B
5543 struct kmip ctx
= {0};
5544 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
5546 struct text_string uuid
= {0};
5547 uuid
.value
= "f4b2b4c3-4c19-4ecf-827a-011ca6057d3e";
5550 struct cryptographic_parameters cp
= {0};
5551 kmip_init_cryptographic_parameters(&cp
);
5553 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
5555 struct encryption_key_information eki
= {0};
5556 eki
.unique_identifier
= &uuid
;
5557 eki
.cryptographic_parameters
= &cp
;
5559 struct text_string attribute_name
= {0};
5560 attribute_name
.value
= "Cryptographic Usage Mask";
5561 attribute_name
.size
= 24;
5563 struct key_wrapping_specification expected
= {0};
5564 expected
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
5565 expected
.encryption_key_info
= &eki
;
5566 expected
.attribute_names
= &attribute_name
;
5567 expected
.attribute_name_count
= 1;
5569 struct key_wrapping_specification observed
= {0};
5571 int result
= kmip_decode_key_wrapping_specification(&ctx
, &observed
);
5572 result
= report_decoding_test_result(
5575 kmip_compare_key_wrapping_specification(&expected
, &observed
),
5578 kmip_free_key_wrapping_specification(&ctx
, &observed
);
5584 test_encode_create_request_payload(TestTracker
*tracker
)
5586 TRACK_TEST(tracker
);
5588 /* This encoding matches the following set of values:
5590 * Object Type - Symmetric Key
5591 * Template Attribute
5593 * Attribute Name - Cryptographic Algorithm
5594 * Attribute Value - AES
5596 * Attribute Name - Cryptographic Length
5597 * Attribute Value - 128
5599 * Attribute Name - Cryptographic Usage Mask
5600 * Attribute Value - Encrypt | Decrypt
5602 uint8 expected
[200] = {
5603 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0xC0,
5604 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
5605 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
5606 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0xA8,
5607 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
5608 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
5609 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5610 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
5611 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
5612 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
5613 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
5614 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
5615 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
5616 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5617 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
5618 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
5619 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
5620 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
5621 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
5622 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
5623 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5624 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
5625 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
5626 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
5627 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
5630 uint8 observed
[200] = {0};
5631 struct kmip ctx
= {0};
5632 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
5634 struct attribute a
[3] = {0};
5635 for(int i
= 0; i
< 3; i
++)
5637 kmip_init_attribute(&a
[i
]);
5640 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
5641 a
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
5642 a
[0].value
= &algorithm
;
5645 a
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
5646 a
[1].value
= &length
;
5648 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
5649 a
[2].type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
5652 struct template_attribute ta
= {0};
5654 ta
.attribute_count
= ARRAY_LENGTH(a
);
5656 struct create_request_payload crp
= {0};
5657 crp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
5658 crp
.template_attribute
= &ta
;
5660 int result
= kmip_encode_create_request_payload(&ctx
, &crp
);
5661 result
= report_encoding_test_result(
5673 test_encode_create_request_payload_kmip_2_0(TestTracker
*tracker
)
5675 TRACK_TEST(tracker
);
5677 /* This encoding matches the following set of values:
5679 * Object Type - Symmetric Key
5681 * Cryptographic Algorithm - AES
5682 * Cryptographic Length - 128
5683 * Cryptographic Usage Mask - Encrypt | Decrypt
5684 * Protection Storage Masks
5685 * Protection Storage Mask - Software | On System
5686 * Protection Storage Mask - Off System | Off Premises
5688 uint8 expected
[120] = {
5689 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x70,
5690 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
5691 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
5692 0x42, 0x01, 0x25, 0x01, 0x00, 0x00, 0x00, 0x30,
5693 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
5694 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
5695 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
5696 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
5697 0x42, 0x00, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x04,
5698 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
5699 0x42, 0x01, 0x5F, 0x01, 0x00, 0x00, 0x00, 0x20,
5700 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
5701 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
5702 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
5703 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00
5706 uint8 observed
[120] = {0};
5707 struct kmip ctx
= {0};
5708 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
5710 Attribute a
[3] = {0};
5711 for(int i
= 0; i
< 3; i
++)
5713 kmip_init_attribute(&a
[i
]);
5716 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
5717 a
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
5718 a
[0].value
= &algorithm
;
5721 a
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
5722 a
[1].value
= &length
;
5724 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
5725 a
[2].type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
5728 Attributes attributes
= {0};
5729 LinkedList list
= {0};
5730 LinkedListItem item_1
, item_2
, item_3
= {0};
5731 item_1
.data
= &a
[0];
5732 item_2
.data
= &a
[1];
5733 item_3
.data
= &a
[2];
5734 kmip_linked_list_enqueue(&list
, &item_1
);
5735 kmip_linked_list_enqueue(&list
, &item_2
);
5736 kmip_linked_list_enqueue(&list
, &item_3
);
5737 attributes
.attribute_list
= &list
;
5739 ProtectionStorageMasks psm
= {0};
5740 LinkedList masks
= {0};
5741 LinkedListItem mask_1
, mask_2
= {0};
5742 int32 m1
= KMIP_PROTECT_SOFTWARE
| KMIP_PROTECT_ON_SYSTEM
;
5743 int32 m2
= KMIP_PROTECT_OFF_SYSTEM
| KMIP_PROTECT_OFF_PREMISES
;
5746 kmip_linked_list_enqueue(&masks
, &mask_1
);
5747 kmip_linked_list_enqueue(&masks
, &mask_2
);
5750 CreateRequestPayload payload
= {0};
5751 payload
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
5752 payload
.attributes
= &attributes
;
5753 payload
.protection_storage_masks
= &psm
;
5755 int result
= kmip_encode_create_request_payload(&ctx
, &payload
);
5756 result
= report_encoding_test_result(
5768 test_decode_create_request_payload(TestTracker
*tracker
)
5770 TRACK_TEST(tracker
);
5772 uint8 encoding
[200] = {
5773 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0xC0,
5774 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
5775 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
5776 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0xA8,
5777 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
5778 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
5779 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5780 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
5781 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
5782 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
5783 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
5784 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
5785 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
5786 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5787 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
5788 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
5789 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
5790 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
5791 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
5792 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
5793 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
5794 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
5795 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
5796 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
5797 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
5800 struct kmip ctx
= {0};
5801 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
5803 struct attribute a
[3] = {0};
5804 for(int i
= 0; i
< 3; i
++)
5806 kmip_init_attribute(&a
[i
]);
5809 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
5810 a
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
5811 a
[0].value
= &algorithm
;
5814 a
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
5815 a
[1].value
= &length
;
5817 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
5818 a
[2].type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
5821 struct template_attribute ta
= {0};
5823 ta
.attribute_count
= ARRAY_LENGTH(a
);
5825 struct create_request_payload expected
= {0};
5826 expected
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
5827 expected
.template_attribute
= &ta
;
5829 struct create_request_payload observed
= {0};
5831 int result
= kmip_decode_create_request_payload(&ctx
, &observed
);
5832 result
= report_decoding_test_result(
5835 kmip_compare_create_request_payload(&expected
, &observed
),
5838 kmip_free_create_request_payload(&ctx
, &observed
);
5844 test_decode_create_request_payload_kmip_2_0(TestTracker
*tracker
)
5846 TRACK_TEST(tracker
);
5848 /* This encoding matches the following set of values:
5850 * Object Type - Symmetric Key
5852 * Cryptographic Algorithm - AES
5853 * Cryptographic Length - 128
5854 * Cryptographic Usage Mask - Encrypt | Decrypt
5855 * Protection Storage Masks
5856 * Protection Storage Mask - Software | On System
5857 * Protection Storage Mask - Off System | Off Premises
5859 uint8 encoding
[120] = {
5860 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x70,
5861 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
5862 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
5863 0x42, 0x01, 0x25, 0x01, 0x00, 0x00, 0x00, 0x30,
5864 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
5865 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
5866 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
5867 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
5868 0x42, 0x00, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x04,
5869 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
5870 0x42, 0x01, 0x5F, 0x01, 0x00, 0x00, 0x00, 0x20,
5871 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
5872 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00,
5873 0x42, 0x01, 0x5E, 0x02, 0x00, 0x00, 0x00, 0x04,
5874 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00
5877 struct kmip ctx
= {0};
5878 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
5880 Attribute a
[3] = {0};
5881 for(int i
= 0; i
< 3; i
++)
5883 kmip_init_attribute(&a
[i
]);
5886 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
5887 a
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
5888 a
[0].value
= &algorithm
;
5891 a
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
5892 a
[1].value
= &length
;
5894 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
5895 a
[2].type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
5898 Attributes attributes
= {0};
5899 LinkedList list
= {0};
5900 LinkedListItem item_1
, item_2
, item_3
= {0};
5901 item_1
.data
= &a
[0];
5902 item_2
.data
= &a
[1];
5903 item_3
.data
= &a
[2];
5904 kmip_linked_list_enqueue(&list
, &item_1
);
5905 kmip_linked_list_enqueue(&list
, &item_2
);
5906 kmip_linked_list_enqueue(&list
, &item_3
);
5907 attributes
.attribute_list
= &list
;
5909 ProtectionStorageMasks psm
= {0};
5910 LinkedList masks
= {0};
5911 LinkedListItem mask_1
, mask_2
= {0};
5912 int32 m1
= KMIP_PROTECT_SOFTWARE
| KMIP_PROTECT_ON_SYSTEM
;
5913 int32 m2
= KMIP_PROTECT_OFF_SYSTEM
| KMIP_PROTECT_OFF_PREMISES
;
5916 kmip_linked_list_enqueue(&masks
, &mask_1
);
5917 kmip_linked_list_enqueue(&masks
, &mask_2
);
5920 CreateRequestPayload expected
= {0};
5921 expected
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
5922 expected
.attributes
= &attributes
;
5923 expected
.protection_storage_masks
= &psm
;
5925 CreateRequestPayload observed
= {0};
5927 int result
= kmip_decode_create_request_payload(&ctx
, &observed
);
5928 result
= report_decoding_test_result(
5931 kmip_compare_create_request_payload(&expected
, &observed
),
5934 kmip_free_create_request_payload(&ctx
, &observed
);
5940 test_encode_create_response_payload(TestTracker
*tracker
)
5942 TRACK_TEST(tracker
);
5944 uint8 expected
[72] = {
5945 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x40,
5946 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
5947 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
5948 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
5949 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
5950 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
5951 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
5952 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
5953 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
5956 uint8 observed
[72] = {0};
5957 struct kmip ctx
= {0};
5958 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
5960 struct text_string uuid
= {0};
5961 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
5964 struct create_response_payload crp
= {0};
5965 crp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
5966 crp
.unique_identifier
= &uuid
;
5968 int result
= kmip_encode_create_response_payload(&ctx
, &crp
);
5969 result
= report_encoding_test_result(
5981 test_decode_create_response_payload(TestTracker
*tracker
)
5983 TRACK_TEST(tracker
);
5985 uint8 encoding
[72] = {
5986 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x40,
5987 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
5988 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
5989 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
5990 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
5991 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
5992 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
5993 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
5994 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
5997 struct kmip ctx
= {0};
5998 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6000 struct text_string uuid
= {0};
6001 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
6004 struct create_response_payload expected
= {0};
6005 expected
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
6006 expected
.unique_identifier
= &uuid
;
6008 struct create_response_payload observed
= {0};
6010 int result
= kmip_decode_create_response_payload(&ctx
, &observed
);
6011 result
= report_decoding_test_result(
6014 kmip_compare_create_response_payload(&expected
, &observed
),
6017 kmip_free_create_response_payload(&ctx
, &observed
);
6023 test_encode_create_response_payload_with_template_attribute(TestTracker
*tracker
)
6025 TRACK_TEST(tracker
);
6027 uint8 expected
[136] = {
6028 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x80,
6029 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
6030 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
6031 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6032 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
6033 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
6034 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
6035 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
6036 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00,
6037 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x38,
6038 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
6039 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
6040 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
6041 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
6042 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
6043 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
6044 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
6047 uint8 observed
[136] = {0};
6048 struct kmip ctx
= {0};
6049 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6051 struct text_string uuid
= {0};
6052 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
6055 struct attribute a
= {0};
6056 kmip_init_attribute(&a
);
6058 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
6059 a
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
6060 a
.value
= &algorithm
;
6062 struct template_attribute ta
= {0};
6064 ta
.attribute_count
= 1;
6066 struct create_response_payload crp
= {0};
6067 crp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
6068 crp
.unique_identifier
= &uuid
;
6069 crp
.template_attribute
= &ta
;
6071 int result
= kmip_encode_create_response_payload(&ctx
, &crp
);
6072 result
= report_encoding_test_result(
6084 test_decode_create_response_payload_with_template_attribute(TestTracker
*tracker
)
6086 TRACK_TEST(tracker
);
6088 uint8 encoding
[136] = {
6089 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x80,
6090 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
6091 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
6092 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6093 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
6094 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
6095 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
6096 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
6097 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00,
6098 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0x38,
6099 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
6100 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
6101 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
6102 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
6103 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
6104 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
6105 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
6108 struct kmip ctx
= {0};
6109 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6111 struct text_string uuid
= {0};
6112 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
6115 struct attribute a
= {0};
6116 kmip_init_attribute(&a
);
6118 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
6119 a
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
6120 a
.value
= &algorithm
;
6122 struct template_attribute ta
= {0};
6124 ta
.attribute_count
= 1;
6126 struct create_response_payload expected
= {0};
6127 expected
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
6128 expected
.unique_identifier
= &uuid
;
6129 expected
.template_attribute
= &ta
;
6131 struct create_response_payload observed
= {0};
6133 int result
= kmip_decode_create_response_payload(&ctx
, &observed
);
6134 result
= report_decoding_test_result(
6137 kmip_compare_create_response_payload(&expected
, &observed
),
6140 kmip_free_create_response_payload(&ctx
, &observed
);
6146 test_encode_get_request_payload(TestTracker
*tracker
)
6148 TRACK_TEST(tracker
);
6150 uint8 expected
[56] = {
6151 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
6152 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6153 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
6154 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
6155 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
6156 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
6157 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
6160 uint8 observed
[56] = {0};
6161 struct kmip ctx
= {0};
6162 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6164 struct text_string uuid
= {0};
6165 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
6168 struct get_request_payload grp
= {0};
6169 grp
.unique_identifier
= &uuid
;
6171 int result
= kmip_encode_get_request_payload(&ctx
, &grp
);
6172 result
= report_encoding_test_result(
6184 test_decode_get_request_payload(TestTracker
*tracker
)
6186 TRACK_TEST(tracker
);
6188 uint8 encoding
[56] = {
6189 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
6190 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6191 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
6192 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
6193 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
6194 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
6195 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
6198 struct kmip ctx
= {0};
6199 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6201 struct text_string uuid
= {0};
6202 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
6205 struct get_request_payload expected
= {0};
6206 expected
.unique_identifier
= &uuid
;
6208 struct get_request_payload observed
= {0};
6210 int result
= kmip_decode_get_request_payload(&ctx
, &observed
);
6211 result
= report_decoding_test_result(
6214 kmip_compare_get_request_payload(&expected
, &observed
),
6217 kmip_free_get_request_payload(&ctx
, &observed
);
6223 test_encode_get_request_payload_with_format_compression(TestTracker
*tracker
)
6225 TRACK_TEST(tracker
);
6227 uint8 expected
[88] = {
6228 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x50,
6229 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6230 0x37, 0x63, 0x66, 0x35, 0x32, 0x30, 0x39, 0x62,
6231 0x2D, 0x36, 0x66, 0x66, 0x36, 0x2D, 0x34, 0x34,
6232 0x32, 0x36, 0x2D, 0x38, 0x39, 0x39, 0x65, 0x2D,
6233 0x32, 0x32, 0x62, 0x30, 0x36, 0x37, 0x38, 0x35,
6234 0x39, 0x33, 0x37, 0x32, 0x00, 0x00, 0x00, 0x00,
6235 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
6236 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
6237 0x42, 0x00, 0x41, 0x05, 0x00, 0x00, 0x00, 0x04,
6238 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
6241 uint8 observed
[88] = {0};
6242 struct kmip ctx
= {0};
6243 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6245 struct text_string uuid
= {0};
6246 uuid
.value
= "7cf5209b-6ff6-4426-899e-22b067859372";
6249 struct get_request_payload grp
= {0};
6250 grp
.unique_identifier
= &uuid
;
6251 grp
.key_format_type
= KMIP_KEYFORMAT_PKCS1
;
6252 grp
.key_compression_type
= KMIP_KEYCOMP_EC_PUB_UNCOMPRESSED
;
6254 int result
= kmip_encode_get_request_payload(&ctx
, &grp
);
6255 result
= report_encoding_test_result(
6267 test_encode_get_request_payload_with_wrapping_spec(TestTracker
*tracker
)
6269 TRACK_TEST(tracker
);
6271 uint8 expected
[160] = {
6272 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x98,
6273 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6274 0x62, 0x66, 0x66, 0x37, 0x33, 0x34, 0x37, 0x62,
6275 0x2D, 0x33, 0x61, 0x33, 0x39, 0x2D, 0x34, 0x63,
6276 0x63, 0x62, 0x2D, 0x38, 0x32, 0x33, 0x34, 0x2D,
6277 0x62, 0x61, 0x32, 0x35, 0x36, 0x30, 0x63, 0x61,
6278 0x31, 0x35, 0x39, 0x38, 0x00, 0x00, 0x00, 0x00,
6279 0x42, 0x00, 0x47, 0x01, 0x00, 0x00, 0x00, 0x60,
6280 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
6281 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6282 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
6283 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6284 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
6285 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
6286 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
6287 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
6288 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
6289 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
6290 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
6291 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00
6294 uint8 observed
[160] = {0};
6295 struct kmip ctx
= {0};
6296 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6298 struct text_string wrapping_uuid
= {0};
6299 wrapping_uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
6300 wrapping_uuid
.size
= 36;
6301 struct text_string uuid
= {0};
6302 uuid
.value
= "bff7347b-3a39-4ccb-8234-ba2560ca1598";
6305 struct cryptographic_parameters cp
= {0};
6306 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
6308 struct encryption_key_information eki
= {0};
6309 eki
.unique_identifier
= &wrapping_uuid
;
6310 eki
.cryptographic_parameters
= &cp
;
6312 struct key_wrapping_specification kws
= {0};
6313 kws
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
6314 kws
.encryption_key_info
= &eki
;
6316 struct get_request_payload grp
= {0};
6317 grp
.unique_identifier
= &uuid
;
6318 grp
.key_wrapping_spec
= &kws
;
6320 int result
= kmip_encode_get_request_payload(&ctx
, &grp
);
6321 result
= report_encoding_test_result(
6333 test_encode_get_response_payload(TestTracker
*tracker
)
6335 TRACK_TEST(tracker
);
6337 uint8 expected
[176] = {
6338 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0xA8,
6339 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
6340 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
6341 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6342 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
6343 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
6344 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
6345 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
6346 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00,
6347 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x60,
6348 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x58,
6349 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
6350 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6351 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x20,
6352 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x18,
6353 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
6354 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
6355 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
6356 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
6357 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
6358 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
6359 0x00, 0x00, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00
6362 uint8 observed
[176] = {0};
6363 struct kmip ctx
= {0};
6364 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6366 struct text_string uuid
= {0};
6367 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
6371 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
6372 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
6373 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
6375 struct byte_string v
= {0};
6377 v
.size
= ARRAY_LENGTH(value
);
6379 struct key_value kv
= {0};
6380 kv
.key_material
= &v
;
6382 struct key_block kb
= {0};
6383 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
6385 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_TRIPLE_DES
;
6386 kb
.cryptographic_length
= 168;
6388 struct symmetric_key key
= {0};
6389 key
.key_block
= &kb
;
6391 struct get_response_payload grp
= {0};
6392 grp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
6393 grp
.unique_identifier
= &uuid
;
6396 int result
= kmip_encode_get_response_payload(&ctx
, &grp
);
6397 result
= report_encoding_test_result(
6409 test_decode_get_response_payload(TestTracker
*tracker
)
6411 TRACK_TEST(tracker
);
6413 uint8 encoding
[176] = {
6414 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0xA8,
6415 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
6416 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
6417 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6418 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
6419 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
6420 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
6421 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
6422 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00,
6423 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x60,
6424 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x58,
6425 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
6426 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6427 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x20,
6428 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x18,
6429 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
6430 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
6431 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
6432 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
6433 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
6434 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
6435 0x00, 0x00, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00
6438 struct kmip ctx
= {0};
6439 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6441 struct text_string uuid
= {0};
6442 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
6446 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
6447 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
6448 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
6450 struct byte_string v
= {0};
6452 v
.size
= ARRAY_LENGTH(value
);
6454 struct key_value kv
= {0};
6455 kv
.key_material
= &v
;
6457 struct key_block kb
= {0};
6458 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
6460 kb
.key_value_type
= KMIP_TYPE_STRUCTURE
;
6461 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_TRIPLE_DES
;
6462 kb
.cryptographic_length
= 168;
6464 struct symmetric_key key
= {0};
6465 key
.key_block
= &kb
;
6467 struct get_response_payload expected
= {0};
6468 expected
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
6469 expected
.unique_identifier
= &uuid
;
6470 expected
.object
= &key
;
6472 struct get_response_payload observed
= {0};
6474 int result
= kmip_decode_get_response_payload(&ctx
, &observed
);
6475 result
= report_decoding_test_result(
6478 kmip_compare_get_response_payload(&expected
, &observed
),
6481 kmip_free_get_response_payload(&ctx
, &observed
);
6487 test_encode_destroy_request_payload(TestTracker
*tracker
)
6489 TRACK_TEST(tracker
);
6491 uint8 expected
[56] = {
6492 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
6493 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6494 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
6495 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
6496 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
6497 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
6498 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
6501 uint8 observed
[56] = {0};
6502 struct kmip ctx
= {0};
6503 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6505 struct text_string uuid
= {0};
6506 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
6509 struct destroy_request_payload drp
= {0};
6510 drp
.unique_identifier
= &uuid
;
6512 int result
= kmip_encode_destroy_request_payload(&ctx
, &drp
);
6513 result
= report_encoding_test_result(
6525 test_decode_destroy_request_payload(TestTracker
*tracker
)
6527 TRACK_TEST(tracker
);
6529 uint8 encoding
[56] = {
6530 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
6531 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6532 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
6533 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
6534 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
6535 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
6536 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
6539 struct kmip ctx
= {0};
6540 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6542 struct text_string uuid
= {0};
6543 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
6546 struct destroy_request_payload expected
= {0};
6547 expected
.unique_identifier
= &uuid
;
6549 struct destroy_request_payload observed
= {0};
6551 int result
= kmip_decode_destroy_request_payload(&ctx
, &observed
);
6552 result
= report_decoding_test_result(
6555 kmip_compare_destroy_request_payload(&expected
, &observed
),
6558 kmip_free_destroy_request_payload(&ctx
, &observed
);
6564 test_encode_destroy_response_payload(TestTracker
*tracker
)
6566 TRACK_TEST(tracker
);
6568 uint8 expected
[56] = {
6569 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x30,
6570 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6571 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
6572 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
6573 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
6574 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
6575 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
6578 uint8 observed
[56] = {0};
6579 struct kmip ctx
= {0};
6580 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6582 struct text_string uuid
= {0};
6583 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
6586 struct destroy_response_payload drp
= {0};
6587 drp
.unique_identifier
= &uuid
;
6589 int result
= kmip_encode_destroy_response_payload(&ctx
, &drp
);
6590 result
= report_encoding_test_result(
6602 test_decode_destroy_response_payload(TestTracker
*tracker
)
6604 TRACK_TEST(tracker
);
6606 uint8 encoding
[56] = {
6607 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x30,
6608 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
6609 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
6610 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
6611 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
6612 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
6613 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
6616 struct kmip ctx
= {0};
6617 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6619 struct text_string uuid
= {0};
6620 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
6623 struct destroy_response_payload expected
= {0};
6624 expected
.unique_identifier
= &uuid
;
6626 struct destroy_response_payload observed
= {0};
6628 int result
= kmip_decode_destroy_response_payload(&ctx
, &observed
);
6629 result
= report_decoding_test_result(
6632 kmip_compare_destroy_response_payload(&expected
, &observed
),
6635 kmip_free_destroy_response_payload(&ctx
, &observed
);
6641 test_encode_username_password_credential(TestTracker
*tracker
)
6643 TRACK_TEST(tracker
);
6645 uint8 expected
[48] = {
6646 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x28,
6647 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x04,
6648 0x46, 0x72, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00,
6649 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x09,
6650 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64,
6651 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6654 uint8 observed
[48] = {0};
6655 struct kmip ctx
= {0};
6656 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6658 struct text_string username
= {0};
6659 username
.value
= "Fred";
6661 struct text_string password
= {0};
6662 password
.value
= "password1";
6665 struct username_password_credential upc
= {0};
6666 upc
.username
= &username
;
6667 upc
.password
= &password
;
6669 int result
= kmip_encode_username_password_credential(&ctx
, &upc
);
6670 result
= report_encoding_test_result(
6682 test_decode_username_password_credential(TestTracker
*tracker
)
6684 TRACK_TEST(tracker
);
6686 uint8 encoding
[48] = {
6687 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x28,
6688 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x04,
6689 0x46, 0x72, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00,
6690 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x09,
6691 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64,
6692 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6695 struct kmip ctx
= {0};
6696 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6698 struct text_string username
= {0};
6699 username
.value
= "Fred";
6701 struct text_string password
= {0};
6702 password
.value
= "password1";
6705 struct username_password_credential expected
= {0};
6706 expected
.username
= &username
;
6707 expected
.password
= &password
;
6709 struct username_password_credential observed
= {0};
6711 int result
= kmip_decode_username_password_credential(&ctx
, &observed
);
6712 result
= report_decoding_test_result(
6715 kmip_compare_username_password_credential(&expected
, &observed
),
6718 kmip_free_username_password_credential(&ctx
, &observed
);
6724 test_encode_credential_username_password_credential(TestTracker
*tracker
)
6726 TRACK_TEST(tracker
);
6728 uint8 expected
[64] = {
6729 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x38,
6730 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
6731 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6732 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
6733 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x06,
6734 0x42, 0x61, 0x72, 0x6E, 0x65, 0x79, 0x00, 0x00,
6735 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x07,
6736 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x00
6739 uint8 observed
[64] = {0};
6740 struct kmip ctx
= {0};
6741 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6743 struct text_string username
= {0};
6744 username
.value
= "Barney";
6746 struct text_string password
= {0};
6747 password
.value
= "secret2";
6750 struct username_password_credential upc
= {0};
6751 upc
.username
= &username
;
6752 upc
.password
= &password
;
6754 struct credential c
= {0};
6755 c
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
6756 c
.credential_value
= &upc
;
6758 int result
= kmip_encode_credential(&ctx
, &c
);
6759 result
= report_encoding_test_result(
6771 test_decode_credential_username_password_credential(TestTracker
*tracker
)
6773 TRACK_TEST(tracker
);
6775 uint8 encoding
[64] = {
6776 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x38,
6777 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
6778 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6779 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
6780 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x06,
6781 0x42, 0x61, 0x72, 0x6E, 0x65, 0x79, 0x00, 0x00,
6782 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x07,
6783 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x00
6786 struct kmip ctx
= {0};
6787 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6789 struct text_string username
= {0};
6790 username
.value
= "Barney";
6792 struct text_string password
= {0};
6793 password
.value
= "secret2";
6796 struct username_password_credential upc
= {0};
6797 upc
.username
= &username
;
6798 upc
.password
= &password
;
6800 struct credential expected
= {0};
6801 expected
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
6802 expected
.credential_value
= &upc
;
6804 struct credential observed
= {0};
6806 int result
= kmip_decode_credential(&ctx
, &observed
);
6807 result
= report_decoding_test_result(
6810 kmip_compare_credential(&expected
, &observed
),
6813 kmip_free_credential(&ctx
, &observed
);
6819 test_encode_authentication_username_password_credential(TestTracker
*tracker
)
6821 TRACK_TEST(tracker
);
6823 uint8 expected
[80] = {
6824 0x42, 0x00, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x48,
6825 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x40,
6826 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
6827 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6828 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x28,
6829 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x04,
6830 0x46, 0x72, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00,
6831 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x09,
6832 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64,
6833 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6836 uint8 observed
[80] = {0};
6837 struct kmip ctx
= {0};
6838 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6840 struct text_string username
= {0};
6841 username
.value
= "Fred";
6843 struct text_string password
= {0};
6844 password
.value
= "password1";
6847 struct username_password_credential upc
= {0};
6848 upc
.username
= &username
;
6849 upc
.password
= &password
;
6851 struct credential c
= {0};
6852 c
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
6853 c
.credential_value
= &upc
;
6855 struct authentication a
= {0};
6858 int result
= kmip_encode_authentication(&ctx
, &a
);
6859 result
= report_encoding_test_result(
6871 test_decode_authentication_username_password_credential(TestTracker
*tracker
)
6873 TRACK_TEST(tracker
);
6875 uint8 encoding
[80] = {
6876 0x42, 0x00, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x48,
6877 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x40,
6878 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
6879 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6880 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x28,
6881 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x04,
6882 0x46, 0x72, 0x65, 0x64, 0x00, 0x00, 0x00, 0x00,
6883 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x09,
6884 0x70, 0x61, 0x73, 0x73, 0x77, 0x6F, 0x72, 0x64,
6885 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
6888 struct kmip ctx
= {0};
6889 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
6891 struct text_string username
= {0};
6892 username
.value
= "Fred";
6894 struct text_string password
= {0};
6895 password
.value
= "password1";
6898 struct username_password_credential upc
= {0};
6899 upc
.username
= &username
;
6900 upc
.password
= &password
;
6902 struct credential c
= {0};
6903 c
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
6904 c
.credential_value
= &upc
;
6906 struct authentication expected
= {0};
6907 expected
.credential
= &c
;
6909 struct authentication observed
= {0};
6911 int result
= kmip_decode_authentication(&ctx
, &observed
);
6912 result
= report_decoding_test_result(
6915 kmip_compare_authentication(&expected
, &observed
),
6918 kmip_free_authentication(&ctx
, &observed
);
6924 test_encode_request_header(TestTracker
*tracker
)
6926 TRACK_TEST(tracker
);
6928 uint8 expected
[168] = {
6929 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0xA0,
6930 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
6931 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
6932 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6933 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
6934 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
6935 0x42, 0x00, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x40,
6936 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x38,
6937 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
6938 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6939 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
6940 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x06,
6941 0x42, 0x61, 0x72, 0x6E, 0x65, 0x79, 0x00, 0x00,
6942 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x07,
6943 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x00,
6944 0x42, 0x00, 0x0E, 0x05, 0x00, 0x00, 0x00, 0x04,
6945 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
6946 0x42, 0x00, 0x10, 0x06, 0x00, 0x00, 0x00, 0x08,
6947 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
6948 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
6949 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
6952 uint8 observed
[168] = {0};
6953 struct kmip ctx
= {0};
6954 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
6956 struct protocol_version pv
= {0};
6960 struct text_string username
= {0};
6961 username
.value
= "Barney";
6963 struct text_string password
= {0};
6964 password
.value
= "secret2";
6967 struct username_password_credential upc
= {0};
6968 upc
.username
= &username
;
6969 upc
.password
= &password
;
6971 struct credential c
= {0};
6972 c
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
6973 c
.credential_value
= &upc
;
6975 struct authentication a
= {0};
6978 struct request_header rh
= {0};
6979 kmip_init_request_header(&rh
);
6981 rh
.protocol_version
= &pv
;
6982 rh
.authentication
= &a
;
6983 rh
.batch_error_continuation_option
= KMIP_BATCH_CONTINUE
;
6984 rh
.batch_order_option
= KMIP_TRUE
;
6987 int result
= kmip_encode_request_header(&ctx
, &rh
);
6988 result
= report_encoding_test_result(
7000 test_decode_request_header(TestTracker
*tracker
)
7002 TRACK_TEST(tracker
);
7004 uint8 encoding
[168] = {
7005 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0xA0,
7006 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
7007 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
7008 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7009 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
7010 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7011 0x42, 0x00, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x40,
7012 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x38,
7013 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
7014 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7015 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
7016 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x06,
7017 0x42, 0x61, 0x72, 0x6E, 0x65, 0x79, 0x00, 0x00,
7018 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x07,
7019 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x00,
7020 0x42, 0x00, 0x0E, 0x05, 0x00, 0x00, 0x00, 0x04,
7021 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7022 0x42, 0x00, 0x10, 0x06, 0x00, 0x00, 0x00, 0x08,
7023 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
7024 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
7025 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
7028 struct kmip ctx
= {0};
7029 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
7031 struct protocol_version pv
= {0};
7035 struct text_string username
= {0};
7036 username
.value
= "Barney";
7038 struct text_string password
= {0};
7039 password
.value
= "secret2";
7042 struct username_password_credential upc
= {0};
7043 upc
.username
= &username
;
7044 upc
.password
= &password
;
7046 struct credential c
= {0};
7047 c
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
7048 c
.credential_value
= &upc
;
7050 struct authentication a
= {0};
7053 struct request_header expected
= {0};
7054 kmip_init_request_header(&expected
);
7056 expected
.protocol_version
= &pv
;
7057 expected
.authentication
= &a
;
7058 expected
.batch_error_continuation_option
= KMIP_BATCH_CONTINUE
;
7059 expected
.batch_order_option
= KMIP_TRUE
;
7060 expected
.batch_count
= 2;
7062 struct request_header observed
= {0};
7063 kmip_init_request_header(&observed
);
7065 int result
= kmip_decode_request_header(&ctx
, &observed
);
7066 result
= report_decoding_test_result(
7069 kmip_compare_request_header(&expected
, &observed
),
7072 kmip_free_request_header(&ctx
, &observed
);
7078 test_encode_response_header(TestTracker
*tracker
)
7080 TRACK_TEST(tracker
);
7082 uint8 expected
[80] = {
7083 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x48,
7084 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
7085 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
7086 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7087 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
7088 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7089 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
7090 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
7091 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
7092 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
7095 uint8 observed
[80] = {0};
7096 struct kmip ctx
= {0};
7097 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
7099 struct protocol_version pv
= {0};
7103 struct response_header rh
= {0};
7104 kmip_init_response_header(&rh
);
7106 rh
.protocol_version
= &pv
;
7107 rh
.time_stamp
= 1335514341;
7110 int result
= kmip_encode_response_header(&ctx
, &rh
);
7111 result
= report_encoding_test_result(
7123 test_decode_response_header(TestTracker
*tracker
)
7125 TRACK_TEST(tracker
);
7127 uint8 encoding
[80] = {
7128 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x48,
7129 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
7130 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
7131 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7132 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
7133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7134 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
7135 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
7136 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
7137 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
7140 struct kmip ctx
= {0};
7141 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
7143 struct protocol_version pv
= {0};
7147 struct response_header expected
= {0};
7148 kmip_init_response_header(&expected
);
7150 expected
.protocol_version
= &pv
;
7151 expected
.time_stamp
= 1335514341;
7152 expected
.batch_count
= 1;
7154 struct response_header observed
= {0};
7155 kmip_init_response_header(&observed
);
7157 int result
= kmip_decode_response_header(&ctx
, &observed
);
7158 result
= report_decoding_test_result(
7161 kmip_compare_response_header(&expected
, &observed
),
7164 kmip_free_response_header(&ctx
, &observed
);
7170 test_encode_request_batch_item_get_payload(TestTracker
*tracker
)
7172 TRACK_TEST(tracker
);
7174 uint8 expected
[80] = {
7175 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x48,
7176 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7177 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7178 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
7179 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7180 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7181 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7182 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7183 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7184 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
7187 uint8 observed
[80] = {0};
7188 struct kmip ctx
= {0};
7189 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
7191 struct text_string uuid
= {0};
7192 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7195 struct get_request_payload grp
= {0};
7196 grp
.unique_identifier
= &uuid
;
7198 struct request_batch_item rbi
= {0};
7199 kmip_init_request_batch_item(&rbi
);
7200 rbi
.operation
= KMIP_OP_GET
;
7201 rbi
.request_payload
= &grp
;
7203 int result
= kmip_encode_request_batch_item(&ctx
, &rbi
);
7204 result
= report_encoding_test_result(
7216 test_encode_request_batch_item_get_payload_kmip_2_0(TestTracker
*tracker
)
7218 TRACK_TEST(tracker
);
7220 /* This encoding matches the following set of values:
7225 * Unique Identifier - 49a1ca88-6bea-4fb2-b450-7e58802c3038
7227 uint8 expected
[96] = {
7228 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x58,
7229 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7230 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7231 0x42, 0x01, 0x54, 0x06, 0x00, 0x00, 0x00, 0x08,
7232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7233 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
7234 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7235 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7236 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7237 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7238 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7239 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
7242 uint8 observed
[96] = {0};
7244 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
7246 TextString uuid
= {0};
7247 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7250 GetRequestPayload grp
= {0};
7251 grp
.unique_identifier
= &uuid
;
7253 RequestBatchItem rbi
= {0};
7254 kmip_init_request_batch_item(&rbi
);
7255 rbi
.operation
= KMIP_OP_GET
;
7256 rbi
.ephemeral
= KMIP_FALSE
;
7257 rbi
.request_payload
= &grp
;
7259 int result
= kmip_encode_request_batch_item(&ctx
, &rbi
);
7260 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
7266 test_decode_request_batch_item_get_payload(TestTracker
*tracker
)
7268 TRACK_TEST(tracker
);
7270 uint8 encoding
[80] = {
7271 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x48,
7272 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7273 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7274 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
7275 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7276 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7277 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7278 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7279 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7280 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
7283 struct kmip ctx
= {0};
7284 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
7286 struct text_string uuid
= {0};
7287 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7290 struct get_request_payload grp
= {0};
7291 grp
.unique_identifier
= &uuid
;
7293 struct request_batch_item expected
= {0};
7294 kmip_init_request_batch_item(&expected
);
7295 expected
.operation
= KMIP_OP_GET
;
7296 expected
.request_payload
= &grp
;
7298 struct request_batch_item observed
= {0};
7299 kmip_init_request_batch_item(&observed
);
7301 int result
= kmip_decode_request_batch_item(&ctx
, &observed
);
7302 result
= report_decoding_test_result(
7305 kmip_compare_request_batch_item(&expected
, &observed
),
7308 kmip_free_request_batch_item(&ctx
, &observed
);
7314 test_decode_request_batch_item_get_payload_kmip_2_0(TestTracker
*tracker
)
7316 TRACK_TEST(tracker
);
7318 /* This encoding matches the following set of values:
7323 * Unique Identifier - 49a1ca88-6bea-4fb2-b450-7e58802c3038
7325 uint8 encoding
[96] = {
7326 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x58,
7327 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7328 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7329 0x42, 0x01, 0x54, 0x06, 0x00, 0x00, 0x00, 0x08,
7330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7331 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
7332 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7333 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7334 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7335 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7336 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7337 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
7341 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
7343 TextString uuid
= {0};
7344 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7347 GetRequestPayload grp
= {0};
7348 grp
.unique_identifier
= &uuid
;
7350 RequestBatchItem expected
= {0};
7351 kmip_init_request_batch_item(&expected
);
7352 expected
.operation
= KMIP_OP_GET
;
7353 expected
.ephemeral
= KMIP_FALSE
;
7354 expected
.request_payload
= &grp
;
7356 RequestBatchItem observed
= {0};
7357 kmip_init_request_batch_item(&observed
);
7359 int result
= kmip_decode_request_batch_item(&ctx
, &observed
);
7360 int comparison
= kmip_compare_request_batch_item(&expected
, &observed
);
7363 kmip_print_request_batch_item(1, &expected
);
7364 kmip_print_request_batch_item(1, &observed
);
7366 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
7368 kmip_free_request_batch_item(&ctx
, &observed
);
7374 test_encode_response_batch_item_get_payload(TestTracker
*tracker
)
7376 TRACK_TEST(tracker
);
7378 uint8 expected
[216] = {
7379 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0xD0,
7380 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7381 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7382 0x42, 0x00, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x04,
7383 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7384 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0xA8,
7385 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
7386 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7387 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7388 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7389 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7390 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7391 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7392 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00,
7393 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x60,
7394 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x58,
7395 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
7396 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7397 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x20,
7398 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x18,
7399 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7400 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7401 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
7402 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
7403 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7404 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
7405 0x00, 0x00, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00
7408 uint8 observed
[216] = {0};
7409 struct kmip ctx
= {0};
7410 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
7412 struct text_string uuid
= {0};
7413 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7417 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7418 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7419 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
7422 struct byte_string v
= {0};
7424 v
.size
= ARRAY_LENGTH(value
);
7426 struct key_value kv
= {0};
7427 kv
.key_material
= &v
;
7429 struct key_block kb
= {0};
7430 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
7432 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_TRIPLE_DES
;
7433 kb
.cryptographic_length
= 168;
7435 struct symmetric_key key
= {0};
7436 key
.key_block
= &kb
;
7438 struct get_response_payload grp
= {0};
7439 grp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
7440 grp
.unique_identifier
= &uuid
;
7443 struct response_batch_item rbi
= {0};
7444 rbi
.operation
= KMIP_OP_GET
;
7445 rbi
.result_status
= KMIP_STATUS_SUCCESS
;
7446 rbi
.response_payload
= &grp
;
7448 int result
= kmip_encode_response_batch_item(&ctx
, &rbi
);
7449 result
= report_encoding_test_result(
7461 test_decode_response_batch_item_get_payload(TestTracker
*tracker
)
7463 TRACK_TEST(tracker
);
7465 uint8 encoding
[216] = {
7466 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0xD0,
7467 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7468 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7469 0x42, 0x00, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x04,
7470 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7471 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0xA8,
7472 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
7473 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7474 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7475 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7476 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7477 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7478 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7479 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00,
7480 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x60,
7481 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x58,
7482 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
7483 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7484 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x20,
7485 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x18,
7486 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7487 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7488 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
7489 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
7490 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7491 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
7492 0x00, 0x00, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00
7495 struct kmip ctx
= {0};
7496 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
7498 struct text_string uuid
= {0};
7499 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7503 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7504 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7505 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
7508 struct byte_string v
= {0};
7510 v
.size
= ARRAY_LENGTH(value
);
7512 struct key_value kv
= {0};
7513 kv
.key_material
= &v
;
7515 struct key_block kb
= {0};
7516 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
7518 kb
.key_value_type
= KMIP_TYPE_STRUCTURE
;
7519 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_TRIPLE_DES
;
7520 kb
.cryptographic_length
= 168;
7522 struct symmetric_key key
= {0};
7523 key
.key_block
= &kb
;
7525 struct get_response_payload grp
= {0};
7526 grp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
7527 grp
.unique_identifier
= &uuid
;
7530 struct response_batch_item expected
= {0};
7531 expected
.operation
= KMIP_OP_GET
;
7532 expected
.result_status
= KMIP_STATUS_SUCCESS
;
7533 expected
.response_payload
= &grp
;
7535 struct response_batch_item observed
= {0};
7537 int result
= kmip_decode_response_batch_item(&ctx
, &observed
);
7538 result
= report_decoding_test_result(
7541 kmip_compare_response_batch_item(&expected
, &observed
),
7544 kmip_free_response_batch_item(&ctx
, &observed
);
7550 test_encode_request_message_get(TestTracker
*tracker
)
7552 TRACK_TEST(tracker
);
7554 uint8 expected
[152] = {
7555 0x42, 0x00, 0x78, 0x01, 0x00, 0x00, 0x00, 0x90,
7556 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0x38,
7557 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
7558 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
7559 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7560 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
7561 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7562 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
7563 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7564 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x48,
7565 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7566 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7567 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
7568 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7569 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7570 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7571 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7572 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7573 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
7576 uint8 observed
[152] = {0};
7577 struct kmip ctx
= {0};
7578 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
7580 struct protocol_version pv
= {0};
7584 struct request_header rh
= {0};
7585 kmip_init_request_header(&rh
);
7587 rh
.protocol_version
= &pv
;
7590 struct text_string uuid
= {0};
7591 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7594 struct get_request_payload grp
= {0};
7595 grp
.unique_identifier
= &uuid
;
7597 struct request_batch_item rbi
= {0};
7598 kmip_init_request_batch_item(&rbi
);
7599 rbi
.operation
= KMIP_OP_GET
;
7600 rbi
.request_payload
= &grp
;
7602 struct request_message rm
= {0};
7603 rm
.request_header
= &rh
;
7604 rm
.batch_items
= &rbi
;
7607 int result
= kmip_encode_request_message(&ctx
, &rm
);
7608 result
= report_encoding_test_result(
7620 test_decode_request_message_get(TestTracker
*tracker
)
7622 TRACK_TEST(tracker
);
7624 uint8 encoding
[152] = {
7625 0x42, 0x00, 0x78, 0x01, 0x00, 0x00, 0x00, 0x90,
7626 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0x38,
7627 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
7628 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
7629 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7630 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
7631 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7632 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
7633 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7634 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x48,
7635 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7636 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7637 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
7638 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7639 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7640 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7641 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7642 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7643 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
7646 struct kmip ctx
= {0};
7647 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
7649 struct protocol_version pv
= {0};
7653 struct request_header rh
= {0};
7654 kmip_init_request_header(&rh
);
7656 rh
.protocol_version
= &pv
;
7659 struct text_string uuid
= {0};
7660 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7663 struct get_request_payload grp
= {0};
7664 grp
.unique_identifier
= &uuid
;
7666 struct request_batch_item rbi
= {0};
7667 kmip_init_request_batch_item(&rbi
);
7668 rbi
.operation
= KMIP_OP_GET
;
7669 rbi
.request_payload
= &grp
;
7671 struct request_message expected
= {0};
7672 expected
.request_header
= &rh
;
7673 expected
.batch_items
= &rbi
;
7674 expected
.batch_count
= 1;
7676 struct request_message observed
= {0};
7678 int result
= kmip_decode_request_message(&ctx
, &observed
);
7679 int comparison
= kmip_compare_request_message(&expected
, &observed
);
7682 kmip_print_request_message(&expected
);
7683 kmip_print_request_message(&observed
);
7685 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
7687 kmip_free_request_message(&ctx
, &observed
);
7693 test_encode_response_message_get(TestTracker
*tracker
)
7695 TRACK_TEST(tracker
);
7697 uint8 expected
[304] = {
7698 0x42, 0x00, 0x7B, 0x01, 0x00, 0x00, 0x01, 0x28,
7699 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x48,
7700 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
7701 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
7702 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7703 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
7704 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7705 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
7706 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE7,
7707 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
7708 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7709 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0xD0,
7710 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7711 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7712 0x42, 0x00, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x04,
7713 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7714 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0xA8,
7715 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
7716 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7717 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7718 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7719 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7720 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7721 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7722 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00,
7723 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x60,
7724 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x58,
7725 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
7726 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7727 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x20,
7728 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x18,
7729 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7730 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7731 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
7732 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
7733 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7734 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
7735 0x00, 0x00, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00
7738 uint8 observed
[304] = {0};
7739 struct kmip ctx
= {0};
7740 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
7742 struct protocol_version pv
= {0};
7746 struct response_header rh
= {0};
7747 kmip_init_response_header(&rh
);
7749 rh
.protocol_version
= &pv
;
7750 rh
.time_stamp
= 1335514343;
7753 struct text_string uuid
= {0};
7754 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7758 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7759 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7760 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
7763 struct byte_string v
= {0};
7765 v
.size
= ARRAY_LENGTH(value
);
7767 struct key_value kv
= {0};
7768 kv
.key_material
= &v
;
7770 struct key_block kb
= {0};
7771 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
7773 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_TRIPLE_DES
;
7774 kb
.cryptographic_length
= 168;
7776 struct symmetric_key key
= {0};
7777 key
.key_block
= &kb
;
7779 struct get_response_payload grp
= {0};
7780 grp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
7781 grp
.unique_identifier
= &uuid
;
7784 struct response_batch_item rbi
= {0};
7785 rbi
.operation
= KMIP_OP_GET
;
7786 rbi
.result_status
= KMIP_STATUS_SUCCESS
;
7787 rbi
.response_payload
= &grp
;
7789 struct response_message rm
= {0};
7790 rm
.response_header
= &rh
;
7791 rm
.batch_items
= &rbi
;
7794 int result
= kmip_encode_response_message(&ctx
, &rm
);
7795 result
= report_encoding_test_result(
7807 test_decode_response_message_get(TestTracker
*tracker
)
7809 TRACK_TEST(tracker
);
7811 uint8 encoding
[304] = {
7812 0x42, 0x00, 0x7B, 0x01, 0x00, 0x00, 0x01, 0x28,
7813 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x48,
7814 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
7815 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
7816 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7817 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
7818 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7819 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
7820 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE7,
7821 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
7822 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7823 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0xD0,
7824 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
7825 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
7826 0x42, 0x00, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x04,
7827 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
7828 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0xA8,
7829 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
7830 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7831 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
7832 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
7833 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
7834 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
7835 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
7836 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00,
7837 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x60,
7838 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x58,
7839 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
7840 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
7841 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x20,
7842 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x18,
7843 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7844 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7845 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
7846 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
7847 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
7848 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
7849 0x00, 0x00, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00
7852 struct kmip ctx
= {0};
7853 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
7855 struct protocol_version pv
= {0};
7859 struct response_header rh
= {0};
7860 kmip_init_response_header(&rh
);
7862 rh
.protocol_version
= &pv
;
7863 rh
.time_stamp
= 1335514343;
7866 struct text_string uuid
= {0};
7867 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
7871 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
7872 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
7873 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
7876 struct byte_string v
= {0};
7878 v
.size
= ARRAY_LENGTH(value
);
7880 struct key_value kv
= {0};
7881 kv
.key_material
= &v
;
7883 struct key_block kb
= {0};
7884 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
7886 kb
.key_value_type
= KMIP_TYPE_STRUCTURE
;
7887 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_TRIPLE_DES
;
7888 kb
.cryptographic_length
= 168;
7890 struct symmetric_key key
= {0};
7891 key
.key_block
= &kb
;
7893 struct get_response_payload grp
= {0};
7894 grp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
7895 grp
.unique_identifier
= &uuid
;
7898 struct response_batch_item rbi
= {0};
7899 rbi
.operation
= KMIP_OP_GET
;
7900 rbi
.result_status
= KMIP_STATUS_SUCCESS
;
7901 rbi
.response_payload
= &grp
;
7903 struct response_message expected
= {0};
7904 expected
.response_header
= &rh
;
7905 expected
.batch_items
= &rbi
;
7906 expected
.batch_count
= 1;
7908 struct response_message observed
= {0};
7910 int result
= kmip_decode_response_message(&ctx
, &observed
);
7911 result
= report_decoding_test_result(
7914 kmip_compare_response_message(&expected
, &observed
),
7917 kmip_free_response_message(&ctx
, &observed
);
7923 test_encode_attributes(TestTracker
*tracker
)
7925 TRACK_TEST(tracker
);
7927 /* This encoding matches the following set of values:
7929 * Cryptographic Algorithm - AES
7930 * Cryptographic Length - 128
7932 uint8 expected
[40] = {
7933 0x42, 0x01, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
7934 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
7935 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
7936 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
7937 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
7940 uint8 observed
[40] = {0};
7941 struct kmip ctx
= {0};
7942 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
7944 LinkedList attribute_list
= {0};
7946 LinkedListItem item_1
= {0};
7947 Attribute attr_1
= {0};
7948 kmip_init_attribute(&attr_1
);
7949 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
7950 attr_1
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
7951 attr_1
.value
= &algorithm
;
7952 item_1
.data
= &attr_1
;
7954 LinkedListItem item_2
= {0};
7955 Attribute attr_2
= {0};
7956 kmip_init_attribute(&attr_2
);
7958 attr_2
.type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
7959 attr_2
.value
= &length
;
7960 item_2
.data
= &attr_2
;
7962 kmip_linked_list_enqueue(&attribute_list
, &item_1
);
7963 kmip_linked_list_enqueue(&attribute_list
, &item_2
);
7965 Attributes attributes
= {0};
7966 attributes
.attribute_list
= &attribute_list
;
7968 int result
= kmip_encode_attributes(&ctx
, &attributes
);
7969 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
7977 test_encode_attributes_with_invalid_kmip_version(TestTracker
*tracker
)
7979 TRACK_TEST(tracker
);
7981 uint8 observed
[40] = {0};
7982 struct kmip ctx
= {0};
7983 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_4
);
7985 Attributes attributes
= {0};
7987 int result
= kmip_encode_attributes(&ctx
, &attributes
);
7990 result
= report_result(tracker
, result
, KMIP_INVALID_FOR_VERSION
, __func__
);
7995 test_encode_attribute_v2_unique_identifier(TestTracker
*tracker
)
7997 TRACK_TEST(tracker
);
7999 /* This encoding matches the following value:
8000 * Unique Identifier - fb4b5b9c-6188-4c63-8142-fe9c328129fc
8002 uint8 expected
[48] = {
8003 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
8004 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
8005 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
8006 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
8007 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
8008 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
8011 uint8 observed
[48] = {0};
8013 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
8015 Attribute attribute
= {0};
8016 kmip_init_attribute(&attribute
);
8017 TextString unique_identifier
= {0};
8018 unique_identifier
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
8019 unique_identifier
.size
= 36;
8020 attribute
.type
= KMIP_ATTR_UNIQUE_IDENTIFIER
;
8021 attribute
.value
= &unique_identifier
;
8023 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8024 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
8032 test_encode_attribute_v2_name(TestTracker
*tracker
)
8034 TRACK_TEST(tracker
);
8036 /* This encoding matches the following value:
8039 * Type - Uninterpreted Text String
8041 uint8 expected
[48] = {
8042 0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28,
8043 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
8044 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
8045 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8046 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
8047 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
8050 uint8 observed
[48] = {0};
8052 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
8054 Attribute attribute
= {0};
8055 kmip_init_attribute(&attribute
);
8056 TextString name_value
= {0};
8057 name_value
.value
= "Template1";
8058 name_value
.size
= 9;
8060 name
.value
= &name_value
;
8061 name
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
8063 attribute
.type
= KMIP_ATTR_NAME
;
8064 attribute
.value
= &name
;
8066 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8067 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
8075 test_encode_attribute_v2_object_type(TestTracker
*tracker
)
8077 TRACK_TEST(tracker
);
8079 /* This encoding matches the following value:
8080 * Object Type - Symmetric Key
8082 uint8 expected
[16] = {
8083 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
8084 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
8087 uint8 observed
[16] = {0};
8089 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
8091 Attribute attribute
= {0};
8092 kmip_init_attribute(&attribute
);
8093 enum object_type object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
8094 attribute
.type
= KMIP_ATTR_OBJECT_TYPE
;
8095 attribute
.value
= &object_type
;
8097 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8098 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
8106 test_encode_attribute_v2_cryptographic_algorithm(TestTracker
*tracker
)
8108 TRACK_TEST(tracker
);
8110 /* This encoding matches the following value:
8111 * Cryptographic Algorithm - AES
8113 uint8 expected
[16] = {
8114 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
8115 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
8118 uint8 observed
[16] = {0};
8120 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
8122 Attribute attribute
= {0};
8123 kmip_init_attribute(&attribute
);
8124 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
8125 attribute
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
8126 attribute
.value
= &algorithm
;
8128 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8129 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
8137 test_encode_attribute_v2_cryptographic_length(TestTracker
*tracker
)
8139 TRACK_TEST(tracker
);
8141 /* This encoding matches the following value:
8142 * Cryptographic Length - 128
8144 uint8 expected
[16] = {
8145 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
8146 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
8149 uint8 observed
[16] = {0};
8151 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
8153 Attribute attribute
= {0};
8154 kmip_init_attribute(&attribute
);
8156 attribute
.type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
8157 attribute
.value
= &length
;
8159 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8160 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
8168 test_encode_attribute_v2_cryptographic_usage_mask(TestTracker
*tracker
)
8170 TRACK_TEST(tracker
);
8172 /* This encoding matches the following value:
8173 * Cryptographic Usage Mask - Encrypt | Decrypt
8175 uint8 expected
[16] = {
8176 0x42, 0x00, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x04,
8177 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
8180 uint8 observed
[16] = {0};
8182 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
8184 Attribute attribute
= {0};
8185 kmip_init_attribute(&attribute
);
8186 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
8187 attribute
.type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
8188 attribute
.value
= &mask
;
8190 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8191 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
8199 test_encode_attribute_v2_state(TestTracker
*tracker
)
8201 TRACK_TEST(tracker
);
8203 /* This encoding matches the following value:
8206 uint8 expected
[16] = {
8207 0x42, 0x00, 0x8D, 0x05, 0x00, 0x00, 0x00, 0x04,
8208 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
8211 uint8 observed
[16] = {0};
8213 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
8215 Attribute attribute
= {0};
8216 kmip_init_attribute(&attribute
);
8217 enum state state
= KMIP_STATE_ACTIVE
;
8218 attribute
.type
= KMIP_ATTR_STATE
;
8219 attribute
.value
= &state
;
8221 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8222 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
8230 test_encode_attribute_v2_unsupported_attribute(TestTracker
*tracker
)
8232 TRACK_TEST(tracker
);
8234 uint8 encoding
[16] = {0};
8237 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8239 Attribute attribute
= {0};
8240 attribute
.type
= -1;
8241 int result
= kmip_encode_attribute_v2(&ctx
, &attribute
);
8242 if(result
!= KMIP_ERROR_ATTR_UNSUPPORTED
)
8244 TEST_FAILED(tracker
, __func__
, __LINE__
);
8249 TEST_PASSED(tracker
, __func__
);
8253 test_decode_attributes(TestTracker
*tracker
)
8255 TRACK_TEST(tracker
);
8257 /* This encoding matches the following set of values:
8259 * Cryptographic Algorithm - AES
8260 * Cryptographic Length - 128
8262 uint8 encoding
[40] = {
8263 0x42, 0x01, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
8264 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
8265 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
8266 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
8267 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
8271 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8273 LinkedList attribute_list
= {0};
8275 LinkedListItem item_1
= {0};
8276 Attribute attr_1
= {0};
8277 kmip_init_attribute(&attr_1
);
8278 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
8279 attr_1
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
8280 attr_1
.value
= &algorithm
;
8281 item_1
.data
= &attr_1
;
8283 LinkedListItem item_2
= {0};
8284 Attribute attr_2
= {0};
8285 kmip_init_attribute(&attr_2
);
8287 attr_2
.type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
8288 attr_2
.value
= &length
;
8289 item_2
.data
= &attr_2
;
8291 kmip_linked_list_enqueue(&attribute_list
, &item_1
);
8292 kmip_linked_list_enqueue(&attribute_list
, &item_2
);
8294 Attributes expected
= {0};
8295 expected
.attribute_list
= &attribute_list
;
8297 Attributes observed
= {0};
8298 int result
= kmip_decode_attributes(&ctx
, &observed
);
8299 int comparison
= kmip_compare_attributes(&expected
, &observed
);
8302 kmip_print_attributes(1, &expected
);
8303 kmip_print_attributes(1, &observed
);
8305 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8307 kmip_free_attributes(&ctx
, &observed
);
8314 test_decode_attributes_with_invalid_kmip_version(TestTracker
*tracker
)
8316 TRACK_TEST(tracker
);
8318 uint8 encoding
[] = {0};
8321 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_4
);
8323 Attributes observed
= {0};
8324 int result
= kmip_decode_attributes(&ctx
, &observed
);
8326 kmip_free_attributes(&ctx
, &observed
);
8329 result
= report_result(tracker
, result
, KMIP_INVALID_FOR_VERSION
, __func__
);
8334 test_decode_attribute_v2_unique_identifier(TestTracker
*tracker
)
8336 TRACK_TEST(tracker
);
8338 /* This encoding matches the following value:
8339 * Unique Identifier - fb4b5b9c-6188-4c63-8142-fe9c328129fc
8341 uint8 encoding
[48] = {
8342 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
8343 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
8344 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
8345 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
8346 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
8347 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
8351 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8353 Attribute expected
= {0};
8354 kmip_init_attribute(&expected
);
8355 TextString unique_identifier
= {0};
8356 unique_identifier
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
8357 unique_identifier
.size
= 36;
8358 expected
.type
= KMIP_ATTR_UNIQUE_IDENTIFIER
;
8359 expected
.value
= &unique_identifier
;
8361 Attribute observed
= {0};
8362 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8363 int comparison
= kmip_compare_attribute(&expected
, &observed
);
8366 kmip_print_attribute(1, &expected
);
8367 kmip_print_attribute(1, &observed
);
8369 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8371 kmip_free_attribute(&ctx
, &observed
);
8378 test_decode_attribute_v2_name(TestTracker
*tracker
)
8380 TRACK_TEST(tracker
);
8382 /* This encoding matches the following value:
8385 * Type - Uninterpreted Text String
8387 uint8 encoding
[48] = {
8388 0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28,
8389 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
8390 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
8391 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8392 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
8393 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
8397 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8399 Attribute expected
= {0};
8400 kmip_init_attribute(&expected
);
8401 TextString name_value
= {0};
8402 name_value
.value
= "Template1";
8403 name_value
.size
= 9;
8405 name
.value
= &name_value
;
8406 name
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
8408 expected
.type
= KMIP_ATTR_NAME
;
8409 expected
.value
= &name
;
8411 Attribute observed
= {0};
8412 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8413 int comparison
= kmip_compare_attribute(&expected
, &observed
);
8416 kmip_print_attribute(1, &expected
);
8417 kmip_print_attribute(1, &observed
);
8419 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8421 kmip_free_attribute(&ctx
, &observed
);
8428 test_decode_attribute_v2_object_type(TestTracker
*tracker
)
8430 TRACK_TEST(tracker
);
8432 /* This encoding matches the following value:
8433 * Object Type - Symmetric Key
8435 uint8 encoding
[16] = {
8436 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
8437 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
8441 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8443 Attribute expected
= {0};
8444 kmip_init_attribute(&expected
);
8445 enum object_type object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
8446 expected
.type
= KMIP_ATTR_OBJECT_TYPE
;
8447 expected
.value
= &object_type
;
8449 Attribute observed
= {0};
8450 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8451 int comparison
= kmip_compare_attribute(&expected
, &observed
);
8454 kmip_print_attribute(1, &expected
);
8455 kmip_print_attribute(1, &observed
);
8457 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8459 kmip_free_attribute(&ctx
, &observed
);
8466 test_decode_attribute_v2_cryptographic_algorithm(TestTracker
*tracker
)
8468 TRACK_TEST(tracker
);
8470 /* This encoding matches the following value:
8471 * Cryptographic Algorithm - AES
8473 uint8 encoding
[16] = {
8474 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
8475 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00
8479 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8481 Attribute expected
= {0};
8482 kmip_init_attribute(&expected
);
8483 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
8484 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
8485 expected
.value
= &algorithm
;
8487 Attribute observed
= {0};
8488 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8489 int comparison
= kmip_compare_attribute(&expected
, &observed
);
8492 kmip_print_attribute(1, &expected
);
8493 kmip_print_attribute(1, &observed
);
8495 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8497 kmip_free_attribute(&ctx
, &observed
);
8504 test_decode_attribute_v2_cryptographic_length(TestTracker
*tracker
)
8506 TRACK_TEST(tracker
);
8508 /* This encoding matches the following value:
8509 * Cryptographic Length - 128
8511 uint8 encoding
[16] = {
8512 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
8513 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00
8517 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8519 Attribute expected
= {0};
8520 kmip_init_attribute(&expected
);
8522 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
8523 expected
.value
= &length
;
8525 Attribute observed
= {0};
8526 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8527 int comparison
= kmip_compare_attribute(&expected
, &observed
);
8530 kmip_print_attribute(1, &expected
);
8531 kmip_print_attribute(1, &observed
);
8533 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8535 kmip_free_attribute(&ctx
, &observed
);
8542 test_decode_attribute_v2_cryptographic_usage_mask(TestTracker
*tracker
)
8544 TRACK_TEST(tracker
);
8546 /* This encoding matches the following value:
8547 * Cryptographic Usage Mask - Encrypt | Decrypt
8549 uint8 encoding
[16] = {
8550 0x42, 0x00, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x04,
8551 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
8555 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8557 Attribute expected
= {0};
8558 kmip_init_attribute(&expected
);
8559 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
8560 expected
.type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
8561 expected
.value
= &mask
;
8563 Attribute observed
= {0};
8564 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8565 int comparison
= kmip_compare_attribute(&expected
, &observed
);
8568 kmip_print_attribute(1, &expected
);
8569 kmip_print_attribute(1, &observed
);
8571 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8573 kmip_free_attribute(&ctx
, &observed
);
8580 test_decode_attribute_v2_state(TestTracker
*tracker
)
8582 TRACK_TEST(tracker
);
8584 /* This encoding matches the following value:
8587 uint8 encoding
[16] = {
8588 0x42, 0x00, 0x8D, 0x05, 0x00, 0x00, 0x00, 0x04,
8589 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
8593 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8595 Attribute expected
= {0};
8596 kmip_init_attribute(&expected
);
8597 enum state state
= KMIP_STATE_ACTIVE
;
8598 expected
.type
= KMIP_ATTR_STATE
;
8599 expected
.value
= &state
;
8601 Attribute observed
= {0};
8602 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8603 int comparison
= kmip_compare_attribute(&expected
, &observed
);
8606 kmip_print_attribute(1, &expected
);
8607 kmip_print_attribute(1, &observed
);
8609 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
8611 kmip_free_attribute(&ctx
, &observed
);
8618 test_decode_attribute_v2_unsupported_attribute(TestTracker
*tracker
)
8620 TRACK_TEST(tracker
);
8622 uint8 encoding
[3] = {0x42, 0x00, 0x00};
8625 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
8627 Attribute observed
= {0};
8628 int result
= kmip_decode_attribute_v2(&ctx
, &observed
);
8629 if(result
!= KMIP_ERROR_ATTR_UNSUPPORTED
)
8631 TEST_FAILED(tracker
, __func__
, __LINE__
);
8634 kmip_free_attribute(&ctx
, &observed
);
8637 TEST_PASSED(tracker
, __func__
);
8641 test_encode_template_attribute(TestTracker
*tracker
)
8643 TRACK_TEST(tracker
);
8645 uint8 expected
[288] = {
8646 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x01, 0x18,
8647 0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28,
8648 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
8649 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
8650 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8651 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
8652 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
8653 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
8654 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
8655 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
8656 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
8657 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
8658 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
8659 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
8660 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
8661 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
8662 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
8663 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
8664 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
8665 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
8666 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
8667 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
8668 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
8669 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
8670 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
8671 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
8672 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
8673 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
8674 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x38,
8675 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x04,
8676 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x00,
8677 0x42, 0x00, 0x0B, 0x01, 0x00, 0x00, 0x00, 0x20,
8678 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x04,
8679 0x4B, 0x65, 0x79, 0x31, 0x00, 0x00, 0x00, 0x00,
8680 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
8681 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
8684 uint8 observed
[288] = {0};
8685 struct kmip ctx
= {0};
8686 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
8688 struct text_string v
= {0};
8689 v
.value
= "Template1";
8692 struct name n
= {0};
8694 n
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
8696 struct attribute a
[4] = {0};
8697 for(int i
= 0; i
< 4; i
++)
8699 kmip_init_attribute(&a
[i
]);
8702 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
8703 a
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
8704 a
[0].value
= &algorithm
;
8707 a
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
8708 a
[1].value
= &length
;
8710 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
8711 a
[2].type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
8714 struct text_string value
= {0};
8715 value
.value
= "Key1";
8718 struct name name
= {0};
8719 name
.value
= &value
;
8720 name
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
8721 a
[3].type
= KMIP_ATTR_NAME
;
8724 struct template_attribute ta
= {0};
8728 ta
.attribute_count
= ARRAY_LENGTH(a
);
8730 int result
= kmip_encode_template_attribute(&ctx
, &ta
);
8731 result
= report_encoding_test_result(
8743 test_decode_template_attribute(TestTracker
*tracker
)
8745 TRACK_TEST(tracker
);
8747 uint8 encoding
[288] = {
8748 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x01, 0x18,
8749 0x42, 0x00, 0x53, 0x01, 0x00, 0x00, 0x00, 0x28,
8750 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x09,
8751 0x54, 0x65, 0x6D, 0x70, 0x6C, 0x61, 0x74, 0x65,
8752 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8753 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
8754 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
8755 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
8756 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
8757 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
8758 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
8759 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
8760 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
8761 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
8762 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
8763 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
8764 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
8765 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
8766 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
8767 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
8768 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
8769 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
8770 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
8771 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
8772 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
8773 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
8774 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
8775 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
8776 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x38,
8777 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x04,
8778 0x4E, 0x61, 0x6D, 0x65, 0x00, 0x00, 0x00, 0x00,
8779 0x42, 0x00, 0x0B, 0x01, 0x00, 0x00, 0x00, 0x20,
8780 0x42, 0x00, 0x55, 0x07, 0x00, 0x00, 0x00, 0x04,
8781 0x4B, 0x65, 0x79, 0x31, 0x00, 0x00, 0x00, 0x00,
8782 0x42, 0x00, 0x54, 0x05, 0x00, 0x00, 0x00, 0x04,
8783 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
8786 struct kmip ctx
= {0};
8787 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_0
);
8789 struct text_string v
= {0};
8790 v
.value
= "Template1";
8793 struct name n
= {0};
8795 n
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
8797 struct attribute a
[4] = {0};
8798 for(int i
= 0; i
< 4; i
++)
8800 kmip_init_attribute(&a
[i
]);
8803 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
8804 a
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
8805 a
[0].value
= &algorithm
;
8808 a
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
8809 a
[1].value
= &length
;
8811 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
8812 a
[2].type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
8815 struct text_string value
= {0};
8816 value
.value
= "Key1";
8819 struct name name
= {0};
8820 name
.value
= &value
;
8821 name
.type
= KMIP_NAME_UNINTERPRETED_TEXT_STRING
;
8822 a
[3].type
= KMIP_ATTR_NAME
;
8825 struct template_attribute expected
= {0};
8826 expected
.names
= &n
;
8827 expected
.name_count
= 1;
8828 expected
.attributes
= a
;
8829 expected
.attribute_count
= ARRAY_LENGTH(a
);
8830 struct template_attribute observed
= {0};
8832 int result
= kmip_decode_template_attribute(&ctx
, &observed
);
8833 result
= report_decoding_test_result(
8836 kmip_compare_template_attribute(&expected
, &observed
),
8839 kmip_free_template_attribute(&ctx
, &observed
);
8845 The following tests cover features added in KMIP 1.1.
8849 test_encode_device_credential(TestTracker
*tracker
)
8851 TRACK_TEST(tracker
);
8853 uint8 expected
[144] = {
8854 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x88,
8855 0x42, 0x00, 0xB0, 0x07, 0x00, 0x00, 0x00, 0x0C,
8856 0x73, 0x65, 0x72, 0x4E, 0x75, 0x6D, 0x31, 0x32,
8857 0x33, 0x34, 0x35, 0x36, 0x00, 0x00, 0x00, 0x00,
8858 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x06,
8859 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x00, 0x00,
8860 0x42, 0x00, 0xA2, 0x07, 0x00, 0x00, 0x00, 0x09,
8861 0x64, 0x65, 0x76, 0x49, 0x44, 0x32, 0x32, 0x33,
8862 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8863 0x42, 0x00, 0xAB, 0x07, 0x00, 0x00, 0x00, 0x09,
8864 0x6E, 0x65, 0x74, 0x49, 0x44, 0x39, 0x30, 0x30,
8865 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8866 0x42, 0x00, 0xA9, 0x07, 0x00, 0x00, 0x00, 0x0A,
8867 0x6D, 0x61, 0x63, 0x68, 0x69, 0x6E, 0x65, 0x49,
8868 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8869 0x42, 0x00, 0xAA, 0x07, 0x00, 0x00, 0x00, 0x0A,
8870 0x6D, 0x65, 0x64, 0x69, 0x61, 0x49, 0x44, 0x33,
8871 0x31, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
8874 uint8 observed
[144] = {0};
8875 struct kmip ctx
= {0};
8876 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
8878 struct text_string dsn
= {0};
8879 dsn
.value
= "serNum123456";
8882 struct text_string p
= {0};
8886 struct text_string di
= {0};
8887 di
.value
= "devID2233";
8890 struct text_string ni
= {0};
8891 ni
.value
= "netID9000";
8894 struct text_string mac
= {0};
8895 mac
.value
= "machineID1";
8898 struct text_string med
= {0};
8899 med
.value
= "mediaID313";
8902 struct device_credential dc
= {0};
8903 dc
.device_serial_number
= &dsn
;
8905 dc
.device_identifier
= &di
;
8906 dc
.network_identifier
= &ni
;
8907 dc
.machine_identifier
= &mac
;
8908 dc
.media_identifier
= &med
;
8910 int result
= kmip_encode_device_credential(&ctx
, &dc
);
8911 result
= report_encoding_test_result(
8923 test_decode_device_credential(TestTracker
*tracker
)
8925 TRACK_TEST(tracker
);
8927 uint8 encoding
[144] = {
8928 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x88,
8929 0x42, 0x00, 0xB0, 0x07, 0x00, 0x00, 0x00, 0x0C,
8930 0x73, 0x65, 0x72, 0x4E, 0x75, 0x6D, 0x31, 0x32,
8931 0x33, 0x34, 0x35, 0x36, 0x00, 0x00, 0x00, 0x00,
8932 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x06,
8933 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x00, 0x00,
8934 0x42, 0x00, 0xA2, 0x07, 0x00, 0x00, 0x00, 0x09,
8935 0x64, 0x65, 0x76, 0x49, 0x44, 0x32, 0x32, 0x33,
8936 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8937 0x42, 0x00, 0xAB, 0x07, 0x00, 0x00, 0x00, 0x09,
8938 0x6E, 0x65, 0x74, 0x49, 0x44, 0x39, 0x30, 0x30,
8939 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8940 0x42, 0x00, 0xA9, 0x07, 0x00, 0x00, 0x00, 0x0A,
8941 0x6D, 0x61, 0x63, 0x68, 0x69, 0x6E, 0x65, 0x49,
8942 0x44, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
8943 0x42, 0x00, 0xAA, 0x07, 0x00, 0x00, 0x00, 0x0A,
8944 0x6D, 0x65, 0x64, 0x69, 0x61, 0x49, 0x44, 0x33,
8945 0x31, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
8948 struct kmip ctx
= {0};
8949 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_1
);
8951 struct text_string dsn
= {0};
8952 dsn
.value
= "serNum123456";
8955 struct text_string p
= {0};
8959 struct text_string di
= {0};
8960 di
.value
= "devID2233";
8963 struct text_string ni
= {0};
8964 ni
.value
= "netID9000";
8967 struct text_string mac
= {0};
8968 mac
.value
= "machineID1";
8971 struct text_string med
= {0};
8972 med
.value
= "mediaID313";
8975 struct device_credential expected
= {0};
8976 expected
.device_serial_number
= &dsn
;
8977 expected
.password
= &p
;
8978 expected
.device_identifier
= &di
;
8979 expected
.network_identifier
= &ni
;
8980 expected
.machine_identifier
= &mac
;
8981 expected
.media_identifier
= &med
;
8983 struct device_credential observed
= {0};
8985 int result
= kmip_decode_device_credential(&ctx
, &observed
);
8986 result
= report_decoding_test_result(
8989 kmip_compare_device_credential(&expected
, &observed
),
8992 kmip_free_device_credential(&ctx
, &observed
);
8998 test_encode_key_wrapping_data_with_encoding_option(TestTracker
*tracker
)
9000 TRACK_TEST(tracker
);
9002 uint8 expected
[120] = {
9003 0x42, 0x00, 0x46, 0x01, 0x00, 0x00, 0x00, 0x70,
9004 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
9005 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9006 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
9007 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
9008 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
9009 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
9010 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
9011 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
9012 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
9013 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
9014 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
9015 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00,
9016 0x42, 0x00, 0xA3, 0x05, 0x00, 0x00, 0x00, 0x04,
9017 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
9020 uint8 observed
[120] = {0};
9021 struct kmip ctx
= {0};
9022 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
9024 struct text_string uuid
= {0};
9025 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
9028 struct cryptographic_parameters cp
= {0};
9029 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
9031 struct encryption_key_information eki
= {0};
9032 eki
.unique_identifier
= &uuid
;
9033 eki
.cryptographic_parameters
= &cp
;
9035 struct key_wrapping_data kwd
= {0};
9036 kwd
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
9037 kwd
.encryption_key_info
= &eki
;
9038 kwd
.encoding_option
= KMIP_ENCODE_NO_ENCODING
;
9040 int result
= kmip_encode_key_wrapping_data(&ctx
, &kwd
);
9041 result
= report_encoding_test_result(
9053 test_decode_key_wrapping_data_with_encoding_option(TestTracker
*tracker
)
9055 TRACK_TEST(tracker
);
9057 uint8 encoding
[120] = {
9058 0x42, 0x00, 0x46, 0x01, 0x00, 0x00, 0x00, 0x70,
9059 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
9060 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9061 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
9062 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
9063 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
9064 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
9065 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
9066 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
9067 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
9068 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
9069 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
9070 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00,
9071 0x42, 0x00, 0xA3, 0x05, 0x00, 0x00, 0x00, 0x04,
9072 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
9075 struct kmip ctx
= {0};
9076 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_1
);
9078 struct text_string uuid
= {0};
9079 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
9082 struct cryptographic_parameters cp
= {0};
9083 kmip_init_cryptographic_parameters(&cp
);
9084 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
9086 struct encryption_key_information eki
= {0};
9087 eki
.unique_identifier
= &uuid
;
9088 eki
.cryptographic_parameters
= &cp
;
9090 struct key_wrapping_data expected
= {0};
9091 expected
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
9092 expected
.encryption_key_info
= &eki
;
9093 expected
.encoding_option
= KMIP_ENCODE_NO_ENCODING
;
9095 struct key_wrapping_data observed
= {0};
9097 int result
= kmip_decode_key_wrapping_data(&ctx
, &observed
);
9098 result
= report_decoding_test_result(
9101 kmip_compare_key_wrapping_data(&expected
, &observed
),
9104 kmip_free_key_wrapping_data(&ctx
, &observed
);
9110 test_encode_key_wrapping_specification_with_encoding_option(TestTracker
*tracker
)
9112 TRACK_TEST(tracker
);
9114 uint8 expected
[120] = {
9115 0x42, 0x00, 0x47, 0x01, 0x00, 0x00, 0x00, 0x70,
9116 0x42, 0x00, 0x9E, 0x05, 0x00, 0x00, 0x00, 0x04,
9117 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9118 0x42, 0x00, 0x36, 0x01, 0x00, 0x00, 0x00, 0x48,
9119 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
9120 0x31, 0x30, 0x30, 0x31, 0x38, 0x32, 0x64, 0x35,
9121 0x2D, 0x37, 0x32, 0x62, 0x38, 0x2D, 0x34, 0x37,
9122 0x61, 0x61, 0x2D, 0x38, 0x33, 0x38, 0x33, 0x2D,
9123 0x34, 0x64, 0x39, 0x37, 0x64, 0x35, 0x31, 0x32,
9124 0x65, 0x39, 0x38, 0x61, 0x00, 0x00, 0x00, 0x00,
9125 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x10,
9126 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
9127 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x00,
9128 0x42, 0x00, 0xA3, 0x05, 0x00, 0x00, 0x00, 0x04,
9129 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
9132 uint8 observed
[120] = {0};
9133 struct kmip ctx
= {0};
9134 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
9136 struct text_string uuid
= {0};
9137 uuid
.value
= "100182d5-72b8-47aa-8383-4d97d512e98a";
9140 struct cryptographic_parameters cp
= {0};
9141 cp
.block_cipher_mode
= KMIP_BLOCK_NIST_KEY_WRAP
;
9143 struct encryption_key_information eki
= {0};
9144 eki
.unique_identifier
= &uuid
;
9145 eki
.cryptographic_parameters
= &cp
;
9147 struct key_wrapping_specification kws
= {0};
9148 kws
.wrapping_method
= KMIP_WRAP_ENCRYPT
;
9149 kws
.encryption_key_info
= &eki
;
9150 kws
.encoding_option
= KMIP_ENCODE_NO_ENCODING
;
9152 int result
= kmip_encode_key_wrapping_specification(&ctx
, &kws
);
9153 result
= report_encoding_test_result(
9165 The following tests cover features added in KMIP 1.2.
9169 test_encode_nonce(TestTracker
*tracker
)
9171 TRACK_TEST(tracker
);
9173 uint8 expected
[40] = {
9174 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
9175 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
9176 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
9177 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
9178 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00
9181 uint8 observed
[40] = {0};
9182 struct kmip ctx
= {0};
9183 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_2
);
9185 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
9186 struct byte_string ni
= {0};
9188 ni
.size
= ARRAY_LENGTH(id
);
9190 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9191 struct byte_string nv
= {0};
9193 nv
.size
= ARRAY_LENGTH(value
);
9195 struct nonce n
= {0};
9197 n
.nonce_value
= &nv
;
9199 int result
= kmip_encode_nonce(&ctx
, &n
);
9200 result
= report_encoding_test_result(
9212 test_decode_nonce(TestTracker
*tracker
)
9214 TRACK_TEST(tracker
);
9216 uint8 encoding
[40] = {
9217 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
9218 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
9219 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
9220 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
9221 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00
9224 struct kmip ctx
= {0};
9225 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_2
);
9227 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
9228 struct byte_string ni
= {0};
9230 ni
.size
= ARRAY_LENGTH(id
);
9232 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9233 struct byte_string nv
= {0};
9235 nv
.size
= ARRAY_LENGTH(value
);
9237 struct nonce expected
= {0};
9238 expected
.nonce_id
= &ni
;
9239 expected
.nonce_value
= &nv
;
9241 struct nonce observed
= {0};
9243 int result
= kmip_decode_nonce(&ctx
, &observed
);
9244 result
= report_decoding_test_result(
9247 kmip_compare_nonce(&expected
, &observed
),
9250 kmip_free_nonce(&ctx
, &observed
);
9256 test_encode_attestation_credential(TestTracker
*tracker
)
9258 TRACK_TEST(tracker
);
9260 uint8 expected
[128] = {
9261 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x70,
9262 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
9263 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
9264 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
9265 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
9266 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
9267 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9268 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9269 0x42, 0x00, 0xCB, 0x08, 0x00, 0x00, 0x00, 0x10,
9270 0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
9271 0x66, 0x66, 0x66, 0x66, 0x88, 0x88, 0x88, 0x88,
9272 0x42, 0x00, 0xCC, 0x08, 0x00, 0x00, 0x00, 0x14,
9273 0x11, 0x11, 0x11, 0x11, 0x33, 0x33, 0x33, 0x33,
9274 0x55, 0x55, 0x55, 0x55, 0x77, 0x77, 0x77, 0x77,
9275 0x99, 0x99, 0x99, 0x99, 0x00, 0x00, 0x00, 0x00
9278 uint8 observed
[128] = {0};
9279 struct kmip ctx
= {0};
9280 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_2
);
9282 uint8 nonce_id
[4] = {0x01, 0x02, 0x03, 0x04};
9283 struct byte_string ni
= {0};
9284 ni
.value
= nonce_id
;
9285 ni
.size
= ARRAY_LENGTH(nonce_id
);
9287 uint8 nonce_value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9288 struct byte_string nv
= {0};
9289 nv
.value
= nonce_value
;
9290 nv
.size
= ARRAY_LENGTH(nonce_value
);
9292 struct nonce n
= {0};
9294 n
.nonce_value
= &nv
;
9296 uint8 measurement
[16] = {
9297 0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
9298 0x66, 0x66, 0x66, 0x66, 0x88, 0x88, 0x88, 0x88
9300 struct byte_string am
= {0};
9301 am
.value
= measurement
;
9302 am
.size
= ARRAY_LENGTH(measurement
);
9304 uint8 assertion
[20] = {
9305 0x11, 0x11, 0x11, 0x11, 0x33, 0x33, 0x33, 0x33,
9306 0x55, 0x55, 0x55, 0x55, 0x77, 0x77, 0x77, 0x77,
9307 0x99, 0x99, 0x99, 0x99
9309 struct byte_string aa
= {0};
9310 aa
.value
= assertion
;
9311 aa
.size
= ARRAY_LENGTH(assertion
);
9313 struct attestation_credential ac
= {0};
9315 ac
.attestation_type
= KMIP_ATTEST_TPM_QUOTE
;
9316 ac
.attestation_measurement
= &am
;
9317 ac
.attestation_assertion
= &aa
;
9319 int result
= kmip_encode_attestation_credential(&ctx
, &ac
);
9320 result
= report_encoding_test_result(
9332 test_decode_attestation_credential(TestTracker
*tracker
)
9334 TRACK_TEST(tracker
);
9336 uint8 encoding
[128] = {
9337 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x70,
9338 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
9339 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
9340 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
9341 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
9342 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
9343 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9344 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9345 0x42, 0x00, 0xCB, 0x08, 0x00, 0x00, 0x00, 0x10,
9346 0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
9347 0x66, 0x66, 0x66, 0x66, 0x88, 0x88, 0x88, 0x88,
9348 0x42, 0x00, 0xCC, 0x08, 0x00, 0x00, 0x00, 0x14,
9349 0x11, 0x11, 0x11, 0x11, 0x33, 0x33, 0x33, 0x33,
9350 0x55, 0x55, 0x55, 0x55, 0x77, 0x77, 0x77, 0x77,
9351 0x99, 0x99, 0x99, 0x99, 0x00, 0x00, 0x00, 0x00
9354 struct kmip ctx
= {0};
9355 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_2
);
9357 uint8 nonce_id
[4] = {0x01, 0x02, 0x03, 0x04};
9358 struct byte_string ni
= {0};
9359 ni
.value
= nonce_id
;
9360 ni
.size
= ARRAY_LENGTH(nonce_id
);
9362 uint8 nonce_value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9363 struct byte_string nv
= {0};
9364 nv
.value
= nonce_value
;
9365 nv
.size
= ARRAY_LENGTH(nonce_value
);
9367 struct nonce n
= {0};
9369 n
.nonce_value
= &nv
;
9371 uint8 measurement
[16] = {
9372 0x22, 0x22, 0x22, 0x22, 0x44, 0x44, 0x44, 0x44,
9373 0x66, 0x66, 0x66, 0x66, 0x88, 0x88, 0x88, 0x88
9375 struct byte_string am
= {0};
9376 am
.value
= measurement
;
9377 am
.size
= ARRAY_LENGTH(measurement
);
9379 uint8 assertion
[20] = {
9380 0x11, 0x11, 0x11, 0x11, 0x33, 0x33, 0x33, 0x33,
9381 0x55, 0x55, 0x55, 0x55, 0x77, 0x77, 0x77, 0x77,
9382 0x99, 0x99, 0x99, 0x99
9384 struct byte_string aa
= {0};
9385 aa
.value
= assertion
;
9386 aa
.size
= ARRAY_LENGTH(assertion
);
9388 struct attestation_credential expected
= {0};
9389 expected
.nonce
= &n
;
9390 expected
.attestation_type
= KMIP_ATTEST_TPM_QUOTE
;
9391 expected
.attestation_measurement
= &am
;
9392 expected
.attestation_assertion
= &aa
;
9394 struct attestation_credential observed
= {0};
9396 int result
= kmip_decode_attestation_credential(&ctx
, &observed
);
9397 result
= report_decoding_test_result(
9400 kmip_compare_attestation_credential(&expected
, &observed
),
9403 kmip_free_attestation_credential(&ctx
, &observed
);
9409 test_encode_request_header_with_attestation_details(TestTracker
*tracker
)
9411 TRACK_TEST(tracker
);
9413 uint8 expected
[216] = {
9414 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0xD0,
9415 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
9416 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
9417 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9418 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
9419 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9420 0x42, 0x00, 0xD3, 0x06, 0x00, 0x00, 0x00, 0x08,
9421 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
9422 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9423 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9424 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9425 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
9426 0x42, 0x00, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x40,
9427 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x38,
9428 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
9429 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9430 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
9431 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x06,
9432 0x42, 0x61, 0x72, 0x6E, 0x65, 0x79, 0x00, 0x00,
9433 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x07,
9434 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x00,
9435 0x42, 0x00, 0x0E, 0x05, 0x00, 0x00, 0x00, 0x04,
9436 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9437 0x42, 0x00, 0x10, 0x06, 0x00, 0x00, 0x00, 0x08,
9438 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
9439 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
9440 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
9443 uint8 observed
[216] = {0};
9444 struct kmip ctx
= {0};
9445 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_2
);
9447 struct protocol_version pv
= {0};
9451 struct text_string username
= {0};
9452 username
.value
= "Barney";
9454 struct text_string password
= {0};
9455 password
.value
= "secret2";
9458 struct username_password_credential upc
= {0};
9459 upc
.username
= &username
;
9460 upc
.password
= &password
;
9462 struct credential c
= {0};
9463 c
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
9464 c
.credential_value
= &upc
;
9466 struct authentication a
= {0};
9469 enum attestation_type types
[2] = {
9470 KMIP_ATTEST_TPM_QUOTE
,
9471 KMIP_ATTEST_SAML_ASSERTION
9474 struct request_header rh
= {0};
9475 kmip_init_request_header(&rh
);
9477 rh
.protocol_version
= &pv
;
9478 rh
.attestation_capable_indicator
= KMIP_TRUE
;
9479 rh
.attestation_types
= types
;
9480 rh
.attestation_type_count
= ARRAY_LENGTH(types
);
9481 rh
.authentication
= &a
;
9482 rh
.batch_error_continuation_option
= KMIP_BATCH_CONTINUE
;
9483 rh
.batch_order_option
= KMIP_TRUE
;
9486 int result
= kmip_encode_request_header(&ctx
, &rh
);
9487 result
= report_encoding_test_result(
9499 test_encode_response_header_with_attestation_details(TestTracker
*tracker
)
9501 TRACK_TEST(tracker
);
9503 uint8 expected
[152] = {
9504 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x90,
9505 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
9506 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
9507 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9508 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
9509 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9510 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
9511 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
9512 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
9513 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
9514 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
9515 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
9516 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
9517 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9518 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9519 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9520 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
9521 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
9522 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
9525 uint8 observed
[152] = {0};
9526 struct kmip ctx
= {0};
9527 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_2
);
9529 struct protocol_version pv
= {0};
9533 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
9534 struct byte_string ni
= {0};
9536 ni
.size
= ARRAY_LENGTH(id
);
9538 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9539 struct byte_string nv
= {0};
9541 nv
.size
= ARRAY_LENGTH(value
);
9543 struct nonce n
= {0};
9545 n
.nonce_value
= &nv
;
9547 enum attestation_type types
[2] = {
9548 KMIP_ATTEST_TPM_QUOTE
,
9549 KMIP_ATTEST_SAML_ASSERTION
9552 struct response_header rh
= {0};
9553 kmip_init_response_header(&rh
);
9555 rh
.protocol_version
= &pv
;
9556 rh
.time_stamp
= 1335514341;
9558 rh
.attestation_types
= types
;
9559 rh
.attestation_type_count
= ARRAY_LENGTH(types
);
9562 int result
= kmip_encode_response_header(&ctx
, &rh
);
9563 result
= report_encoding_test_result(
9575 test_decode_response_header_with_attestation_details(TestTracker
*tracker
)
9577 TRACK_TEST(tracker
);
9579 uint8 encoding
[152] = {
9580 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x90,
9581 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
9582 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
9583 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9584 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
9585 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9586 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
9587 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
9588 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
9589 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
9590 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
9591 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
9592 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
9593 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9594 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9595 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
9596 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
9597 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
9598 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
9601 struct kmip ctx
= {0};
9602 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_2
);
9604 struct protocol_version pv
= {0};
9608 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
9609 struct byte_string ni
= {0};
9611 ni
.size
= ARRAY_LENGTH(id
);
9613 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9614 struct byte_string nv
= {0};
9616 nv
.size
= ARRAY_LENGTH(value
);
9618 struct nonce n
= {0};
9620 n
.nonce_value
= &nv
;
9622 enum attestation_type types
[2] = {
9623 KMIP_ATTEST_TPM_QUOTE
,
9624 KMIP_ATTEST_SAML_ASSERTION
9627 struct response_header expected
= {0};
9628 kmip_init_response_header(&expected
);
9630 expected
.protocol_version
= &pv
;
9631 expected
.time_stamp
= 1335514341;
9632 expected
.nonce
= &n
;
9633 expected
.attestation_types
= types
;
9634 expected
.attestation_type_count
= ARRAY_LENGTH(types
);
9635 expected
.batch_count
= 1;
9637 struct response_header observed
= {0};
9638 kmip_init_response_header(&observed
);
9640 int result
= kmip_decode_response_header(&ctx
, &observed
);
9641 result
= report_decoding_test_result(
9644 kmip_compare_response_header(&expected
, &observed
),
9647 kmip_free_response_header(&ctx
, &observed
);
9653 test_encode_cryptographic_parameters_with_digital_signature_fields(TestTracker
*tracker
)
9655 TRACK_TEST(tracker
);
9657 uint8 expected
[216] = {
9658 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0xD0,
9659 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
9660 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9661 0x42, 0x00, 0x5F, 0x05, 0x00, 0x00, 0x00, 0x04,
9662 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
9663 0x42, 0x00, 0x38, 0x05, 0x00, 0x00, 0x00, 0x04,
9664 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9665 0x42, 0x00, 0x83, 0x05, 0x00, 0x00, 0x00, 0x04,
9666 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00,
9667 0x42, 0x00, 0xAE, 0x05, 0x00, 0x00, 0x00, 0x04,
9668 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
9669 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
9670 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9671 0x42, 0x00, 0xC5, 0x06, 0x00, 0x00, 0x00, 0x08,
9672 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
9673 0x42, 0x00, 0xCD, 0x02, 0x00, 0x00, 0x00, 0x04,
9674 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
9675 0x42, 0x00, 0xCE, 0x02, 0x00, 0x00, 0x00, 0x04,
9676 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9677 0x42, 0x00, 0xCF, 0x02, 0x00, 0x00, 0x00, 0x04,
9678 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9679 0x42, 0x00, 0xD2, 0x02, 0x00, 0x00, 0x00, 0x04,
9680 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9681 0x42, 0x00, 0xD0, 0x02, 0x00, 0x00, 0x00, 0x04,
9682 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
9683 0x42, 0x00, 0xD1, 0x02, 0x00, 0x00, 0x00, 0x04,
9684 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
9687 uint8 observed
[216] = {0};
9688 struct kmip ctx
= {0};
9689 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_2
);
9691 struct cryptographic_parameters cp
= {0};
9692 cp
.block_cipher_mode
= KMIP_BLOCK_CBC
;
9693 cp
.padding_method
= KMIP_PAD_PKCS5
;
9694 cp
.hashing_algorithm
= KMIP_HASH_SHA1
;
9695 cp
.key_role_type
= KMIP_ROLE_KEK
;
9697 cp
.digital_signature_algorithm
= KMIP_DIGITAL_SHA256_WITH_RSA
;
9698 cp
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
9699 cp
.random_iv
= KMIP_TRUE
;
9702 cp
.fixed_field_length
= 64;
9703 cp
.invocation_field_length
= 64;
9704 cp
.counter_length
= 256;
9705 cp
.initial_counter_value
= 0;
9707 int result
= kmip_encode_cryptographic_parameters(&ctx
, &cp
);
9708 result
= report_encoding_test_result(
9720 test_decode_cryptographic_parameters_with_digital_signature_fields(TestTracker
*tracker
)
9722 TRACK_TEST(tracker
);
9724 uint8 encoding
[216] = {
9725 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x00, 0xD0,
9726 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
9727 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9728 0x42, 0x00, 0x5F, 0x05, 0x00, 0x00, 0x00, 0x04,
9729 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
9730 0x42, 0x00, 0x38, 0x05, 0x00, 0x00, 0x00, 0x04,
9731 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9732 0x42, 0x00, 0x83, 0x05, 0x00, 0x00, 0x00, 0x04,
9733 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00,
9734 0x42, 0x00, 0xAE, 0x05, 0x00, 0x00, 0x00, 0x04,
9735 0x00, 0x00 ,0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
9736 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
9737 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9738 0x42, 0x00, 0xC5, 0x06, 0x00, 0x00, 0x00, 0x08,
9739 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
9740 0x42, 0x00, 0xCD, 0x02, 0x00, 0x00, 0x00, 0x04,
9741 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
9742 0x42, 0x00, 0xCE, 0x02, 0x00, 0x00, 0x00, 0x04,
9743 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9744 0x42, 0x00, 0xCF, 0x02, 0x00, 0x00, 0x00, 0x04,
9745 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9746 0x42, 0x00, 0xD2, 0x02, 0x00, 0x00, 0x00, 0x04,
9747 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9748 0x42, 0x00, 0xD0, 0x02, 0x00, 0x00, 0x00, 0x04,
9749 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
9750 0x42, 0x00, 0xD1, 0x02, 0x00, 0x00, 0x00, 0x04,
9751 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
9754 struct kmip ctx
= {0};
9755 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_2
);
9757 struct cryptographic_parameters expected
= {0};
9758 kmip_init_cryptographic_parameters(&expected
);
9759 expected
.block_cipher_mode
= KMIP_BLOCK_CBC
;
9760 expected
.padding_method
= KMIP_PAD_PKCS5
;
9761 expected
.hashing_algorithm
= KMIP_HASH_SHA1
;
9762 expected
.key_role_type
= KMIP_ROLE_KEK
;
9764 expected
.digital_signature_algorithm
= KMIP_DIGITAL_SHA256_WITH_RSA
;
9765 expected
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
9766 expected
.random_iv
= KMIP_TRUE
;
9767 expected
.iv_length
= 128;
9768 expected
.tag_length
= 64;
9769 expected
.fixed_field_length
= 64;
9770 expected
.invocation_field_length
= 64;
9771 expected
.counter_length
= 256;
9772 expected
.initial_counter_value
= 0;
9774 struct cryptographic_parameters observed
= {0};
9775 kmip_init_cryptographic_parameters(&observed
);
9777 int result
= kmip_decode_cryptographic_parameters(&ctx
, &observed
);
9778 result
= report_decoding_test_result(
9781 kmip_compare_cryptographic_parameters(&expected
, &observed
),
9784 kmip_free_cryptographic_parameters(&ctx
, &observed
);
9790 The following tests cover features added in KMIP 1.4.
9794 test_encode_cryptographic_parameters_with_mask_fields(TestTracker
*tracker
)
9796 TRACK_TEST(tracker
);
9798 uint8 expected
[312] = {
9799 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x01, 0x30,
9800 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
9801 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9802 0x42, 0x00, 0x5F, 0x05, 0x00, 0x00, 0x00, 0x04,
9803 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
9804 0x42, 0x00, 0x38, 0x05, 0x00, 0x00, 0x00, 0x04,
9805 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9806 0x42, 0x00, 0x83, 0x05, 0x00, 0x00, 0x00, 0x04,
9807 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00,
9808 0x42, 0x00, 0xAE, 0x05, 0x00, 0x00, 0x00, 0x04,
9809 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
9810 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
9811 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9812 0x42, 0x00, 0xC5, 0x06, 0x00, 0x00, 0x00, 0x08,
9813 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
9814 0x42, 0x00, 0xCD, 0x02, 0x00, 0x00, 0x00, 0x04,
9815 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
9816 0x42, 0x00, 0xCE, 0x02, 0x00, 0x00, 0x00, 0x04,
9817 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9818 0x42, 0x00, 0xCF, 0x02, 0x00, 0x00, 0x00, 0x04,
9819 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9820 0x42, 0x00, 0xD2, 0x02, 0x00, 0x00, 0x00, 0x04,
9821 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9822 0x42, 0x00, 0xD0, 0x02, 0x00, 0x00, 0x00, 0x04,
9823 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
9824 0x42, 0x00, 0xD1, 0x02, 0x00, 0x00, 0x00, 0x04,
9825 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9826 0x42, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04,
9827 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
9828 0x42, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x04,
9829 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9830 0x42, 0x01, 0x02, 0x05, 0x00, 0x00, 0x00, 0x04,
9831 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
9832 0x42, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00, 0x18,
9833 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
9834 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
9835 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
9836 0x42, 0x01, 0x04, 0x02, 0x00, 0x00, 0x00, 0x04,
9837 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
9840 uint8 observed
[312] = {0};
9841 struct kmip ctx
= {0};
9842 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_4
);
9845 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
9846 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
9847 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
9849 struct byte_string ps
= {0};
9851 ps
.size
= ARRAY_LENGTH(value
);
9853 struct cryptographic_parameters cp
= {0};
9854 cp
.block_cipher_mode
= KMIP_BLOCK_CBC
;
9855 cp
.padding_method
= KMIP_PAD_PKCS5
;
9856 cp
.hashing_algorithm
= KMIP_HASH_SHA1
;
9857 cp
.key_role_type
= KMIP_ROLE_KEK
;
9859 cp
.digital_signature_algorithm
= KMIP_DIGITAL_SHA256_WITH_RSA
;
9860 cp
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
9861 cp
.random_iv
= KMIP_TRUE
;
9864 cp
.fixed_field_length
= 64;
9865 cp
.invocation_field_length
= 64;
9866 cp
.counter_length
= 256;
9867 cp
.initial_counter_value
= 0;
9869 cp
.salt_length
= 32;
9870 cp
.mask_generator
= KMIP_MASKGEN_MGF1
;
9871 cp
.mask_generator_hashing_algorithm
= KMIP_HASH_SHA256
;
9873 cp
.trailer_field
= 1;
9875 int result
= kmip_encode_cryptographic_parameters(&ctx
, &cp
);
9876 result
= report_encoding_test_result(
9888 test_decode_cryptographic_parameters_with_mask_fields(TestTracker
*tracker
)
9890 TRACK_TEST(tracker
);
9892 uint8 encoding
[312] = {
9893 0x42, 0x00, 0x2B, 0x01, 0x00, 0x00, 0x01, 0x30,
9894 0x42, 0x00, 0x11, 0x05, 0x00, 0x00, 0x00, 0x04,
9895 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9896 0x42, 0x00, 0x5F, 0x05, 0x00, 0x00, 0x00, 0x04,
9897 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
9898 0x42, 0x00, 0x38, 0x05, 0x00, 0x00, 0x00, 0x04,
9899 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9900 0x42, 0x00, 0x83, 0x05, 0x00, 0x00, 0x00, 0x04,
9901 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x00,
9902 0x42, 0x00, 0xAE, 0x05, 0x00, 0x00, 0x00, 0x04,
9903 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00,
9904 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
9905 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
9906 0x42, 0x00, 0xC5, 0x06, 0x00, 0x00, 0x00, 0x08,
9907 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
9908 0x42, 0x00, 0xCD, 0x02, 0x00, 0x00, 0x00, 0x04,
9909 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
9910 0x42, 0x00, 0xCE, 0x02, 0x00, 0x00, 0x00, 0x04,
9911 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9912 0x42, 0x00, 0xCF, 0x02, 0x00, 0x00, 0x00, 0x04,
9913 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9914 0x42, 0x00, 0xD2, 0x02, 0x00, 0x00, 0x00, 0x04,
9915 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
9916 0x42, 0x00, 0xD0, 0x02, 0x00, 0x00, 0x00, 0x04,
9917 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
9918 0x42, 0x00, 0xD1, 0x02, 0x00, 0x00, 0x00, 0x04,
9919 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
9920 0x42, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04,
9921 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
9922 0x42, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00, 0x04,
9923 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
9924 0x42, 0x01, 0x02, 0x05, 0x00, 0x00, 0x00, 0x04,
9925 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
9926 0x42, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00, 0x18,
9927 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
9928 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
9929 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
9930 0x42, 0x01, 0x04, 0x02, 0x00, 0x00, 0x00, 0x04,
9931 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
9934 struct kmip ctx
= {0};
9935 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_4
);
9938 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
9939 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
9940 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
9942 struct byte_string ps
= {0};
9944 ps
.size
= ARRAY_LENGTH(value
);
9946 struct cryptographic_parameters expected
= {0};
9947 kmip_init_cryptographic_parameters(&expected
);
9949 expected
.block_cipher_mode
= KMIP_BLOCK_CBC
;
9950 expected
.padding_method
= KMIP_PAD_PKCS5
;
9951 expected
.hashing_algorithm
= KMIP_HASH_SHA1
;
9952 expected
.key_role_type
= KMIP_ROLE_KEK
;
9954 expected
.digital_signature_algorithm
= KMIP_DIGITAL_SHA256_WITH_RSA
;
9955 expected
.cryptographic_algorithm
= KMIP_CRYPTOALG_RSA
;
9956 expected
.random_iv
= KMIP_TRUE
;
9957 expected
.iv_length
= 128;
9958 expected
.tag_length
= 64;
9959 expected
.fixed_field_length
= 64;
9960 expected
.invocation_field_length
= 64;
9961 expected
.counter_length
= 256;
9962 expected
.initial_counter_value
= 0;
9964 expected
.salt_length
= 32;
9965 expected
.mask_generator
= KMIP_MASKGEN_MGF1
;
9966 expected
.mask_generator_hashing_algorithm
= KMIP_HASH_SHA256
;
9967 expected
.p_source
= &ps
;
9968 expected
.trailer_field
= 1;
9970 struct cryptographic_parameters observed
= {0};
9971 kmip_init_cryptographic_parameters(&observed
);
9973 int result
= kmip_decode_cryptographic_parameters(&ctx
, &observed
);
9974 result
= report_decoding_test_result(
9977 kmip_compare_cryptographic_parameters(&expected
, &observed
),
9980 kmip_free_cryptographic_parameters(&ctx
, &observed
);
9986 test_encode_get_request_payload_with_wrap_type(TestTracker
*tracker
)
9988 TRACK_TEST(tracker
);
9990 uint8 expected
[104] = {
9991 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x60,
9992 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
9993 0x37, 0x63, 0x66, 0x35, 0x32, 0x30, 0x39, 0x62,
9994 0x2D, 0x36, 0x66, 0x66, 0x36, 0x2D, 0x34, 0x34,
9995 0x32, 0x36, 0x2D, 0x38, 0x39, 0x39, 0x65, 0x2D,
9996 0x32, 0x32, 0x62, 0x30, 0x36, 0x37, 0x38, 0x35,
9997 0x39, 0x33, 0x37, 0x32, 0x00, 0x00, 0x00, 0x00,
9998 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
9999 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
10000 0x42, 0x00, 0xF8, 0x05, 0x00, 0x00, 0x00, 0x04,
10001 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10002 0x42, 0x00, 0x41, 0x05, 0x00, 0x00, 0x00, 0x04,
10003 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
10006 uint8 observed
[104] = {0};
10007 struct kmip ctx
= {0};
10008 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_4
);
10010 struct text_string uuid
= {0};
10011 uuid
.value
= "7cf5209b-6ff6-4426-899e-22b067859372";
10014 struct get_request_payload grp
= {0};
10015 grp
.unique_identifier
= &uuid
;
10016 grp
.key_format_type
= KMIP_KEYFORMAT_PKCS1
;
10017 grp
.key_compression_type
= KMIP_KEYCOMP_EC_PUB_UNCOMPRESSED
;
10019 grp
.key_wrap_type
= KMIP_WRAPTYPE_NOT_WRAPPED
;
10021 int result
= kmip_encode_get_request_payload(&ctx
, &grp
);
10022 result
= report_encoding_test_result(
10029 kmip_destroy(&ctx
);
10034 test_encode_request_header_with_correlation_values(TestTracker
*tracker
)
10036 TRACK_TEST(tracker
);
10038 uint8 expected
[280] = {
10039 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x01, 0x10,
10040 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10041 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10042 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10043 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10044 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10045 0x42, 0x00, 0x50, 0x02, 0x00, 0x00, 0x00, 0x04,
10046 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
10047 0x42, 0x01, 0x05, 0x07, 0x00, 0x00, 0x00, 0x08,
10048 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x31,
10049 0x42, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x08,
10050 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x31,
10051 0x42, 0x00, 0x07, 0x06, 0x00, 0x00, 0x00, 0x08,
10052 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
10053 0x42, 0x00, 0xD3, 0x06, 0x00, 0x00, 0x00, 0x08,
10054 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
10055 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10056 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10057 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10058 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
10059 0x42, 0x00, 0x0C, 0x01, 0x00, 0x00, 0x00, 0x40,
10060 0x42, 0x00, 0x23, 0x01, 0x00, 0x00, 0x00, 0x38,
10061 0x42, 0x00, 0x24, 0x05, 0x00, 0x00, 0x00, 0x04,
10062 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10063 0x42, 0x00, 0x25, 0x01, 0x00, 0x00, 0x00, 0x20,
10064 0x42, 0x00, 0x99, 0x07, 0x00, 0x00, 0x00, 0x06,
10065 0x42, 0x61, 0x72, 0x6E, 0x65, 0x79, 0x00, 0x00,
10066 0x42, 0x00, 0xA1, 0x07, 0x00, 0x00, 0x00, 0x07,
10067 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x32, 0x00,
10068 0x42, 0x00, 0x0E, 0x05, 0x00, 0x00, 0x00, 0x04,
10069 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10070 0x42, 0x00, 0x10, 0x06, 0x00, 0x00, 0x00, 0x08,
10071 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
10072 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10073 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00
10076 uint8 observed
[280] = {0};
10077 struct kmip ctx
= {0};
10078 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_4
);
10080 struct protocol_version pv
= {0};
10084 struct text_string username
= {0};
10085 username
.value
= "Barney";
10087 struct text_string password
= {0};
10088 password
.value
= "secret2";
10091 struct username_password_credential upc
= {0};
10092 upc
.username
= &username
;
10093 upc
.password
= &password
;
10095 struct credential c
= {0};
10096 c
.credential_type
= KMIP_CRED_USERNAME_AND_PASSWORD
;
10097 c
.credential_value
= &upc
;
10099 struct authentication a
= {0};
10102 enum attestation_type types
[2] = {
10103 KMIP_ATTEST_TPM_QUOTE
,
10104 KMIP_ATTEST_SAML_ASSERTION
10107 struct text_string ccv
= {0};
10108 ccv
.value
= "client 1";
10111 struct text_string scv
= {0};
10112 scv
.value
= "server 1";
10115 struct request_header rh
= {0};
10116 kmip_init_request_header(&rh
);
10118 rh
.protocol_version
= &pv
;
10119 rh
.maximum_response_size
= 4096;
10120 rh
.asynchronous_indicator
= KMIP_TRUE
;
10121 rh
.attestation_capable_indicator
= KMIP_TRUE
;
10122 rh
.attestation_types
= types
;
10123 rh
.attestation_type_count
= ARRAY_LENGTH(types
);
10124 rh
.authentication
= &a
;
10125 rh
.batch_error_continuation_option
= KMIP_BATCH_CONTINUE
;
10126 rh
.batch_order_option
= KMIP_TRUE
;
10127 rh
.batch_count
= 2;
10129 rh
.client_correlation_value
= &ccv
;
10130 rh
.server_correlation_value
= &scv
;
10132 int result
= kmip_encode_request_header(&ctx
, &rh
);
10133 result
= report_encoding_test_result(
10140 kmip_destroy(&ctx
);
10145 test_encode_response_header_with_correlation_values(TestTracker
*tracker
)
10147 TRACK_TEST(tracker
);
10149 uint8 expected
[184] = {
10150 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0xB0,
10151 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10152 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10153 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10154 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10156 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
10157 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
10158 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
10159 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
10160 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
10161 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
10162 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10163 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10164 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10165 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10166 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
10167 0x42, 0x01, 0x05, 0x07, 0x00, 0x00, 0x00, 0x08,
10168 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x31,
10169 0x42, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x08,
10170 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x31,
10171 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10172 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
10175 uint8 observed
[184] = {0};
10176 struct kmip ctx
= {0};
10177 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_4
);
10179 struct protocol_version pv
= {0};
10183 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
10184 struct byte_string ni
= {0};
10186 ni
.size
= ARRAY_LENGTH(id
);
10188 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10189 struct byte_string nv
= {0};
10191 nv
.size
= ARRAY_LENGTH(value
);
10193 struct nonce n
= {0};
10195 n
.nonce_value
= &nv
;
10197 enum attestation_type types
[2] = {
10198 KMIP_ATTEST_TPM_QUOTE
,
10199 KMIP_ATTEST_SAML_ASSERTION
10202 struct text_string ccv
= {0};
10203 ccv
.value
= "client 1";
10206 struct text_string scv
= {0};
10207 scv
.value
= "server 1";
10210 struct response_header rh
= {0};
10211 kmip_init_response_header(&rh
);
10213 rh
.protocol_version
= &pv
;
10214 rh
.time_stamp
= 1335514341;
10216 rh
.attestation_types
= types
;
10217 rh
.attestation_type_count
= ARRAY_LENGTH(types
);
10218 rh
.batch_count
= 1;
10220 rh
.client_correlation_value
= &ccv
;
10221 rh
.server_correlation_value
= &scv
;
10223 int result
= kmip_encode_response_header(&ctx
, &rh
);
10224 result
= report_encoding_test_result(
10231 kmip_destroy(&ctx
);
10236 test_decode_response_header_with_correlation_values(TestTracker
*tracker
)
10238 TRACK_TEST(tracker
);
10240 uint8 encoding
[184] = {
10241 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0xB0,
10242 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10243 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10244 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10245 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10247 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
10248 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
10249 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
10250 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
10251 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
10252 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
10253 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10254 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10255 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10256 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10257 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
10258 0x42, 0x01, 0x05, 0x07, 0x00, 0x00, 0x00, 0x08,
10259 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x31,
10260 0x42, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x08,
10261 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x31,
10262 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10263 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
10266 struct kmip ctx
= {0};
10267 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_1_4
);
10269 struct protocol_version pv
= {0};
10273 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
10274 struct byte_string ni
= {0};
10276 ni
.size
= ARRAY_LENGTH(id
);
10278 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10279 struct byte_string nv
= {0};
10281 nv
.size
= ARRAY_LENGTH(value
);
10283 struct nonce n
= {0};
10285 n
.nonce_value
= &nv
;
10287 enum attestation_type types
[2] = {
10288 KMIP_ATTEST_TPM_QUOTE
,
10289 KMIP_ATTEST_SAML_ASSERTION
10292 struct text_string ccv
= {0};
10293 ccv
.value
= "client 1";
10296 struct text_string scv
= {0};
10297 scv
.value
= "server 1";
10300 struct response_header expected
= {0};
10301 kmip_init_response_header(&expected
);
10303 expected
.protocol_version
= &pv
;
10304 expected
.time_stamp
= 1335514341;
10305 expected
.nonce
= &n
;
10306 expected
.attestation_types
= types
;
10307 expected
.attestation_type_count
= ARRAY_LENGTH(types
);
10308 expected
.batch_count
= 1;
10310 expected
.client_correlation_value
= &ccv
;
10311 expected
.server_correlation_value
= &scv
;
10313 struct response_header observed
= {0};
10314 kmip_init_response_header(&observed
);
10316 int result
= kmip_decode_response_header(&ctx
, &observed
);
10317 result
= report_decoding_test_result(
10320 kmip_compare_response_header(&expected
, &observed
),
10323 kmip_free_response_header(&ctx
, &observed
);
10324 kmip_destroy(&ctx
);
10329 test_encode_response_header_kmip_2_0(TestTracker
*tracker
)
10331 TRACK_TEST(tracker
);
10333 /* This encoding matches the following set of values:
10336 * Protocol Version Major - 2
10337 * Protocol Version Minor - 0
10338 * Time Stamp - 1335514341
10340 * Nonce ID - 0x01020304
10341 * Nonce Value - 0xFFFFFFFFFFFF
10342 * Server Hashed Password - 301EC144E9C6C4F64C29C01C3E11839C97D6E7D2BC0C5DBC68377B679AE51D4D
10343 * Attestation Type - TPM Quote
10344 * Attestation Type - SAML Assertion
10345 * Client Correlation Value - client 1
10346 * Server Correlation Value - server 1
10349 uint8 expected
[224] = {
10350 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0xD8,
10351 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10352 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10353 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
10354 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10355 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10356 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
10357 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
10358 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
10359 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
10360 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
10361 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
10362 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10363 0x42, 0x01, 0x55, 0x08, 0x00, 0x00, 0x00, 0x20,
10364 0x30, 0x1E, 0xC1, 0x44, 0xE9, 0xC6, 0xC4, 0xF6,
10365 0x4C, 0x29, 0xC0, 0x1C, 0x3E, 0x11, 0x83, 0x9C,
10366 0x97, 0xD6, 0xE7, 0xD2, 0xBC, 0x0C, 0x5D, 0xBC,
10367 0x68, 0x37, 0x7B, 0x67, 0x9A, 0xE5, 0x1D, 0x4D,
10368 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10369 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10370 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10371 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
10372 0x42, 0x01, 0x05, 0x07, 0x00, 0x00, 0x00, 0x08,
10373 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x31,
10374 0x42, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x08,
10375 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x31,
10376 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10377 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
10380 uint8 observed
[224] = {0};
10382 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_2_0
);
10384 ProtocolVersion pv
= {0};
10388 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
10389 ByteString ni
= {0};
10391 ni
.size
= ARRAY_LENGTH(id
);
10393 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10394 ByteString nv
= {0};
10396 nv
.size
= ARRAY_LENGTH(value
);
10400 n
.nonce_value
= &nv
;
10403 0x30, 0x1E, 0xC1, 0x44, 0xE9, 0xC6, 0xC4, 0xF6,
10404 0x4C, 0x29, 0xC0, 0x1C, 0x3E, 0x11, 0x83, 0x9C,
10405 0x97, 0xD6, 0xE7, 0xD2, 0xBC, 0x0C, 0x5D, 0xBC,
10406 0x68, 0x37, 0x7B, 0x67, 0x9A, 0xE5, 0x1D, 0x4D
10408 ByteString shp
= {0};
10410 shp
.size
= ARRAY_LENGTH(hash
);
10412 enum attestation_type types
[2] = {
10413 KMIP_ATTEST_TPM_QUOTE
,
10414 KMIP_ATTEST_SAML_ASSERTION
10417 TextString ccv
= {0};
10418 ccv
.value
= "client 1";
10421 TextString scv
= {0};
10422 scv
.value
= "server 1";
10425 ResponseHeader rh
= {0};
10426 kmip_init_response_header(&rh
);
10428 rh
.protocol_version
= &pv
;
10429 rh
.time_stamp
= 1335514341;
10431 rh
.server_hashed_password
= &shp
;
10432 rh
.attestation_types
= types
;
10433 rh
.attestation_type_count
= ARRAY_LENGTH(types
);
10434 rh
.batch_count
= 1;
10436 rh
.client_correlation_value
= &ccv
;
10437 rh
.server_correlation_value
= &scv
;
10439 int result
= kmip_encode_response_header(&ctx
, &rh
);
10440 result
= report_encoding_test_result(tracker
, &ctx
, expected
, observed
, result
, __func__
);
10442 kmip_destroy(&ctx
);
10447 test_decode_response_header_kmip_2_0(TestTracker
*tracker
)
10449 TRACK_TEST(tracker
);
10451 /* This encoding matches the following set of values:
10454 * Protocol Version Major - 2
10455 * Protocol Version Minor - 0
10456 * Time Stamp - 1335514341
10458 * Nonce ID - 0x01020304
10459 * Nonce Value - 0xFFFFFFFFFFFF
10460 * Server Hashed Password - 301EC144E9C6C4F64C29C01C3E11839C97D6E7D2BC0C5DBC68377B679AE51D4D
10461 * Attestation Type - TPM Quote
10462 * Attestation Type - SAML Assertion
10463 * Client Correlation Value - client 1
10464 * Server Correlation Value - server 1
10467 uint8 encoding
[224] = {
10468 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0xD8,
10469 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10470 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10471 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
10472 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10473 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10474 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
10475 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
10476 0x42, 0x00, 0xC8, 0x01, 0x00, 0x00, 0x00, 0x20,
10477 0x42, 0x00, 0xC9, 0x08, 0x00, 0x00, 0x00, 0x04,
10478 0x01, 0x02, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00,
10479 0x42, 0x00, 0xCA, 0x08, 0x00, 0x00, 0x00, 0x06,
10480 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
10481 0x42, 0x01, 0x55, 0x08, 0x00, 0x00, 0x00, 0x20,
10482 0x30, 0x1E, 0xC1, 0x44, 0xE9, 0xC6, 0xC4, 0xF6,
10483 0x4C, 0x29, 0xC0, 0x1C, 0x3E, 0x11, 0x83, 0x9C,
10484 0x97, 0xD6, 0xE7, 0xD2, 0xBC, 0x0C, 0x5D, 0xBC,
10485 0x68, 0x37, 0x7B, 0x67, 0x9A, 0xE5, 0x1D, 0x4D,
10486 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10487 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10488 0x42, 0x00, 0xC7, 0x05, 0x00, 0x00, 0x00, 0x04,
10489 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
10490 0x42, 0x01, 0x05, 0x07, 0x00, 0x00, 0x00, 0x08,
10491 0x63, 0x6C, 0x69, 0x65, 0x6E, 0x74, 0x20, 0x31,
10492 0x42, 0x01, 0x06, 0x07, 0x00, 0x00, 0x00, 0x08,
10493 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x31,
10494 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10495 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00
10499 kmip_init(&ctx
, encoding
, ARRAY_LENGTH(encoding
), KMIP_2_0
);
10501 ProtocolVersion pv
= {0};
10505 uint8 id
[4] = {0x01, 0x02, 0x03, 0x04};
10506 ByteString ni
= {0};
10508 ni
.size
= ARRAY_LENGTH(id
);
10510 uint8 value
[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
10511 ByteString nv
= {0};
10513 nv
.size
= ARRAY_LENGTH(value
);
10517 n
.nonce_value
= &nv
;
10520 0x30, 0x1E, 0xC1, 0x44, 0xE9, 0xC6, 0xC4, 0xF6,
10521 0x4C, 0x29, 0xC0, 0x1C, 0x3E, 0x11, 0x83, 0x9C,
10522 0x97, 0xD6, 0xE7, 0xD2, 0xBC, 0x0C, 0x5D, 0xBC,
10523 0x68, 0x37, 0x7B, 0x67, 0x9A, 0xE5, 0x1D, 0x4D
10525 ByteString shp
= {0};
10527 shp
.size
= ARRAY_LENGTH(hash
);
10529 enum attestation_type types
[2] = {
10530 KMIP_ATTEST_TPM_QUOTE
,
10531 KMIP_ATTEST_SAML_ASSERTION
10534 TextString ccv
= {0};
10535 ccv
.value
= "client 1";
10538 TextString scv
= {0};
10539 scv
.value
= "server 1";
10542 ResponseHeader expected
= {0};
10543 kmip_init_response_header(&expected
);
10545 expected
.protocol_version
= &pv
;
10546 expected
.time_stamp
= 1335514341;
10547 expected
.nonce
= &n
;
10548 expected
.server_hashed_password
= &shp
;
10549 expected
.attestation_types
= types
;
10550 expected
.attestation_type_count
= ARRAY_LENGTH(types
);
10551 expected
.batch_count
= 1;
10553 expected
.client_correlation_value
= &ccv
;
10554 expected
.server_correlation_value
= &scv
;
10556 ResponseHeader observed
= {0};
10557 kmip_init_response_header(&observed
);
10559 int result
= kmip_decode_response_header(&ctx
, &observed
);
10560 int comparison
= kmip_compare_response_header(&expected
, &observed
);
10563 /* TODO (ph) Reorder these with printing result so that objects are
10564 below function name.
10566 kmip_print_response_header(1, &expected
);
10567 kmip_print_response_header(1, &observed
);
10569 result
= report_decoding_test_result(tracker
, &ctx
, comparison
, result
, __func__
);
10571 kmip_free_response_header(&ctx
, &observed
);
10572 kmip_destroy(&ctx
);
10577 The following tests are taken verbatim from the KMIP 1.1 Test Cases
10578 documentation, available here:
10580 http://docs.oasis-open.org/kmip/testcases/v1.1/kmip-testcases-v1.1.html
10584 test_kmip_1_1_test_suite_3_1_1_0_a(TestTracker
*tracker
)
10586 TRACK_TEST(tracker
);
10588 /* KMIP 1.1 Test Suite - Test 3.1.1.0a */
10589 uint8 expected
[296] = {
10590 0x42, 0x00, 0x78, 0x01, 0x00, 0x00, 0x01, 0x20,
10591 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0x38,
10592 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10593 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10594 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10595 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10596 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10597 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10598 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10599 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0xD8,
10600 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
10601 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10602 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0xC0,
10603 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
10604 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
10605 0x42, 0x00, 0x91, 0x01, 0x00, 0x00, 0x00, 0xA8,
10606 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
10607 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x17,
10608 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
10609 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x41, 0x6C,
10610 0x67, 0x6F, 0x72, 0x69, 0x74, 0x68, 0x6D, 0x00,
10611 0x42, 0x00, 0x0B, 0x05, 0x00, 0x00, 0x00, 0x04,
10612 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
10613 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
10614 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x14,
10615 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
10616 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x4C, 0x65,
10617 0x6E, 0x67, 0x74, 0x68, 0x00, 0x00, 0x00, 0x00,
10618 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
10619 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
10620 0x42, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x30,
10621 0x42, 0x00, 0x0A, 0x07, 0x00, 0x00, 0x00, 0x18,
10622 0x43, 0x72, 0x79, 0x70, 0x74, 0x6F, 0x67, 0x72,
10623 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x55, 0x73,
10624 0x61, 0x67, 0x65, 0x20, 0x4D, 0x61, 0x73, 0x6B,
10625 0x42, 0x00, 0x0B, 0x02, 0x00, 0x00, 0x00, 0x04,
10626 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00
10629 uint8 observed
[296] = {0};
10630 struct kmip ctx
= {0};
10631 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
10633 /* TODO (ph) If protocol version omitted, pull from context? */
10634 struct protocol_version pv
= {0};
10638 struct request_header rh
= {0};
10639 kmip_init_request_header(&rh
);
10641 rh
.protocol_version
= &pv
;
10642 rh
.batch_count
= 1;
10644 struct attribute a
[3] = {0};
10645 for(int i
= 0; i
< 3; i
++)
10647 kmip_init_attribute(&a
[i
]);
10650 enum cryptographic_algorithm algorithm
= KMIP_CRYPTOALG_AES
;
10651 a
[0].type
= KMIP_ATTR_CRYPTOGRAPHIC_ALGORITHM
;
10652 a
[0].value
= &algorithm
;
10654 int32 length
= 128;
10655 a
[1].type
= KMIP_ATTR_CRYPTOGRAPHIC_LENGTH
;
10656 a
[1].value
= &length
;
10658 int32 mask
= KMIP_CRYPTOMASK_ENCRYPT
| KMIP_CRYPTOMASK_DECRYPT
;
10659 a
[2].type
= KMIP_ATTR_CRYPTOGRAPHIC_USAGE_MASK
;
10660 a
[2].value
= &mask
;
10662 struct template_attribute ta
= {0};
10664 ta
.attribute_count
= ARRAY_LENGTH(a
);
10666 struct create_request_payload crp
= {0};
10667 crp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
10668 crp
.template_attribute
= &ta
;
10670 struct request_batch_item rbi
= {0};
10671 kmip_init_request_batch_item(&rbi
);
10672 rbi
.operation
= KMIP_OP_CREATE
;
10673 rbi
.request_payload
= &crp
;
10675 struct request_message rm
= {0};
10676 rm
.request_header
= &rh
;
10677 rm
.batch_items
= &rbi
;
10678 rm
.batch_count
= 1;
10680 int result
= kmip_encode_request_message(&ctx
, &rm
);
10681 result
= report_encoding_test_result(
10688 kmip_destroy(&ctx
);
10693 test_kmip_1_1_test_suite_3_1_1_0_b(TestTracker
*tracker
)
10695 TRACK_TEST(tracker
);
10697 /* KMIP 1.1 Test Suite - Test 3.1.1.0b */
10698 uint8 expected
[200] = {
10699 0x42, 0x00, 0x7B, 0x01, 0x00, 0x00, 0x00, 0xC0,
10700 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x48,
10701 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10702 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10703 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10704 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10705 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10706 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
10707 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
10708 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10709 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10710 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x68,
10711 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
10712 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10713 0x42, 0x00, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x04,
10714 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10715 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x40,
10716 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
10717 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
10718 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
10719 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
10720 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
10721 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
10722 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
10723 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
10726 uint8 observed
[200] = {0};
10727 struct kmip ctx
= {0};
10728 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_0
);
10730 struct protocol_version pv
= {0};
10734 struct response_header rh
= {0};
10735 kmip_init_response_header(&rh
);
10737 rh
.protocol_version
= &pv
;
10738 rh
.time_stamp
= 1335514341;
10739 rh
.batch_count
= 1;
10741 struct text_string uuid
= {0};
10742 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
10745 struct create_response_payload crp
= {0};
10746 crp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
10747 crp
.unique_identifier
= &uuid
;
10749 struct response_batch_item rbi
= {0};
10750 rbi
.operation
= KMIP_OP_CREATE
;
10751 rbi
.result_status
= KMIP_STATUS_SUCCESS
;
10752 rbi
.response_payload
= &crp
;
10754 struct response_message rm
= {0};
10755 rm
.response_header
= &rh
;
10756 rm
.batch_items
= &rbi
;
10757 rm
.batch_count
= 1;
10759 int result
= kmip_encode_response_message(&ctx
, &rm
);
10760 result
= report_encoding_test_result(
10767 kmip_destroy(&ctx
);
10772 test_kmip_1_1_test_suite_3_1_1_1_a(TestTracker
*tracker
)
10774 TRACK_TEST(tracker
);
10776 /* KMIP 1.1 Test Suite - Test 3.1.1.1a */
10777 uint8 expected
[152] = {
10778 0x42, 0x00, 0x78, 0x01, 0x00, 0x00, 0x00, 0x90,
10779 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0x38,
10780 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10781 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10782 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10783 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10784 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10785 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10786 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10787 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x48,
10788 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
10789 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
10790 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
10791 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
10792 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
10793 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
10794 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
10795 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
10796 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
10799 uint8 observed
[152] = {0};
10800 struct kmip ctx
= {0};
10801 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
10803 struct protocol_version pv
= {0};
10807 struct request_header rh
= {0};
10808 kmip_init_request_header(&rh
);
10810 rh
.protocol_version
= &pv
;
10811 rh
.batch_count
= 1;
10813 struct text_string uuid
= {0};
10814 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
10817 struct destroy_request_payload drp
= {0};
10818 drp
.unique_identifier
= &uuid
;
10820 struct request_batch_item rbi
= {0};
10821 kmip_init_request_batch_item(&rbi
);
10822 rbi
.operation
= KMIP_OP_DESTROY
;
10823 rbi
.request_payload
= &drp
;
10825 struct request_message rm
= {0};
10826 rm
.request_header
= &rh
;
10827 rm
.batch_items
= &rbi
;
10828 rm
.batch_count
= 1;
10830 int result
= kmip_encode_request_message(&ctx
, &rm
);
10831 result
= report_encoding_test_result(
10838 kmip_destroy(&ctx
);
10843 test_kmip_1_1_test_suite_3_1_1_1_b(TestTracker
*tracker
)
10845 TRACK_TEST(tracker
);
10847 /* KMIP 1.1 Test Suite - Test 3.1.1.1b */
10848 uint8 expected
[184] = {
10849 0x42, 0x00, 0x7B, 0x01, 0x00, 0x00, 0x00, 0xB0,
10850 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x48,
10851 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10852 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10853 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10854 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10855 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10856 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
10857 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE5,
10858 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10859 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10860 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x58,
10861 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
10862 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
10863 0x42, 0x00, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x04,
10864 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
10865 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0x30,
10866 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
10867 0x66, 0x62, 0x34, 0x62, 0x35, 0x62, 0x39, 0x63,
10868 0x2D, 0x36, 0x31, 0x38, 0x38, 0x2D, 0x34, 0x63,
10869 0x36, 0x33, 0x2D, 0x38, 0x31, 0x34, 0x32, 0x2D,
10870 0x66, 0x65, 0x39, 0x63, 0x33, 0x32, 0x38, 0x31,
10871 0x32, 0x39, 0x66, 0x63, 0x00, 0x00, 0x00, 0x00
10874 uint8 observed
[184] = {0};
10875 struct kmip ctx
= {0};
10876 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
10878 struct protocol_version pv
= {0};
10882 struct response_header rh
= {0};
10883 kmip_init_response_header(&rh
);
10885 rh
.protocol_version
= &pv
;
10886 rh
.time_stamp
= 1335514341;
10887 rh
.batch_count
= 1;
10889 struct text_string uuid
= {0};
10890 uuid
.value
= "fb4b5b9c-6188-4c63-8142-fe9c328129fc";
10893 struct destroy_response_payload drp
= {0};
10894 drp
.unique_identifier
= &uuid
;
10896 struct response_batch_item rbi
= {0};
10897 rbi
.operation
= KMIP_OP_DESTROY
;
10898 rbi
.result_status
= KMIP_STATUS_SUCCESS
;
10899 rbi
.response_payload
= &drp
;
10901 struct response_message rm
= {0};
10902 rm
.response_header
= &rh
;
10903 rm
.batch_items
= &rbi
;
10904 rm
.batch_count
= 1;
10906 int result
= kmip_encode_response_message(&ctx
, &rm
);
10907 result
= report_encoding_test_result(
10914 kmip_destroy(&ctx
);
10919 test_kmip_1_1_test_suite_3_1_3_2_a(TestTracker
*tracker
)
10921 TRACK_TEST(tracker
);
10923 /* KMIP 1.1 Test Suite - Test 3.1.3.2a */
10924 uint8 expected
[152] = {
10925 0x42, 0x00, 0x78, 0x01, 0x00, 0x00, 0x00, 0x90,
10926 0x42, 0x00, 0x77, 0x01, 0x00, 0x00, 0x00, 0x38,
10927 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10928 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10929 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10930 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
10931 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10932 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
10933 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
10934 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0x48,
10935 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
10936 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
10937 0x42, 0x00, 0x79, 0x01, 0x00, 0x00, 0x00, 0x30,
10938 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
10939 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
10940 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
10941 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
10942 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
10943 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00
10946 uint8 observed
[152] = {0};
10947 struct kmip ctx
= {0};
10948 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
10950 struct protocol_version pv
= {0};
10954 struct request_header rh
= {0};
10955 kmip_init_request_header(&rh
);
10957 rh
.protocol_version
= &pv
;
10958 rh
.batch_count
= 1;
10960 struct text_string uuid
= {0};
10961 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
10964 struct get_request_payload grp
= {0};
10965 grp
.unique_identifier
= &uuid
;
10967 struct request_batch_item rbi
= {0};
10968 kmip_init_request_batch_item(&rbi
);
10969 rbi
.operation
= KMIP_OP_GET
;
10970 rbi
.request_payload
= &grp
;
10972 struct request_message rm
= {0};
10973 rm
.request_header
= &rh
;
10974 rm
.batch_items
= &rbi
;
10975 rm
.batch_count
= 1;
10977 int result
= kmip_encode_request_message(&ctx
, &rm
);
10978 result
= report_encoding_test_result(
10985 kmip_destroy(&ctx
);
10990 test_kmip_1_1_test_suite_3_1_3_2_b(TestTracker
*tracker
)
10992 TRACK_TEST(tracker
);
10994 uint8 expected
[304] = {
10995 0x42, 0x00, 0x7B, 0x01, 0x00, 0x00, 0x01, 0x28,
10996 0x42, 0x00, 0x7A, 0x01, 0x00, 0x00, 0x00, 0x48,
10997 0x42, 0x00, 0x69, 0x01, 0x00, 0x00, 0x00, 0x20,
10998 0x42, 0x00, 0x6A, 0x02, 0x00, 0x00, 0x00, 0x04,
10999 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
11000 0x42, 0x00, 0x6B, 0x02, 0x00, 0x00, 0x00, 0x04,
11001 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
11002 0x42, 0x00, 0x92, 0x09, 0x00, 0x00, 0x00, 0x08,
11003 0x00, 0x00, 0x00, 0x00, 0x4F, 0x9A, 0x54, 0xE7,
11004 0x42, 0x00, 0x0D, 0x02, 0x00, 0x00, 0x00, 0x04,
11005 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
11006 0x42, 0x00, 0x0F, 0x01, 0x00, 0x00, 0x00, 0xD0,
11007 0x42, 0x00, 0x5C, 0x05, 0x00, 0x00, 0x00, 0x04,
11008 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x00,
11009 0x42, 0x00, 0x7F, 0x05, 0x00, 0x00, 0x00, 0x04,
11010 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
11011 0x42, 0x00, 0x7C, 0x01, 0x00, 0x00, 0x00, 0xA8,
11012 0x42, 0x00, 0x57, 0x05, 0x00, 0x00, 0x00, 0x04,
11013 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
11014 0x42, 0x00, 0x94, 0x07, 0x00, 0x00, 0x00, 0x24,
11015 0x34, 0x39, 0x61, 0x31, 0x63, 0x61, 0x38, 0x38,
11016 0x2D, 0x36, 0x62, 0x65, 0x61, 0x2D, 0x34, 0x66,
11017 0x62, 0x32, 0x2D, 0x62, 0x34, 0x35, 0x30, 0x2D,
11018 0x37, 0x65, 0x35, 0x38, 0x38, 0x30, 0x32, 0x63,
11019 0x33, 0x30, 0x33, 0x38, 0x00, 0x00, 0x00, 0x00,
11020 0x42, 0x00, 0x8F, 0x01, 0x00, 0x00, 0x00, 0x60,
11021 0x42, 0x00, 0x40, 0x01, 0x00, 0x00, 0x00, 0x58,
11022 0x42, 0x00, 0x42, 0x05, 0x00, 0x00, 0x00, 0x04,
11023 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
11024 0x42, 0x00, 0x45, 0x01, 0x00, 0x00, 0x00, 0x20,
11025 0x42, 0x00, 0x43, 0x08, 0x00, 0x00, 0x00, 0x18,
11026 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
11027 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
11028 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8,
11029 0x42, 0x00, 0x28, 0x05, 0x00, 0x00, 0x00, 0x04,
11030 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
11031 0x42, 0x00, 0x2A, 0x02, 0x00, 0x00, 0x00, 0x04,
11032 0x00, 0x00, 0x00, 0xA8, 0x00, 0x00, 0x00, 0x00
11035 uint8 observed
[304] = {0};
11036 struct kmip ctx
= {0};
11037 kmip_init(&ctx
, observed
, ARRAY_LENGTH(observed
), KMIP_1_1
);
11039 struct protocol_version pv
= {0};
11043 struct response_header rh
= {0};
11044 kmip_init_response_header(&rh
);
11046 rh
.protocol_version
= &pv
;
11047 rh
.time_stamp
= 1335514343;
11048 rh
.batch_count
= 1;
11050 struct text_string uuid
= {0};
11051 uuid
.value
= "49a1ca88-6bea-4fb2-b450-7e58802c3038";
11054 uint8 value
[24] = {
11055 0x73, 0x67, 0x57, 0x80, 0x51, 0x01, 0x2A, 0x6D,
11056 0x13, 0x4A, 0x85, 0x5E, 0x25, 0xC8, 0xCD, 0x5E,
11057 0x4C, 0xA1, 0x31, 0x45, 0x57, 0x29, 0xD3, 0xC8
11060 struct byte_string v
= {0};
11062 v
.size
= ARRAY_LENGTH(value
);
11064 struct key_value kv
= {0};
11065 kv
.key_material
= &v
;
11067 struct key_block kb
= {0};
11068 kb
.key_format_type
= KMIP_KEYFORMAT_RAW
;
11069 kb
.key_value
= &kv
;
11070 kb
.cryptographic_algorithm
= KMIP_CRYPTOALG_TRIPLE_DES
;
11071 kb
.cryptographic_length
= 168;
11073 struct symmetric_key key
= {0};
11074 key
.key_block
= &kb
;
11076 struct get_response_payload grp
= {0};
11077 grp
.object_type
= KMIP_OBJTYPE_SYMMETRIC_KEY
;
11078 grp
.unique_identifier
= &uuid
;
11081 struct response_batch_item rbi
= {0};
11082 rbi
.operation
= KMIP_OP_GET
;
11083 rbi
.result_status
= KMIP_STATUS_SUCCESS
;
11084 rbi
.response_payload
= &grp
;
11086 struct response_message rm
= {0};
11087 rm
.response_header
= &rh
;
11088 rm
.batch_items
= &rbi
;
11089 rm
.batch_count
= 1;
11091 int result
= kmip_encode_response_message(&ctx
, &rm
);
11092 result
= report_encoding_test_result(
11099 kmip_destroy(&ctx
);
11108 TestTracker tracker
= {0};
11113 printf("\nUtility Tests\n");
11114 printf("-------------\n");
11115 test_linked_list_pop(&tracker
);
11116 test_linked_list_push(&tracker
);
11117 test_linked_list_enqueue(&tracker
);
11118 test_buffer_bytes_left(&tracker
);
11119 test_peek_tag(&tracker
);
11120 test_is_attribute_tag(&tracker
);
11121 test_get_enum_string_index(&tracker
);
11122 test_check_enum_value_protection_storage_masks(&tracker
);
11123 test_init_protocol_version(&tracker
);
11124 test_init_request_batch_item(&tracker
);
11125 test_deep_copy_int32(&tracker
);
11126 test_deep_copy_text_string(&tracker
);
11127 test_deep_copy_name(&tracker
);
11128 test_deep_copy_attribute(&tracker
);
11130 printf("\nKMIP 1.0 Feature Tests\n");
11131 printf("----------------------\n");
11132 test_buffer_full_and_resize(&tracker
);
11133 test_is_tag_next(&tracker
);
11134 test_get_num_items_next(&tracker
);
11135 test_get_num_items_next_with_partial_item(&tracker
);
11136 test_get_num_items_next_with_mismatch_item(&tracker
);
11137 test_get_num_items_next_with_no_matches(&tracker
);
11138 test_get_num_items_next_with_non_structures(&tracker
);
11141 test_decode_int8_be(&tracker
);
11142 test_decode_int32_be(&tracker
);
11143 test_decode_int64_be(&tracker
);
11144 test_decode_integer(&tracker
);
11145 test_decode_long(&tracker
);
11146 test_decode_enum(&tracker
);
11147 test_decode_bool(&tracker
);
11148 test_decode_text_string(&tracker
);
11149 test_decode_byte_string(&tracker
);
11150 test_decode_date_time(&tracker
);
11151 test_decode_interval(&tracker
);
11152 test_decode_name(&tracker
);
11153 test_decode_attribute_unique_identifier(&tracker
);
11154 test_decode_attribute_name(&tracker
);
11155 test_decode_attribute_object_type(&tracker
);
11156 test_decode_attribute_cryptographic_algorithm(&tracker
);
11157 test_decode_attribute_cryptographic_length(&tracker
);
11158 test_decode_attribute_operation_policy_name(&tracker
);
11159 test_decode_attribute_cryptographic_usage_mask(&tracker
);
11160 test_decode_attribute_state(&tracker
);
11161 test_decode_template_attribute(&tracker
);
11162 test_decode_protocol_version(&tracker
);
11163 test_decode_key_material_byte_string(&tracker
);
11164 test_decode_key_material_transparent_symmetric_key(&tracker
);
11165 test_decode_key_value(&tracker
);
11166 test_decode_key_value_with_attributes(&tracker
);
11167 test_decode_cryptographic_parameters(&tracker
);
11168 test_decode_encryption_key_information(&tracker
);
11169 test_decode_mac_signature_key_information(&tracker
);
11170 test_decode_key_wrapping_data(&tracker
);
11171 test_decode_key_block_key_value_byte_string(&tracker
);
11172 test_decode_key_block_key_value_structure(&tracker
);
11173 test_decode_symmetric_key(&tracker
);
11174 test_decode_public_key(&tracker
);
11175 test_decode_private_key(&tracker
);
11176 test_decode_key_wrapping_specification(&tracker
);
11177 test_decode_create_request_payload(&tracker
);
11178 test_decode_create_response_payload(&tracker
);
11179 test_decode_create_response_payload_with_template_attribute(&tracker
);
11180 test_decode_get_request_payload(&tracker
);
11181 test_decode_get_response_payload(&tracker
);
11182 test_decode_destroy_request_payload(&tracker
);
11183 test_decode_destroy_response_payload(&tracker
);
11184 test_decode_response_batch_item_get_payload(&tracker
);
11185 test_decode_username_password_credential(&tracker
);
11186 test_decode_credential_username_password_credential(&tracker
);
11187 test_decode_authentication_username_password_credential(&tracker
);
11188 test_decode_request_header(&tracker
);
11189 test_decode_response_header(&tracker
);
11190 test_decode_request_batch_item_get_payload(&tracker
);
11191 test_decode_request_message_get(&tracker
);
11192 test_decode_response_message_get(&tracker
);
11195 test_encode_integer(&tracker
);
11196 test_encode_long(&tracker
);
11197 test_encode_enum(&tracker
);
11198 test_encode_bool(&tracker
);
11199 test_encode_text_string(&tracker
);
11200 test_encode_byte_string(&tracker
);
11201 test_encode_date_time(&tracker
);
11202 test_encode_interval(&tracker
);
11203 test_encode_name(&tracker
);
11204 test_encode_attribute_unique_identifier(&tracker
);
11205 test_encode_attribute_name(&tracker
);
11206 test_encode_attribute_object_type(&tracker
);
11207 test_encode_attribute_cryptographic_algorithm(&tracker
);
11208 test_encode_attribute_cryptographic_length(&tracker
);
11209 test_encode_attribute_operation_policy_name(&tracker
);
11210 test_encode_attribute_cryptographic_usage_mask(&tracker
);
11211 test_encode_attribute_state(&tracker
);
11212 test_encode_protocol_version(&tracker
);
11213 test_encode_cryptographic_parameters(&tracker
);
11214 test_encode_encryption_key_information(&tracker
);
11215 test_encode_mac_signature_key_information(&tracker
);
11216 test_encode_key_wrapping_data(&tracker
);
11217 test_encode_key_material_byte_string(&tracker
);
11218 test_encode_key_material_transparent_symmetric_key(&tracker
);
11219 test_encode_key_value(&tracker
);
11220 test_encode_key_value_with_attributes(&tracker
);
11221 test_encode_key_block_key_value_byte_string(&tracker
);
11222 test_encode_key_block_key_value_structure(&tracker
);
11223 test_encode_symmetric_key(&tracker
);
11224 test_encode_public_key(&tracker
);
11225 test_encode_private_key(&tracker
);
11226 test_encode_key_wrapping_specification(&tracker
);
11227 test_encode_create_request_payload(&tracker
);
11228 test_encode_create_response_payload(&tracker
);
11229 test_encode_create_response_payload_with_template_attribute(&tracker
);
11230 test_encode_get_request_payload(&tracker
);
11231 test_encode_get_request_payload_with_format_compression(&tracker
);
11232 test_encode_get_request_payload_with_wrapping_spec(&tracker
);
11233 test_encode_get_response_payload(&tracker
);
11234 test_encode_destroy_request_payload(&tracker
);
11235 test_encode_destroy_response_payload(&tracker
);
11236 test_encode_username_password_credential(&tracker
);
11237 test_encode_credential_username_password_credential(&tracker
);
11238 test_encode_authentication_username_password_credential(&tracker
);
11239 test_encode_request_header(&tracker
);
11240 test_encode_response_header(&tracker
);
11241 test_encode_request_batch_item_get_payload(&tracker
);
11242 test_encode_response_batch_item_get_payload(&tracker
);
11243 test_encode_request_message_get(&tracker
);
11244 test_encode_response_message_get(&tracker
);
11245 test_encode_template_attribute(&tracker
);
11247 printf("\nKMIP 1.1 Feature Tests\n");
11248 printf("----------------------\n");
11249 test_decode_device_credential(&tracker
);
11250 test_decode_key_wrapping_data_with_encoding_option(&tracker
);
11253 test_encode_device_credential(&tracker
);
11254 test_encode_key_wrapping_data_with_encoding_option(&tracker
);
11255 test_encode_key_wrapping_specification_with_encoding_option(&tracker
);
11257 printf("\nKMIP 1.1 Test Suite Test Cases\n");
11258 printf("------------------------------\n");
11259 test_kmip_1_1_test_suite_3_1_1_0_a(&tracker
);
11260 test_kmip_1_1_test_suite_3_1_1_0_b(&tracker
);
11261 test_kmip_1_1_test_suite_3_1_1_1_a(&tracker
);
11262 test_kmip_1_1_test_suite_3_1_1_1_b(&tracker
);
11263 test_kmip_1_1_test_suite_3_1_3_2_a(&tracker
);
11264 test_kmip_1_1_test_suite_3_1_3_2_b(&tracker
);
11266 printf("\nKMIP 1.2 Feature Tests\n");
11267 printf("----------------------\n");
11268 test_decode_nonce(&tracker
);
11269 test_decode_attestation_credential(&tracker
);
11270 test_decode_response_header_with_attestation_details(&tracker
);
11271 test_decode_cryptographic_parameters_with_digital_signature_fields(&tracker
);
11274 test_encode_nonce(&tracker
);
11275 test_encode_attestation_credential(&tracker
);
11276 test_encode_request_header_with_attestation_details(&tracker
);
11277 test_encode_response_header_with_attestation_details(&tracker
);
11278 test_encode_cryptographic_parameters_with_digital_signature_fields(&tracker
);
11280 printf("\nKMIP 1.4 Feature Tests\n");
11281 printf("----------------------\n");
11282 test_decode_cryptographic_parameters_with_mask_fields(&tracker
);
11283 test_decode_response_header_with_correlation_values(&tracker
);
11286 test_encode_cryptographic_parameters_with_mask_fields(&tracker
);
11287 test_encode_get_request_payload_with_wrap_type(&tracker
);
11288 test_encode_request_header_with_correlation_values(&tracker
);
11289 test_encode_response_header_with_correlation_values(&tracker
);
11291 printf("\nKMIP 2.0 Feature Tests\n");
11292 printf("----------------------\n");
11293 test_decode_protection_storage_masks(&tracker
);
11294 test_decode_attributes(&tracker
);
11295 test_decode_attributes_with_invalid_kmip_version(&tracker
);
11296 test_decode_attribute_v2_unique_identifier(&tracker
);
11297 test_decode_attribute_v2_name(&tracker
);
11298 test_decode_attribute_v2_object_type(&tracker
);
11299 test_decode_attribute_v2_cryptographic_algorithm(&tracker
);
11300 test_decode_attribute_v2_cryptographic_length(&tracker
);
11301 test_decode_attribute_v2_cryptographic_usage_mask(&tracker
);
11302 test_decode_attribute_v2_state(&tracker
);
11303 test_decode_attribute_v2_unsupported_attribute(&tracker
);
11304 test_decode_create_request_payload_kmip_2_0(&tracker
);
11305 test_decode_request_batch_item_get_payload_kmip_2_0(&tracker
);
11306 test_decode_response_header_kmip_2_0(&tracker
);
11309 test_encode_protection_storage_masks(&tracker
);
11310 test_encode_attributes(&tracker
);
11311 test_encode_attributes_with_invalid_kmip_version(&tracker
);
11312 test_encode_attribute_v2_unique_identifier(&tracker
);
11313 test_encode_attribute_v2_name(&tracker
);
11314 test_encode_attribute_v2_object_type(&tracker
);
11315 test_encode_attribute_v2_cryptographic_algorithm(&tracker
);
11316 test_encode_attribute_v2_cryptographic_length(&tracker
);
11317 test_encode_attribute_v2_cryptographic_usage_mask(&tracker
);
11318 test_encode_attribute_v2_state(&tracker
);
11319 test_encode_attribute_v2_unsupported_attribute(&tracker
);
11320 test_encode_create_request_payload_kmip_2_0(&tracker
);
11321 test_encode_request_batch_item_get_payload_kmip_2_0(&tracker
);
11322 test_encode_response_header_kmip_2_0(&tracker
);
11324 printf("\nSummary\n");
11325 printf("================\n");
11326 printf("Total tests: %u\n", tracker
.test_count
);
11327 printf(" PASS: %u\n", tracker
.tests_passed
);
11328 printf(" FAILURE: %u\n", tracker
.tests_failed
);
11330 return(tracker
.tests_failed
);
11334 print_help(const char *app
)
11336 printf("Usage: %s [flag] ...\n\n", app
);
11337 printf("Flags:\n");
11338 printf("-h : print this help info\n");
11339 printf("-i : run the test suite forever\n");
11343 parse_arguments(int argc
,
11348 for(int i
= 1; i
< argc
; i
++)
11350 if(strncmp(argv
[i
], "-h", 2) == 0)
11354 else if(strncmp(argv
[i
], "-i", 2) == 0)
11360 printf("Invalid option: '%s'\n", argv
[i
]);
11361 print_help(argv
[0]);
11370 main(int argc
, char **argv
)
11372 int print_usage
= 0;
11373 int run_forever
= 0;
11375 int error
= parse_arguments(argc
, argv
, &print_usage
, &run_forever
);
11382 print_help(argv
[0]);
11396 results
= run_tests();