From 4ddd5aceccee47f5d530b4741b02c839cefc9001 Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sat, 30 Jan 2016 13:17:09 +0000 Subject: handle "Ctrl" in separate function Reviewed-by: Viktor Dukhovni --- test/evp_test.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'test/evp_test.c') diff --git a/test/evp_test.c b/test/evp_test.c index 8618cfe708..6c9f4b8ece 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -1228,6 +1228,22 @@ static void pkey_test_cleanup(struct evp_test *t) EVP_PKEY_CTX_free(kdata->ctx); } +static int pkey_test_ctrl(EVP_PKEY_CTX *pctx, const char *value) +{ + int rv; + char *p, *tmpval; + + tmpval = OPENSSL_strdup(value); + if (tmpval == NULL) + return 0; + p = strchr(tmpval, ':'); + if (p != NULL) + *p++ = 0; + rv = EVP_PKEY_CTX_ctrl_str(pctx, tmpval, p); + OPENSSL_free(tmpval); + return rv > 0; +} + static int pkey_test_parse(struct evp_test *t, const char *keyword, const char *value) { @@ -1236,14 +1252,8 @@ static int pkey_test_parse(struct evp_test *t, return test_bin(value, &kdata->input, &kdata->input_len); if (strcmp(keyword, "Output") == 0) return test_bin(value, &kdata->output, &kdata->output_len); - if (strcmp(keyword, "Ctrl") == 0) { - char *p = strchr(value, ':'); - if (p) - *p++ = 0; - if (EVP_PKEY_CTX_ctrl_str(kdata->ctx, value, p) <= 0) - return 0; - return 1; - } + if (strcmp(keyword, "Ctrl") == 0) + return pkey_test_ctrl(kdata->ctx, value); return 0; } @@ -1362,14 +1372,8 @@ static int pderive_test_parse(struct evp_test *t, } if (strcmp(keyword, "SharedSecret") == 0) return test_bin(value, &kdata->output, &kdata->output_len); - if (strcmp(keyword, "Ctrl") == 0) { - char *p = strchr(value, ':'); - if (p) - *p++ = 0; - if (EVP_PKEY_CTX_ctrl_str(kdata->ctx, value, p) <= 0) - return 0; - return 1; - } + if (strcmp(keyword, "Ctrl") == 0) + return pkey_test_ctrl(kdata->ctx, value); return 0; } -- cgit v1.2.3 size='10' name='q' value=''/>
blob: 38560f2fa756849ebb673cf17a67d79167de368c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23