diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2017-01-08 19:30:41 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2017-01-15 00:23:33 +0000 |
commit | 7f5f35af223f9c1d641f46446f6bbf9d1493a9e6 (patch) | |
tree | ad1997b23e2dcb3df7b67358b2d378e271663316 /test/ssl_test_ctx.c | |
parent | 5071824321e1bbe20b859c1a3609ea5ab09fb3f2 (diff) | |
download | openssl-7f5f35af223f9c1d641f46446f6bbf9d1493a9e6.tar.gz |
Add options to check certificate types.
Reviewed-by: Emilia Käsper <emilia@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/2224)
Diffstat (limited to 'test/ssl_test_ctx.c')
-rw-r--r-- | test/ssl_test_ctx.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/test/ssl_test_ctx.c b/test/ssl_test_ctx.c index 2c5ba1e5bb..f8d5ecda14 100644 --- a/test/ssl_test_ctx.c +++ b/test/ssl_test_ctx.c @@ -433,17 +433,21 @@ IMPLEMENT_SSL_TEST_INT_OPTION(SSL_TEST_CTX, test, app_data_size) IMPLEMENT_SSL_TEST_INT_OPTION(SSL_TEST_CTX, test, max_fragment_size) /***********************/ -/* ExpectedTmpKeyType */ +/* Expected key types */ /***********************/ -__owur static int parse_expected_tmp_key_type(SSL_TEST_CTX *test_ctx, - const char *value) +__owur static int parse_expected_key_type(int *ptype, const char *value) { int nid; + const EVP_PKEY_ASN1_METHOD *ameth; if (value == NULL) return 0; - nid = OBJ_sn2nid(value); + ameth = EVP_PKEY_asn1_find_str(NULL, value, -1); + if (ameth != NULL) + EVP_PKEY_asn1_get0_info(&nid, NULL, NULL, NULL, NULL, ameth); + else + nid = OBJ_sn2nid(value); if (nid == NID_undef) nid = OBJ_ln2nid(value); #ifndef OPENSSL_NO_EC @@ -452,10 +456,30 @@ __owur static int parse_expected_tmp_key_type(SSL_TEST_CTX *test_ctx, #endif if (nid == NID_undef) return 0; - test_ctx->expected_tmp_key_type = nid; + *ptype = nid; return 1; } +__owur static int parse_expected_tmp_key_type(SSL_TEST_CTX *test_ctx, + const char *value) +{ + return parse_expected_key_type(&test_ctx->expected_tmp_key_type, value); +} + +__owur static int parse_expected_server_cert_type(SSL_TEST_CTX *test_ctx, + const char *value) +{ + return parse_expected_key_type(&test_ctx->expected_server_cert_type, + value); +} + +__owur static int parse_expected_client_cert_type(SSL_TEST_CTX *test_ctx, + const char *value) +{ + return parse_expected_key_type(&test_ctx->expected_client_cert_type, + value); +} + /*************************************************************/ /* Known test options and their corresponding parse methods. */ /*************************************************************/ @@ -481,6 +505,8 @@ static const ssl_test_ctx_option ssl_test_ctx_options[] = { { "ApplicationData", &parse_test_app_data_size }, { "MaxFragmentSize", &parse_test_max_fragment_size }, { "ExpectedTmpKeyType", &parse_expected_tmp_key_type }, + { "ExpectedServerCertType", &parse_expected_server_cert_type }, + { "ExpectedClientCertType", &parse_expected_client_cert_type }, }; /* Nested client options. */ |