diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-04-20 16:39:00 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-04-23 10:48:20 +0200 |
commit | 5af6e154d0a4cd5b1d3a46bcfab444e714364d67 (patch) | |
tree | 3563e1526dc84ad14d04a4dd4048890df66687ae /test | |
parent | 0ba8bc058376d423d7c5649cfce83a23cce97267 (diff) |
Trivial shortcuts for EVP_PKEY_eq()
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14942)
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_extra_test.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index a290878a7d..b781c583b5 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -478,7 +478,8 @@ static EVP_PKEY *load_example_hmac_key(void) 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f }; - pkey = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL, key, sizeof(key)); + pkey = EVP_PKEY_new_raw_private_key_ex(testctx, "HMAC", + NULL, key, sizeof(key)); if (!TEST_ptr(pkey)) return NULL; @@ -1544,10 +1545,14 @@ static struct keys_st { } keys[] = { { EVP_PKEY_HMAC, "0123456789", NULL +#ifndef OPENSSL_NO_POLY1305 }, { EVP_PKEY_POLY1305, "01234567890123456789012345678901", NULL +#endif +#ifndef OPENSSL_NO_SIPHASH }, { EVP_PKEY_SIPHASH, "0123456789012345", NULL +#endif }, #ifndef OPENSSL_NO_EC { @@ -1576,16 +1581,14 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx) size_t inlen, len = 0; EVP_PKEY *pkey; - if (nullprov != NULL) - return TEST_skip("Test does not support a non-default library context"); - /* Check if this algorithm supports public keys */ - if (keys[tst].pub == NULL) + if (pub && keys[tst].pub == NULL) return 1; memset(buf, 0, sizeof(buf)); if (pub) { +#ifndef OPENSSL_NO_EC inlen = strlen(keys[tst].pub); in = (unsigned char *)keys[tst].pub; if (uselibctx) { @@ -1601,6 +1604,9 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx) in, inlen); } +#else + return 1; +#endif } else { inlen = strlen(keys[tst].priv); in = (unsigned char *)keys[tst].priv; @@ -1619,6 +1625,7 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx) } if (!TEST_ptr(pkey) + || !TEST_int_eq(EVP_PKEY_eq(pkey, pkey), 1) || (!pub && !TEST_true(EVP_PKEY_get_raw_private_key(pkey, NULL, &len))) || (pub && !TEST_true(EVP_PKEY_get_raw_public_key(pkey, NULL, &len))) || !TEST_true(len == inlen) @@ -1635,9 +1642,9 @@ static int test_set_get_raw_keys_int(int tst, int pub, int uselibctx) static int test_set_get_raw_keys(int tst) { - return test_set_get_raw_keys_int(tst, 0, 0) + return (nullprov != NULL || test_set_get_raw_keys_int(tst, 0, 0)) && test_set_get_raw_keys_int(tst, 0, 1) - && test_set_get_raw_keys_int(tst, 1, 0) + && (nullprov != NULL || test_set_get_raw_keys_int(tst, 1, 0)) && test_set_get_raw_keys_int(tst, 1, 1); } |