Skip to content

Commit e1744e3

Browse files
committed
Reuse EVP_MD
1 parent 4981f8f commit e1744e3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

source/evp_hash.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
#include <stdio.h>
2020
#ifndef _WIN32
2121
# include <unistd.h>
22-
# include <libgen.h>
2322
#else
24-
# include <windows.h>
2523
# include "perflib/getopt.h"
2624
#endif /* _WIN32 */
2725

@@ -132,19 +130,19 @@ int hash_sha512_deprecated()
132130
}
133131

134132

135-
int hash_evp(EVP_MD_CTX *mctx, const EVP_MD *evp_md)
133+
int hash_evp(EVP_MD_CTX *mctx)
136134
{
137135
int i;
138136
unsigned char md[EVP_MAX_MD_SIZE];
139137

140-
if (!EVP_DigestInit(mctx, evp_md))
138+
if (!EVP_DigestInit_ex(mctx, NULL, NULL))
141139
return 0;
142140

143141
for (i = 0; i < update_times; i++)
144142
if (!EVP_DigestUpdate(mctx, data, sizeof(data)))
145143
return 0;
146144

147-
return EVP_DigestFinal(mctx, md, NULL);
145+
return EVP_DigestFinal_ex(mctx, md, NULL);
148146
}
149147

150148
void do_hash_deprecated(size_t num)
@@ -167,13 +165,13 @@ void do_hash_evp(size_t num)
167165
OSSL_TIME time;
168166
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
169167

170-
if (mctx == NULL) {
168+
if (mctx == NULL || !EVP_DigestInit_ex(mctx, evp_md, NULL)) {
171169
err = 1;
172170
return;
173171
}
174172

175173
do {
176-
if (!hash_evp(mctx, evp_md)) {
174+
if (!hash_evp(mctx)) {
177175
err = 1;
178176
goto err;
179177
}

0 commit comments

Comments
 (0)