summaryrefslogtreecommitdiffstats
path: root/test/evp_extra_test.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-10-15 11:35:09 +0200
committerRichard Levitte <levitte@openssl.org>2019-10-17 13:01:15 +0200
commitcd32a0f5894344b6c8739a3586a20683a6bf2d5a (patch)
tree4fe931ad6bccfc6010880123471a686d9f5047e8 /test/evp_extra_test.c
parent13aa5d29601683e0971763836ec37302fc7cece9 (diff)
Don't abuse the API when that's not what is tested
test_EVP_PKEY_CTX_get_set_params() in test/evp_extra_test.c abused previously sloppy checking in EVP_PKEY_sign_init_ex(), by passing a "key to sign with" that was really just domain parameters. Now that underlying provider import of key payload has become a bit more strict, that leads to errors, so we need to provide at least a public part (even though fake), and because this is a signing operation, a private part as well. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10169)
Diffstat (limited to 'test/evp_extra_test.c')
-rw-r--r--test/evp_extra_test.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index 3a843e6a43..cea1c318c6 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -1201,7 +1201,7 @@ static int test_EVP_PKEY_CTX_get_set_params(void)
const OSSL_PARAM *params;
OSSL_PARAM ourparams[2], *param = ourparams;
DSA *dsa = NULL;
- BIGNUM *p = NULL, *q = NULL, *g = NULL;
+ BIGNUM *p = NULL, *q = NULL, *g = NULL, *pub = NULL, *priv = NULL;
EVP_PKEY *pkey = NULL;
int ret = 0;
const EVP_MD *md;
@@ -1209,21 +1209,24 @@ static int test_EVP_PKEY_CTX_get_set_params(void)
char ssl3ms[48];
/*
- * Setup the parameters for our DSA object. For our purposes they don't have
- * to actually be *valid* parameters. We just need to set something. We
- * don't even need a pub_key/priv_key.
+ * Setup the parameters for our DSA object. For our purposes they don't
+ * have to actually be *valid* parameters. We just need to set something.
*/
dsa = DSA_new();
p = BN_new();
q = BN_new();
g = BN_new();
+ pub = BN_new();
+ priv = BN_new();
if (!TEST_ptr(dsa)
|| !TEST_ptr(p)
|| !TEST_ptr(q)
|| !TEST_ptr(g)
- || !DSA_set0_pqg(dsa, p, q, g))
+ || !TEST_ptr(pub)
+ || !DSA_set0_pqg(dsa, p, q, g)
+ || !DSA_set0_key(dsa, pub, priv))
goto err;
- p = q = g = NULL;
+ p = q = g = pub = priv = NULL;
pkey = EVP_PKEY_new();
if (!TEST_ptr(pkey)
@@ -1331,6 +1334,8 @@ static int test_EVP_PKEY_CTX_get_set_params(void)
BN_free(p);
BN_free(q);
BN_free(g);
+ BN_free(pub);
+ BN_free(priv);
return ret;
}