summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2019-09-25 11:49:04 +0100
committerMatt Caswell <matt@openssl.org>2019-10-03 09:47:34 +0100
commit9a071fef00a6d58cfbce4dab4848eda12f1c7dcf (patch)
tree99df9c9c977160148cc64d764d3814f7971c14d6 /test
parent5f5c3b4f278bedea466bc4338649b8c540372264 (diff)
Add a test for the newly added md params code
Previous commits added code for routing md related parameters via and EVP_SIGNATURE implementation during a DigestSign operation. This adds a test to make sure this works as expected. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/10013)
Diffstat (limited to 'test')
-rw-r--r--test/evp_extra_test.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c
index 12c21e195c..d7f63f0247 100644
--- a/test/evp_extra_test.c
+++ b/test/evp_extra_test.c
@@ -1077,6 +1077,7 @@ done:
/* Test getting and setting parameters on an EVP_PKEY_CTX */
static int test_EVP_PKEY_CTX_get_set_params(void)
{
+ EVP_MD_CTX *mdctx = NULL;
EVP_PKEY_CTX *ctx = NULL;
EVP_SIGNATURE *dsaimpl = NULL;
const OSSL_PARAM *params;
@@ -1087,6 +1088,7 @@ static int test_EVP_PKEY_CTX_get_set_params(void)
int ret = 0;
const EVP_MD *md;
size_t mdsize = SHA512_DIGEST_LENGTH;
+ char ssl3ms[48];
/*
* Setup the parameters for our DSA object. For our purposes they don't have
@@ -1171,9 +1173,39 @@ static int test_EVP_PKEY_CTX_get_set_params(void)
|| !TEST_ptr_eq(md, EVP_sha256()))
goto err;
+ /*
+ * Test getting MD parameters via an associated EVP_PKEY_CTX
+ */
+ mdctx = EVP_MD_CTX_new();
+ if (!TEST_ptr(mdctx)
+ || !TEST_true(EVP_DigestSignInit_ex(mdctx, NULL, "SHA1", NULL,
+ pkey, dsaimpl)))
+ goto err;
+
+ /*
+ * We now have an EVP_MD_CTX with an EVP_PKEY_CTX inside it. We should be
+ * able to obtain the digest's settable parameters from the provider.
+ */
+ params = EVP_MD_CTX_settable_params(mdctx);
+ if (!TEST_ptr(params)
+ || !TEST_int_eq(strcmp(params[0].key, OSSL_DIGEST_PARAM_SSL3_MS), 0)
+ /* The final key should be NULL */
+ || !TEST_ptr_null(params[1].key))
+ goto err;
+
+ param = ourparams;
+ memset(ssl3ms, 0, sizeof(ssl3ms));
+ *param++ = OSSL_PARAM_construct_octet_string(OSSL_DIGEST_PARAM_SSL3_MS,
+ ssl3ms, sizeof(ssl3ms));
+ *param++ = OSSL_PARAM_construct_end();
+
+ if (!TEST_true(EVP_MD_CTX_set_params(mdctx, ourparams)))
+ goto err;
+
ret = 1;
err:
+ EVP_MD_CTX_free(mdctx);
EVP_PKEY_CTX_free(ctx);
EVP_SIGNATURE_free(dsaimpl);
EVP_PKEY_free(pkey);