diff options
author | Tomas Mraz <tomas@openssl.org> | 2021-04-22 11:16:37 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-04-23 16:12:22 +0200 |
commit | fff6d5966d00a9e2cb5270e0f7e49abbfce0c9bf (patch) | |
tree | e9431264f727937702c12c4ce1ed1c91d158f309 /test | |
parent | 1636de49219fd9ee11c91015f9c079c45aaf57c6 (diff) |
Test that EVP_PKEY_cmp() returns 1 when comparing a key to itself
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14982)
Diffstat (limited to 'test')
-rw-r--r-- | test/evp_extra_test.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index a74f6332ac..f7ee73e6e2 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -818,10 +818,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 { @@ -851,18 +855,22 @@ static int test_set_get_raw_keys_int(int tst, int pub) EVP_PKEY *pkey; /* 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; pkey = EVP_PKEY_new_raw_public_key(keys[tst].type, NULL, in, inlen); +#else + return 1; +#endif } else { inlen = strlen(keys[tst].priv); in = (unsigned char *)keys[tst].priv; @@ -873,6 +881,7 @@ static int test_set_get_raw_keys_int(int tst, int pub) } if (!TEST_ptr(pkey) + || !TEST_int_eq(EVP_PKEY_cmp(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) |