From 3b1b6f9d98b38480ba2074158fa640b881cdb97e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 3 Dec 1997 10:20:03 +0000 Subject: detached signatures are working --- g10/plaintext.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'g10/plaintext.c') diff --git a/g10/plaintext.c b/g10/plaintext.c index d317fd789..edd12891c 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -82,6 +82,8 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx ) rc = G10ERR_READ_FILE; goto leave; } + if( mfx->md ) + md_putchar(mfx->md, c ); if( mfx->rmd160 ) rmd160_putchar(mfx->rmd160, c ); if( mfx->md5 ) @@ -124,3 +126,42 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx ) return rc; } + +/**************** + * Ask for the detached datafile and calculate the digest from it. + */ +int +ask_for_detached_datafile( md_filter_context_t *mfx ) +{ + char *answer; + FILE *fp; + int rc = 0; + int c; + + tty_printf("Detached signature.\n"); + answer = tty_get("Please enter name of data file: "); + tty_kill_prompt(); + + fp = fopen(answer,"rb"); + if( !fp ) { + log_error("can't open '%s': %s\n", answer, strerror(errno) ); + rc = G10ERR_READ_FILE; + goto leave; + } + + while( (c = getc(fp)) != EOF ) { + if( mfx->md ) + md_putchar(mfx->md, c ); + if( mfx->rmd160 ) + rmd160_putchar(mfx->rmd160, c ); + if( mfx->md5 ) + md5_putchar(mfx->md5, c ); + } + fclose(fp); + + leave: + m_free(answer); + return rc; +} + + -- cgit v1.2.3