summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/ct/cttest.c58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/ct/cttest.c b/src/regress/lib/libcrypto/ct/cttest.c
index f4c5237e5a..a14ae75d89 100644
--- a/src/regress/lib/libcrypto/ct/cttest.c
+++ b/src/regress/lib/libcrypto/ct/cttest.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cttest.c,v 1.1 2021/12/05 13:01:08 jsing Exp $ */ 1/* $OpenBSD: cttest.c,v 1.2 2021/12/20 16:52:26 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2021 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2021 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -62,6 +62,8 @@ const uint8_t scts_asn1[] = {
62 0x49, 0x00, 0xc4, 0x57, 0xb8, 62 0x49, 0x00, 0xc4, 0x57, 0xb8,
63}; 63};
64 64
65const char *sct_log_id1_base64 = "KXm+8J45OSHwVnOfY6V35b5XfZxgCvj5TV0mXCVdx4Q=";
66
65const uint8_t sct_signature1[] = { 67const uint8_t sct_signature1[] = {
66 0x30, 0x46, 0x02, 0x21, 0x00, 0x93, 0xed, 0x3a, 68 0x30, 0x46, 0x02, 0x21, 0x00, 0x93, 0xed, 0x3a,
67 0x65, 0x98, 0x9a, 0x85, 0xf0, 0x3b, 0x3c, 0x26, 69 0x65, 0x98, 0x9a, 0x85, 0xf0, 0x3b, 0x3c, 0x26,
@@ -74,6 +76,12 @@ const uint8_t sct_signature1[] = {
74 0x4e, 0x02, 0xe8, 0xdb, 0x24, 0x65, 0x1e, 0xc8 76 0x4e, 0x02, 0xe8, 0xdb, 0x24, 0x65, 0x1e, 0xc8
75}; 77};
76 78
79const char *sct_signature1_base64 =
80 "BAMASDBGAiEAk+06ZZiahfA7PCb3UpTXkkjCwGTLAfXs921B4L0oVq0CIQDCT5L7oLvvVWeABh"
81 "AH57mxlqepi7LL05xOAujbJGUeyA==";
82
83const char *sct_log_id2_base64 = "b1N2rDHwMRnYmQCkURX/dxUcEdkCwQApBo2yCJo32RM=";
84
77const uint8_t sct_signature2[] = { 85const uint8_t sct_signature2[] = {
78 0x30, 0x44, 0x02, 0x20, 0x26, 0xc9, 0x12, 0x28, 86 0x30, 0x44, 0x02, 0x20, 0x26, 0xc9, 0x12, 0x28,
79 0x70, 0x2d, 0x15, 0x05, 0xa7, 0xa2, 0xea, 0x12, 87 0x70, 0x2d, 0x15, 0x05, 0xa7, 0xa2, 0xea, 0x12,
@@ -86,6 +94,10 @@ const uint8_t sct_signature2[] = {
86 0xa5, 0x49, 0x00, 0xc4, 0x57, 0xb8 94 0xa5, 0x49, 0x00, 0xc4, 0x57, 0xb8
87}; 95};
88 96
97const char *sct_signature2_base64 =
98 "BAMARjBEAiAmyRIocC0VBaei6hIa/zk2X5PfgzZf7Qc4uApA4Y25+gIgYa4rhr2OhmUr+2Ph2n"
99 "ez88UqMrgjHn76fYOlSQDEV7g=";
100
89struct sct_data { 101struct sct_data {
90 uint8_t version; 102 uint8_t version;
91 uint8_t log_id[32]; 103 uint8_t log_id[32];
@@ -336,6 +348,49 @@ ct_sct_test(void)
336 return failed; 348 return failed;
337} 349}
338 350
351static int
352ct_sct_base64_test(void)
353{
354 SCT *sct1 = NULL, *sct2 = NULL;
355 STACK_OF(SCT) *scts = NULL;
356 int failed = 1;
357
358 if ((sct1 = SCT_new_from_base64(SCT_VERSION_V1, sct_log_id1_base64,
359 CT_LOG_ENTRY_TYPE_X509, 1637344157551, "",
360 sct_signature1_base64)) == NULL) {
361 fprintf(stderr, "FAIL: SCT_new_from_base64() failed\n");
362 ERR_print_errors_fp(stderr);
363 goto failure;
364 }
365 if ((sct2 = SCT_new_from_base64(SCT_VERSION_V1, sct_log_id2_base64,
366 CT_LOG_ENTRY_TYPE_X509, 1637344157755, "",
367 sct_signature2_base64)) == NULL) {
368 fprintf(stderr, "FAIL: SCT_new_from_base64() failed\n");
369 ERR_print_errors_fp(stderr);
370 goto failure;
371 }
372 if ((scts = sk_SCT_new_null()) == NULL)
373 goto failure;
374 if (!sk_SCT_push(scts, sct1))
375 goto failure;
376 sct1 = NULL;
377 if (!sk_SCT_push(scts, sct2))
378 goto failure;
379 sct2 = NULL;
380
381 if (!ct_compare_test_scts(scts))
382 goto failure;
383
384 failed = 0;
385
386 failure:
387 SCT_LIST_free(scts);
388 SCT_free(sct1);
389 SCT_free(sct2);
390
391 return failed;
392}
393
339int 394int
340main(int argc, char **argv) 395main(int argc, char **argv)
341{ 396{
@@ -350,6 +405,7 @@ main(int argc, char **argv)
350 405
351 failed |= ct_cert_test(); 406 failed |= ct_cert_test();
352 failed |= ct_sct_test(); 407 failed |= ct_sct_test();
408 failed |= ct_sct_base64_test();
353 409
354 return (failed); 410 return (failed);
355} 411}