mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
speed: Fix regression of measuring shake with -evp
After commit b911fef216
speed with shake128 or
shake256 does not run anymore:
# openssl speed -seconds 1 -evp shake128 -bytes 256
Doing shake128 ops for 1s on 256 size blocks: shake128 error!
000003FF9B7F2080:error:1C8000A6:Provider routines:keccak_final:invalid digest
length:providers/implementations/digests/sha3_prov.c:117:
version: 3.4.0-dev
...
type 256 bytes
shake128 0.00
Function EVP_Digest_loop() must use EVP_DigestInit_ex2(), EVP_DigestUpdate(),
and EVP_DigestFinalXOF() in case of shake instead of just EVP_Digest() to get
around this.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24462)
This commit is contained in:
parent
05faa4ffee
commit
184d29dbab
28
apps/speed.c
28
apps/speed.c
@ -613,17 +613,37 @@ static int EVP_Digest_loop(const char *mdname, ossl_unused int algindex, void *a
|
||||
unsigned char digest[EVP_MAX_MD_SIZE];
|
||||
int count;
|
||||
EVP_MD *md = NULL;
|
||||
EVP_MD_CTX *ctx = NULL;
|
||||
|
||||
if (!opt_md_silent(mdname, &md))
|
||||
return -1;
|
||||
for (count = 0; COND(c[algindex][testnum]); count++) {
|
||||
if (!EVP_Digest(buf, (size_t)lengths[testnum], digest, NULL, md,
|
||||
NULL)) {
|
||||
if (EVP_MD_get_flags(md) & EVP_MD_FLAG_XOF) {
|
||||
ctx = EVP_MD_CTX_new();
|
||||
if (ctx == NULL) {
|
||||
count = -1;
|
||||
break;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (count = 0; COND(c[algindex][testnum]); count++) {
|
||||
if (!EVP_DigestInit_ex2(ctx, md, NULL)
|
||||
|| !EVP_DigestUpdate(ctx, buf, (size_t)lengths[testnum])
|
||||
|| !EVP_DigestFinalXOF(ctx, digest, sizeof(digest))) {
|
||||
count = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (count = 0; COND(c[algindex][testnum]); count++) {
|
||||
if (!EVP_Digest(buf, (size_t)lengths[testnum], digest, NULL, md,
|
||||
NULL)) {
|
||||
count = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
EVP_MD_free(md);
|
||||
EVP_MD_CTX_free(ctx);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user