--- pgp/src/mdfile.c 2018/04/24 16:38:21 1.1.1.2 +++ pgp/src/mdfile.c 2018/04/24 16:39:56 1.1.1.4 @@ -61,7 +61,7 @@ int MDfile0_len(MD5_CTX *mdContext, FILE /* Computes the message digest for a file from current position to EOF. Uses the RSA Data Security Inc. MD5 Message Digest Algorithm */ -int MDfile0(MD5_CTX *mdContext,FILE *inFile) +static int MDfile0(MD5_CTX *mdContext,FILE *inFile) { int bytes; unsigned char buffer[1024]; @@ -87,14 +87,16 @@ int MDfile(MD5_CTX *mdContext,char *file return(0); } -/* Finish the MD5 calculation with an extra buffer implicitly appended - * to the data. +/* Add a buffer's worth of data to the MD5 computation. If a digest + * pointer is supplied, complete the computation and write the digest. */ -void MD_addbuffer (MD5_CTX *mdContext, byte *buf, int buflen, boolean finish) +void MD_addbuffer (MD5_CTX *mdContext, byte *buf, int buflen, byte digest[16]) { MD5Update(mdContext,buf,buflen); - if (finish) - MD5Final(mdContext); + if (digest) { + MD5Final(digest, mdContext); + burn(*mdContext); /* Paranoia */ + } } /* End MD5 routines */