diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2016-03-01 18:04:42 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2016-03-02 20:57:32 +0000 |
commit | 7d04be79dbd4cf47d2b079057f272b34c2256e8f (patch) | |
tree | 0d76d6964daf0843c7b3a405f38b2d5c1ff03bc3 /test/evp_test.c | |
parent | 2ff9e7432d32c454ccc6c6b67442662baa335557 (diff) |
Generalise KDF test in evp_test.c
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 32 |
1 files 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; } |