return result;
}
-#define X509_NAME_ADD(n, rd, s) X509_NAME_add_entry_by_txt((n), (rd), \
- MBSTRING_ASC, (unsigned char *)(s), -1, -1, 0)
+#define X509_NAME_ADD(n, rd, s) \
+ X509_NAME_add_entry_by_txt((n), (rd), MBSTRING_ASC, (unsigned char *)(s), \
+ -1, -1, 0)
static int execute_HDR_get0_senderNonce_test(CMP_HDR_TEST_FIXTURE *fixture)
{
if (!TEST_int_eq(fixture->hdr->sender->type, GEN_DIRNAME))
return 0;
- if (!TEST_int_eq(
- X509_NAME_cmp(fixture->hdr->sender->d.directoryName, x509name), 0))
+ if (!TEST_int_eq(X509_NAME_cmp(fixture->hdr->sender->d.directoryName,
+ x509name), 0))
return 0;
X509_NAME_free(x509name);
if (!TEST_int_eq(fixture->hdr->recipient->type, GEN_DIRNAME))
return 0;
- if (!TEST_int_eq(
- X509_NAME_cmp(fixture->hdr->recipient->d.directoryName, x509name),0))
+ if (!TEST_int_eq(X509_NAME_cmp(fixture->hdr->recipient->d.directoryName,
+ x509name), 0))
return 0;
X509_NAME_free(x509name);
static int execute_HDR_set1_senderKID_test(CMP_HDR_TEST_FIXTURE *fixture)
{
- ASN1_OCTET_STRING* senderKID = ASN1_OCTET_STRING_new();
+ ASN1_OCTET_STRING *senderKID = ASN1_OCTET_STRING_new();
if (!TEST_ptr(senderKID))
return 0;
return 0;
if (!TEST_int_eq(ossl_cmp_hdr_set1_senderKID(fixture->hdr, senderKID), 1))
return 0;
- if (!TEST_int_eq(
- ASN1_OCTET_STRING_cmp(fixture->hdr->senderKID, senderKID), 0))
+ if (!TEST_int_eq(ASN1_OCTET_STRING_cmp(fixture->hdr->senderKID,
+ senderKID), 0))
return 0;
ASN1_OCTET_STRING_free(senderKID);
static int execute_HDR_push0_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
{
- ASN1_UTF8STRING* text = ASN1_UTF8STRING_new();
+ ASN1_UTF8STRING *text = ASN1_UTF8STRING_new();
if (!TEST_ptr(text))
return 0;
if (!ASN1_STRING_set(text, "A free text", -1))
return 0;
- if (!TEST_int_eq(
- ossl_cmp_hdr_push0_freeText(fixture->hdr, text), 1))
+ if (!TEST_int_eq(ossl_cmp_hdr_push0_freeText(fixture->hdr, text), 1))
return 0;
- if (!TEST_true(text == sk_ASN1_UTF8STRING_value(
- fixture->hdr->freeText, 0)))
+
+ if (!TEST_true(text == sk_ASN1_UTF8STRING_value(fixture->hdr->freeText, 0)))
return 0;
return 1;
static int execute_HDR_push1_freeText_test(CMP_HDR_TEST_FIXTURE *fixture)
{
- ASN1_UTF8STRING* text = ASN1_UTF8STRING_new();
+ ASN1_UTF8STRING *text = ASN1_UTF8STRING_new();
+ ASN1_UTF8STRING *pushed_text;
if (!TEST_ptr(text))
return 0;
if (!ASN1_STRING_set(text, "A free text", -1))
return 0;
- if (!TEST_int_eq(
- ossl_cmp_hdr_push1_freeText(fixture->hdr, text), 1))
+ if (!TEST_int_eq(ossl_cmp_hdr_push1_freeText(fixture->hdr, text), 1))
return 0;
- if (!TEST_int_eq(ASN1_STRING_cmp(
- sk_ASN1_UTF8STRING_value(fixture->hdr->freeText, 0), text), 0))
+
+ pushed_text = sk_ASN1_UTF8STRING_value(fixture->hdr->freeText, 0);
+ if (!TEST_int_eq(ASN1_STRING_cmp(text, pushed_text), 0))
return 0;
ASN1_UTF8STRING_free(text);
if (!TEST_ptr(itav))
return 0;
- if (!TEST_int_eq(
- ossl_cmp_hdr_generalInfo_push0_item(fixture->hdr, itav), 1))
+ if (!TEST_int_eq(ossl_cmp_hdr_generalInfo_push0_item(fixture->hdr, itav),
+ 1))
return 0;
- if (!TEST_true(itav == sk_OSSL_CMP_ITAV_value(
- fixture->hdr->generalInfo, 0)))
+
+ if (!TEST_true(itav == sk_OSSL_CMP_ITAV_value(fixture->hdr->generalInfo,
+ 0)))
return 0;
return 1;
{
const char oid[] = "1.2.3.4";
char buf[20];
- OSSL_CMP_ITAV *itav;
- STACK_OF(OSSL_CMP_ITAV) *itavs = NULL;
+ OSSL_CMP_ITAV *itav, *pushed_itav;
+ STACK_OF(OSSL_CMP_ITAV) *itavs = NULL, *ginfo;
ASN1_INTEGER *asn1int = ASN1_INTEGER_new();
ASN1_TYPE *val = ASN1_TYPE_new();
+ ASN1_TYPE *pushed_val;
if (!TEST_ptr(asn1int))
return 0;
itav = OSSL_CMP_ITAV_create(OBJ_txt2obj(oid, 1), val);
OSSL_CMP_ITAV_push0_stack_item(&itavs, itav);
- if (!TEST_int_eq(
- ossl_cmp_hdr_generalInfo_push1_items(fixture->hdr, itavs), 1))
+ if (!TEST_int_eq(ossl_cmp_hdr_generalInfo_push1_items(fixture->hdr, itavs),
+ 1))
return 0;
- OBJ_obj2txt(buf, sizeof(buf), OSSL_CMP_ITAV_get0_type(
- sk_OSSL_CMP_ITAV_value(fixture->hdr->generalInfo, 0)), 0);
+ ginfo = fixture->hdr->generalInfo;
+ pushed_itav = sk_OSSL_CMP_ITAV_value(ginfo, 0);
+ OBJ_obj2txt(buf, sizeof(buf), OSSL_CMP_ITAV_get0_type(pushed_itav), 0);
if (!TEST_int_eq(memcmp(oid, buf, sizeof(oid)), 0))
return 0;
- if (!TEST_int_eq(ASN1_TYPE_cmp(itav->infoValue.other,
- OSSL_CMP_ITAV_get0_value(
- sk_OSSL_CMP_ITAV_value(fixture->hdr->generalInfo, 0))), 0))
+ pushed_val = OSSL_CMP_ITAV_get0_value(sk_OSSL_CMP_ITAV_value(ginfo, 0));
+ if (!TEST_int_eq(ASN1_TYPE_cmp(itav->infoValue.other, pushed_val), 0))
return 0;
sk_OSSL_CMP_ITAV_pop_free(itavs, OSSL_CMP_ITAV_free);
execute_HDR_set_and_check_implicitConfirm_test(CMP_HDR_TEST_FIXTURE
* fixture)
{
- return TEST_false(ossl_cmp_hdr_check_implicitConfirm(fixture->hdr))
+ return TEST_false(ossl_cmp_hdr_has_implicitConfirm(fixture->hdr))
&& TEST_true(ossl_cmp_hdr_set_implicitConfirm(fixture->hdr))
- && TEST_true(ossl_cmp_hdr_check_implicitConfirm(fixture->hdr));
+ && TEST_true(ossl_cmp_hdr_has_implicitConfirm(fixture->hdr));
}
static int test_HDR_set_and_check_implicit_confirm(void)
static int execute_HDR_init_test(CMP_HDR_TEST_FIXTURE *fixture)
{
- ASN1_OCTET_STRING *header_nonce = NULL;
- ASN1_OCTET_STRING *ctx_nonce = NULL;
- int res = 0;
+ ASN1_OCTET_STRING *header_nonce, *header_transactionID;
+ ASN1_OCTET_STRING *ctx_nonce;
if (!TEST_int_eq(fixture->expected,
ossl_cmp_hdr_init(fixture->cmp_ctx, fixture->hdr)))
- goto err;
- if (fixture->expected != 0) {
- if (!TEST_int_eq(ossl_cmp_hdr_get_pvno(fixture->hdr), OSSL_CMP_PVNO)
- || !TEST_true(0 == ASN1_OCTET_STRING_cmp(
- ossl_cmp_hdr_get0_senderNonce(fixture->hdr),
- fixture->cmp_ctx->senderNonce))
- || !TEST_true(0 == ASN1_OCTET_STRING_cmp(
- OSSL_CMP_HDR_get0_transactionID(fixture->hdr),
- fixture->cmp_ctx->transactionID)))
- goto err;
- header_nonce = OSSL_CMP_HDR_get0_recipNonce(fixture->hdr);
- ctx_nonce = fixture->cmp_ctx->recipNonce;
- if (ctx_nonce != NULL
- && (!TEST_ptr(header_nonce)
- || !TEST_int_eq(0, ASN1_OCTET_STRING_cmp(header_nonce,
- ctx_nonce))))
- goto err;
- }
+ return 0;
+ if (fixture->expected == 0)
+ return 1;
- res = 1;
+ if (!TEST_int_eq(ossl_cmp_hdr_get_pvno(fixture->hdr), OSSL_CMP_PVNO))
+ return 0;
- err:
- return res;
+ header_nonce = ossl_cmp_hdr_get0_senderNonce(fixture->hdr);
+ if (!TEST_int_eq(0, ASN1_OCTET_STRING_cmp(header_nonce,
+ fixture->cmp_ctx->senderNonce)))
+ return 0;
+ header_transactionID = OSSL_CMP_HDR_get0_transactionID(fixture->hdr);
+ if (!TEST_true(0 == ASN1_OCTET_STRING_cmp(header_transactionID,
+ fixture->cmp_ctx->transactionID)))
+ return 0;
+
+ header_nonce = OSSL_CMP_HDR_get0_recipNonce(fixture->hdr);
+ ctx_nonce = fixture->cmp_ctx->recipNonce;
+ if (ctx_nonce != NULL
+ && (!TEST_ptr(header_nonce)
+ || !TEST_int_eq(0, ASN1_OCTET_STRING_cmp(header_nonce,
+ ctx_nonce))))
+ return 0;
+
+ return 1;
}
-static int test_HDR_init(void)
+static int test_HDR_init_with_ref(void)
{
SETUP_TEST_FIXTURE(CMP_HDR_TEST_FIXTURE, set_up);
unsigned char ref[CMP_TEST_REFVALUE_LENGTH];
return result;
}
-static int test_HDR_init_no_ref_no_subject(void)
-{
- SETUP_TEST_FIXTURE(CMP_HDR_TEST_FIXTURE, set_up);
- fixture->expected = 0;
- EXECUTE_TEST(execute_HDR_init_test, tear_down);
- return result;
-}
-
void cleanup_tests(void)
{
/* also tests public function OSSL_CMP_HDR_get0_transactionID(): */
/* also tests public function OSSL_CMP_HDR_get0_recipNonce(): */
/* also tests internal function ossl_cmp_hdr_get_pvno(): */
- ADD_TEST(test_HDR_init);
+ ADD_TEST(test_HDR_init_with_ref);
ADD_TEST(test_HDR_init_with_subject);
- ADD_TEST(test_HDR_init_no_ref_no_subject);
/*
* TODO make sure that total number of tests (here currently 24) is shown,
* also for other cmp_*text.c. Currently the test drivers always show 1.