diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2018-11-09 14:00:05 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2018-11-14 07:01:09 +1000 |
commit | 6e624a645300d784eaa97ddda29364081ede36d7 (patch) | |
tree | fdf0227b4b31d05f4824f0422cf5ade1500c5420 /test/evp_test.c | |
parent | 7dc6875c5562fce2336b87f59b081e0bf4d7855c (diff) |
KMAC implementation using EVP_MAC
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/7597)
Diffstat (limited to 'test/evp_test.c')
-rw-r--r-- | test/evp_test.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/evp_test.c b/test/evp_test.c index 18b20af5ff..0677b85e6f 100644 --- a/test/evp_test.c +++ b/test/evp_test.c @@ -847,6 +847,8 @@ typedef struct mac_data_st { /* Expected output */ unsigned char *output; size_t output_len; + unsigned char *custom; + size_t custom_len; /* Collection of controls */ STACK_OF(OPENSSL_STRING) *controls; } MAC_DATA; @@ -929,6 +931,7 @@ static void mac_test_cleanup(EVP_TEST *t) OPENSSL_free(mdat->alg); OPENSSL_free(mdat->key); OPENSSL_free(mdat->iv); + OPENSSL_free(mdat->custom); OPENSSL_free(mdat->input); OPENSSL_free(mdat->output); } @@ -942,6 +945,8 @@ static int mac_test_parse(EVP_TEST *t, return parse_bin(value, &mdata->key, &mdata->key_len); if (strcmp(keyword, "IV") == 0) return parse_bin(value, &mdata->iv, &mdata->iv_len); + if (strcmp(keyword, "Custom") == 0) + return parse_bin(value, &mdata->custom, &mdata->custom_len); if (strcmp(keyword, "Algorithm") == 0) { mdata->alg = OPENSSL_strdup(value); if (!mdata->alg) @@ -1124,6 +1129,17 @@ static int mac_test_run_mac(EVP_TEST *t) t->err = "MAC_CTRL_ERROR"; goto err; } + if (expected->custom != NULL) { + rv = EVP_MAC_ctrl(ctx, EVP_MAC_CTRL_SET_CUSTOM, + expected->custom, expected->custom_len); + if (rv == -2) { + t->err = "MAC_CTRL_INVALID"; + goto err; + } else if (rv <= 0) { + t->err = "MAC_CTRL_ERROR"; + goto err; + } + } if (expected->iv != NULL) { rv = EVP_MAC_ctrl(ctx, EVP_MAC_CTRL_SET_IV, |