-/* $OpenBSD: ts.c,v 1.15 2018/02/07 05:47:55 jsing Exp $ */
+/* $OpenBSD: ts.c,v 1.16 2021/12/12 20:22:08 tb Exp $ */
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
* project 2002.
*/
goto err;
if (input) {
/* Digest must be computed from an input file. */
- EVP_MD_CTX md_ctx;
+ EVP_MD_CTX *md_ctx;
unsigned char buffer[4096];
int length;
if (*md_value == 0)
goto err;
- EVP_DigestInit(&md_ctx, md);
+ if ((md_ctx = EVP_MD_CTX_new()) == NULL)
+ goto err;
+
+ EVP_DigestInit(md_ctx, md);
while ((length = BIO_read(input, buffer, sizeof(buffer))) > 0) {
- EVP_DigestUpdate(&md_ctx, buffer, length);
+ EVP_DigestUpdate(md_ctx, buffer, length);
}
- EVP_DigestFinal(&md_ctx, *md_value, NULL);
+ EVP_DigestFinal(md_ctx, *md_value, NULL);
+
+ EVP_MD_CTX_free(md_ctx);
} else {
/* Digest bytes are specified with digest. */
long digest_len;