From 7d04be79dbd4cf47d2b079057f272b34c2256e8f Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Tue, 1 Mar 2016 18:04:42 +0000 Subject: [PATCH] Generalise KDF test in evp_test.c Reviewed-by: Rich Salz --- test/evp_test.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/test/evp_test.c b/test/evp_test.c index fca8107980..bda7f694a3 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -1739,9 +1739,7 @@ static const struct evp_test_method encode_test_method = { encode_test_run, }; -/* - * KDF operations: initially just TLS1 PRF but can be adapted. - */ +/* KDF operations */ struct kdf_data { /* Context for this operation */ @@ -1780,39 +1778,13 @@ static void kdf_test_cleanup(struct evp_test *t) EVP_PKEY_CTX_free(kdata->ctx); } -static int kdf_ctrl(EVP_PKEY_CTX *ctx, int op, const char *value) -{ - unsigned char *buf = NULL; - size_t buf_len; - int rv = 0; - if (test_bin(value, &buf, &buf_len) == 0) - return 0; - if (EVP_PKEY_CTX_ctrl(ctx, -1, -1, op, buf_len, buf) <= 0) - goto err; - rv = 1; - err: - OPENSSL_free(buf); - return rv; -} - static int kdf_test_parse(struct evp_test *t, const char *keyword, const char *value) { struct kdf_data *kdata = t->data; if (strcmp(keyword, "Output") == 0) return test_bin(value, &kdata->output, &kdata->output_len); - else if (strcmp(keyword, "MD") == 0) { - const EVP_MD *md = EVP_get_digestbyname(value); - if (md == NULL) - return 0; - if (EVP_PKEY_CTX_set_tls1_prf_md(kdata->ctx, md) <= 0) - return 0; - return 1; - } else if (strcmp(keyword, "Secret") == 0) { - return kdf_ctrl(kdata->ctx, EVP_PKEY_CTRL_TLS_SECRET, value); - } else if (strncmp("Seed", keyword, 4) == 0) { - return kdf_ctrl(kdata->ctx, EVP_PKEY_CTRL_TLS_SEED, value); - } else if (strncmp(keyword, "Ctrl", 4) == 0) + if (strncmp(keyword, "Ctrl", 4) == 0) return pkey_test_ctrl(kdata->ctx, value); return 0; } -- 2.25.1