summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorTomas Mraz <tomas@openssl.org>2023-10-24 13:44:26 +0200
committerMatt Caswell <matt@openssl.org>2023-10-25 20:13:39 +0100
commit6a0ae393dd554eb718e5148696e8f437d4faae5b (patch)
treec263d550046a8373339a7b2241df3b1e6ab9c66e /test
parentc7ed5e4697a71012e0a2d9dd5eaf997754ae5156 (diff)
Blake2b: Use OSSL_DIGEST_PARAM_SIZE as settable instead of XOFLEN
BLAKE2 is not really an extensible output function unlike SHAKE as the digest size must be set during the context initialization. Thus it makes no sense to use OSSL_DIGEST_PARAM_XOFLEN. We also need to adjust EVP_DigestFinal_ex() to query the OSSL_DIGEST_PARAM_SIZE as gettable ctx param for the size. Fixes #22488 Reviewed-by: Richard Levitte <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22491)
Diffstat (limited to 'test')
-rw-r--r--test/evp_test.c15
-rw-r--r--test/recipes/30-test_evp_data/evpmd_blake.txt4
2 files changed, 17 insertions, 2 deletions
diff --git a/test/evp_test.c b/test/evp_test.c
index bd1a7cc122..487d6a1ad2 100644
--- a/test/evp_test.c
+++ b/test/evp_test.c
@@ -355,6 +355,8 @@ typedef struct digest_data_st {
int pad_type;
/* XOF mode? */
int xof;
+ /* Size for variable output length but non-XOF */
+ size_t digest_size;
} DIGEST_DATA;
static int digest_test_init(EVP_TEST *t, const char *alg)
@@ -410,6 +412,15 @@ static int digest_test_parse(EVP_TEST *t,
return (mdata->pad_type = atoi(value)) > 0;
if (strcmp(keyword, "XOF") == 0)
return (mdata->xof = atoi(value)) > 0;
+ if (strcmp(keyword, "OutputSize") == 0) {
+ int sz;
+
+ sz = atoi(value);
+ if (sz < 0)
+ return -1;
+ mdata->digest_size = sz;
+ return 1;
+ }
return 0;
}
@@ -463,6 +474,10 @@ static int digest_test_run(EVP_TEST *t)
*p++ = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_XOFLEN,
&expected->output_len);
}
+ if (expected->digest_size > 0) {
+ *p++ = OSSL_PARAM_construct_size_t(OSSL_DIGEST_PARAM_SIZE,
+ &expected->digest_size);
+ }
if (expected->pad_type > 0)
*p++ = OSSL_PARAM_construct_int(OSSL_DIGEST_PARAM_PAD_TYPE,
&expected->pad_type);
diff --git a/test/recipes/30-test_evp_data/evpmd_blake.txt b/test/recipes/30-test_evp_data/evpmd_blake.txt
index 02b3df9e9c..474e659142 100644
--- a/test/recipes/30-test_evp_data/evpmd_blake.txt
+++ b/test/recipes/30-test_evp_data/evpmd_blake.txt
@@ -92,10 +92,10 @@ Output = DF0A9D0C212843A6A934E3902B2DD30D17FBA5F969D2030B12A546D8A6A45E80CF5635F
Digest = BLAKE2b512
Input =
-XOF = 1
+OutputSize = 32
Output = 0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8
Digest = BLAKE2b512
Input = 61
-XOF = 1
+OutputSize = 32
Output = 8928aae63c84d87ea098564d1e03ad813f107add474e56aedd286349c0c03ea4