/*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
#include "handshake_helper.h"
#include "ssl_test_ctx.h"
#include "testutil.h"
-#include "test_main_custom.h"
static CONF *conf = NULL;
return 0;
}
+static void print_ca_names(STACK_OF(X509_NAME) *names)
+{
+ int i;
+
+ if (names == NULL || sk_X509_NAME_num(names) == 0) {
+ TEST_note(" <empty>");
+ return;
+ }
+ for (i = 0; i < sk_X509_NAME_num(names); i++) {
+ X509_NAME_print_ex(bio_err, sk_X509_NAME_value(names, i), 4,
+ XN_FLAG_ONELINE);
+ BIO_puts(bio_err, "\n");
+ }
+}
+
+static int check_ca_names(const char *name,
+ STACK_OF(X509_NAME) *expected_names,
+ STACK_OF(X509_NAME) *names)
+{
+ int i;
+
+ if (expected_names == NULL)
+ return 1;
+ if (names == NULL || sk_X509_NAME_num(names) == 0) {
+ if (TEST_int_eq(sk_X509_NAME_num(expected_names), 0))
+ return 1;
+ goto err;
+ }
+ if (sk_X509_NAME_num(names) != sk_X509_NAME_num(expected_names))
+ goto err;
+ for (i = 0; i < sk_X509_NAME_num(names); i++) {
+ if (!TEST_int_eq(X509_NAME_cmp(sk_X509_NAME_value(names, i),
+ sk_X509_NAME_value(expected_names, i)),
+ 0)) {
+ goto err;
+ }
+ }
+ return 1;
+err:
+ TEST_info("%s: list mismatch", name);
+ TEST_note("Expected Names:");
+ print_ca_names(expected_names);
+ TEST_note("Received Names:");
+ print_ca_names(names);
+ return 0;
+}
+
static int check_tmp_key(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx)
{
return check_nid("Tmp key", test_ctx->expected_tmp_key_type,
result->server_sign_type);
}
+static int check_server_ca_names(HANDSHAKE_RESULT *result,
+ SSL_TEST_CTX *test_ctx)
+{
+ return check_ca_names("Server CA names",
+ test_ctx->expected_server_ca_names,
+ result->server_ca_names);
+}
+
static int check_client_cert_type(HANDSHAKE_RESULT *result,
SSL_TEST_CTX *test_ctx)
{
result->client_sign_type);
}
-static void print_ca_names(STACK_OF(X509_NAME) *names)
-{
- BIO *err;
- int i;
-
- if (names == NULL || sk_X509_NAME_num(names) == 0) {
- fprintf(stderr, " <empty>\n");
- return;
- }
- err = BIO_new_fp(stderr, BIO_NOCLOSE);
- for (i = 0; i < sk_X509_NAME_num(names); i++) {
- X509_NAME_print_ex(err, sk_X509_NAME_value(names, i), 4,
- XN_FLAG_ONELINE);
- BIO_puts(err, "\n");
- }
- BIO_free(err);
-}
-
-static int check_ca_names(const char *name,
- STACK_OF(X509_NAME) *expected_names,
- STACK_OF(X509_NAME) *names)
-{
- int i;
-
- if (expected_names == NULL)
- return 1;
- if (names == NULL || sk_X509_NAME_num(names) == 0) {
- if (sk_X509_NAME_num(expected_names) == 0)
- return 1;
- goto err;
- }
- if (sk_X509_NAME_num(names) != sk_X509_NAME_num(expected_names))
- goto err;
- for (i = 0; i < sk_X509_NAME_num(names); i++) {
- if (X509_NAME_cmp(sk_X509_NAME_value(names, i),
- sk_X509_NAME_value(expected_names, i)) != 0) {
- goto err;
- }
- }
- return 1;
- err:
- fprintf(stderr, "%s: list mismatch\nExpected Names:\n", name);
- print_ca_names(expected_names);
- fprintf(stderr, "Received Names:\n");
- print_ca_names(names);
- return 0;
-}
-
static int check_client_ca_names(HANDSHAKE_RESULT *result,
SSL_TEST_CTX *test_ctx)
{
ret &= check_server_cert_type(result, test_ctx);
ret &= check_server_sign_hash(result, test_ctx);
ret &= check_server_sign_type(result, test_ctx);
+ ret &= check_server_ca_names(result, test_ctx);
ret &= check_client_cert_type(result, test_ctx);
ret &= check_client_sign_hash(result, test_ctx);
ret &= check_client_sign_type(result, test_ctx);