From dcabaf1d56d410ba7ddb3dfbab9011bbbea5e6bc Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 5 Apr 2013 23:52:39 +0200 Subject: Our own unit testing framework * Support the TAP protocol * Much cleaner without having to carry around state * First class support for setup/teardown * Port the common tests * Wait on porting other tests until we've merged outstanding code --- trust/tests/Makefile.am | 5 +- trust/tests/test-builder.c | 446 +++++++++++++++--------------------------- trust/tests/test-data.c | 160 --------------- trust/tests/test-data.h | 273 -------------------------- trust/tests/test-index.c | 395 ++++++++++++++++--------------------- trust/tests/test-module.c | 470 +++++++++++++++++++-------------------------- trust/tests/test-parser.c | 219 ++++++++------------- trust/tests/test-persist.c | 155 +++++++-------- trust/tests/test-token.c | 93 +++------ trust/tests/test-trust.c | 152 +++++++++++++++ trust/tests/test-trust.h | 273 ++++++++++++++++++++++++++ 11 files changed, 1127 insertions(+), 1514 deletions(-) delete mode 100644 trust/tests/test-data.c delete mode 100644 trust/tests/test-data.h create mode 100644 trust/tests/test-trust.c create mode 100644 trust/tests/test-trust.h (limited to 'trust') diff --git a/trust/tests/Makefile.am b/trust/tests/Makefile.am index 90b9fb5..240bd7d 100644 --- a/trust/tests/Makefile.am +++ b/trust/tests/Makefile.am @@ -7,18 +7,19 @@ INCLUDES = \ -I$(top_srcdir)/common \ -DDATADIR=\"$(datadir)\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ - $(CUTEST_CFLAGS) + $(TEST_CFLAGS) noinst_LTLIBRARIES = \ libtestdata.la libtestdata_la_SOURCES = \ - test-data.c test-data.h + test-trust.c test-trust.h LDADD = \ $(top_builddir)/trust/libtrust-testable.la \ $(top_builddir)/common/libp11-data.la \ $(top_builddir)/common/libp11-library.la \ + $(top_builddir)/common/libp11-test.la \ $(top_builddir)/common/libp11-common.la \ $(builddir)/libtestdata.la \ $(LIBTASN1_LIBS) \ diff --git a/trust/tests/test-builder.c b/trust/tests/test-builder.c index a875b96..891c722 100644 --- a/trust/tests/test-builder.c +++ b/trust/tests/test-builder.c @@ -33,7 +33,8 @@ */ #include "config.h" -#include "CuTest.h" +#include "test.h" +#include "test-trust.h" #include #include @@ -48,8 +49,6 @@ #include "oid.h" #include "pkcs11x.h" -#include "test-data.h" - struct { p11_builder *builder; p11_index *index; @@ -73,17 +72,17 @@ static CK_BBOOL truev = CK_TRUE; static CK_BBOOL falsev = CK_FALSE; static void -setup (CuTest *cu) +setup (void *unused) { test.builder = p11_builder_new (P11_BUILDER_FLAG_TOKEN); - CuAssertPtrNotNull (cu, test.builder); + assert_ptr_not_null (test.builder); test.index = p11_index_new (p11_builder_build, p11_builder_changed, test.builder); - CuAssertPtrNotNull (cu, test.index); + assert_ptr_not_null (test.index); } static void -teardown (CuTest *cu) +teardown (void *unused) { p11_builder_free (test.builder); p11_index_free (test.index); @@ -91,20 +90,16 @@ teardown (CuTest *cu) } static void -test_get_cache (CuTest *cu) +test_get_cache (void) { p11_asn1_cache *cache; - setup (cu); - cache = p11_builder_get_cache (test.builder); - CuAssertPtrEquals (cu, NULL, p11_asn1_cache_get (cache, "blah", (unsigned char *)"blah", 4)); - - teardown (cu); + assert_ptr_eq (NULL, p11_asn1_cache_get (cache, "blah", (unsigned char *)"blah", 4)); } static void -test_build_data (CuTest *cu) +test_build_data (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -128,21 +123,17 @@ test_build_data (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, check, attrs); + test_check_attrs (check, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_build_certificate (CuTest *cu) +test_build_certificate (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -171,21 +162,17 @@ test_build_certificate (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_build_certificate_empty (CuTest *cu) +test_build_certificate_empty (void) { unsigned char checksum[P11_HASH_SHA1_LEN]; CK_ULONG domain = 0; @@ -223,19 +210,15 @@ test_build_certificate_empty (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_hash_sha1 (checksum, test_cacert3_ca_der, sizeof (test_cacert3_ca_der), NULL); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static const unsigned char entrust_pretend_ca[] = { @@ -312,7 +295,7 @@ static const unsigned char entrust_pretend_ca[] = { }; static void -test_build_certificate_non_ca (CuTest *cu) +test_build_certificate_non_ca (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -329,20 +312,16 @@ test_build_certificate_non_ca (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_build_certificate_v1_ca (CuTest *cu) +test_build_certificate_v1_ca (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -359,20 +338,16 @@ test_build_certificate_v1_ca (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_build_certificate_staple_ca (CuTest *cu) +test_build_certificate_staple_ca (void) { CK_ULONG category = 2; /* CA */ @@ -400,28 +375,24 @@ test_build_certificate_staple_ca (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - /* Add a stapled certificate */ rv = p11_index_add (test.index, stapled, 4, NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* * Even though the certificate is not a valid CA, the presence of the * stapled certificate extension transforms it into a CA. */ - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_build_certificate_no_type (CuTest *cu) +test_build_certificate_no_type (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -432,23 +403,19 @@ test_build_certificate_no_type (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv); + assert_num_eq (CKR_TEMPLATE_INCOMPLETE, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_build_certificate_bad_type (CuTest *cu) +test_build_certificate_bad_type (void) { CK_CERTIFICATE_TYPE type = CKC_WTLS; @@ -462,23 +429,19 @@ test_build_certificate_bad_type (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + assert_num_eq (CKR_TEMPLATE_INCONSISTENT, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_build_extension (CuTest *cu) +test_build_extension (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &certificate_extension, sizeof (certificate_extension) }, @@ -502,16 +465,12 @@ test_build_extension (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, check, attrs); + test_check_attrs (check, attrs); p11_attrs_free (attrs); - - teardown (cu); } /* This certificate has and end date in 2067 */ @@ -542,7 +501,7 @@ static const unsigned char cert_distant_end_date[] = { }; static void -test_build_distant_end_date (CuTest *cu) +test_build_distant_end_date (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -560,20 +519,16 @@ test_build_distant_end_date (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_create_not_settable (CuTest *cu) +test_create_not_settable (void) { /* * CKA_TRUSTED cannot be set by the normal user according to spec @@ -591,25 +546,21 @@ test_create_not_settable (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv); + assert_num_eq (CKR_ATTRIBUTE_READ_ONLY, rv); p11_attrs_free (merge); p11_message_loud (); p11_attrs_free (attrs); - - teardown (cu); } static void -test_create_but_loadable (CuTest *cu) +test_create_but_loadable (void) { /* * CKA_TRUSTED cannot be set on creation, but can be set if we're @@ -627,24 +578,20 @@ test_create_but_loadable (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - p11_index_batch (test.index); attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); - test_check_attrs (cu, input, attrs); + test_check_attrs (input, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_create_unsupported (CuTest *cu) +test_create_unsupported (void) { CK_OBJECT_CLASS klass = CKO_PRIVATE_KEY; @@ -657,23 +604,19 @@ test_create_unsupported (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + assert_num_eq (CKR_TEMPLATE_INCONSISTENT, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_create_generated (CuTest *cu) +test_create_generated (void) { CK_OBJECT_CLASS klass = CKO_NSS_TRUST; @@ -686,23 +629,19 @@ test_create_generated (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + assert_num_eq (CKR_TEMPLATE_INCONSISTENT, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_create_bad_attribute (CuTest *cu) +test_create_bad_attribute (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -715,23 +654,19 @@ test_create_bad_attribute (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + assert_num_eq (CKR_TEMPLATE_INCONSISTENT, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_create_missing_attribute (CuTest *cu) +test_create_missing_attribute (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &certificate_extension, sizeof (certificate_extension) }, @@ -742,23 +677,19 @@ test_create_missing_attribute (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv); + assert_num_eq (CKR_TEMPLATE_INCOMPLETE, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_create_no_class (CuTest *cu) +test_create_no_class (void) { CK_ATTRIBUTE input[] = { { CKA_VALUE, "the value", 9 }, @@ -769,23 +700,19 @@ test_create_no_class (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv); + assert_num_eq (CKR_TEMPLATE_INCOMPLETE, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_create_token_mismatch (CuTest *cu) +test_create_token_mismatch (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -797,23 +724,19 @@ test_create_token_mismatch (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - p11_message_quiet (); attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv); + assert_num_eq (CKR_TEMPLATE_INCONSISTENT, rv); p11_attrs_free (merge); p11_message_loud (); - - teardown (cu); } static void -test_modify_success (CuTest *cu) +test_modify_success (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -839,23 +762,19 @@ test_modify_success (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (modify)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_modify_read_only (CuTest *cu) +test_modify_read_only (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -873,29 +792,25 @@ test_modify_read_only (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - attrs = NULL; merge = p11_attrs_dup (input); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_message_quiet (); merge = p11_attrs_dup (modify); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv); + assert_num_eq (CKR_ATTRIBUTE_READ_ONLY, rv); p11_attrs_free (merge); p11_message_loud (); p11_attrs_free (attrs); - - teardown (cu); } static void -test_modify_unchanged (CuTest *cu) +test_modify_unchanged (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -924,23 +839,19 @@ test_modify_unchanged (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (modify)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, expected, attrs); + test_check_attrs (expected, attrs); p11_attrs_free (attrs); - - teardown (cu); } static void -test_modify_not_modifiable (CuTest *cu) +test_modify_not_modifiable (void) { CK_ATTRIBUTE input[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -958,24 +869,20 @@ test_modify_not_modifiable (CuTest *cu) CK_ATTRIBUTE *merge; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input)); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_message_quiet (); merge = p11_attrs_dup (modify); rv = p11_builder_build (test.builder, test.index, &attrs, merge); - CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv); + assert_num_eq (CKR_ATTRIBUTE_READ_ONLY, rv); p11_attrs_free (merge); p11_message_loud (); p11_attrs_free (attrs); - - teardown (cu); } static CK_ATTRIBUTE cacert3_assert_distrust_server[] = { @@ -1059,7 +966,7 @@ static CK_ATTRIBUTE cacert3_assert_distrust_time[] = { }; static void -test_changed_trusted_certificate (CuTest *cu) +test_changed_trusted_certificate (void) { static CK_ATTRIBUTE cacert3_trusted_certificate[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -1173,38 +1080,34 @@ test_changed_trusted_certificate (CuTest *cu) CK_RV rv; int i; - setup (cu); - /* * A trusted cetrificate, trusted for server and client purposes, * and explicitly rejects the email and timestamping purposes. */ p11_index_batch (test.index); rv = p11_index_take (test.index, p11_attrs_dup (cacert3_trusted_certificate), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = p11_index_take (test.index, p11_attrs_dup (eku_extension_server_and_client), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = p11_index_take (test.index, p11_attrs_dup (reject_extension_email), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); /* The other objects */ for (i = 0; expected[i]; i++) { handle = p11_index_find (test.index, expected[i], 2); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); attrs = p11_index_lookup (test.index, handle); - CuAssertPtrNotNull (cu, attrs); + assert_ptr_not_null (attrs); - test_check_attrs (cu, expected[i], attrs); + test_check_attrs (expected[i], attrs); } - - teardown (cu); } static void -test_changed_distrust_value (CuTest *cu) +test_changed_distrust_value (void) { CK_ATTRIBUTE distrust_cert[] = { { CKA_CLASS, &certificate, sizeof (certificate), }, @@ -1287,37 +1190,33 @@ test_changed_distrust_value (CuTest *cu) CK_RV rv; int i; - setup (cu); - /* * A distrusted certificate with a value, plus some extra * extensions (which should be ignored). */ p11_index_batch (test.index); rv = p11_index_take (test.index, p11_attrs_dup (distrust_cert), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = p11_index_take (test.index, p11_attrs_dup (eku_extension), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = p11_index_take (test.index, p11_attrs_dup (reject_extension), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); /* The other objects */ for (i = 0; expected[i]; i++) { handle = p11_index_find (test.index, expected[i], 2); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); attrs = p11_index_lookup (test.index, handle); - CuAssertPtrNotNull (cu, attrs); + assert_ptr_not_null (attrs); - test_check_attrs (cu, expected[i], attrs); + test_check_attrs (expected[i], attrs); } - - teardown (cu); } static void -test_changed_distrust_serial (CuTest *cu) +test_changed_distrust_serial (void) { CK_ATTRIBUTE distrust_cert[] = { { CKA_CLASS, &certificate, sizeof (certificate), }, @@ -1377,29 +1276,25 @@ test_changed_distrust_serial (CuTest *cu) CK_RV rv; int i; - setup (cu); - /* * A distrusted certificate without a value. */ p11_index_batch (test.index); rv = p11_index_take (test.index, p11_attrs_dup (distrust_cert), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); for (i = 0; expected[i]; i++) { handle = p11_index_find (test.index, expected[i], 2); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); attrs = p11_index_lookup (test.index, handle); - CuAssertPtrNotNull (cu, attrs); - test_check_attrs (cu, expected[i], attrs); + assert_ptr_not_null (attrs); + test_check_attrs (expected[i], attrs); } - - teardown (cu); } static void -test_changed_dup_certificates (CuTest *cu) +test_changed_dup_certificates (void) { static CK_ATTRIBUTE trusted_cert[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -1481,68 +1376,64 @@ test_changed_dup_certificates (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - /* * A trusted certificate, should create trutsed nss trust * and anchor assertions */ p11_index_batch (test.index); rv = p11_index_take (test.index, p11_attrs_dup (trusted_cert), &handle1); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); handle = p11_index_find (test.index, match_nss, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); handle = p11_index_find (test.index, match_assertion, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); handle = p11_index_find (test.index, trusted_nss, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); handle = p11_index_find (test.index, anchor_assertion, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); /* Now we add a distrusted certificate, should update the objects */ p11_index_batch (test.index); rv = p11_index_take (test.index, p11_attrs_dup (distrust_cert), &handle2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); handle = p11_index_find (test.index, trusted_nss, -1); - CuAssertTrue (cu, handle == 0); + assert (handle == 0); handle = p11_index_find (test.index, distrust_nss, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); handle = p11_index_find (test.index, anchor_assertion, -1); - CuAssertTrue (cu, handle == 0); + assert (handle == 0); handle = p11_index_find (test.index, distrust_assertion, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); /* Now remove the trusted cetrificate, should update again */ rv = p11_index_remove (test.index, handle2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); handle = p11_index_find (test.index, trusted_nss, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); handle = p11_index_find (test.index, distrust_nss, -1); - CuAssertTrue (cu, handle == 0); + assert (handle == 0); handle = p11_index_find (test.index, anchor_assertion, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); handle = p11_index_find (test.index, distrust_assertion, -1); - CuAssertTrue (cu, handle == 0); + assert (handle == 0); /* Now remove the original certificate, unknown nss and no assertions */ rv = p11_index_remove (test.index, handle1); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); handle = p11_index_find (test.index, unknown_nss, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); handle = p11_index_find (test.index, match_assertion, -1); - CuAssertTrue (cu, handle == 0); - - teardown (cu); + assert (handle == 0); } static void -test_changed_without_id (CuTest *cu) +test_changed_without_id (void) { static CK_ATTRIBUTE trusted_without_id[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -1568,26 +1459,22 @@ test_changed_without_id (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - p11_index_batch (test.index); rv = p11_index_take (test.index, p11_attrs_dup (trusted_without_id), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); klass = CKO_NSS_TRUST; handle = p11_index_find (test.index, match, -1); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); klass = CKO_X_TRUST_ASSERTION; handle = p11_index_find (test.index, match, -1); - CuAssertTrue (cu, handle != 0); - - teardown (cu); + assert (handle != 0); } static void -test_changed_staple_ca (CuTest *cu) +test_changed_staple_ca (void) { CK_ULONG category = 0; @@ -1616,31 +1503,27 @@ test_changed_staple_ca (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - attrs = NULL; rv = p11_index_take (test.index, p11_attrs_dup (input), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Not a CA at this point, until we staple */ category = 0; - CuAssertTrue (cu, p11_index_find (test.index, match, -1) == 0); + assert (p11_index_find (test.index, match, -1) == 0); /* Add a stapled basic constraint */ rv = p11_index_add (test.index, stapled, 4, NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Now should be a CA */ category = 2; - CuAssertTrue (cu, p11_index_find (test.index, match, -1) != 0); + assert (p11_index_find (test.index, match, -1) != 0); p11_attrs_free (attrs); - - teardown (cu); } static void -test_changed_staple_ku (CuTest *cu) +test_changed_staple_ku (void) { CK_ATTRIBUTE stapled_ds_and_np[] = { { CKA_CLASS, &certificate_extension, sizeof (certificate_extension) }, @@ -1684,74 +1567,55 @@ test_changed_staple_ku (CuTest *cu) CK_ATTRIBUTE *attrs; CK_RV rv; - setup (cu); - p11_index_batch (test.index); rv = p11_index_take (test.index, p11_attrs_dup (input), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = p11_index_take (test.index, p11_attrs_dup (stapled_ds_and_np), NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); p11_index_finish (test.index); handle = p11_index_find (test.index, nss_trust_ds_and_np, 2); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); attrs = p11_index_lookup (test.index, handle); - test_check_attrs (cu, nss_trust_ds_and_np, attrs); - - teardown (cu); + test_check_attrs (nss_trust_ds_and_np, attrs); } int -main (void) +main (int argc, + char *argv[]) { - CuString *output = CuStringNew (); - CuSuite* suite = CuSuiteNew (); - int ret; - - putenv ("P11_KIT_STRICT=1"); - p11_debug_init (); - /* p11_message_quiet (); */ - - SUITE_ADD_TEST (suite, test_get_cache); - SUITE_ADD_TEST (suite, test_build_data); - SUITE_ADD_TEST (suite, test_build_certificate); - SUITE_ADD_TEST (suite, test_build_certificate_empty); - SUITE_ADD_TEST (suite, test_build_certificate_non_ca); - SUITE_ADD_TEST (suite, test_build_certificate_v1_ca); - SUITE_ADD_TEST (suite, test_build_certificate_staple_ca); - SUITE_ADD_TEST (suite, test_build_certificate_no_type); - SUITE_ADD_TEST (suite, test_build_certificate_bad_type); - SUITE_ADD_TEST (suite, test_build_extension); - SUITE_ADD_TEST (suite, test_build_distant_end_date); - SUITE_ADD_TEST (suite, test_create_not_settable); - SUITE_ADD_TEST (suite, test_create_but_loadable); - SUITE_ADD_TEST (suite, test_create_unsupported); - SUITE_ADD_TEST (suite, test_create_generated); - SUITE_ADD_TEST (suite, test_create_bad_attribute); - SUITE_ADD_TEST (suite, test_create_missing_attribute); - SUITE_ADD_TEST (suite, test_create_no_class); - SUITE_ADD_TEST (suite, test_create_token_mismatch); - SUITE_ADD_TEST (suite, test_modify_success); - SUITE_ADD_TEST (suite, test_modify_read_only); - SUITE_ADD_TEST (suite, test_modify_unchanged); - SUITE_ADD_TEST (suite, test_modify_not_modifiable); - - SUITE_ADD_TEST (suite, test_changed_trusted_certificate); - SUITE_ADD_TEST (suite, test_changed_distrust_value); - SUITE_ADD_TEST (suite, test_changed_distrust_serial); - SUITE_ADD_TEST (suite, test_changed_without_id); - SUITE_ADD_TEST (suite, test_changed_staple_ca); - SUITE_ADD_TEST (suite, test_changed_staple_ku); - SUITE_ADD_TEST (suite, test_changed_dup_certificates); - - CuSuiteRun (suite); - CuSuiteSummary (suite, output); - CuSuiteDetails (suite, output); - printf ("%s\n", output->buffer); - ret = suite->failCount; - CuSuiteDelete (suite); - CuStringDelete (output); - - return ret; + p11_fixture (setup, teardown); + p11_test (test_get_cache, "/builder/get_cache"); + p11_test (test_build_data, "/builder/build_data"); + p11_test (test_build_certificate, "/builder/build_certificate"); + p11_test (test_build_certificate_empty, "/builder/build_certificate_empty"); + p11_test (test_build_certificate_non_ca, "/builder/build_certificate_non_ca"); + p11_test (test_build_certificate_v1_ca, "/builder/build_certificate_v1_ca"); + p11_test (test_build_certificate_staple_ca, "/builder/build_certificate_staple_ca"); + p11_test (test_build_certificate_no_type, "/builder/build_certificate_no_type"); + p11_test (test_build_certificate_bad_type, "/builder/build_certificate_bad_type"); + p11_test (test_build_extension, "/builder/build_extension"); + p11_test (test_build_distant_end_date, "/builder/build_distant_end_date"); + p11_test (test_create_not_settable, "/builder/create_not_settable"); + p11_test (test_create_but_loadable, "/builder/create_but_loadable"); + p11_test (test_create_unsupported, "/builder/create_unsupported"); + p11_test (test_create_generated, "/builder/create_generated"); + p11_test (test_create_bad_attribute, "/builder/create_bad_attribute"); + p11_test (test_create_missing_attribute, "/builder/create_missing_attribute"); + p11_test (test_create_no_class, "/builder/create_no_class"); + p11_test (test_create_token_mismatch, "/builder/create_token_mismatch"); + p11_test (test_modify_success, "/builder/modify_success"); + p11_test (test_modify_read_only, "/builder/modify_read_only"); + p11_test (test_modify_unchanged, "/builder/modify_unchanged"); + p11_test (test_modify_not_modifiable, "/builder/modify_not_modifiable"); + + p11_test (test_changed_trusted_certificate, "/builder/changed_trusted_certificate"); + p11_test (test_changed_distrust_value, "/builder/changed_distrust_value"); + p11_test (test_changed_distrust_serial, "/builder/changed_distrust_serial"); + p11_test (test_changed_without_id, "/builder/changed_without_id"); + p11_test (test_changed_staple_ca, "/builder/changed_staple_ca"); + p11_test (test_changed_staple_ku, "/builder/changed_staple_ku"); + p11_test (test_changed_dup_certificates, "/builder/changed_dup_certificates"); + return p11_test_run (argc, argv); } diff --git a/trust/tests/test-data.c b/trust/tests/test-data.c deleted file mode 100644 index 6c55fd0..0000000 --- a/trust/tests/test-data.c +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2012 Red Hat Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * * The names of contributors to this software may not be - * used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * Author: Stef Walter - */ - -#include "config.h" -#include "CuTest.h" - -#include "attrs.h" -#include "test-data.h" - -#include -#include -#include -#include - -void -test_check_object_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *attrs, - CK_OBJECT_CLASS klass, - const char *label) -{ - CK_BBOOL vfalse = CK_FALSE; - - CK_ATTRIBUTE expected[] = { - { CKA_PRIVATE, &vfalse, sizeof (vfalse) }, - { CKA_MODIFIABLE, &vfalse, sizeof (vfalse) }, - { CKA_CLASS, &klass, sizeof (klass) }, - { label ? CKA_LABEL : CKA_INVALID, (void *)label, label ? strlen (label) : 0 }, - { CKA_INVALID }, - }; - - test_check_attrs_msg (cu, file, line, expected, attrs); -} - -void -test_check_cacert3_ca_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *attrs, - const char *label) -{ - CK_CERTIFICATE_TYPE x509 = CKC_X_509; - CK_ULONG category = 2; /* authority */ - - CK_ATTRIBUTE expected[] = { - { CKA_CERTIFICATE_TYPE, &x509, sizeof (x509) }, - { CKA_CERTIFICATE_CATEGORY, &category, sizeof (category) }, - { CKA_VALUE, (void *)test_cacert3_ca_der, sizeof (test_cacert3_ca_der) }, - { CKA_CHECK_VALUE, "\xad\x7c\x3f", 3 }, - { CKA_START_DATE, "20110523", 8 }, - { CKA_END_DATE, "20210520", 8, }, - { CKA_SUBJECT, (void *)test_cacert3_ca_subject, sizeof (test_cacert3_ca_subject) }, - { CKA_ISSUER, (void *)test_cacert3_ca_issuer, sizeof (test_cacert3_ca_issuer) }, - { CKA_SERIAL_NUMBER, (void *)test_cacert3_ca_serial, sizeof (test_cacert3_ca_serial) }, - { CKA_INVALID }, - }; - - test_check_object_msg (cu, file, line, attrs, CKO_CERTIFICATE, label); - test_check_attrs_msg (cu, file, line, expected, attrs); -} - -void -test_check_id_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *expected, - CK_ATTRIBUTE *attr) -{ - CK_ATTRIBUTE *one; - CK_ATTRIBUTE *two; - - one = p11_attrs_find (expected, CKA_ID); - two = p11_attrs_find (attr, CKA_ID); - - test_check_attr_msg (cu, file, line, CKA_INVALID, one, two); -} - -void -test_check_attrs_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *expected, - CK_ATTRIBUTE *attrs) -{ - CK_OBJECT_CLASS klass; - CK_ATTRIBUTE *attr; - - if (!p11_attrs_find_ulong (expected, CKA_CLASS, &klass)) - klass = CKA_INVALID; - - while (!p11_attrs_terminator (expected)) { - attr = p11_attrs_find (attrs, expected->type); - test_check_attr_msg (cu, file, line, klass, expected, attr); - expected++; - } -} - -void -test_check_attr_msg (CuTest *cu, - const char *file, - int line, - CK_OBJECT_CLASS klass, - CK_ATTRIBUTE *expected, - CK_ATTRIBUTE *attr) -{ - char *message; - assert (expected != NULL); - - if (attr == NULL) { - asprintf (&message, "expected %s but found NULL", - p11_attr_to_string (expected, klass)); - CuFail_Line (cu, file, line, "attribute does not match", message); - } - - if (!p11_attr_equal (attr, expected)) { - asprintf (&message, "expected %s but found %s", - p11_attr_to_string (expected, klass), - p11_attr_to_string (attr, klass)); - CuFail_Line (cu, file, line, "attribute does not match", message); - } -} - -void -test_fail_attrs_match (CuTest *cu, - const char *file, - const char *line, - CK_ATTRIBUTE *expect, - CK_ATTRIBUTE *attrs); diff --git a/trust/tests/test-data.h b/trust/tests/test-data.h deleted file mode 100644 index 275dd70..0000000 --- a/trust/tests/test-data.h +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) 2012 Red Hat Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * * The names of contributors to this software may not be - * used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF - * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * Author: Stef Walter - */ - -#include "pkcs11.h" - -#include - -#ifndef TEST_DATA_H_ -#define TEST_DATA_H_ - -#define test_check_object(cu, attrs, klass, label) \ - test_check_object_msg (cu, __FILE__, __LINE__, attrs, klass, label) - -void test_check_object_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *attrs, - CK_OBJECT_CLASS klass, - const char *label); - -#define test_check_cacert3_ca(cu, attrs, label) \ - test_check_cacert3_ca_msg (cu, __FILE__, __LINE__, attrs, label) - -void test_check_cacert3_ca_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *attrs, - const char *label); - -#define test_check_attrs(cu, expected, attrs) \ - test_check_attrs_msg (cu, __FILE__, __LINE__, expected, attrs) - -void test_check_attrs_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *expected, - CK_ATTRIBUTE *attrs); - -#define test_check_attr(cu, expected, attr) \ - test_check_attr_msg (cu, __FILE__, __LINE__, CKA_INVALID, expected, attr) - -void test_check_attr_msg (CuTest *cu, - const char *file, - int line, - CK_OBJECT_CLASS klass, - CK_ATTRIBUTE *expected, - CK_ATTRIBUTE *attr); - -#define test_check_id(cu, expected, attrs) \ - test_check_id_msg (cu, __FILE__, __LINE__, expected, attrs) - -void test_check_id_msg (CuTest *cu, - const char *file, - int line, - CK_ATTRIBUTE *expected, - CK_ATTRIBUTE *attr); - -static const unsigned char test_cacert3_ca_der[] = { - 0x30, 0x82, 0x07, 0x59, 0x30, 0x82, 0x05, 0x41, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, 0x0a, - 0x41, 0x8a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, - 0x00, 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, - 0x6f, 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, - 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, - 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, - 0x43, 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, - 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, - 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, - 0x74, 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x1e, 0x17, 0x0d, - 0x31, 0x31, 0x30, 0x35, 0x32, 0x33, 0x31, 0x37, 0x34, 0x38, 0x30, 0x32, 0x5a, 0x17, 0x0d, 0x32, - 0x31, 0x30, 0x35, 0x32, 0x30, 0x31, 0x37, 0x34, 0x38, 0x30, 0x32, 0x5a, 0x30, 0x54, 0x31, 0x14, - 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, - 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68, - 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, - 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x13, 0x43, - 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x33, 0x20, 0x52, 0x6f, - 0x6f, 0x74, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, - 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, - 0x02, 0x01, 0x00, 0xab, 0x49, 0x35, 0x11, 0x48, 0x7c, 0xd2, 0x26, 0x7e, 0x53, 0x94, 0xcf, 0x43, - 0xa9, 0xdd, 0x28, 0xd7, 0x42, 0x2a, 0x8b, 0xf3, 0x87, 0x78, 0x19, 0x58, 0x7c, 0x0f, 0x9e, 0xda, - 0x89, 0x7d, 0xe1, 0xfb, 0xeb, 0x72, 0x90, 0x0d, 0x74, 0xa1, 0x96, 0x64, 0xab, 0x9f, 0xa0, 0x24, - 0x99, 0x73, 0xda, 0xe2, 0x55, 0x76, 0xc7, 0x17, 0x7b, 0xf5, 0x04, 0xac, 0x46, 0xb8, 0xc3, 0xbe, - 0x7f, 0x64, 0x8d, 0x10, 0x6c, 0x24, 0xf3, 0x61, 0x9c, 0xc0, 0xf2, 0x90, 0xfa, 0x51, 0xe6, 0xf5, - 0x69, 0x01, 0x63, 0xc3, 0x0f, 0x56, 0xe2, 0x4a, 0x42, 0xcf, 0xe2, 0x44, 0x8c, 0x25, 0x28, 0xa8, - 0xc5, 0x79, 0x09, 0x7d, 0x46, 0xb9, 0x8a, 0xf3, 0xe9, 0xf3, 0x34, 0x29, 0x08, 0x45, 0xe4, 0x1c, - 0x9f, 0xcb, 0x94, 0x04, 0x1c, 0x81, 0xa8, 0x14, 0xb3, 0x98, 0x65, 0xc4, 0x43, 0xec, 0x4e, 0x82, - 0x8d, 0x09, 0xd1, 0xbd, 0xaa, 0x5b, 0x8d, 0x92, 0xd0, 0xec, 0xde, 0x90, 0xc5, 0x7f, 0x0a, 0xc2, - 0xe3, 0xeb, 0xe6, 0x31, 0x5a, 0x5e, 0x74, 0x3e, 0x97, 0x33, 0x59, 0xe8, 0xc3, 0x03, 0x3d, 0x60, - 0x33, 0xbf, 0xf7, 0xd1, 0x6f, 0x47, 0xc4, 0xcd, 0xee, 0x62, 0x83, 0x52, 0x6e, 0x2e, 0x08, 0x9a, - 0xa4, 0xd9, 0x15, 0x18, 0x91, 0xa6, 0x85, 0x92, 0x47, 0xb0, 0xae, 0x48, 0xeb, 0x6d, 0xb7, 0x21, - 0xec, 0x85, 0x1a, 0x68, 0x72, 0x35, 0xab, 0xff, 0xf0, 0x10, 0x5d, 0xc0, 0xf4, 0x94, 0xa7, 0x6a, - 0xd5, 0x3b, 0x92, 0x7e, 0x4c, 0x90, 0x05, 0x7e, 0x93, 0xc1, 0x2c, 0x8b, 0xa4, 0x8e, 0x62, 0x74, - 0x15, 0x71, 0x6e, 0x0b, 0x71, 0x03, 0xea, 0xaf, 0x15, 0x38, 0x9a, 0xd4, 0xd2, 0x05, 0x72, 0x6f, - 0x8c, 0xf9, 0x2b, 0xeb, 0x5a, 0x72, 0x25, 0xf9, 0x39, 0x46, 0xe3, 0x72, 0x1b, 0x3e, 0x04, 0xc3, - 0x64, 0x27, 0x22, 0x10, 0x2a, 0x8a, 0x4f, 0x58, 0xa7, 0x03, 0xad, 0xbe, 0xb4, 0x2e, 0x13, 0xed, - 0x5d, 0xaa, 0x48, 0xd7, 0xd5, 0x7d, 0xd4, 0x2a, 0x7b, 0x5c, 0xfa, 0x46, 0x04, 0x50, 0xe4, 0xcc, - 0x0e, 0x42, 0x5b, 0x8c, 0xed, 0xdb, 0xf2, 0xcf, 0xfc, 0x96, 0x93, 0xe0, 0xdb, 0x11, 0x36, 0x54, - 0x62, 0x34, 0x38, 0x8f, 0x0c, 0x60, 0x9b, 0x3b, 0x97, 0x56, 0x38, 0xad, 0xf3, 0xd2, 0x5b, 0x8b, - 0xa0, 0x5b, 0xea, 0x4e, 0x96, 0xb8, 0x7c, 0xd7, 0xd5, 0xa0, 0x86, 0x70, 0x40, 0xd3, 0x91, 0x29, - 0xb7, 0xa2, 0x3c, 0xad, 0xf5, 0x8c, 0xbb, 0xcf, 0x1a, 0x92, 0x8a, 0xe4, 0x34, 0x7b, 0xc0, 0xd8, - 0x6c, 0x5f, 0xe9, 0x0a, 0xc2, 0xc3, 0xa7, 0x20, 0x9a, 0x5a, 0xdf, 0x2c, 0x5d, 0x52, 0x5c, 0xba, - 0x47, 0xd5, 0x9b, 0xef, 0x24, 0x28, 0x70, 0x38, 0x20, 0x2f, 0xd5, 0x7f, 0x29, 0xc0, 0xb2, 0x41, - 0x03, 0x68, 0x92, 0xcc, 0xe0, 0x9c, 0xcc, 0x97, 0x4b, 0x45, 0xef, 0x3a, 0x10, 0x0a, 0xab, 0x70, - 0x3a, 0x98, 0x95, 0x70, 0xad, 0x35, 0xb1, 0xea, 0x85, 0x2b, 0xa4, 0x1c, 0x80, 0x21, 0x31, 0xa9, - 0xae, 0x60, 0x7a, 0x80, 0x26, 0x48, 0x00, 0xb8, 0x01, 0xc0, 0x93, 0x63, 0x55, 0x22, 0x91, 0x3c, - 0x56, 0xe7, 0xaf, 0xdb, 0x3a, 0x25, 0xf3, 0x8f, 0x31, 0x54, 0xea, 0x26, 0x8b, 0x81, 0x59, 0xf9, - 0xa1, 0xd1, 0x53, 0x11, 0xc5, 0x7b, 0x9d, 0x03, 0xf6, 0x74, 0x11, 0xe0, 0x6d, 0xb1, 0x2c, 0x3f, - 0x2c, 0x86, 0x91, 0x99, 0x71, 0x9a, 0xa6, 0x77, 0x8b, 0x34, 0x60, 0xd1, 0x14, 0xb4, 0x2c, 0xac, - 0x9d, 0xaf, 0x8c, 0x10, 0xd3, 0x9f, 0xc4, 0x6a, 0xf8, 0x6f, 0x13, 0xfc, 0x73, 0x59, 0xf7, 0x66, - 0x42, 0x74, 0x1e, 0x8a, 0xe3, 0xf8, 0xdc, 0xd2, 0x6f, 0x98, 0x9c, 0xcb, 0x47, 0x98, 0x95, 0x40, - 0x05, 0xfb, 0xe9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x02, 0x0d, 0x30, 0x82, 0x02, 0x09, - 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x75, 0xa8, 0x71, 0x60, 0x4c, - 0x88, 0x13, 0xf0, 0x78, 0xd9, 0x89, 0x77, 0xb5, 0x6d, 0xc5, 0x89, 0xdf, 0xbc, 0xb1, 0x7a, 0x30, - 0x81, 0xa3, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x81, 0x9b, 0x30, 0x81, 0x98, 0x80, 0x14, 0x16, - 0xb5, 0x32, 0x1b, 0xd4, 0xc7, 0xf3, 0xe0, 0xe6, 0x8e, 0xf3, 0xbd, 0xd2, 0xb0, 0x3a, 0xee, 0xb2, - 0x39, 0x18, 0xd1, 0xa1, 0x7d, 0xa4, 0x7b, 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, - 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, - 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, - 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, 0x43, 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, - 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, - 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, - 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, - 0x72, 0x67, 0x82, 0x01, 0x00, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, - 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x5d, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, - 0x01, 0x01, 0x04, 0x51, 0x30, 0x4f, 0x30, 0x23, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, - 0x30, 0x01, 0x86, 0x17, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, - 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x30, 0x28, 0x06, 0x08, 0x2b, - 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x1c, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, - 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x63, - 0x61, 0x2e, 0x63, 0x72, 0x74, 0x30, 0x4a, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x43, 0x30, 0x41, - 0x30, 0x3f, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0x90, 0x4a, 0x30, 0x33, 0x30, 0x31, - 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, 0x25, 0x68, 0x74, 0x74, 0x70, - 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, - 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x70, 0x68, 0x70, 0x3f, 0x69, 0x64, 0x3d, 0x31, - 0x30, 0x30, 0x34, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x08, 0x04, 0x27, - 0x16, 0x25, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, - 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x70, 0x68, - 0x70, 0x3f, 0x69, 0x64, 0x3d, 0x31, 0x30, 0x30, 0x50, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, - 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x43, 0x16, 0x41, 0x54, 0x6f, 0x20, 0x67, 0x65, 0x74, 0x20, 0x79, - 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e, 0x20, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, - 0x61, 0x74, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x46, 0x52, 0x45, 0x45, 0x2c, 0x20, 0x67, 0x6f, - 0x20, 0x74, 0x6f, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, - 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, - 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x29, 0x28, 0x85, - 0xae, 0x44, 0xa9, 0xb9, 0xaf, 0xa4, 0x79, 0x13, 0xf0, 0xa8, 0xa3, 0x2b, 0x97, 0x60, 0xf3, 0x5c, - 0xee, 0xe3, 0x2f, 0xc1, 0xf6, 0xe2, 0x66, 0xa0, 0x11, 0xae, 0x36, 0x37, 0x3a, 0x76, 0x15, 0x04, - 0x53, 0xea, 0x42, 0xf5, 0xf9, 0xea, 0xc0, 0x15, 0xd8, 0xa6, 0x82, 0xd9, 0xe4, 0x61, 0xae, 0x72, - 0x0b, 0x29, 0x5c, 0x90, 0x43, 0xe8, 0x41, 0xb2, 0xe1, 0x77, 0xdb, 0x02, 0x13, 0x44, 0x78, 0x47, - 0x55, 0xaf, 0x58, 0xfc, 0xcc, 0x98, 0xf6, 0x45, 0xb9, 0xd1, 0x20, 0xf8, 0xd8, 0x21, 0x07, 0xfe, - 0x6d, 0xaa, 0x73, 0xd4, 0xb3, 0xc6, 0x07, 0xe9, 0x09, 0x85, 0xcc, 0x3b, 0xf2, 0xb6, 0xbe, 0x2c, - 0x1c, 0x25, 0xd5, 0x71, 0x8c, 0x39, 0xb5, 0x2e, 0xea, 0xbe, 0x18, 0x81, 0xba, 0xb0, 0x93, 0xb8, - 0x0f, 0xe3, 0xe6, 0xd7, 0x26, 0x8c, 0x31, 0x5a, 0x72, 0x03, 0x84, 0x52, 0xe6, 0xa6, 0xf5, 0x33, - 0x22, 0x45, 0x0a, 0xc8, 0x0b, 0x0d, 0x8a, 0xb8, 0x36, 0x6f, 0x90, 0x09, 0xa1, 0xab, 0xbd, 0xd7, - 0xd5, 0x4e, 0x2e, 0x71, 0xa2, 0xd4, 0xae, 0xfa, 0xa7, 0x54, 0x2b, 0xeb, 0x35, 0x8d, 0x5a, 0xb7, - 0x54, 0x88, 0x2f, 0xee, 0x74, 0x9f, 0xed, 0x48, 0x16, 0xca, 0x0d, 0x48, 0xd0, 0x94, 0xd3, 0xac, - 0xa4, 0xa2, 0xf6, 0x24, 0xdf, 0x92, 0xe3, 0xbd, 0xeb, 0x43, 0x40, 0x91, 0x6e, 0x1c, 0x18, 0x8e, - 0x56, 0xb4, 0x82, 0x12, 0xf3, 0xa9, 0x93, 0x9f, 0xd4, 0xbc, 0x9c, 0xad, 0x9c, 0x75, 0xee, 0x5a, - 0x97, 0x1b, 0x95, 0xe7, 0x74, 0x2d, 0x1c, 0x0f, 0xb0, 0x2c, 0x97, 0x9f, 0xfb, 0xa9, 0x33, 0x39, - 0x7a, 0xe7, 0x03, 0x3a, 0x92, 0x8e, 0x22, 0xf6, 0x8c, 0x0d, 0xe4, 0xd9, 0x7e, 0x0d, 0x76, 0x18, - 0xf7, 0x01, 0xf9, 0xef, 0x96, 0x96, 0xa2, 0x55, 0x73, 0xc0, 0x3c, 0x71, 0xb4, 0x1d, 0x1a, 0x56, - 0x43, 0xb7, 0xc3, 0x0a, 0x8d, 0x72, 0xfc, 0xe2, 0x10, 0x09, 0x0b, 0x41, 0xce, 0x8c, 0x94, 0xa0, - 0xf9, 0x03, 0xfd, 0x71, 0x73, 0x4b, 0x8a, 0x57, 0x33, 0xe5, 0x8e, 0x74, 0x7e, 0x15, 0x01, 0x00, - 0xe6, 0xcc, 0x4a, 0x1c, 0xe7, 0x7f, 0x95, 0x19, 0x2d, 0xc5, 0xa5, 0x0c, 0x8b, 0xbb, 0xb5, 0xed, - 0x85, 0xb3, 0x5c, 0xd3, 0xdf, 0xb8, 0xb9, 0xf2, 0xca, 0xc7, 0x0d, 0x01, 0x14, 0xac, 0x70, 0x58, - 0xc5, 0x8c, 0x8d, 0x33, 0xd4, 0x9d, 0x66, 0xa3, 0x1a, 0x50, 0x95, 0x23, 0xfc, 0x48, 0xe0, 0x06, - 0x43, 0x12, 0xd9, 0xcd, 0xa7, 0x86, 0x39, 0x2f, 0x36, 0x72, 0xa3, 0x80, 0x10, 0xe4, 0xe1, 0xf3, - 0xd1, 0xcb, 0x5b, 0x1a, 0xc0, 0xe4, 0x80, 0x9a, 0x7c, 0x13, 0x73, 0x06, 0x4f, 0xdb, 0xa3, 0x6b, - 0x24, 0x0a, 0xba, 0xb3, 0x1c, 0xbc, 0x4a, 0x78, 0xbb, 0xe5, 0xe3, 0x75, 0x38, 0xa5, 0x48, 0xa7, - 0xa2, 0x1e, 0xaf, 0x76, 0xd4, 0x5e, 0xf7, 0x38, 0x86, 0x56, 0x5a, 0x89, 0xce, 0xd6, 0xc3, 0xa7, - 0x79, 0xb2, 0x52, 0xa0, 0xc6, 0xf1, 0x85, 0xb4, 0x25, 0x8c, 0xf2, 0x3f, 0x96, 0xb3, 0x10, 0xd9, - 0x8d, 0x6c, 0x57, 0x3b, 0x9f, 0x6f, 0x86, 0x3a, 0x18, 0x82, 0x22, 0x36, 0xc8, 0xb0, 0x91, 0x38, - 0xdb, 0x2a, 0xa1, 0x93, 0xaa, 0x84, 0x3f, 0xf5, 0x27, 0x65, 0xae, 0x73, 0xd5, 0xc8, 0xd5, 0xd3, - 0x77, 0xea, 0x4b, 0x9d, 0xc7, 0x41, 0xbb, 0xc7, 0xc0, 0xe3, 0xa0, 0x3f, 0xe4, 0x7d, 0xa4, 0x8d, - 0x73, 0xe6, 0x12, 0x4b, 0xdf, 0xa1, 0x73, 0x73, 0x73, 0x3a, 0x80, 0xe8, 0xd5, 0xcb, 0x8e, 0x2f, - 0xcb, 0xea, 0x13, 0xa7, 0xd6, 0x41, 0x8b, 0xac, 0xfa, 0x3c, 0x89, 0xd7, 0x24, 0xf5, 0x4e, 0xb4, - 0xe0, 0x61, 0x92, 0xb7, 0xf3, 0x37, 0x98, 0xc4, 0xbe, 0x96, 0xa3, 0xb7, 0x8a, -}; - -static const char test_cacert3_ca_subject[] = { - 0x30, 0x54, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x43, 0x41, 0x63, - 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, - 0x0b, 0x13, 0x15, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, - 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, - 0x03, 0x13, 0x13, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, - 0x33, 0x20, 0x52, 0x6f, 0x6f, 0x74, -}; - -static const char test_cacert3_ca_issuer[] = { - 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, 0x6f, - 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68, - 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, - 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, 0x43, - 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x41, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, - 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, -}; - -static const char test_cacert3_ca_serial[] = { - 0x02, 0x03, 0x0a, 0x41, 0x8a, -}; - -static const unsigned char verisign_v1_ca[] = { - 0x30, 0x82, 0x02, 0x3c, 0x30, 0x82, 0x01, 0xa5, 0x02, 0x10, 0x3f, 0x69, 0x1e, 0x81, 0x9c, 0xf0, - 0x9a, 0x4a, 0xf3, 0x73, 0xff, 0xb9, 0x48, 0xa2, 0xe4, 0xdd, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, - 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, 0x06, - 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, - 0x0a, 0x13, 0x0e, 0x56, 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, 0x63, - 0x2e, 0x31, 0x37, 0x30, 0x35, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2e, 0x43, 0x6c, 0x61, 0x73, - 0x73, 0x20, 0x31, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x50, 0x72, 0x69, 0x6d, 0x61, - 0x72, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x39, 0x36, - 0x30, 0x31, 0x32, 0x39, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x38, 0x30, - 0x38, 0x30, 0x32, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, - 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, - 0x04, 0x0a, 0x13, 0x0e, 0x56, 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, - 0x63, 0x2e, 0x31, 0x37, 0x30, 0x35, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2e, 0x43, 0x6c, 0x61, - 0x73, 0x73, 0x20, 0x31, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x50, 0x72, 0x69, 0x6d, - 0x61, 0x72, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x81, 0x9f, 0x30, 0x0d, - 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, - 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xe5, 0x19, 0xbf, 0x6d, 0xa3, 0x56, 0x61, 0x2d, - 0x99, 0x48, 0x71, 0xf6, 0x67, 0xde, 0xb9, 0x8d, 0xeb, 0xb7, 0x9e, 0x86, 0x80, 0x0a, 0x91, 0x0e, - 0xfa, 0x38, 0x25, 0xaf, 0x46, 0x88, 0x82, 0xe5, 0x73, 0xa8, 0xa0, 0x9b, 0x24, 0x5d, 0x0d, 0x1f, - 0xcc, 0x65, 0x6e, 0x0c, 0xb0, 0xd0, 0x56, 0x84, 0x18, 0x87, 0x9a, 0x06, 0x9b, 0x10, 0xa1, 0x73, - 0xdf, 0xb4, 0x58, 0x39, 0x6b, 0x6e, 0xc1, 0xf6, 0x15, 0xd5, 0xa8, 0xa8, 0x3f, 0xaa, 0x12, 0x06, - 0x8d, 0x31, 0xac, 0x7f, 0xb0, 0x34, 0xd7, 0x8f, 0x34, 0x67, 0x88, 0x09, 0xcd, 0x14, 0x11, 0xe2, - 0x4e, 0x45, 0x56, 0x69, 0x1f, 0x78, 0x02, 0x80, 0xda, 0xdc, 0x47, 0x91, 0x29, 0xbb, 0x36, 0xc9, - 0x63, 0x5c, 0xc5, 0xe0, 0xd7, 0x2d, 0x87, 0x7b, 0xa1, 0xb7, 0x32, 0xb0, 0x7b, 0x30, 0xba, 0x2a, - 0x2f, 0x31, 0xaa, 0xee, 0xa3, 0x67, 0xda, 0xdb, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, - 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, - 0x58, 0x15, 0x29, 0x39, 0x3c, 0x77, 0xa3, 0xda, 0x5c, 0x25, 0x03, 0x7c, 0x60, 0xfa, 0xee, 0x09, - 0x99, 0x3c, 0x27, 0x10, 0x70, 0xc8, 0x0c, 0x09, 0xe6, 0xb3, 0x87, 0xcf, 0x0a, 0xe2, 0x18, 0x96, - 0x35, 0x62, 0xcc, 0xbf, 0x9b, 0x27, 0x79, 0x89, 0x5f, 0xc9, 0xc4, 0x09, 0xf4, 0xce, 0xb5, 0x1d, - 0xdf, 0x2a, 0xbd, 0xe5, 0xdb, 0x86, 0x9c, 0x68, 0x25, 0xe5, 0x30, 0x7c, 0xb6, 0x89, 0x15, 0xfe, - 0x67, 0xd1, 0xad, 0xe1, 0x50, 0xac, 0x3c, 0x7c, 0x62, 0x4b, 0x8f, 0xba, 0x84, 0xd7, 0x12, 0x15, - 0x1b, 0x1f, 0xca, 0x5d, 0x0f, 0xc1, 0x52, 0x94, 0x2a, 0x11, 0x99, 0xda, 0x7b, 0xcf, 0x0c, 0x36, - 0x13, 0xd5, 0x35, 0xdc, 0x10, 0x19, 0x59, 0xea, 0x94, 0xc1, 0x00, 0xbf, 0x75, 0x8f, 0xd9, 0xfa, - 0xfd, 0x76, 0x04, 0xdb, 0x62, 0xbb, 0x90, 0x6a, 0x03, 0xd9, 0x46, 0x35, 0xd9, 0xf8, 0x7c, 0x5b, -}; - -#endif /* TEST_DATA_H_ */ diff --git a/trust/tests/test-index.c b/trust/tests/test-index.c index 8405061..85c44b7 100644 --- a/trust/tests/test-index.c +++ b/trust/tests/test-index.c @@ -33,8 +33,10 @@ */ #include "config.h" -#include "CuTest.h" +#include "test.h" +#include "test-trust.h" +#include #include #include #include @@ -44,28 +46,26 @@ #include "index.h" #include "message.h" -#include "test-data.h" - struct { p11_index *index; } test; static void -setup (CuTest *cu) +setup (void *unused) { test.index = p11_index_new (NULL, NULL, NULL); - CuAssertPtrNotNull (cu, test.index); + assert_ptr_not_null (test.index); } static void -teardown (CuTest *cu) +teardown (void *unused) { p11_index_free (test.index); memset (&test, 0, sizeof (test)); } static void -test_take_lookup (CuTest *cu) +test_take_lookup (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -78,26 +78,22 @@ test_take_lookup (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - attrs = p11_attrs_dup (original); rv = p11_index_take (test.index, attrs, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - test_check_attrs (cu, original, check); + test_check_attrs (original, check); check = p11_index_lookup (test.index, 1UL); - CuAssertPtrEquals (cu, NULL, check); + assert_ptr_eq (NULL, check); check = p11_index_lookup (test.index, 0UL); - CuAssertPtrEquals (cu, NULL, check); - - teardown (cu); + assert_ptr_eq (NULL, check); } static void -test_add_lookup (CuTest *cu) +test_add_lookup (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -109,19 +105,15 @@ test_add_lookup (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - rv = p11_index_add (test.index, original, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - test_check_attrs (cu, original, check); - - teardown (cu); + test_check_attrs (original, check); } static void -test_size (CuTest *cu) +test_size (void) { static CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -131,20 +123,16 @@ test_size (CuTest *cu) CK_RV rv; - setup (cu); - rv = p11_index_add (test.index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = p11_index_add (test.index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = p11_index_add (test.index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); - - CuAssertIntEquals (cu, 3, p11_index_size (test.index)); + assert (rv == CKR_OK); - teardown (cu); + assert_num_eq (3, p11_index_size (test.index)); } static int @@ -162,7 +150,7 @@ compar_ulong (const void *one, } static void -test_snapshot (CuTest *cu) +test_snapshot (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -175,29 +163,26 @@ test_snapshot (CuTest *cu) CK_OBJECT_HANDLE *snapshot; int i; - setup (cu); - for (i = 0; i < NUM; i++) p11_index_add (test.index, original, 2, expected + i); snapshot = p11_index_snapshot (test.index, NULL, NULL, 0); - CuAssertPtrNotNull (cu, snapshot); + assert_ptr_not_null (snapshot); for (i = 0; i < NUM; i++) - CuAssertTrue (cu, snapshot[i] != 0); - CuAssertTrue (cu, snapshot[NUM] == 0); + assert (snapshot[i] != 0); + assert (snapshot[NUM] == 0); qsort (snapshot, NUM, sizeof (CK_OBJECT_HANDLE), compar_ulong); for (i = 0; i < NUM; i++) - CuAssertIntEquals (cu, expected[i], snapshot[i]); + assert_num_eq (expected[i], snapshot[i]); free (snapshot); - teardown (cu); } static void -test_snapshot_base (CuTest *cu) +test_snapshot_base (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -211,31 +196,28 @@ test_snapshot_base (CuTest *cu) CK_RV rv; int i; - setup (cu); - for (i = 0; i < NUM; i++) { rv = p11_index_add (test.index, original, 2, expected + i); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); } snapshot = p11_index_snapshot (test.index, test.index, NULL, 0); - CuAssertPtrNotNull (cu, snapshot); + assert_ptr_not_null (snapshot); for (i = 0; i < NUM * 2; i++) - CuAssertTrue (cu, snapshot[i] != 0); - CuAssertTrue (cu, snapshot[NUM * 2] == 0); + assert (snapshot[i] != 0); + assert (snapshot[NUM * 2] == 0); qsort (snapshot, NUM * 2, sizeof (CK_OBJECT_HANDLE), compar_ulong); for (i = 0; i < NUM * 2; i++) - CuAssertIntEquals (cu, expected[i / 2], snapshot[i]); + assert_num_eq (expected[i / 2], snapshot[i]); free (snapshot); - teardown (cu); } static void -test_remove (CuTest *cu) +test_remove (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -248,29 +230,25 @@ test_remove (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - attrs = p11_attrs_dup (original); rv = p11_index_take (test.index, attrs, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - CuAssertPtrEquals (cu, attrs, check); + assert_ptr_eq (attrs, check); rv = p11_index_remove (test.index, 1UL); - CuAssertTrue (cu, rv == CKR_OBJECT_HANDLE_INVALID); + assert (rv == CKR_OBJECT_HANDLE_INVALID); rv = p11_index_remove (test.index, handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - CuAssertPtrEquals (cu, NULL, check); - - teardown (cu); + assert_ptr_eq (NULL, check); } static void -test_set (CuTest *cu) +test_set (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -291,29 +269,25 @@ test_set (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - attrs = p11_attrs_dup (original); rv = p11_index_take (test.index, attrs, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - test_check_attrs (cu, original, check); + test_check_attrs (original, check); rv = p11_index_set (test.index, handle, &change, 1); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - test_check_attrs (cu, changed, check); + test_check_attrs (changed, check); rv = p11_index_set (test.index, 1UL, &change, 1); - CuAssertTrue (cu, rv == CKR_OBJECT_HANDLE_INVALID); - - teardown (cu); + assert (rv == CKR_OBJECT_HANDLE_INVALID); } static void -test_update (CuTest *cu) +test_update (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -334,31 +308,27 @@ test_update (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - attrs = p11_attrs_dup (original); rv = p11_index_take (test.index, attrs, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - test_check_attrs (cu, original, check); + test_check_attrs (original, check); attrs = p11_attrs_build (NULL, &change, NULL); rv = p11_index_update (test.index, handle, attrs); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (test.index, handle); - test_check_attrs (cu, changed, check); + test_check_attrs (changed, check); attrs = p11_attrs_build (NULL, &change, NULL); rv = p11_index_update (test.index, 1L, attrs); - CuAssertTrue (cu, rv == CKR_OBJECT_HANDLE_INVALID); - - teardown (cu); + assert (rv == CKR_OBJECT_HANDLE_INVALID); } static void -test_find (CuTest *tc) +test_find (void) { CK_ATTRIBUTE first[] = { { CKA_LABEL, "yay", 3 }, @@ -399,31 +369,27 @@ test_find (CuTest *tc) CK_OBJECT_HANDLE two; CK_OBJECT_HANDLE three; - setup (tc); - p11_index_add (test.index, first, 2, &one); p11_index_add (test.index, second, 2, &two); p11_index_add (test.index, third, 2, &three); check = p11_index_find (test.index, match3, -1); - CuAssertIntEquals (tc, three, check); + assert_num_eq (three, check); check = p11_index_find (test.index, match3, 1); - CuAssertIntEquals (tc, three, check); + assert_num_eq (three, check); check = p11_index_find (test.index, match_any, -1); - CuAssertTrue (tc, check == one || check == two || check == three); + assert (check == one || check == two || check == three); check = p11_index_find (test.index, match_any, 1); - CuAssertTrue (tc, check == one || check == two || check == three); + assert (check == one || check == two || check == three); check = p11_index_find (test.index, match_none, -1); - CuAssertIntEquals (tc, 0, check); + assert_num_eq (0, check); check = p11_index_find (test.index, match_none, 2); - CuAssertIntEquals (tc, 0, check); - - teardown (tc); + assert_num_eq (0, check); } static bool @@ -464,7 +430,7 @@ handles_are (CK_OBJECT_HANDLE *handles, } static void -test_find_all (CuTest *tc) +test_find_all (void) { CK_ATTRIBUTE first[] = { { CKA_LABEL, "odd", 3 }, @@ -513,44 +479,40 @@ test_find_all (CuTest *tc) CK_OBJECT_HANDLE two; CK_OBJECT_HANDLE three; - setup (tc); - p11_index_add (test.index, first, 3, &one); p11_index_add (test.index, second, 3, &two); p11_index_add (test.index, third, 3, &three); check = p11_index_find_all (test.index, match_3, -1); - CuAssertTrue (tc, handles_are (check, three, 0UL)); + assert (handles_are (check, three, 0UL)); free (check); check = p11_index_find_all (test.index, match_none, -1); - CuAssertTrue (tc, handles_are (check, 0UL)); + assert (handles_are (check, 0UL)); free (check); check = p11_index_find_all (test.index, match_odd, -1); - CuAssertTrue (tc, handles_are (check, one, three, 0UL)); + assert (handles_are (check, one, three, 0UL)); free (check); check = p11_index_find_all (test.index, match_any, -1); - CuAssertTrue (tc, handles_are (check, one, two, three, 0UL)); + assert (handles_are (check, one, two, three, 0UL)); free (check); check = p11_index_find_all (test.index, match_none, -1); - CuAssertPtrNotNull (tc, check); - CuAssertIntEquals (tc, 0, check[0]); + assert_ptr_not_null (check); + assert_num_eq (0, check[0]); free (check); /* A double check of this method */ one = 0UL; check = &one; - CuAssertTrue (tc, !handles_are (check, 29292929, 0UL)); - CuAssertTrue (tc, !handles_are (NULL, 0UL)); - - teardown (tc); + assert (!handles_are (check, 29292929, 0UL)); + assert (!handles_are (NULL, 0UL)); } static void -test_find_realloc (CuTest *tc) +test_find_realloc (void) { CK_ATTRIBUTE attrs[] = { { CKA_LABEL, "odd", 3 }, @@ -566,24 +528,21 @@ test_find_realloc (CuTest *tc) CK_OBJECT_HANDLE *check; int i; - setup (tc); - for (i = 0; i < 1000; i++) p11_index_add (test.index, attrs, 3, NULL); check = p11_index_find_all (test.index, match, -1); - CuAssertPtrNotNull (tc, check); + assert_ptr_not_null (check); for (i = 0; i < 1000; i++) - CuAssertTrue (tc, check[i] != 0); - CuAssertIntEquals (tc, 0, check[1000]); + assert (check[i] != 0); + assert_num_eq (0, check[1000]); free (check); - teardown (tc); } static void -test_replace_all (CuTest *tc) +test_replace_all (void) { CK_ATTRIBUTE first[] = { { CKA_LABEL, "odd", 3 }, @@ -647,16 +606,14 @@ test_replace_all (CuTest *tc) p11_array *array; CK_RV rv; - setup (tc); - p11_index_add (test.index, first, 3, &one); - CuAssertTrue (tc, one != 0); + assert (one != 0); p11_index_add (test.index, second, 3, &two); - CuAssertTrue (tc, two != 0); + assert (two != 0); p11_index_add (test.index, third, 3, &three); - CuAssertTrue (tc, three != 0); + assert (three != 0); p11_index_add (test.index, fifth, 3, &five); - CuAssertTrue (tc, five != 0); + assert (five != 0); array = p11_array_new (p11_attrs_free); p11_array_push (array, p11_attrs_buildn (NULL, eins, 3)); @@ -664,38 +621,36 @@ test_replace_all (CuTest *tc) p11_array_push (array, p11_attrs_buildn (NULL, neun, 3)); rv = p11_index_replace_all (test.index, match, CKA_VALUE, array); - CuAssertTrue (tc, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (tc, 0, array->num); + assert_num_eq (0, array->num); p11_array_free (array); /* eins should have replaced one */ check = p11_index_find (test.index, eins, -1); - CuAssertIntEquals (tc, one, check); + assert_num_eq (one, check); /* two should still be around */ check = p11_index_find (test.index, second, -1); - CuAssertIntEquals (tc, two, check); + assert_num_eq (two, check); /* three should have been removed */ check = p11_index_find (test.index, third, -1); - CuAssertIntEquals (tc, 0, check); + assert_num_eq (0, check); /* five should have been removed */ check = p11_index_find (test.index, fifth, -1); - CuAssertIntEquals (tc, 0, check); + assert_num_eq (0, check); /* sieben should have been added */ check = p11_index_find (test.index, sieben, -1); - CuAssertTrue (tc, check != one && check != two && check != three && check != five); + assert (check != one && check != two && check != three && check != five); /* neun should have been added */ check = p11_index_find (test.index, neun, -1); - CuAssertTrue (tc, check != one && check != two && check != three && check != five); - - CuAssertIntEquals (tc, 4, p11_index_size (test.index)); + assert (check != one && check != two && check != three && check != five); - teardown (tc); + assert_num_eq (4, p11_index_size (test.index)); } @@ -705,17 +660,16 @@ on_build_populate (void *data, CK_ATTRIBUTE **attrs, CK_ATTRIBUTE *merge) { - CuTest *cu = data; - CK_ATTRIBUTE override[] = { { CKA_APPLICATION, "vigorous", 8 }, { CKA_LABEL, "naay", 4 }, { CKA_INVALID }, }; - CuAssertPtrNotNull (cu, index); - CuAssertPtrNotNull (cu, attrs); - CuAssertPtrNotNull (cu, merge); + assert_str_eq (data, "blah"); + assert_ptr_not_null (index); + assert_ptr_not_null (attrs); + assert_ptr_not_null (merge); *attrs = p11_attrs_merge (*attrs, merge, true); *attrs = p11_attrs_merge (*attrs, p11_attrs_dup (override), true); @@ -723,7 +677,7 @@ on_build_populate (void *data, } static void -test_build_populate (CuTest *cu) +test_build_populate (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -744,24 +698,24 @@ test_build_populate (CuTest *cu) p11_index *index; CK_RV rv; - index = p11_index_new (on_build_populate, NULL, cu); - CuAssertPtrNotNull (cu, index); + index = p11_index_new (on_build_populate, NULL, "blah"); + assert_ptr_not_null (index); rv = p11_index_add (index, original, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (index, handle); - CuAssertPtrNotNull (cu, check); + assert_ptr_not_null (check); - test_check_attrs (cu, after, check); + test_check_attrs (after, check); rv = p11_index_set (index, handle, original, 2); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); check = p11_index_lookup (index, handle); - CuAssertPtrNotNull (cu, check); + assert_ptr_not_null (check); - test_check_attrs (cu, after, check); + test_check_attrs (after, check); p11_index_free (index); } @@ -772,14 +726,13 @@ on_build_fail (void *data, CK_ATTRIBUTE **attrs, CK_ATTRIBUTE *merge) { - CuTest *cu = data; - CK_ATTRIBUTE check[] = { { CKA_LABEL, "nay", 3 }, { CKA_INVALID } }; - CuAssertPtrNotNull (cu, merge); + assert_str_eq (data, "testo"); + assert_ptr_not_null (merge); if (p11_attrs_match (merge, check)) return CKR_DEVICE_ERROR; @@ -790,7 +743,7 @@ on_build_fail (void *data, static void -test_build_fail (CuTest *cu) +test_build_fail (void) { CK_ATTRIBUTE okay[] = { { CKA_LABEL, "yay", 3 }, @@ -808,20 +761,20 @@ test_build_fail (CuTest *cu) p11_index *index; CK_RV rv; - index = p11_index_new (on_build_fail, NULL, cu); - CuAssertPtrNotNull (cu, index); + index = p11_index_new (on_build_fail, NULL, "testo"); + assert_ptr_not_null (index); rv = p11_index_add (index, okay, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = p11_index_add (index, fails, 2, NULL); - CuAssertTrue (cu, rv == CKR_DEVICE_ERROR); + assert (rv == CKR_DEVICE_ERROR); rv = p11_index_set (index, handle, fails, 2); - CuAssertTrue (cu, rv == CKR_DEVICE_ERROR); + assert (rv == CKR_DEVICE_ERROR); rv = p11_index_set (index, handle, okay, 2); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); p11_index_free (index); } @@ -836,8 +789,6 @@ on_change_check (void *data, CK_OBJECT_HANDLE handle, CK_ATTRIBUTE *attrs) { - CuTest *cu = data; - CK_ATTRIBUTE check[] = { { CKA_LABEL, "yay", 3 }, { CKA_VALUE, "eight", 5 }, @@ -845,22 +796,23 @@ on_change_check (void *data, }; - CuAssertPtrNotNull (cu, index); - CuAssertPtrNotNull (cu, attrs); + assert_str_eq (data, "change-check"); + assert_ptr_not_null (index); + assert_ptr_not_null (attrs); if (!on_change_batching) { if (on_change_removing) - CuAssertIntEquals (cu, 0, handle); + assert_num_eq (0, handle); else - CuAssertTrue (cu, handle != 0); + assert (handle != 0); } - test_check_attrs (cu, check, attrs); + test_check_attrs (check, attrs); on_change_called++; } static void -test_change_called (CuTest *cu) +test_change_called (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -873,39 +825,39 @@ test_change_called (CuTest *cu) p11_index *index; CK_RV rv; - index = p11_index_new (NULL, on_change_check, cu); - CuAssertPtrNotNull (cu, index); + index = p11_index_new (NULL, on_change_check, "change-check"); + assert_ptr_not_null (index); on_change_removing = false; on_change_called = 0; rv = p11_index_add (index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 1, on_change_called); + assert_num_eq (1, on_change_called); rv = p11_index_add (index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 2, on_change_called); + assert_num_eq (2, on_change_called); rv = p11_index_add (index, original, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 3, on_change_called); + assert_num_eq (3, on_change_called); on_change_removing = true; rv = p11_index_remove (index, handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 4, on_change_called); + assert_num_eq (4, on_change_called); p11_index_free (index); } static void -test_change_batch (CuTest *cu) +test_change_batch (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -918,38 +870,38 @@ test_change_batch (CuTest *cu) p11_index *index; CK_RV rv; - index = p11_index_new (NULL, on_change_check, cu); - CuAssertPtrNotNull (cu, index); + index = p11_index_new (NULL, on_change_check, "change-check"); + assert_ptr_not_null (index); on_change_batching = true; on_change_called = 0; p11_index_batch (index); - CuAssertTrue (cu, p11_index_in_batch (index)); + assert (p11_index_in_batch (index)); rv = p11_index_add (index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 0, on_change_called); + assert_num_eq (0, on_change_called); rv = p11_index_add (index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 0, on_change_called); + assert_num_eq (0, on_change_called); rv = p11_index_add (index, original, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 0, on_change_called); + assert_num_eq (0, on_change_called); /* Nested batch is a noop */ p11_index_batch (index); rv = p11_index_remove (index, handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); - CuAssertIntEquals (cu, 0, on_change_called); + assert_num_eq (0, on_change_called); /* * Batch finishes when first finish call is called, @@ -957,18 +909,18 @@ test_change_batch (CuTest *cu) */ p11_index_finish (index); - CuAssertTrue (cu, !p11_index_in_batch (index)); + assert (!p11_index_in_batch (index)); /* * Only three calls, because later operations on the * same handle override the earlier one. */ - CuAssertIntEquals (cu, 3, on_change_called); + assert_num_eq (3, on_change_called); /* This is a noop */ p11_index_finish (index); - CuAssertTrue (cu, !p11_index_in_batch (index)); + assert (!p11_index_in_batch (index)); p11_index_free (index); } @@ -979,7 +931,6 @@ on_change_nested (void *data, CK_OBJECT_HANDLE handle, CK_ATTRIBUTE *attrs) { - CuTest *cu = data; CK_RV rv; CK_ATTRIBUTE second[] = { @@ -989,15 +940,16 @@ on_change_nested (void *data, }; + assert_str_eq (data, "change-nested"); on_change_called++; /* A nested call */ rv = p11_index_add (index, second, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); } static void -test_change_nested (CuTest *cu) +test_change_nested (void) { CK_ATTRIBUTE original[] = { { CKA_LABEL, "yay", 3 }, @@ -1009,61 +961,50 @@ test_change_nested (CuTest *cu) p11_index *index; CK_RV rv; - index = p11_index_new (NULL, on_change_nested, cu); - CuAssertPtrNotNull (cu, index); + index = p11_index_new (NULL, on_change_nested, "change-nested"); + assert_ptr_not_null (index); on_change_called = 0; rv = p11_index_add (index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertIntEquals (cu, 1, on_change_called); + assert (rv == CKR_OK); + assert_num_eq (1, on_change_called); on_change_called = 0; p11_index_batch (index); rv = p11_index_add (index, original, 2, NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); p11_index_finish (index); - CuAssertIntEquals (cu, 1, on_change_called); + assert_num_eq (1, on_change_called); p11_index_free (index); } int -main (void) +main (int argc, + char *argv[]) { - CuString *output = CuStringNew (); - CuSuite* suite = CuSuiteNew (); - int ret; - - putenv ("P11_KIT_STRICT=1"); - p11_debug_init (); p11_message_quiet (); - SUITE_ADD_TEST (suite, test_add_lookup); - SUITE_ADD_TEST (suite, test_take_lookup); - SUITE_ADD_TEST (suite, test_size); - SUITE_ADD_TEST (suite, test_remove); - SUITE_ADD_TEST (suite, test_snapshot); - SUITE_ADD_TEST (suite, test_snapshot_base); - SUITE_ADD_TEST (suite, test_set); - SUITE_ADD_TEST (suite, test_update); - SUITE_ADD_TEST (suite, test_find); - SUITE_ADD_TEST (suite, test_find_all); - SUITE_ADD_TEST (suite, test_find_realloc); - SUITE_ADD_TEST (suite, test_replace_all); - SUITE_ADD_TEST (suite, test_build_populate); - SUITE_ADD_TEST (suite, test_build_fail); - SUITE_ADD_TEST (suite, test_change_called); - SUITE_ADD_TEST (suite, test_change_batch); - SUITE_ADD_TEST (suite, test_change_nested); - - CuSuiteRun (suite); - CuSuiteSummary (suite, output); - CuSuiteDetails (suite, output); - printf ("%s\n", output->buffer); - ret = suite->failCount; - CuSuiteDelete (suite); - CuStringDelete (output); - - return ret; + p11_fixture (setup, teardown); + p11_test (test_add_lookup, "/index/add_lookup"); + p11_test (test_take_lookup, "/index/take_lookup"); + p11_test (test_size, "/index/size"); + p11_test (test_remove, "/index/remove"); + p11_test (test_snapshot, "/index/snapshot"); + p11_test (test_snapshot_base, "/index/snapshot_base"); + p11_test (test_set, "/index/set"); + p11_test (test_update, "/index/update"); + p11_test (test_find, "/index/find"); + p11_test (test_find_all, "/index/find_all"); + p11_test (test_find_realloc, "/index/find_realloc"); + p11_test (test_replace_all, "/index/replace_all"); + + p11_fixture (NULL, NULL); + p11_test (test_build_populate, "/index/build_populate"); + p11_test (test_build_fail, "/index/build_fail"); + p11_test (test_change_called, "/index/change_called"); + p11_test (test_change_batch, "/index/change_batch"); + p11_test (test_change_nested, "/index/change_nested"); + return p11_test_run (argc, argv); } diff --git a/trust/tests/test-module.c b/trust/tests/test-module.c index 16d8037..45ec74d 100644 --- a/trust/tests/test-module.c +++ b/trust/tests/test-module.c @@ -32,21 +32,21 @@ * Author: Stef Walter */ +#define CRYPTOKI_EXPORTS + #include "config.h" -#include "CuTest.h" +#include "test.h" +#include "test-trust.h" #include #include #include -#define CRYPTOKI_EXPORTS - #include "attrs.h" #include "hash.h" #include "library.h" #include "path.h" #include "pkcs11x.h" -#include "test-data.h" #include "token.h" #include @@ -67,7 +67,7 @@ struct { } test; static void -setup (CuTest *cu) +setup (void *unused) { CK_C_INITIALIZE_ARGS args; const char *paths; @@ -79,72 +79,68 @@ setup (CuTest *cu) /* This is the entry point of the trust module, linked to this test */ rv = C_GetFunctionList (&test.module); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); memset (&args, 0, sizeof (args)); paths = SRCDIR "/input" P11_PATH_SEP \ SRCDIR "/files/self-signed-with-ku.der" P11_PATH_SEP \ SRCDIR "/files/thawte.pem"; if (asprintf (&arguments, "paths='%s'", paths) < 0) - CuAssertTrue (cu, false && "not reached"); + assert (false && "not reached"); args.pReserved = arguments; args.flags = CKF_OS_LOCKING_OK; rv = test.module->C_Initialize (&args); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); free (arguments); count = NUM_SLOTS; rv = test.module->C_GetSlotList (CK_TRUE, test.slots, &count); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertTrue (cu, count == NUM_SLOTS); + assert (rv == CKR_OK); + assert (count == NUM_SLOTS); } static void -teardown (CuTest *cu) +teardown (void *unused) { CK_RV rv; rv = test.module->C_Finalize (NULL); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); memset (&test, 0, sizeof (test)); } static void -test_get_slot_list (CuTest *cu) +test_get_slot_list (void) { CK_SLOT_ID slots[NUM_SLOTS]; CK_ULONG count; CK_RV rv; int i; - setup (cu); - rv = test.module->C_GetSlotList (TRUE, NULL, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, NUM_SLOTS, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (NUM_SLOTS, count); count = 1; rv = test.module->C_GetSlotList (TRUE, slots, &count); - CuAssertIntEquals (cu, CKR_BUFFER_TOO_SMALL, rv); - CuAssertIntEquals (cu, NUM_SLOTS, count); + assert_num_eq (CKR_BUFFER_TOO_SMALL, rv); + assert_num_eq (NUM_SLOTS, count); count = NUM_SLOTS; memset (slots, 0, sizeof (slots)); rv = test.module->C_GetSlotList (TRUE, slots, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, NUM_SLOTS, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (NUM_SLOTS, count); for (i = 0; i < NUM_SLOTS; i++) - CuAssertTrue (cu, slots[i] != 0); - - teardown (cu); + assert (slots[i] != 0); } static void -test_get_slot_info (CuTest *cu) +test_get_slot_info (void) { CK_SLOT_ID slots[NUM_SLOTS]; CK_SLOT_INFO info; @@ -161,30 +157,26 @@ test_get_slot_info (CuTest *cu) SRCDIR "/files/thawte.pem" }; - setup (cu); - count = NUM_SLOTS; rv = test.module->C_GetSlotList (TRUE, slots, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, NUM_SLOTS, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (NUM_SLOTS, count); for (i = 0; i < NUM_SLOTS; i++) { rv = test.module->C_GetSlotInfo (slots[i], &info); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); memset (description, ' ', sizeof (description)); length = strlen(paths[i]); if (length > sizeof (description)) length = sizeof (description); memcpy (description, paths[i], length); - CuAssertTrue (cu, memcmp (info.slotDescription, description, sizeof (description)) == 0); + assert (memcmp (info.slotDescription, description, sizeof (description)) == 0); } - - teardown (cu); } static void -test_get_token_info (CuTest *cu) +test_get_token_info (void) { CK_C_INITIALIZE_ARGS args; CK_FUNCTION_LIST *module; @@ -204,7 +196,7 @@ test_get_token_info (CuTest *cu) /* This is the entry point of the trust module, linked to this test */ rv = C_GetFunctionList (&module); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); memset (&args, 0, sizeof (args)); args.pReserved = "paths='" \ @@ -214,28 +206,28 @@ test_get_token_info (CuTest *cu) args.flags = CKF_OS_LOCKING_OK; rv = module->C_Initialize (&args); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); count = NUM_SLOTS; rv = module->C_GetSlotList (CK_TRUE, slots, &count); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertTrue (cu, count == NUM_SLOTS); + assert (rv == CKR_OK); + assert (count == NUM_SLOTS); for (i = 0; i < NUM_SLOTS; i++) { rv = module->C_GetTokenInfo (slots[i], &info); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); memset (label, ' ', sizeof (label)); memcpy (label, labels[i], strlen (labels[i])); - CuAssertTrue (cu, memcmp (info.label, label, sizeof (label)) == 0); + assert (memcmp (info.label, label, sizeof (label)) == 0); } rv = module->C_Finalize (NULL); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); } static void -test_get_session_info (CuTest *cu) +test_get_session_info (void) { CK_SLOT_ID slots[NUM_SLOTS]; CK_SESSION_HANDLE sessions[NUM_SLOTS]; @@ -244,30 +236,26 @@ test_get_session_info (CuTest *cu) CK_RV rv; int i; - setup (cu); - count = NUM_SLOTS; rv = test.module->C_GetSlotList (TRUE, slots, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, NUM_SLOTS, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (NUM_SLOTS, count); /* Open two sessions with each token */ for (i = 0; i < NUM_SLOTS; i++) { rv = test.module->C_OpenSession (slots[i], CKF_SERIAL_SESSION, NULL, NULL, &sessions[i]); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_GetSessionInfo (sessions[i], &info); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - CuAssertIntEquals (cu, slots[i], info.slotID); - CuAssertIntEquals (cu, CKF_SERIAL_SESSION, info.flags); + assert_num_eq (slots[i], info.slotID); + assert_num_eq (CKF_SERIAL_SESSION, info.flags); } - - teardown (cu); } static void -test_close_all_sessions (CuTest *cu) +test_close_all_sessions (void) { CK_SLOT_ID slots[NUM_SLOTS]; CK_SESSION_HANDLE sessions[NUM_SLOTS][2]; @@ -276,52 +264,47 @@ test_close_all_sessions (CuTest *cu) CK_RV rv; int i; - setup (cu); - count = NUM_SLOTS; rv = test.module->C_GetSlotList (TRUE, slots, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, NUM_SLOTS, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (NUM_SLOTS, count); /* Open two sessions with each token */ for (i = 0; i < NUM_SLOTS; i++) { rv = test.module->C_OpenSession (slots[i], CKF_SERIAL_SESSION, NULL, NULL, &sessions[i][0]); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_GetSessionInfo (sessions[i][0], &info); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_OpenSession (slots[i], CKF_SERIAL_SESSION, NULL, NULL, &sessions[i][1]); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_GetSessionInfo (sessions[i][0], &info); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); } /* Close all the sessions on the first token */ rv = test.module->C_CloseAllSessions (slots[0]); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Those sessions should be closed */ rv = test.module->C_GetSessionInfo (sessions[0][0], &info); - CuAssertIntEquals (cu, CKR_SESSION_HANDLE_INVALID, rv); + assert_num_eq (CKR_SESSION_HANDLE_INVALID, rv); rv = test.module->C_GetSessionInfo (sessions[0][1], &info); - CuAssertIntEquals (cu, CKR_SESSION_HANDLE_INVALID, rv); + assert_num_eq (CKR_SESSION_HANDLE_INVALID, rv); /* Other sessions should still be open */ for (i = 1; i < NUM_SLOTS; i++) { rv = test.module->C_GetSessionInfo (sessions[i][0], &info); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_GetSessionInfo (sessions[i][0], &info); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); } - - teardown (cu); } static CK_ULONG -find_objects (CuTest *cu, - CK_ATTRIBUTE *match, +find_objects (CK_ATTRIBUTE *match, CK_OBJECT_HANDLE *sessions, CK_OBJECT_HANDLE *objects, CK_ULONG max_objects) @@ -335,14 +318,14 @@ find_objects (CuTest *cu, found = 0; for (i = 0; i < NUM_SLOTS; i++) { rv = test.module->C_OpenSession (test.slots[i], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_FindObjectsInit (session, match, p11_attrs_count (match)); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_FindObjects (session, objects + found, max_objects - found, &count); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_FindObjectsFinal (session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); for (j = found ; j < found + count; j++) sessions[j] = session; @@ -354,8 +337,7 @@ find_objects (CuTest *cu, } static void -check_trust_object_equiv (CuTest *cu, - CK_SESSION_HANDLE session, +check_trust_object_equiv (CK_SESSION_HANDLE session, CK_OBJECT_HANDLE trust, CK_ATTRIBUTE *cert) { @@ -379,14 +361,13 @@ check_trust_object_equiv (CuTest *cu, }; rv = test.module->C_GetAttributeValue (session, trust, equiv, 6); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); - test_check_attrs (cu, equiv, cert); + test_check_attrs (equiv, cert); } static void -check_trust_object_hashes (CuTest *cu, - CK_SESSION_HANDLE session, +check_trust_object_hashes (CK_SESSION_HANDLE session, CK_OBJECT_HANDLE trust, CK_ATTRIBUTE *cert) { @@ -403,21 +384,20 @@ check_trust_object_hashes (CuTest *cu, }; rv = test.module->C_GetAttributeValue (session, trust, hashes, 2); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); value = p11_attrs_find_valid (cert, CKA_VALUE); - CuAssertPtrNotNull (cu, value); + assert_ptr_not_null (value); p11_hash_md5 (check, value->pValue, value->ulValueLen, NULL); - CuAssertTrue (cu, memcmp (md5, check, sizeof (md5)) == 0); + assert (memcmp (md5, check, sizeof (md5)) == 0); p11_hash_sha1 (check, value->pValue, value->ulValueLen, NULL); - CuAssertTrue (cu, memcmp (sha1, check, sizeof (sha1)) == 0); + assert (memcmp (sha1, check, sizeof (sha1)) == 0); } static void -check_has_trust_object (CuTest *cu, - CK_ATTRIBUTE *cert) +check_has_trust_object (CK_ATTRIBUTE *cert) { CK_OBJECT_CLASS trust_object = CKO_NSS_TRUST; CK_ATTRIBUTE klass = { CKA_CLASS, &trust_object, sizeof (trust_object) }; @@ -428,21 +408,20 @@ check_has_trust_object (CuTest *cu, CK_ULONG count; attr = p11_attrs_find_valid (cert, CKA_ID); - CuAssertPtrNotNull (cu, attr); + assert_ptr_not_null (attr); match = p11_attrs_build (NULL, &klass, attr, NULL); - count = find_objects (cu, match, sessions, objects, 2); - CuAssertIntEquals (cu, 1, count); + count = find_objects (match, sessions, objects, 2); + assert_num_eq (1, count); - check_trust_object_equiv (cu, sessions[0], objects[0], cert); - check_trust_object_hashes (cu, sessions[0], objects[0], cert); + check_trust_object_equiv (sessions[0], objects[0], cert); + check_trust_object_hashes (sessions[0], objects[0], cert); p11_attrs_free (match); } static void -check_certificate (CuTest *cu, - CK_SESSION_HANDLE session, +check_certificate (CK_SESSION_HANDLE session, CK_OBJECT_HANDLE handle) { unsigned char label[4096]= { 0, }; @@ -483,7 +462,7 @@ check_certificate (CuTest *cu, /* Note that we don't pass the CKA_INVALID attribute in */ rv = test.module->C_GetAttributeValue (session, handle, attrs, 15); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); /* If this is the cacert3 certificate, check its values */ if (memcmp (value, test_cacert3_ca_der, sizeof (test_cacert3_ca_der)) == 0) { @@ -500,25 +479,25 @@ check_certificate (CuTest *cu, { CKA_INVALID, }, }; - test_check_cacert3_ca (cu, attrs, NULL); + test_check_cacert3_ca (attrs, NULL); /* Get anchor specific attributes */ rv = test.module->C_GetAttributeValue (session, handle, anchor, 1); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); /* It lives in the trusted directory */ - test_check_attrs (cu, check, anchor); + test_check_attrs (check, anchor); /* Other certificates, we can't check the values */ } else { - test_check_object (cu, attrs, CKO_CERTIFICATE, NULL); + test_check_object (attrs, CKO_CERTIFICATE, NULL); } - check_has_trust_object (cu, attrs); + check_has_trust_object (attrs); } static void -test_find_certificates (CuTest *cu) +test_find_certificates (void) { CK_OBJECT_CLASS klass = CKO_CERTIFICATE; @@ -532,19 +511,15 @@ test_find_certificates (CuTest *cu) CK_ULONG count; CK_ULONG i; - setup (cu); - - count = find_objects (cu, match, sessions, objects, 16); - CuAssertIntEquals (cu, 8, count); + count = find_objects (match, sessions, objects, 16); + assert_num_eq (8, count); for (i = 0; i < count; i++) - check_certificate (cu, sessions[i], objects[i]); - - teardown (cu); + check_certificate (sessions[i], objects[i]); } static void -test_find_builtin (CuTest *cu) +test_find_builtin (void) { CK_OBJECT_CLASS klass = CKO_NSS_BUILTIN_ROOT_LIST; CK_BBOOL vtrue = CK_TRUE; @@ -562,17 +537,13 @@ test_find_builtin (CuTest *cu) CK_SESSION_HANDLE sessions[16]; CK_ULONG count; - setup (cu); - /* One per token */ - count = find_objects (cu, match, sessions, objects, 16); - CuAssertIntEquals (cu, NUM_SLOTS, count); - - teardown (cu); + count = find_objects (match, sessions, objects, 16); + assert_num_eq (NUM_SLOTS, count); } static void -test_session_object (CuTest *cu) +test_session_object (void) { CK_ATTRIBUTE original[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -586,22 +557,18 @@ test_session_object (CuTest *cu) CK_ULONG size; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_CreateObject (session, original, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_GetObjectSize (session, handle, &size); - CuAssertTrue (cu, rv == CKR_OK); - - teardown (cu); + assert (rv == CKR_OK); } static void -test_session_find (CuTest *cu) +test_session_find (void) { CK_ATTRIBUTE original[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -616,30 +583,26 @@ test_session_find (CuTest *cu) CK_ULONG count; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_CreateObject (session, original, 2, &handle); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjectsInit (session, original, 2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjects (session, &check, 1, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, 1, count); - CuAssertIntEquals (cu, handle, check); + assert_num_eq (CKR_OK, rv); + assert_num_eq (1, count); + assert_num_eq (handle, check); rv = test.module->C_FindObjectsFinal (session); - CuAssertIntEquals (cu, CKR_OK, rv); - - teardown (cu); + assert_num_eq (CKR_OK, rv); } static void -test_session_find_no_attr (CuTest *cu) +test_session_find_no_attr (void) { CK_ATTRIBUTE original[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -659,71 +622,59 @@ test_session_find_no_attr (CuTest *cu) CK_ULONG count; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_CreateObject (session, original, 3, &handle); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjectsInit (session, match, 1); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjects (session, &check, 1, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, 0, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (0, count); rv = test.module->C_FindObjectsFinal (session); - CuAssertIntEquals (cu, CKR_OK, rv); - - teardown (cu); + assert_num_eq (CKR_OK, rv); } static void -test_lookup_invalid (CuTest *cu) +test_lookup_invalid (void) { CK_SESSION_HANDLE session; CK_ULONG size; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_GetObjectSize (session, 88888, &size); - CuAssertTrue (cu, rv == CKR_OBJECT_HANDLE_INVALID); - - teardown (cu); + assert (rv == CKR_OBJECT_HANDLE_INVALID); } static void -test_remove_token (CuTest *cu) +test_remove_token (void) { CK_SESSION_HANDLE session; CK_OBJECT_HANDLE handle; CK_ULONG count; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_FindObjectsInit (session, NULL, 0); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_FindObjects (session, &handle, 1, &count); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertIntEquals (cu, 1, count); + assert (rv == CKR_OK); + assert_num_eq (1, count); rv = test.module->C_DestroyObject (session, handle); - CuAssertTrue (cu, rv == CKR_TOKEN_WRITE_PROTECTED); - - teardown (cu); + assert (rv == CKR_TOKEN_WRITE_PROTECTED); } static void -test_setattr_token (CuTest *cu) +test_setattr_token (void) { CK_ATTRIBUTE original[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -737,26 +688,22 @@ test_setattr_token (CuTest *cu) CK_ULONG count; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_FindObjectsInit (session, NULL, 0); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_FindObjects (session, &handle, 1, &count); - CuAssertTrue (cu, rv == CKR_OK); - CuAssertIntEquals (cu, 1, count); + assert (rv == CKR_OK); + assert_num_eq (1, count); rv = test.module->C_SetAttributeValue (session, handle, original, 2); - CuAssertTrue (cu, rv == CKR_TOKEN_WRITE_PROTECTED); - - teardown (cu); + assert (rv == CKR_TOKEN_WRITE_PROTECTED); } static void -test_session_copy (CuTest *cu) +test_session_copy (void) { CK_ATTRIBUTE original[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -771,25 +718,21 @@ test_session_copy (CuTest *cu) CK_ULONG size; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_CreateObject (session, original, 2, &handle); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_CopyObject (session, handle, original, 2, ©); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_GetObjectSize (session, copy, &size); - CuAssertIntEquals (cu, CKR_OK, rv); - - teardown (cu); + assert_num_eq (CKR_OK, rv); } static void -test_session_setattr (CuTest *cu) +test_session_setattr (void) { CK_ATTRIBUTE original[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -802,22 +745,18 @@ test_session_setattr (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_CreateObject (session, original, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_SetAttributeValue (session, handle, original, 2); - CuAssertTrue (cu, rv == CKR_OK); - - teardown (cu); + assert (rv == CKR_OK); } static void -test_session_remove (CuTest *cu) +test_session_remove (void) { CK_ATTRIBUTE original[] = { { CKA_CLASS, &data, sizeof (data) }, @@ -830,25 +769,21 @@ test_session_remove (CuTest *cu) CK_OBJECT_HANDLE handle; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_CreateObject (session, original, 2, &handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_DestroyObject (session, handle); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); rv = test.module->C_DestroyObject (session, handle); - CuAssertTrue (cu, rv == CKR_OBJECT_HANDLE_INVALID); - - teardown (cu); + assert (rv == CKR_OBJECT_HANDLE_INVALID); } static void -test_find_serial_der_decoded (CuTest *cu) +test_find_serial_der_decoded (void) { CK_OBJECT_CLASS nss_trust = CKO_NSS_TRUST; @@ -881,39 +816,35 @@ test_find_serial_der_decoded (CuTest *cu) * See work_around_broken_nss_serial_number_lookups(). */ - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_CreateObject (session, object, 2, &handle); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Do a standard find for the same object */ rv = test.module->C_FindObjectsInit (session, object, 2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjects (session, &check, 1, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, 1, count); - CuAssertIntEquals (cu, handle, check); + assert_num_eq (CKR_OK, rv); + assert_num_eq (1, count); + assert_num_eq (handle, check); rv = test.module->C_FindObjectsFinal (session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Do a find for the serial number decoded */ rv = test.module->C_FindObjectsInit (session, match_decoded, 2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjects (session, &check, 1, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, 1, count); - CuAssertIntEquals (cu, handle, check); + assert_num_eq (CKR_OK, rv); + assert_num_eq (1, count); + assert_num_eq (handle, check); rv = test.module->C_FindObjectsFinal (session); - CuAssertIntEquals (cu, CKR_OK, rv); - - teardown (cu); + assert_num_eq (CKR_OK, rv); } static void -test_find_serial_der_mismatch (CuTest *cu) +test_find_serial_der_mismatch (void) { CK_OBJECT_CLASS nss_trust = CKO_NSS_TRUST; @@ -935,107 +866,92 @@ test_find_serial_der_mismatch (CuTest *cu) CK_ULONG count; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_CreateObject (session, object, 2, &handle); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Do a find with a null serial number, no match */ rv = test.module->C_FindObjectsInit (session, match, 2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjects (session, &check, 1, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, 0, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (0, count); rv = test.module->C_FindObjectsFinal (session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Do a find with a wrong length, no match */ match[0].pValue = "at"; match[0].ulValueLen = 2; rv = test.module->C_FindObjectsInit (session, match, 2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjects (session, &check, 1, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, 0, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (0, count); rv = test.module->C_FindObjectsFinal (session); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); /* Do a find with a right length, wrong value, no match */ match[0].pValue = "one"; match[0].ulValueLen = 3; rv = test.module->C_FindObjectsInit (session, match, 2); - CuAssertIntEquals (cu, CKR_OK, rv); + assert_num_eq (CKR_OK, rv); rv = test.module->C_FindObjects (session, &check, 1, &count); - CuAssertIntEquals (cu, CKR_OK, rv); - CuAssertIntEquals (cu, 0, count); + assert_num_eq (CKR_OK, rv); + assert_num_eq (0, count); rv = test.module->C_FindObjectsFinal (session); - CuAssertIntEquals (cu, CKR_OK, rv); - - teardown (cu); + assert_num_eq (CKR_OK, rv); } static void -test_login_logout (CuTest *cu) +test_login_logout (void) { CK_SESSION_HANDLE session; CK_RV rv; - setup (cu); - rv = test.module->C_OpenSession (test.slots[0], CKF_SERIAL_SESSION, NULL, NULL, &session); - CuAssertTrue (cu, rv == CKR_OK); + assert (rv == CKR_OK); /* Just testing our stubs for now */ rv = test.module->C_Login (session, CKU_USER, NULL, 0); - CuAssertTrue (cu, rv == CKR_USER_TYPE_INVALID); + assert (rv == CKR_USER_TYPE_INVALID); rv = test.module->C_Logout (session); - CuAssertTrue (cu, rv == CKR_USER_NOT_LOGGED_IN); - - teardown (cu); + assert (rv == CKR_USER_NOT_LOGGED_IN); } int -main (void) +main (int argc, + char *argv[]) { - CuString *output = CuStringNew (); - CuSuite* suite = CuSuiteNew (); - int ret; - - putenv ("P11_KIT_STRICT=1"); p11_library_init (); - SUITE_ADD_TEST (suite, test_get_slot_list); - SUITE_ADD_TEST (suite, test_get_slot_info); - SUITE_ADD_TEST (suite, test_get_token_info); - SUITE_ADD_TEST (suite, test_get_session_info); - SUITE_ADD_TEST (suite, test_close_all_sessions); - SUITE_ADD_TEST (suite, test_find_certificates); - SUITE_ADD_TEST (suite, test_find_builtin); - SUITE_ADD_TEST (suite, test_lookup_invalid); - SUITE_ADD_TEST (suite, test_remove_token); - SUITE_ADD_TEST (suite, test_setattr_token); - SUITE_ADD_TEST (suite, test_session_object); - SUITE_ADD_TEST (suite, test_session_find); - SUITE_ADD_TEST (suite, test_session_find_no_attr); - SUITE_ADD_TEST (suite, test_session_copy); - SUITE_ADD_TEST (suite, test_session_remove); - SUITE_ADD_TEST (suite, test_session_setattr); - SUITE_ADD_TEST (suite, test_find_serial_der_decoded); - SUITE_ADD_TEST (suite, test_find_serial_der_mismatch); - SUITE_ADD_TEST (suite, test_login_logout); - - CuSuiteRun (suite); - CuSuiteSummary (suite, output); - CuSuiteDetails (suite, output); - printf ("%s\n", output->buffer); - ret = suite->failCount; - CuSuiteDelete (suite); - CuStringDelete (output); - - return ret; + p11_fixture (setup, teardown); + p11_test (test_get_slot_list, "/module/get_slot_list"); + p11_test (test_get_slot_info, "/module/get_slot_info"); + + p11_fixture (NULL, NULL); + p11_test (test_get_token_info, "/module/get_token_info"); + + p11_fixture (setup, teardown); + p11_test (test_get_session_info, "/module/get_session_info"); + p11_test (test_close_all_sessions, "/module/close_all_sessions"); + p11_test (test_find_certificates, "/module/find_certificates"); + p11_test (test_find_builtin, "/module/find_builtin"); + p11_test (test_lookup_invalid, "/module/lookup_invalid"); + p11_test (test_remove_token, "/module/remove_token"); + p11_test (test_setattr_token, "/module/setattr_token"); + p11_test (test_session_object, "/module/session_object"); + p11_test (test_session_find, "/module/session_find"); + p11_test (test_session_find_no_attr, "/module/session_find_no_attr"); + p11_test (test_session_copy, "/module/session_copy"); + p11_test (test_session_remove, "/module/session_remove"); + p11_test (test_session_setattr, "/module/session_setattr"); + p11_test (test_find_serial_der_decoded, "/module/find_serial_der_decoded"); + p11_test (test_find_serial_der_mismatch, "/module/find_serial_der_mismatch"); + p11_test (test_login_logout, "/module/login_logout"); + + return p11_test_run (argc, argv); } diff --git a/trust/tests/test-parser.c b/trust/tests/test-parser.c index 147823a..2b60254 100644 --- a/trust/tests/test-parser.c +++ b/trust/tests/test-parser.c @@ -33,7 +33,8 @@ */ #include "config.h" -#include "CuTest.h" +#include "test.h" +#include "test-trust.h" #include #include @@ -47,7 +48,6 @@ #include "oid.h" #include "parser.h" #include "pkcs11x.h" -#include "test-data.h" struct { p11_parser *parser; @@ -56,16 +56,16 @@ struct { } test; static void -setup (CuTest *cu) +setup (void *unused) { test.index = p11_index_new (NULL, NULL, NULL); test.cache = p11_asn1_cache_new (); test.parser = p11_parser_new (test.index, test.cache); - CuAssertPtrNotNull (cu, test.parser); + assert_ptr_not_null (test.parser); } static void -teardown (CuTest *cu) +teardown (void *unused) { p11_parser_free (test.parser); p11_index_free (test.index); @@ -94,7 +94,7 @@ parsed_attrs (CK_ATTRIBUTE *match) } static void -test_parse_der_certificate (CuTest *cu) +test_parse_der_certificate (void) { CK_ATTRIBUTE *cert; int ret; @@ -109,23 +109,19 @@ test_parse_der_certificate (CuTest *cu) { CKA_INVALID }, }; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.der", P11_PARSE_FLAG_NONE); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); /* Should have gotten certificate */ - CuAssertIntEquals (cu, 1, p11_index_size (test.index)); + assert_num_eq (1, p11_index_size (test.index)); cert = parsed_attrs (certificate_match); - test_check_attrs (cu, expected, cert); - - teardown (cu); + test_check_attrs (expected, cert); } static void -test_parse_pem_certificate (CuTest *cu) +test_parse_pem_certificate (void) { CK_ATTRIBUTE *cert; int ret; @@ -140,23 +136,19 @@ test_parse_pem_certificate (CuTest *cu) { CKA_INVALID }, }; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.pem", P11_PARSE_FLAG_NONE); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); /* Should have gotten certificate */ - CuAssertIntEquals (cu, 1, p11_index_size (test.index)); + assert_num_eq (1, p11_index_size (test.index)); cert = parsed_attrs (certificate_match); - test_check_attrs (cu, expected, cert); - - teardown (cu); + test_check_attrs (expected, cert); } static void -test_parse_p11_kit_persist (CuTest *cu) +test_parse_p11_kit_persist (void) { CK_ATTRIBUTE *cert; int ret; @@ -171,23 +163,19 @@ test_parse_p11_kit_persist (CuTest *cu) { CKA_INVALID }, }; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/input/verisign-v1.p11-kit", P11_PARSE_FLAG_NONE); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); /* Should have gotten certificate */ - CuAssertIntEquals (cu, 1, p11_index_size (test.index)); + assert_num_eq (1, p11_index_size (test.index)); cert = parsed_attrs (certificate_match); - test_check_attrs (cu, expected, cert); - - teardown (cu); + test_check_attrs (expected, cert); } static void -test_parse_openssl_trusted (CuTest *cu) +test_parse_openssl_trusted (void) { CK_ATTRIBUTE cacert3[] = { { CKA_CERTIFICATE_TYPE, &x509, sizeof (x509) }, @@ -228,40 +216,36 @@ test_parse_openssl_trusted (CuTest *cu) int ret; int i; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3-trusted.pem", P11_PARSE_FLAG_ANCHOR); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); /* * Should have gotten: * - 1 certificate * - 2 stapled extensions */ - CuAssertIntEquals (cu, 3, p11_index_size (test.index)); + assert_num_eq (3, p11_index_size (test.index)); /* The certificate */ cert = parsed_attrs (certificate_match); - test_check_attrs (cu, expected[0], cert); + test_check_attrs (expected[0], cert); /* The other objects */ for (i = 1; expected[i]; i++) { handle = p11_index_find (test.index, expected[i], 2); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); object = p11_index_lookup (test.index, handle); - CuAssertPtrNotNull (cu, object); + assert_ptr_not_null (object); - test_check_attrs (cu, expected[i], object); - test_check_id (cu, cert, object); + test_check_attrs (expected[i], object); + test_check_id (cert, object); } - - teardown (cu); } static void -test_parse_openssl_distrusted (CuTest *cu) +test_parse_openssl_distrusted (void) { CK_ATTRIBUTE distrust_cert[] = { { CKA_CLASS, &certificate, sizeof (certificate), }, @@ -301,42 +285,38 @@ test_parse_openssl_distrusted (CuTest *cu) int ret; int i; - setup (cu); - /* * OpenSSL style is to litter the blacklist in with the anchors, * so we parse this as an anchor, but expect it to be blacklisted */ ret = p11_parse_file (test.parser, SRCDIR "/files/distrusted.pem", P11_PARSE_FLAG_ANCHOR); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); /* * Should have gotten: * - 1 certificate * - 2 stapled extensions */ - CuAssertIntEquals (cu, 3, p11_index_size (test.index)); + assert_num_eq (3, p11_index_size (test.index)); cert = parsed_attrs (certificate_match); - test_check_attrs (cu, expected[0], cert); + test_check_attrs (expected[0], cert); /* The other objects */ for (i = 1; expected[i]; i++) { handle = p11_index_find (test.index, expected[i], 2); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); object = p11_index_lookup (test.index, handle); - CuAssertPtrNotNull (cu, object); + assert_ptr_not_null (object); - test_check_attrs (cu, expected[i], object); - test_check_id (cu, cert, object); + test_check_attrs (expected[i], object); + test_check_id (cert, object); } - - teardown (cu); } static void -test_parse_anchor (CuTest *cu) +test_parse_anchor (void) { CK_ATTRIBUTE cacert3[] = { { CKA_CERTIFICATE_TYPE, &x509, sizeof (x509) }, @@ -351,26 +331,22 @@ test_parse_anchor (CuTest *cu) CK_ATTRIBUTE *cert; int ret; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.der", P11_PARSE_FLAG_ANCHOR); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); /* * Should have gotten: * - 1 certificate */ - CuAssertIntEquals (cu, 1, p11_index_size (test.index)); + assert_num_eq (1, p11_index_size (test.index)); cert = parsed_attrs (certificate_match); - test_check_attrs (cu, cacert3, cert); - - teardown (cu); + test_check_attrs (cacert3, cert); } static void -test_parse_thawte (CuTest *cu) +test_parse_thawte (void) { CK_ATTRIBUTE *cert; int ret; @@ -384,61 +360,49 @@ test_parse_thawte (CuTest *cu) { CKA_INVALID }, }; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/files/thawte.pem", P11_PARSE_FLAG_NONE); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); /* Should have gotten certificate */ - CuAssertIntEquals (cu, 1, p11_index_size (test.index)); + assert_num_eq (1, p11_index_size (test.index)); cert = parsed_attrs (certificate_match); - test_check_attrs (cu, expected, cert); - - teardown (cu); + test_check_attrs (expected, cert); } /* TODO: A certificate that uses generalTime needs testing */ static void -test_parse_invalid_file (CuTest *cu) +test_parse_invalid_file (void) { int ret; - setup (cu); - p11_message_quiet (); ret = p11_parse_file (test.parser, "/nonexistant", P11_PARSE_FLAG_NONE); - CuAssertIntEquals (cu, P11_PARSE_FAILURE, ret); + assert_num_eq (P11_PARSE_FAILURE, ret); p11_message_loud (); - - teardown (cu); } static void -test_parse_unrecognized (CuTest *cu) +test_parse_unrecognized (void) { int ret; - setup (cu); - p11_message_quiet (); ret = p11_parse_file (test.parser, SRCDIR "/files/unrecognized-file.txt", P11_PARSE_FLAG_NONE); - CuAssertIntEquals (cu, P11_PARSE_UNRECOGNIZED, ret); + assert_num_eq (P11_PARSE_UNRECOGNIZED, ret); p11_message_loud (); - - teardown (cu); } static void -test_duplicate (CuTest *cu) +test_duplicate (void) { CK_ATTRIBUTE cacert3[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -454,36 +418,33 @@ test_duplicate (CuTest *cu) CK_ATTRIBUTE *cert; int ret; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.der", 0); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); p11_message_quiet (); /* This shouldn't be added, should print a message */ ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.der", 0); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); - CuAssertTrue (cu, strstr (p11_message_last (), "duplicate") != NULL); + assert (strstr (p11_message_last (), "duplicate") != NULL); p11_message_loud (); /* Should only be one certificate since the above two are identical */ handles = p11_index_find_all (test.index, cacert3, 2); - CuAssertPtrNotNull (cu, handles); - CuAssertTrue (cu, handles[0] != 0); - CuAssertTrue (cu, handles[1] == 0); + assert_ptr_not_null (handles); + assert (handles[0] != 0); + assert (handles[1] == 0); cert = p11_index_lookup (test.index, handles[0]); - test_check_attrs (cu, cacert3, cert); + test_check_attrs (cacert3, cert); free (handles); - teardown (cu); } static void -test_duplicate_priority (CuTest *cu) +test_duplicate_priority (void) { CK_ATTRIBUTE cacert3[] = { { CKA_CLASS, &certificate, sizeof (certificate) }, @@ -515,29 +476,27 @@ test_duplicate_priority (CuTest *cu) CK_ATTRIBUTE *cert; int ret; - setup (cu); - ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.der", 0); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); p11_message_quiet (); /* This shouldn't be added, should print a message */ ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.der", P11_PARSE_FLAG_ANCHOR); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); - CuAssertTrue (cu, strstr (p11_message_last (), "duplicate") != NULL); + assert (strstr (p11_message_last (), "duplicate") != NULL); p11_message_loud (); /* We should now find the trusted certificate */ handles = p11_index_find_all (test.index, cacert3, 2); - CuAssertPtrNotNull (cu, handles); - CuAssertTrue (cu, handles[0] != 0); - CuAssertTrue (cu, handles[1] == 0); + assert_ptr_not_null (handles); + assert (handles[0] != 0); + assert (handles[1] == 0); cert = p11_index_lookup (test.index, handles[0]); - test_check_attrs (cu, trusted, cert); + test_check_attrs (trusted, cert); free (handles); /* Now add a distrutsed one, this should override the trusted */ @@ -546,51 +505,35 @@ test_duplicate_priority (CuTest *cu) ret = p11_parse_file (test.parser, SRCDIR "/files/cacert3.der", P11_PARSE_FLAG_BLACKLIST); - CuAssertIntEquals (cu, P11_PARSE_SUCCESS, ret); + assert_num_eq (P11_PARSE_SUCCESS, ret); p11_message_loud (); /* We should now find the distrusted certificate */ handles = p11_index_find_all (test.index, cacert3, 2); - CuAssertPtrNotNull (cu, handles); - CuAssertTrue (cu, handles[0] != 0); - CuAssertTrue (cu, handles[1] == 0); + assert_ptr_not_null (handles); + assert (handles[0] != 0); + assert (handles[1] == 0); cert = p11_index_lookup (test.index, handles[0]); - test_check_attrs (cu, distrust, cert); + test_check_attrs (distrust, cert); free (handles); - - teardown (cu); } int -main (void) +main (int argc, + char *argv[]) { - CuString *output = CuStringNew (); - CuSuite* suite = CuSuiteNew (); - int ret; - - putenv ("P11_KIT_STRICT=1"); - p11_debug_init (); - - SUITE_ADD_TEST (suite, test_parse_der_certificate); - SUITE_ADD_TEST (suite, test_parse_pem_certificate); - SUITE_ADD_TEST (suite, test_parse_p11_kit_persist); - SUITE_ADD_TEST (suite, test_parse_openssl_trusted); - SUITE_ADD_TEST (suite, test_parse_openssl_distrusted); - SUITE_ADD_TEST (suite, test_parse_anchor); - SUITE_ADD_TEST (suite, test_parse_thawte); - SUITE_ADD_TEST (suite, test_parse_invalid_file); - SUITE_ADD_TEST (suite, test_parse_unrecognized); - SUITE_ADD_TEST (suite, test_duplicate); - SUITE_ADD_TEST (suite, test_duplicate_priority); - - CuSuiteRun (suite); - CuSuiteSummary (suite, output); - CuSuiteDetails (suite, output); - printf ("%s\n", output->buffer); - ret = suite->failCount; - CuSuiteDelete (suite); - CuStringDelete (output); - - return ret; + p11_fixture (setup, teardown); + p11_test (test_parse_der_certificate, "/parser/parse_der_certificate"); + p11_test (test_parse_pem_certificate, "/parser/parse_pem_certificate"); + p11_test (test_parse_p11_kit_persist, "/parser/parse_p11_kit_persist"); + p11_test (test_parse_openssl_trusted, "/parser/parse_openssl_trusted"); + p11_test (test_parse_openssl_distrusted, "/parser/parse_openssl_distrusted"); + p11_test (test_parse_anchor, "/parser/parse_anchor"); + p11_test (test_parse_thawte, "/parser/parse_thawte"); + p11_test (test_parse_invalid_file, "/parser/parse_invalid_file"); + p11_test (test_parse_unrecognized, "/parser/parse_unrecognized"); + p11_test (test_duplicate, "/parser/duplicate"); + p11_test (test_duplicate_priority, "/parser/duplicate_priority"); + return p11_test_run (argc, argv); } diff --git a/trust/tests/test-persist.c b/trust/tests/test-persist.c index ee73331..defeecf 100644 --- a/trust/tests/test-persist.c +++ b/trust/tests/test-persist.c @@ -33,8 +33,10 @@ */ #include "config.h" -#include "CuTest.h" +#include "test.h" +#include "test-trust.h" +#include #include #include #include @@ -48,10 +50,8 @@ #include "pkcs11.h" #include "pkcs11x.h" -#include "test-data.h" - static void -test_magic (CuTest *tc) +test_magic (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -64,10 +64,10 @@ test_magic (CuTest *tc) "value: \"blah\"\n" "application: \"test-persist\"\n"; - CuAssertTrue (tc, p11_persist_magic ((unsigned char *)input, strlen (input))); - CuAssertTrue (tc, !p11_persist_magic ((unsigned char *)input, 5)); - CuAssertTrue (tc, p11_persist_magic ((unsigned char *)other, strlen (other))); - CuAssertTrue (tc, !p11_persist_magic ((unsigned char *)"blah", 4)); + assert (p11_persist_magic ((unsigned char *)input, strlen (input))); + assert (!p11_persist_magic ((unsigned char *)input, 5)); + assert (p11_persist_magic ((unsigned char *)other, strlen (other))); + assert (!p11_persist_magic ((unsigned char *)"blah", 4)); } static p11_array * @@ -94,9 +94,9 @@ args_to_array (void *arg, } static void -check_read_msg (CuTest *tc, - const char *file, +check_read_msg (const char *file, int line, + const char *function, const char *input, p11_array *expected) { @@ -108,14 +108,18 @@ check_read_msg (CuTest *tc, objects = p11_array_new (p11_attrs_free); if (p11_persist_read (persist, "test", (const unsigned char *)input, strlen (input), objects)) { - CuAssert_Line (tc, file, line, "decoding should have failed", expected != NULL); + if (expected == NULL) + p11_test_fail (file, line, function, "decoding should have failed"); for (i = 0; i < expected->num; i++) { - CuAssert_Line (tc, file, line, "too few objects read", i < objects->num); - test_check_attrs_msg (tc, file, line, expected->elem[i], objects->elem[i]); + if (i >= objects->num) + p11_test_fail (file, line, function, "too few objects read"); + test_check_attrs_msg (file, line, function, expected->elem[i], objects->elem[i]); } - CuAssert_Line (tc, file, line, "too many objects read", i == objects->num); + if (i != objects->num) + p11_test_fail (file, line, function, "too many objects read"); } else { - CuAssert_Line (tc, file, line, "decoding failed", expected == NULL); + if (expected != NULL) + p11_test_fail (file, line, function, "decoding failed"); } p11_array_free (objects); @@ -123,11 +127,11 @@ check_read_msg (CuTest *tc, p11_array_free (expected); } -#define check_read_success(tc, input, objs) \ - check_read_msg (tc, __FILE__, __LINE__, input, args_to_array objs) +#define check_read_success(input, objs) \ + check_read_msg (__FILE__, __LINE__, __FUNCTION__, input, args_to_array objs) -#define check_read_failure(tc, input) \ - check_read_msg (tc, __FILE__, __LINE__, input, NULL) +#define check_read_failure(input) \ + check_read_msg (__FILE__, __LINE__, __FUNCTION__, input, NULL) static CK_OBJECT_CLASS certificate = CKO_CERTIFICATE; static CK_CERTIFICATE_TYPE x509 = CKC_X_509; @@ -137,7 +141,7 @@ static CK_BBOOL truev = CK_TRUE; static CK_BBOOL falsev = CK_FALSE; static void -test_simple (CuTest *tc) +test_simple (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -151,11 +155,11 @@ test_simple (CuTest *tc) { CKA_INVALID }, }; - check_read_success (tc, input, (expected, NULL)); + check_read_success (input, (expected, NULL)); } static void -test_number (CuTest *tc) +test_number (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -171,11 +175,11 @@ test_number (CuTest *tc) { CKA_INVALID }, }; - check_read_success (tc, input, (expected, NULL)); + check_read_success (input, (expected, NULL)); } static void -test_bool (CuTest *tc) +test_bool (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -191,11 +195,11 @@ test_bool (CuTest *tc) { CKA_INVALID }, }; - check_read_success (tc, input, (expected, NULL)); + check_read_success (input, (expected, NULL)); } static void -test_oid (CuTest *tc) +test_oid (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -207,11 +211,11 @@ test_oid (CuTest *tc) { CKA_INVALID }, }; - check_read_success (tc, input, (expected, NULL)); + check_read_success (input, (expected, NULL)); } static void -test_constant (CuTest *tc) +test_constant (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -225,11 +229,11 @@ test_constant (CuTest *tc) { CKA_INVALID }, }; - check_read_success (tc, input, (expected, NULL)); + check_read_success (input, (expected, NULL)); } static void -test_multiple (CuTest *tc) +test_multiple (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -252,11 +256,11 @@ test_multiple (CuTest *tc) { CKA_INVALID }, }; - check_read_success (tc, input, (expected1, expected2, NULL)); + check_read_success (input, (expected1, expected2, NULL)); } static void -test_pem_block (CuTest *tc) +test_pem_block (void) { const char *input = "[p11-kit-object-v1]\n" "class: certificate\n" @@ -286,11 +290,11 @@ test_pem_block (CuTest *tc) { CKA_INVALID }, }; - check_read_success (tc, input, (expected, NULL)); + check_read_success (input, (expected, NULL)); } static void -test_pem_invalid (CuTest *tc) +test_pem_invalid (void) { const char *input = "[p11-kit-object-v1]\n" "class: certificate\n" @@ -311,13 +315,13 @@ test_pem_invalid (CuTest *tc) p11_message_quiet (); - check_read_failure (tc, input); + check_read_failure (input); p11_message_loud (); } static void -test_pem_unsupported (CuTest *tc) +test_pem_unsupported (void) { const char *input = "[p11-kit-object-v1]\n" "class: certificate\n" @@ -327,13 +331,13 @@ test_pem_unsupported (CuTest *tc) p11_message_quiet (); - check_read_failure (tc, input); + check_read_failure (input); p11_message_loud (); } static void -test_pem_first (CuTest *tc) +test_pem_first (void) { const char *input = "-----BEGIN BLOCK1-----\n" "aYNNXqshlVxCdo8QfKeXh3GUzd/yn4LYIVgQrx4a\n" @@ -343,13 +347,13 @@ test_pem_first (CuTest *tc) p11_message_quiet (); - check_read_failure (tc, input); + check_read_failure (input); p11_message_loud (); } static void -test_skip_unknown (CuTest *tc) +test_skip_unknown (void) { const char *input = "[version-2]\n" "class: data\n" @@ -371,13 +375,13 @@ test_skip_unknown (CuTest *tc) p11_message_quiet (); - check_read_success (tc, input, (expected2, NULL)); + check_read_success (input, (expected2, NULL)); p11_message_loud (); } static void -test_bad_value (CuTest *tc) +test_bad_value (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -385,13 +389,13 @@ test_bad_value (CuTest *tc) p11_message_quiet (); - check_read_failure (tc, input); + check_read_failure (input); p11_message_loud (); } static void -test_bad_oid (CuTest *tc) +test_bad_oid (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -399,13 +403,13 @@ test_bad_oid (CuTest *tc) p11_message_quiet (); - check_read_failure (tc, input); + check_read_failure (input); p11_message_loud (); } static void -test_bad_field (CuTest *tc) +test_bad_field (void) { const char *input = "[p11-kit-object-v1]\n" "class: data\n" @@ -413,13 +417,13 @@ test_bad_field (CuTest *tc) p11_message_quiet (); - check_read_failure (tc, input); + check_read_failure (input); p11_message_loud (); } static void -test_attribute_first (CuTest *tc) +test_attribute_first (void) { const char *input = "class: data\n" "[p11-kit-object-v1]\n" @@ -427,45 +431,30 @@ test_attribute_first (CuTest *tc) p11_message_quiet (); - check_read_failure (tc, input); + check_read_failure (input); p11_message_loud (); } int -main (void) +main (int argc, + char *argv[]) { - CuString *output = CuStringNew (); - CuSuite* suite = CuSuiteNew (); - int ret; - - putenv ("P11_KIT_STRICT=1"); - p11_debug_init (); - - SUITE_ADD_TEST (suite, test_magic); - SUITE_ADD_TEST (suite, test_simple); - SUITE_ADD_TEST (suite, test_number); - SUITE_ADD_TEST (suite, test_bool); - SUITE_ADD_TEST (suite, test_oid); - SUITE_ADD_TEST (suite, test_constant); - SUITE_ADD_TEST (suite, test_multiple); - SUITE_ADD_TEST (suite, test_pem_block); - SUITE_ADD_TEST (suite, test_pem_invalid); - SUITE_ADD_TEST (suite, test_pem_unsupported); - SUITE_ADD_TEST (suite, test_pem_first); - SUITE_ADD_TEST (suite, test_bad_value); - SUITE_ADD_TEST (suite, test_bad_oid); - SUITE_ADD_TEST (suite, test_bad_field); - SUITE_ADD_TEST (suite, test_skip_unknown); - SUITE_ADD_TEST (suite, test_attribute_first); - - CuSuiteRun (suite); - CuSuiteSummary (suite, output); - CuSuiteDetails (suite, output); - printf ("%s\n", output->buffer); - ret = suite->failCount; - CuSuiteDelete (suite); - CuStringDelete (output); - - return ret; + p11_test (test_magic, "/persist/magic"); + p11_test (test_simple, "/persist/simple"); + p11_test (test_number, "/persist/number"); + p11_test (test_bool, "/persist/bool"); + p11_test (test_oid, "/persist/oid"); + p11_test (test_constant, "/persist/constant"); + p11_test (test_multiple, "/persist/multiple"); + p11_test (test_pem_block, "/persist/pem_block"); + p11_test (test_pem_invalid, "/persist/pem_invalid"); + p11_test (test_pem_unsupported, "/persist/pem_unsupported"); + p11_test (test_pem_first, "/persist/pem_first"); + p11_test (test_bad_value, "/persist/bad_value"); + p11_test (test_bad_oid, "/persist/bad_oid"); + p11_test (test_bad_field, "/persist/bad_field"); + p11_test (test_skip_unknown, "/persist/skip_unknown"); + p11_test (test_attribute_first, "/persist/attribute_first"); + return p11_test_run (argc, argv); } diff --git a/trust/tests/test-token.c b/trust/tests/test-token.c index ffd733f..6f5ccdb 100644 --- a/trust/tests/test-token.c +++ b/trust/tests/test-token.c @@ -33,7 +33,8 @@ */ #include "config.h" -#include "CuTest.h" +#include "test.h" +#include "test-trust.h" #include #include @@ -43,7 +44,6 @@ #include "debug.h" #include "pkcs11x.h" #include "message.h" -#include "test-data.h" #include "token.h" struct { @@ -51,40 +51,35 @@ struct { } test; static void -setup (CuTest *cu, - const char *path) +setup (void *path) { test.token = p11_token_new (333, path, "Label"); - CuAssertPtrNotNull (cu, test.token); + assert_ptr_not_null (test.token); } static void -teardown (CuTest *cu) +teardown (void *path) { p11_token_free (test.token); memset (&test, 0, sizeof (test)); } static void -test_token_load (CuTest *cu) +test_token_load (void *path) { p11_index *index; int count; - setup (cu, SRCDIR "/input"); - count = p11_token_load (test.token); - CuAssertIntEquals (cu, 7, count); + assert_num_eq (7, count); /* A certificate and trust object for each parsed object + builtin */ index = p11_token_index (test.token); - CuAssertTrue (cu, ((count - 1) * 2) + 1 <= p11_index_size (index)); - - teardown (cu); + assert (((count - 1) * 2) + 1 <= p11_index_size (index)); } static void -test_token_flags (CuTest *cu) +test_token_flags (void *path) { CK_OBJECT_CLASS certificate = CKO_CERTIFICATE; CK_BBOOL falsev = CK_FALSE; @@ -178,78 +173,50 @@ test_token_flags (CuTest *cu) CK_ATTRIBUTE *object; int i; - setup (cu, SRCDIR "/input"); - if (p11_token_load (test.token) < 0) - CuFail (cu, "should not be reached"); + assert_not_reached (); /* The other objects */ for (i = 0; expected[i]; i++) { handle = p11_index_find (p11_token_index (test.token), expected[i], 2); - CuAssertTrue (cu, handle != 0); + assert (handle != 0); object = p11_index_lookup (p11_token_index (test.token), handle); - CuAssertPtrNotNull (cu, object); + assert_ptr_not_null (object); - test_check_attrs (cu, expected[i], object); + test_check_attrs (expected[i], object); } - - teardown (cu); } static void -test_token_path (CuTest *cu) +test_token_path (void *path) { - setup (cu, "/wheee"); - - CuAssertStrEquals (cu, "/wheee", p11_token_get_path (test.token)); - - teardown (cu); + assert_str_eq (path, p11_token_get_path (test.token)); } static void -test_token_label (CuTest *cu) +test_token_label (void *path) { - setup (cu, "/wheee"); - - CuAssertStrEquals (cu, "Label", p11_token_get_label (test.token)); - - teardown (cu); + assert_str_eq ("Label", p11_token_get_label (test.token)); } static void -test_token_slot (CuTest *cu) +test_token_slot (void *path) { - setup (cu, "/unneeded"); - - CuAssertIntEquals (cu, 333, p11_token_get_slot (test.token)); - - teardown (cu); + assert_num_eq (333, p11_token_get_slot (test.token)); } int -main (void) +main (int argc, + char *argv[]) { - CuString *output = CuStringNew (); - CuSuite* suite = CuSuiteNew (); - int ret; - - putenv ("P11_KIT_STRICT=1"); - p11_debug_init (); - - SUITE_ADD_TEST (suite, test_token_load); - SUITE_ADD_TEST (suite, test_token_flags); - SUITE_ADD_TEST (suite, test_token_path); - SUITE_ADD_TEST (suite, test_token_label); - SUITE_ADD_TEST (suite, test_token_slot); - - CuSuiteRun (suite); - CuSuiteSummary (suite, output); - CuSuiteDetails (suite, output); - printf ("%s\n", output->buffer); - ret = suite->failCount; - CuSuiteDelete (suite); - CuStringDelete (output); - - return ret; + p11_fixture (setup, teardown); + p11_testx (test_token_load, SRCDIR "/input", "/token/load"); + p11_testx (test_token_flags, SRCDIR "/input", "/token/flags"); + + p11_fixture (setup, teardown); + p11_testx (test_token_path, "/wheee", "/token/path"); + p11_testx (test_token_label, "/wheee", "/token/label"); + p11_testx (test_token_slot, "/unneeded", "/token/slot"); + return p11_test_run (argc, argv); } diff --git a/trust/tests/test-trust.c b/trust/tests/test-trust.c new file mode 100644 index 0000000..6b990dc --- /dev/null +++ b/trust/tests/test-trust.c @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2012 Red Hat Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * * The names of contributors to this software may not be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * Author: Stef Walter + */ + +#include "config.h" +#include "test.h" + +#include "attrs.h" +#include "test-trust.h" + +#include +#include +#include +#include + +void +test_check_object_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *attrs, + CK_OBJECT_CLASS klass, + const char *label) +{ + CK_BBOOL vfalse = CK_FALSE; + + CK_ATTRIBUTE expected[] = { + { CKA_PRIVATE, &vfalse, sizeof (vfalse) }, + { CKA_MODIFIABLE, &vfalse, sizeof (vfalse) }, + { CKA_CLASS, &klass, sizeof (klass) }, + { label ? CKA_LABEL : CKA_INVALID, (void *)label, label ? strlen (label) : 0 }, + { CKA_INVALID }, + }; + + test_check_attrs_msg (file, line, function, expected, attrs); +} + +void +test_check_cacert3_ca_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *attrs, + const char *label) +{ + CK_CERTIFICATE_TYPE x509 = CKC_X_509; + CK_ULONG category = 2; /* authority */ + + CK_ATTRIBUTE expected[] = { + { CKA_CERTIFICATE_TYPE, &x509, sizeof (x509) }, + { CKA_CERTIFICATE_CATEGORY, &category, sizeof (category) }, + { CKA_VALUE, (void *)test_cacert3_ca_der, sizeof (test_cacert3_ca_der) }, + { CKA_CHECK_VALUE, "\xad\x7c\x3f", 3 }, + { CKA_START_DATE, "20110523", 8 }, + { CKA_END_DATE, "20210520", 8, }, + { CKA_SUBJECT, (void *)test_cacert3_ca_subject, sizeof (test_cacert3_ca_subject) }, + { CKA_ISSUER, (void *)test_cacert3_ca_issuer, sizeof (test_cacert3_ca_issuer) }, + { CKA_SERIAL_NUMBER, (void *)test_cacert3_ca_serial, sizeof (test_cacert3_ca_serial) }, + { CKA_INVALID }, + }; + + test_check_object_msg (file, line, function, attrs, CKO_CERTIFICATE, label); + test_check_attrs_msg (file, line, function, expected, attrs); +} + +void +test_check_id_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *expected, + CK_ATTRIBUTE *attr) +{ + CK_ATTRIBUTE *one; + CK_ATTRIBUTE *two; + + one = p11_attrs_find (expected, CKA_ID); + two = p11_attrs_find (attr, CKA_ID); + + test_check_attr_msg (file, line, function, CKA_INVALID, one, two); +} + +void +test_check_attrs_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *expected, + CK_ATTRIBUTE *attrs) +{ + CK_OBJECT_CLASS klass; + CK_ATTRIBUTE *attr; + + if (!p11_attrs_find_ulong (expected, CKA_CLASS, &klass)) + klass = CKA_INVALID; + + while (!p11_attrs_terminator (expected)) { + attr = p11_attrs_find (attrs, expected->type); + test_check_attr_msg (file, line, function, klass, expected, attr); + expected++; + } +} + +void +test_check_attr_msg (const char *file, + int line, + const char *function, + CK_OBJECT_CLASS klass, + CK_ATTRIBUTE *expected, + CK_ATTRIBUTE *attr) +{ + assert (expected != NULL); + + if (attr == NULL) { + p11_test_fail (file, line, function, + "attribute does not match: (expected %s but found NULL)", + p11_attr_to_string (expected, klass)); + } + + if (!p11_attr_equal (attr, expected)) { + p11_test_fail (file, line, function, + "attribute does not match: (expected %s but found %s)", + p11_attr_to_string (expected, klass), + p11_attr_to_string (attr, klass)); + } +} diff --git a/trust/tests/test-trust.h b/trust/tests/test-trust.h new file mode 100644 index 0000000..672ae64 --- /dev/null +++ b/trust/tests/test-trust.h @@ -0,0 +1,273 @@ +/* + * Copyright (c) 2012 Red Hat Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or + * other materials provided with the distribution. + * * The names of contributors to this software may not be + * used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF + * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * Author: Stef Walter + */ + +#include "pkcs11.h" + +#include + +#ifndef TEST_DATA_H_ +#define TEST_DATA_H_ + +#define test_check_object(attrs, klass, label) \ + test_check_object_msg (__FILE__, __LINE__, __FUNCTION__, attrs, klass, label) + +void test_check_object_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *attrs, + CK_OBJECT_CLASS klass, + const char *label); + +#define test_check_cacert3_ca(attrs, label) \ + test_check_cacert3_ca_msg (__FILE__, __LINE__, __FUNCTION__, attrs, label) + +void test_check_cacert3_ca_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *attrs, + const char *label); + +#define test_check_attrs(expected, attrs) \ + test_check_attrs_msg (__FILE__, __LINE__, __FUNCTION__, expected, attrs) + +void test_check_attrs_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *expected, + CK_ATTRIBUTE *attrs); + +#define test_check_attr(expected, attr) \ + test_check_attr_msg (__FILE__, __LINE__, __FUNCTION__, CKA_INVALID, expected, attr) + +void test_check_attr_msg (const char *file, + int line, + const char *function, + CK_OBJECT_CLASS klass, + CK_ATTRIBUTE *expected, + CK_ATTRIBUTE *attr); + +#define test_check_id(expected, attrs) \ + test_check_id_msg (__FILE__, __LINE__, __FUNCTION__, expected, attrs) + +void test_check_id_msg (const char *file, + int line, + const char *function, + CK_ATTRIBUTE *expected, + CK_ATTRIBUTE *attr); + +static const unsigned char test_cacert3_ca_der[] = { + 0x30, 0x82, 0x07, 0x59, 0x30, 0x82, 0x05, 0x41, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x03, 0x0a, + 0x41, 0x8a, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, + 0x00, 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, + 0x6f, 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, + 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, + 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, + 0x43, 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, + 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, + 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, + 0x74, 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x1e, 0x17, 0x0d, + 0x31, 0x31, 0x30, 0x35, 0x32, 0x33, 0x31, 0x37, 0x34, 0x38, 0x30, 0x32, 0x5a, 0x17, 0x0d, 0x32, + 0x31, 0x30, 0x35, 0x32, 0x30, 0x31, 0x37, 0x34, 0x38, 0x30, 0x32, 0x5a, 0x30, 0x54, 0x31, 0x14, + 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, + 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, + 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x13, 0x43, + 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, 0x33, 0x20, 0x52, 0x6f, + 0x6f, 0x74, 0x30, 0x82, 0x02, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, + 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x82, 0x02, 0x0f, 0x00, 0x30, 0x82, 0x02, 0x0a, 0x02, 0x82, + 0x02, 0x01, 0x00, 0xab, 0x49, 0x35, 0x11, 0x48, 0x7c, 0xd2, 0x26, 0x7e, 0x53, 0x94, 0xcf, 0x43, + 0xa9, 0xdd, 0x28, 0xd7, 0x42, 0x2a, 0x8b, 0xf3, 0x87, 0x78, 0x19, 0x58, 0x7c, 0x0f, 0x9e, 0xda, + 0x89, 0x7d, 0xe1, 0xfb, 0xeb, 0x72, 0x90, 0x0d, 0x74, 0xa1, 0x96, 0x64, 0xab, 0x9f, 0xa0, 0x24, + 0x99, 0x73, 0xda, 0xe2, 0x55, 0x76, 0xc7, 0x17, 0x7b, 0xf5, 0x04, 0xac, 0x46, 0xb8, 0xc3, 0xbe, + 0x7f, 0x64, 0x8d, 0x10, 0x6c, 0x24, 0xf3, 0x61, 0x9c, 0xc0, 0xf2, 0x90, 0xfa, 0x51, 0xe6, 0xf5, + 0x69, 0x01, 0x63, 0xc3, 0x0f, 0x56, 0xe2, 0x4a, 0x42, 0xcf, 0xe2, 0x44, 0x8c, 0x25, 0x28, 0xa8, + 0xc5, 0x79, 0x09, 0x7d, 0x46, 0xb9, 0x8a, 0xf3, 0xe9, 0xf3, 0x34, 0x29, 0x08, 0x45, 0xe4, 0x1c, + 0x9f, 0xcb, 0x94, 0x04, 0x1c, 0x81, 0xa8, 0x14, 0xb3, 0x98, 0x65, 0xc4, 0x43, 0xec, 0x4e, 0x82, + 0x8d, 0x09, 0xd1, 0xbd, 0xaa, 0x5b, 0x8d, 0x92, 0xd0, 0xec, 0xde, 0x90, 0xc5, 0x7f, 0x0a, 0xc2, + 0xe3, 0xeb, 0xe6, 0x31, 0x5a, 0x5e, 0x74, 0x3e, 0x97, 0x33, 0x59, 0xe8, 0xc3, 0x03, 0x3d, 0x60, + 0x33, 0xbf, 0xf7, 0xd1, 0x6f, 0x47, 0xc4, 0xcd, 0xee, 0x62, 0x83, 0x52, 0x6e, 0x2e, 0x08, 0x9a, + 0xa4, 0xd9, 0x15, 0x18, 0x91, 0xa6, 0x85, 0x92, 0x47, 0xb0, 0xae, 0x48, 0xeb, 0x6d, 0xb7, 0x21, + 0xec, 0x85, 0x1a, 0x68, 0x72, 0x35, 0xab, 0xff, 0xf0, 0x10, 0x5d, 0xc0, 0xf4, 0x94, 0xa7, 0x6a, + 0xd5, 0x3b, 0x92, 0x7e, 0x4c, 0x90, 0x05, 0x7e, 0x93, 0xc1, 0x2c, 0x8b, 0xa4, 0x8e, 0x62, 0x74, + 0x15, 0x71, 0x6e, 0x0b, 0x71, 0x03, 0xea, 0xaf, 0x15, 0x38, 0x9a, 0xd4, 0xd2, 0x05, 0x72, 0x6f, + 0x8c, 0xf9, 0x2b, 0xeb, 0x5a, 0x72, 0x25, 0xf9, 0x39, 0x46, 0xe3, 0x72, 0x1b, 0x3e, 0x04, 0xc3, + 0x64, 0x27, 0x22, 0x10, 0x2a, 0x8a, 0x4f, 0x58, 0xa7, 0x03, 0xad, 0xbe, 0xb4, 0x2e, 0x13, 0xed, + 0x5d, 0xaa, 0x48, 0xd7, 0xd5, 0x7d, 0xd4, 0x2a, 0x7b, 0x5c, 0xfa, 0x46, 0x04, 0x50, 0xe4, 0xcc, + 0x0e, 0x42, 0x5b, 0x8c, 0xed, 0xdb, 0xf2, 0xcf, 0xfc, 0x96, 0x93, 0xe0, 0xdb, 0x11, 0x36, 0x54, + 0x62, 0x34, 0x38, 0x8f, 0x0c, 0x60, 0x9b, 0x3b, 0x97, 0x56, 0x38, 0xad, 0xf3, 0xd2, 0x5b, 0x8b, + 0xa0, 0x5b, 0xea, 0x4e, 0x96, 0xb8, 0x7c, 0xd7, 0xd5, 0xa0, 0x86, 0x70, 0x40, 0xd3, 0x91, 0x29, + 0xb7, 0xa2, 0x3c, 0xad, 0xf5, 0x8c, 0xbb, 0xcf, 0x1a, 0x92, 0x8a, 0xe4, 0x34, 0x7b, 0xc0, 0xd8, + 0x6c, 0x5f, 0xe9, 0x0a, 0xc2, 0xc3, 0xa7, 0x20, 0x9a, 0x5a, 0xdf, 0x2c, 0x5d, 0x52, 0x5c, 0xba, + 0x47, 0xd5, 0x9b, 0xef, 0x24, 0x28, 0x70, 0x38, 0x20, 0x2f, 0xd5, 0x7f, 0x29, 0xc0, 0xb2, 0x41, + 0x03, 0x68, 0x92, 0xcc, 0xe0, 0x9c, 0xcc, 0x97, 0x4b, 0x45, 0xef, 0x3a, 0x10, 0x0a, 0xab, 0x70, + 0x3a, 0x98, 0x95, 0x70, 0xad, 0x35, 0xb1, 0xea, 0x85, 0x2b, 0xa4, 0x1c, 0x80, 0x21, 0x31, 0xa9, + 0xae, 0x60, 0x7a, 0x80, 0x26, 0x48, 0x00, 0xb8, 0x01, 0xc0, 0x93, 0x63, 0x55, 0x22, 0x91, 0x3c, + 0x56, 0xe7, 0xaf, 0xdb, 0x3a, 0x25, 0xf3, 0x8f, 0x31, 0x54, 0xea, 0x26, 0x8b, 0x81, 0x59, 0xf9, + 0xa1, 0xd1, 0x53, 0x11, 0xc5, 0x7b, 0x9d, 0x03, 0xf6, 0x74, 0x11, 0xe0, 0x6d, 0xb1, 0x2c, 0x3f, + 0x2c, 0x86, 0x91, 0x99, 0x71, 0x9a, 0xa6, 0x77, 0x8b, 0x34, 0x60, 0xd1, 0x14, 0xb4, 0x2c, 0xac, + 0x9d, 0xaf, 0x8c, 0x10, 0xd3, 0x9f, 0xc4, 0x6a, 0xf8, 0x6f, 0x13, 0xfc, 0x73, 0x59, 0xf7, 0x66, + 0x42, 0x74, 0x1e, 0x8a, 0xe3, 0xf8, 0xdc, 0xd2, 0x6f, 0x98, 0x9c, 0xcb, 0x47, 0x98, 0x95, 0x40, + 0x05, 0xfb, 0xe9, 0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x02, 0x0d, 0x30, 0x82, 0x02, 0x09, + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x75, 0xa8, 0x71, 0x60, 0x4c, + 0x88, 0x13, 0xf0, 0x78, 0xd9, 0x89, 0x77, 0xb5, 0x6d, 0xc5, 0x89, 0xdf, 0xbc, 0xb1, 0x7a, 0x30, + 0x81, 0xa3, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x81, 0x9b, 0x30, 0x81, 0x98, 0x80, 0x14, 0x16, + 0xb5, 0x32, 0x1b, 0xd4, 0xc7, 0xf3, 0xe0, 0xe6, 0x8e, 0xf3, 0xbd, 0xd2, 0xb0, 0x3a, 0xee, 0xb2, + 0x39, 0x18, 0xd1, 0xa1, 0x7d, 0xa4, 0x7b, 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, + 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, + 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, + 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, 0x43, 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, + 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, + 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, + 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, + 0x72, 0x67, 0x82, 0x01, 0x00, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, + 0x05, 0x30, 0x03, 0x01, 0x01, 0xff, 0x30, 0x5d, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, + 0x01, 0x01, 0x04, 0x51, 0x30, 0x4f, 0x30, 0x23, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, + 0x30, 0x01, 0x86, 0x17, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73, 0x70, 0x2e, + 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x30, 0x28, 0x06, 0x08, 0x2b, + 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x02, 0x86, 0x1c, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, + 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x63, + 0x61, 0x2e, 0x63, 0x72, 0x74, 0x30, 0x4a, 0x06, 0x03, 0x55, 0x1d, 0x20, 0x04, 0x43, 0x30, 0x41, + 0x30, 0x3f, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x81, 0x90, 0x4a, 0x30, 0x33, 0x30, 0x31, + 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x02, 0x01, 0x16, 0x25, 0x68, 0x74, 0x74, 0x70, + 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, + 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x70, 0x68, 0x70, 0x3f, 0x69, 0x64, 0x3d, 0x31, + 0x30, 0x30, 0x34, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, 0xf8, 0x42, 0x01, 0x08, 0x04, 0x27, + 0x16, 0x25, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, 0x63, + 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x70, 0x68, + 0x70, 0x3f, 0x69, 0x64, 0x3d, 0x31, 0x30, 0x30, 0x50, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x86, + 0xf8, 0x42, 0x01, 0x0d, 0x04, 0x43, 0x16, 0x41, 0x54, 0x6f, 0x20, 0x67, 0x65, 0x74, 0x20, 0x79, + 0x6f, 0x75, 0x72, 0x20, 0x6f, 0x77, 0x6e, 0x20, 0x63, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, + 0x61, 0x74, 0x65, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x46, 0x52, 0x45, 0x45, 0x2c, 0x20, 0x67, 0x6f, + 0x20, 0x74, 0x6f, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, + 0x41, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, + 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x03, 0x82, 0x02, 0x01, 0x00, 0x29, 0x28, 0x85, + 0xae, 0x44, 0xa9, 0xb9, 0xaf, 0xa4, 0x79, 0x13, 0xf0, 0xa8, 0xa3, 0x2b, 0x97, 0x60, 0xf3, 0x5c, + 0xee, 0xe3, 0x2f, 0xc1, 0xf6, 0xe2, 0x66, 0xa0, 0x11, 0xae, 0x36, 0x37, 0x3a, 0x76, 0x15, 0x04, + 0x53, 0xea, 0x42, 0xf5, 0xf9, 0xea, 0xc0, 0x15, 0xd8, 0xa6, 0x82, 0xd9, 0xe4, 0x61, 0xae, 0x72, + 0x0b, 0x29, 0x5c, 0x90, 0x43, 0xe8, 0x41, 0xb2, 0xe1, 0x77, 0xdb, 0x02, 0x13, 0x44, 0x78, 0x47, + 0x55, 0xaf, 0x58, 0xfc, 0xcc, 0x98, 0xf6, 0x45, 0xb9, 0xd1, 0x20, 0xf8, 0xd8, 0x21, 0x07, 0xfe, + 0x6d, 0xaa, 0x73, 0xd4, 0xb3, 0xc6, 0x07, 0xe9, 0x09, 0x85, 0xcc, 0x3b, 0xf2, 0xb6, 0xbe, 0x2c, + 0x1c, 0x25, 0xd5, 0x71, 0x8c, 0x39, 0xb5, 0x2e, 0xea, 0xbe, 0x18, 0x81, 0xba, 0xb0, 0x93, 0xb8, + 0x0f, 0xe3, 0xe6, 0xd7, 0x26, 0x8c, 0x31, 0x5a, 0x72, 0x03, 0x84, 0x52, 0xe6, 0xa6, 0xf5, 0x33, + 0x22, 0x45, 0x0a, 0xc8, 0x0b, 0x0d, 0x8a, 0xb8, 0x36, 0x6f, 0x90, 0x09, 0xa1, 0xab, 0xbd, 0xd7, + 0xd5, 0x4e, 0x2e, 0x71, 0xa2, 0xd4, 0xae, 0xfa, 0xa7, 0x54, 0x2b, 0xeb, 0x35, 0x8d, 0x5a, 0xb7, + 0x54, 0x88, 0x2f, 0xee, 0x74, 0x9f, 0xed, 0x48, 0x16, 0xca, 0x0d, 0x48, 0xd0, 0x94, 0xd3, 0xac, + 0xa4, 0xa2, 0xf6, 0x24, 0xdf, 0x92, 0xe3, 0xbd, 0xeb, 0x43, 0x40, 0x91, 0x6e, 0x1c, 0x18, 0x8e, + 0x56, 0xb4, 0x82, 0x12, 0xf3, 0xa9, 0x93, 0x9f, 0xd4, 0xbc, 0x9c, 0xad, 0x9c, 0x75, 0xee, 0x5a, + 0x97, 0x1b, 0x95, 0xe7, 0x74, 0x2d, 0x1c, 0x0f, 0xb0, 0x2c, 0x97, 0x9f, 0xfb, 0xa9, 0x33, 0x39, + 0x7a, 0xe7, 0x03, 0x3a, 0x92, 0x8e, 0x22, 0xf6, 0x8c, 0x0d, 0xe4, 0xd9, 0x7e, 0x0d, 0x76, 0x18, + 0xf7, 0x01, 0xf9, 0xef, 0x96, 0x96, 0xa2, 0x55, 0x73, 0xc0, 0x3c, 0x71, 0xb4, 0x1d, 0x1a, 0x56, + 0x43, 0xb7, 0xc3, 0x0a, 0x8d, 0x72, 0xfc, 0xe2, 0x10, 0x09, 0x0b, 0x41, 0xce, 0x8c, 0x94, 0xa0, + 0xf9, 0x03, 0xfd, 0x71, 0x73, 0x4b, 0x8a, 0x57, 0x33, 0xe5, 0x8e, 0x74, 0x7e, 0x15, 0x01, 0x00, + 0xe6, 0xcc, 0x4a, 0x1c, 0xe7, 0x7f, 0x95, 0x19, 0x2d, 0xc5, 0xa5, 0x0c, 0x8b, 0xbb, 0xb5, 0xed, + 0x85, 0xb3, 0x5c, 0xd3, 0xdf, 0xb8, 0xb9, 0xf2, 0xca, 0xc7, 0x0d, 0x01, 0x14, 0xac, 0x70, 0x58, + 0xc5, 0x8c, 0x8d, 0x33, 0xd4, 0x9d, 0x66, 0xa3, 0x1a, 0x50, 0x95, 0x23, 0xfc, 0x48, 0xe0, 0x06, + 0x43, 0x12, 0xd9, 0xcd, 0xa7, 0x86, 0x39, 0x2f, 0x36, 0x72, 0xa3, 0x80, 0x10, 0xe4, 0xe1, 0xf3, + 0xd1, 0xcb, 0x5b, 0x1a, 0xc0, 0xe4, 0x80, 0x9a, 0x7c, 0x13, 0x73, 0x06, 0x4f, 0xdb, 0xa3, 0x6b, + 0x24, 0x0a, 0xba, 0xb3, 0x1c, 0xbc, 0x4a, 0x78, 0xbb, 0xe5, 0xe3, 0x75, 0x38, 0xa5, 0x48, 0xa7, + 0xa2, 0x1e, 0xaf, 0x76, 0xd4, 0x5e, 0xf7, 0x38, 0x86, 0x56, 0x5a, 0x89, 0xce, 0xd6, 0xc3, 0xa7, + 0x79, 0xb2, 0x52, 0xa0, 0xc6, 0xf1, 0x85, 0xb4, 0x25, 0x8c, 0xf2, 0x3f, 0x96, 0xb3, 0x10, 0xd9, + 0x8d, 0x6c, 0x57, 0x3b, 0x9f, 0x6f, 0x86, 0x3a, 0x18, 0x82, 0x22, 0x36, 0xc8, 0xb0, 0x91, 0x38, + 0xdb, 0x2a, 0xa1, 0x93, 0xaa, 0x84, 0x3f, 0xf5, 0x27, 0x65, 0xae, 0x73, 0xd5, 0xc8, 0xd5, 0xd3, + 0x77, 0xea, 0x4b, 0x9d, 0xc7, 0x41, 0xbb, 0xc7, 0xc0, 0xe3, 0xa0, 0x3f, 0xe4, 0x7d, 0xa4, 0x8d, + 0x73, 0xe6, 0x12, 0x4b, 0xdf, 0xa1, 0x73, 0x73, 0x73, 0x3a, 0x80, 0xe8, 0xd5, 0xcb, 0x8e, 0x2f, + 0xcb, 0xea, 0x13, 0xa7, 0xd6, 0x41, 0x8b, 0xac, 0xfa, 0x3c, 0x89, 0xd7, 0x24, 0xf5, 0x4e, 0xb4, + 0xe0, 0x61, 0x92, 0xb7, 0xf3, 0x37, 0x98, 0xc4, 0xbe, 0x96, 0xa3, 0xb7, 0x8a, +}; + +static const char test_cacert3_ca_subject[] = { + 0x30, 0x54, 0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x0b, 0x43, 0x41, 0x63, + 0x65, 0x72, 0x74, 0x20, 0x49, 0x6e, 0x63, 0x2e, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, + 0x0b, 0x13, 0x15, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x43, 0x41, + 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, + 0x03, 0x13, 0x13, 0x43, 0x41, 0x63, 0x65, 0x72, 0x74, 0x20, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x20, + 0x33, 0x20, 0x52, 0x6f, 0x6f, 0x74, +}; + +static const char test_cacert3_ca_issuer[] = { + 0x30, 0x79, 0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x07, 0x52, 0x6f, 0x6f, + 0x74, 0x20, 0x43, 0x41, 0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x15, 0x68, + 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, + 0x2e, 0x6f, 0x72, 0x67, 0x31, 0x22, 0x30, 0x20, 0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x19, 0x43, + 0x41, 0x20, 0x43, 0x65, 0x72, 0x74, 0x20, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x20, 0x41, + 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x09, 0x01, 0x16, 0x12, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, + 0x40, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74, 0x2e, 0x6f, 0x72, 0x67, +}; + +static const char test_cacert3_ca_serial[] = { + 0x02, 0x03, 0x0a, 0x41, 0x8a, +}; + +static const unsigned char verisign_v1_ca[] = { + 0x30, 0x82, 0x02, 0x3c, 0x30, 0x82, 0x01, 0xa5, 0x02, 0x10, 0x3f, 0x69, 0x1e, 0x81, 0x9c, 0xf0, + 0x9a, 0x4a, 0xf3, 0x73, 0xff, 0xb9, 0x48, 0xa2, 0xe4, 0xdd, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, + 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, 0x06, + 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, 0x04, + 0x0a, 0x13, 0x0e, 0x56, 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, 0x63, + 0x2e, 0x31, 0x37, 0x30, 0x35, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2e, 0x43, 0x6c, 0x61, 0x73, + 0x73, 0x20, 0x31, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x50, 0x72, 0x69, 0x6d, 0x61, + 0x72, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x39, 0x36, + 0x30, 0x31, 0x32, 0x39, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x17, 0x0d, 0x32, 0x38, 0x30, + 0x38, 0x30, 0x32, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x5f, 0x31, 0x0b, 0x30, 0x09, + 0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55, 0x53, 0x31, 0x17, 0x30, 0x15, 0x06, 0x03, 0x55, + 0x04, 0x0a, 0x13, 0x0e, 0x56, 0x65, 0x72, 0x69, 0x53, 0x69, 0x67, 0x6e, 0x2c, 0x20, 0x49, 0x6e, + 0x63, 0x2e, 0x31, 0x37, 0x30, 0x35, 0x06, 0x03, 0x55, 0x04, 0x0b, 0x13, 0x2e, 0x43, 0x6c, 0x61, + 0x73, 0x73, 0x20, 0x31, 0x20, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x20, 0x50, 0x72, 0x69, 0x6d, + 0x61, 0x72, 0x79, 0x20, 0x43, 0x65, 0x72, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x20, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x30, 0x81, 0x9f, 0x30, 0x0d, + 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, + 0x00, 0x30, 0x81, 0x89, 0x02, 0x81, 0x81, 0x00, 0xe5, 0x19, 0xbf, 0x6d, 0xa3, 0x56, 0x61, 0x2d, + 0x99, 0x48, 0x71, 0xf6, 0x67, 0xde, 0xb9, 0x8d, 0xeb, 0xb7, 0x9e, 0x86, 0x80, 0x0a, 0x91, 0x0e, + 0xfa, 0x38, 0x25, 0xaf, 0x46, 0x88, 0x82, 0xe5, 0x73, 0xa8, 0xa0, 0x9b, 0x24, 0x5d, 0x0d, 0x1f, + 0xcc, 0x65, 0x6e, 0x0c, 0xb0, 0xd0, 0x56, 0x84, 0x18, 0x87, 0x9a, 0x06, 0x9b, 0x10, 0xa1, 0x73, + 0xdf, 0xb4, 0x58, 0x39, 0x6b, 0x6e, 0xc1, 0xf6, 0x15, 0xd5, 0xa8, 0xa8, 0x3f, 0xaa, 0x12, 0x06, + 0x8d, 0x31, 0xac, 0x7f, 0xb0, 0x34, 0xd7, 0x8f, 0x34, 0x67, 0x88, 0x09, 0xcd, 0x14, 0x11, 0xe2, + 0x4e, 0x45, 0x56, 0x69, 0x1f, 0x78, 0x02, 0x80, 0xda, 0xdc, 0x47, 0x91, 0x29, 0xbb, 0x36, 0xc9, + 0x63, 0x5c, 0xc5, 0xe0, 0xd7, 0x2d, 0x87, 0x7b, 0xa1, 0xb7, 0x32, 0xb0, 0x7b, 0x30, 0xba, 0x2a, + 0x2f, 0x31, 0xaa, 0xee, 0xa3, 0x67, 0xda, 0xdb, 0x02, 0x03, 0x01, 0x00, 0x01, 0x30, 0x0d, 0x06, + 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x05, 0x05, 0x00, 0x03, 0x81, 0x81, 0x00, + 0x58, 0x15, 0x29, 0x39, 0x3c, 0x77, 0xa3, 0xda, 0x5c, 0x25, 0x03, 0x7c, 0x60, 0xfa, 0xee, 0x09, + 0x99, 0x3c, 0x27, 0x10, 0x70, 0xc8, 0x0c, 0x09, 0xe6, 0xb3, 0x87, 0xcf, 0x0a, 0xe2, 0x18, 0x96, + 0x35, 0x62, 0xcc, 0xbf, 0x9b, 0x27, 0x79, 0x89, 0x5f, 0xc9, 0xc4, 0x09, 0xf4, 0xce, 0xb5, 0x1d, + 0xdf, 0x2a, 0xbd, 0xe5, 0xdb, 0x86, 0x9c, 0x68, 0x25, 0xe5, 0x30, 0x7c, 0xb6, 0x89, 0x15, 0xfe, + 0x67, 0xd1, 0xad, 0xe1, 0x50, 0xac, 0x3c, 0x7c, 0x62, 0x4b, 0x8f, 0xba, 0x84, 0xd7, 0x12, 0x15, + 0x1b, 0x1f, 0xca, 0x5d, 0x0f, 0xc1, 0x52, 0x94, 0x2a, 0x11, 0x99, 0xda, 0x7b, 0xcf, 0x0c, 0x36, + 0x13, 0xd5, 0x35, 0xdc, 0x10, 0x19, 0x59, 0xea, 0x94, 0xc1, 0x00, 0xbf, 0x75, 0x8f, 0xd9, 0xfa, + 0xfd, 0x76, 0x04, 0xdb, 0x62, 0xbb, 0x90, 0x6a, 0x03, 0xd9, 0x46, 0x35, 0xd9, 0xf8, 0x7c, 0x5b, +}; + +#endif /* TEST_DATA_H_ */ -- cgit v1.1