diff options
author | Matt Caswell <matt@openssl.org> | 2018-03-19 17:17:58 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2018-03-19 18:12:19 +0100 |
commit | 1bf2cc237e8ac8177a36d179441327f170f96f1b (patch) | |
tree | c22806bfdc88cdfbc67b2e62f1a9693038427477 /test/evp_test.c | |
parent | Fix no-posix-io compile failure (diff) | |
download | openssl-1bf2cc237e8ac8177a36d179441327f170f96f1b.tar.xz openssl-1bf2cc237e8ac8177a36d179441327f170f96f1b.zip |
Fix no-sm2
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5673)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index 3244da6549..32f843e156 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -2413,6 +2413,23 @@ static char *take_value(PAIR *pp) return p; } +static int key_disabled(EVP_PKEY *pkey) +{ +#if defined(OPENSSL_NO_SM2) && !defined(OPENSSL_NO_EC) + int type = EVP_PKEY_base_id(pkey); + + if (type == EVP_PKEY_EC) { + EC_KEY *ec = EVP_PKEY_get0_EC_KEY(pkey); + int nid = EC_GROUP_get_curve_name(EC_KEY_get0_group(ec)); + + if (nid == NID_sm2) + return 1; + } +#endif /* OPENSSL_NO_SM2 */ + + return 0; +} + /* * Read and parse one test. Return 0 if failure, 1 if okay. */ @@ -2439,6 +2456,7 @@ top: if (strcmp(pp->key, "PrivateKey") == 0) { pkey = PEM_read_bio_PrivateKey(t->s.key, NULL, 0, NULL); if (pkey == NULL && !key_unsupported()) { + EVP_PKEY_free(pkey); TEST_info("Can't read private key %s", pp->value); TEST_openssl_errors(); return 0; @@ -2447,6 +2465,7 @@ top: } else if (strcmp(pp->key, "PublicKey") == 0) { pkey = PEM_read_bio_PUBKEY(t->s.key, NULL, 0, NULL); if (pkey == NULL && !key_unsupported()) { + EVP_PKEY_free(pkey); TEST_info("Can't read public key %s", pp->value); TEST_openssl_errors(); return 0; @@ -2497,6 +2516,10 @@ top: } OPENSSL_free(keybin); } + if (pkey != NULL && key_disabled(pkey)) { + EVP_PKEY_free(pkey); + pkey = NULL; + } /* If we have a key add to list */ if (klist != NULL) { |