summaryrefslogtreecommitdiffstats
path: root/cipher/md.c
diff options
context:
space:
mode:
Diffstat (limited to 'cipher/md.c')
-rw-r--r--cipher/md.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/cipher/md.c b/cipher/md.c
index 221cf7199..c89c8bb95 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -28,6 +28,8 @@
#include "errors.h"
+static FILE *dumpfp;
+
/****************
* Open a message digest handle for use with algorithm ALGO.
* More algorithms may be added by md_enable(). The initial algorithm
@@ -38,6 +40,12 @@ md_open( int algo, int secure )
{
MD_HANDLE hd;
+ if( !dumpfp )
+ dumpfp = fopen("md.out", "w");
+ if( !dumpfp )
+ BUG();
+ { int i; for(i=0; i < 16; i++ ) putc('\xff', dumpfp ); }
+
hd = secure ? m_alloc_secure_clear( sizeof *hd )
: m_alloc_clear( sizeof *hd );
if( algo )
@@ -70,6 +78,7 @@ md_copy( MD_HANDLE a )
{
MD_HANDLE b;
+ { int i; for(i=0; i < 16; i++ ) putc('\xee', dumpfp ); }
b = m_is_secure(a)? m_alloc_secure( sizeof *b )
: m_alloc( sizeof *b );
memcpy( b, a, sizeof *a );
@@ -89,6 +98,10 @@ md_close(MD_HANDLE a)
void
md_write( MD_HANDLE a, byte *inbuf, size_t inlen)
{
+ if( a->bufcount && fwrite(a->buffer, a->bufcount, 1, dumpfp ) != 1 )
+ BUG();
+ if( inlen && fwrite(inbuf, inlen, 1, dumpfp ) != 1 )
+ BUG();
if( a->use_rmd160 ) {
rmd160_write( &a->rmd160, a->buffer, a->bufcount );
rmd160_write( &a->rmd160, inbuf, inlen );
@@ -111,6 +124,7 @@ md_final(MD_HANDLE a)
{
if( a->bufcount )
md_write( a, NULL, 0 );
+ { int i; for(i=0; i < 16; i++ ) putc('\xcc', dumpfp ); }
if( a->use_rmd160 ) {
byte *p;
rmd160_final( &a->rmd160 );