diff options
author | slontis <shane.lontis@oracle.com> | 2021-10-11 12:00:12 +1000 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2021-11-05 16:57:08 +0100 |
commit | 51f416d7c90e0eb04f9b0c5be189426e27f5779e (patch) | |
tree | 8d4561b4e691019c4a36e93923c2f6c0dfdc7fd0 /test | |
parent | 07e6c857364770f6e986b5d8ceb9fbe296f3c6d0 (diff) |
Fix tests to check for negative results when calling EVP_PKEY_fromdata_init
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16801)
(cherry picked from commit 884400d78992d1da1573a3677876b06421b797eb)
Diffstat (limited to 'test')
-rw-r--r-- | test/acvp_test.c | 14 | ||||
-rw-r--r-- | test/ectest.c | 10 | ||||
-rw-r--r-- | test/evp_pkey_provided_test.c | 42 | ||||
-rw-r--r-- | test/sslapitest.c | 7 |
4 files changed, 38 insertions, 35 deletions
diff --git a/test/acvp_test.c b/test/acvp_test.c index 10621c3e48..6512a6ec35 100644 --- a/test/acvp_test.c +++ b/test/acvp_test.c @@ -165,7 +165,7 @@ static int ecdsa_create_pkey(EVP_PKEY **pkey, const char *curve_name, pub, pub_len) > 0) || !TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)) || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "EC", NULL)) - || !TEST_true(EVP_PKEY_fromdata_init(ctx)) + || !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) || !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_PUBLIC_KEY, params), expected)) goto err; @@ -504,8 +504,9 @@ static int dsa_create_pkey(EVP_PKEY **pkey, } if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)) || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "DSA", NULL)) - || !TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_PUBLIC_KEY, params))) + || !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_PUBLIC_KEY, + params), 1)) goto err; ret = 1; @@ -925,7 +926,7 @@ static int dh_create_pkey(EVP_PKEY **pkey, const char *group_name, if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)) || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "DH", NULL)) - || !TEST_true(EVP_PKEY_fromdata_init(ctx)) + || !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) || !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_KEYPAIR, params), pass)) goto err; @@ -1034,8 +1035,9 @@ static int rsa_create_pkey(EVP_PKEY **pkey, } if (!TEST_ptr(params = OSSL_PARAM_BLD_to_param(bld)) || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(libctx, "RSA", NULL)) - || !TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_KEYPAIR, params))) + || !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, pkey, EVP_PKEY_KEYPAIR, params), + 1)) goto err; ret = 1; diff --git a/test/ectest.c b/test/ectest.c index c08b14be45..84e515d808 100644 --- a/test/ectest.c +++ b/test/ectest.c @@ -2919,11 +2919,11 @@ static int custom_params_test(int id) /* create two new provider-native `EVP_PKEY`s */ EVP_PKEY_CTX_free(pctx2); if (!TEST_ptr(pctx2 = EVP_PKEY_CTX_new_from_name(NULL, "EC", NULL)) - || !TEST_true(EVP_PKEY_fromdata_init(pctx2)) - || !TEST_true(EVP_PKEY_fromdata(pctx2, &pkey1, EVP_PKEY_KEYPAIR, - params1)) - || !TEST_true(EVP_PKEY_fromdata(pctx2, &pkey2, EVP_PKEY_PUBLIC_KEY, - params2))) + || !TEST_int_eq(EVP_PKEY_fromdata_init(pctx2), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(pctx2, &pkey1, EVP_PKEY_KEYPAIR, + params1), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(pctx2, &pkey2, EVP_PKEY_PUBLIC_KEY, + params2), 1)) goto err; /* compute keyexchange once more using the provider keys */ diff --git a/test/evp_pkey_provided_test.c b/test/evp_pkey_provided_test.c index f6424b86fa..8b5c7b3457 100644 --- a/test/evp_pkey_provided_test.c +++ b/test/evp_pkey_provided_test.c @@ -340,9 +340,9 @@ static int test_fromdata_rsa(void) if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL))) goto err; - if (!TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, - fromdata_params))) + if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, + fromdata_params), 1)) goto err; while (dup_pk == NULL) { @@ -431,9 +431,9 @@ static int test_evp_pkey_get_bn_param_large(void) || !TEST_true(OSSL_PARAM_BLD_push_BN(bld, OSSL_PKEY_PARAM_RSA_D, d)) || !TEST_ptr(fromdata_params = OSSL_PARAM_BLD_to_param(bld)) || !TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL)) - || !TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, - fromdata_params)) + || !TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, + fromdata_params), 1) || !TEST_ptr(key_ctx = EVP_PKEY_CTX_new_from_pkey(NULL, pk, "")) || !TEST_true(EVP_PKEY_get_bn_param(pk, OSSL_PKEY_PARAM_RSA_N, &n_out)) || !TEST_BN_eq(n, n_out)) @@ -522,9 +522,9 @@ static int test_fromdata_dh_named_group(void) if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL))) goto err; - if (!TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, - fromdata_params))) + if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, + fromdata_params), 1)) goto err; /* @@ -734,9 +734,9 @@ static int test_fromdata_dh_fips186_4(void) if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DH", NULL))) goto err; - if (!TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, - fromdata_params))) + if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, + fromdata_params), 1)) goto err; while (dup_pk == NULL) { @@ -1041,9 +1041,9 @@ static int test_fromdata_ecx(int tst) fromdata_params = params; } - if (!TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, - fromdata_params))) + if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, + fromdata_params), 1)) goto err; while (dup_pk == NULL) { @@ -1179,9 +1179,9 @@ static int test_fromdata_ec(void) if (!TEST_ptr(ctx)) goto err; - if (!TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, - fromdata_params))) + if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, + fromdata_params), 1)) goto err; while (dup_pk == NULL) { @@ -1484,9 +1484,9 @@ static int test_fromdata_dsa_fips186_4(void) if (!TEST_ptr(ctx = EVP_PKEY_CTX_new_from_name(NULL, "DSA", NULL))) goto err; - if (!TEST_true(EVP_PKEY_fromdata_init(ctx)) - || !TEST_true(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, - fromdata_params))) + if (!TEST_int_eq(EVP_PKEY_fromdata_init(ctx), 1) + || !TEST_int_eq(EVP_PKEY_fromdata(ctx, &pk, EVP_PKEY_KEYPAIR, + fromdata_params), 1)) goto err; while (dup_pk == NULL) { diff --git a/test/sslapitest.c b/test/sslapitest.c index 68907923e8..c85c8f42c3 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -9014,7 +9014,7 @@ static EVP_PKEY *get_tmp_dh_params(void) pctx = EVP_PKEY_CTX_new_from_name(libctx, "DH", NULL); if (!TEST_ptr(pctx) - || !TEST_true(EVP_PKEY_fromdata_init(pctx))) + || !TEST_int_eq(EVP_PKEY_fromdata_init(pctx), 1)) goto end; tmpl = OSSL_PARAM_BLD_new(); @@ -9029,8 +9029,9 @@ static EVP_PKEY *get_tmp_dh_params(void) params = OSSL_PARAM_BLD_to_param(tmpl); if (!TEST_ptr(params) - || !TEST_true(EVP_PKEY_fromdata(pctx, &dhpkey, - EVP_PKEY_KEY_PARAMETERS, params))) + || !TEST_int_eq(EVP_PKEY_fromdata(pctx, &dhpkey, + EVP_PKEY_KEY_PARAMETERS, + params), 1)) goto end; tmp_dh_params = dhpkey; |