1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

See ChangeLog: Mon May 17 21:54:43 CEST 1999 Werner Koch

This commit is contained in:
Werner Koch 1999-05-17 20:03:24 +00:00
parent a1dcec76c1
commit 3983f30bd2
24 changed files with 378 additions and 182 deletions

View file

@ -46,12 +46,18 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
byte temp[18];
unsigned blocksize;
unsigned nprefix;
int use_mdc = opt.force_mdc;
memset( &ed, 0, sizeof ed );
ed.len = cfx->datalen;
ed.new_ctb = !ed.len && !opt.rfc1991;
if( use_mdc ) {
ed.mdc_method = DIGEST_ALGO_SHA1;
cfx->mdc_hash = md_open( DIGEST_ALGO_SHA1, 0 );
md_start_debug( cfx->mdc_hash, "mdccreat" );
}
init_packet( &pkt );
pkt.pkttype = PKT_ENCRYPTED;
pkt.pkttype = use_mdc? PKT_ENCRYPTED_MDC : PKT_ENCRYPTED;
pkt.pkt.encrypted = &ed;
if( build_packet( a, &pkt ))
log_bug("build_packet(ENCR_DATA) failed\n");
@ -68,6 +74,8 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
cipher_setkey( cfx->cipher_hd, cfx->dek->key, cfx->dek->keylen );
cipher_setiv( cfx->cipher_hd, NULL, 0 );
/* log_hexdump( "prefix", temp, nprefix+2 ); */
if( cfx->mdc_hash )
md_write( cfx->mdc_hash, temp, nprefix+2 );
cipher_encrypt( cfx->cipher_hd, temp, temp, nprefix+2);
cipher_sync( cfx->cipher_hd );
iobuf_write(a, temp, nprefix+2);
@ -75,6 +83,7 @@ write_header( cipher_filter_context_t *cfx, IOBUF a )
}
/****************
* This filter is used to en/de-cipher data with a conventional algorithm
*/
@ -94,11 +103,23 @@ cipher_filter( void *opaque, int control,
if( !cfx->header ) {
write_header( cfx, a );
}
if( cfx->mdc_hash )
md_write( cfx->mdc_hash, buf, size );
cipher_encrypt( cfx->cipher_hd, buf, buf, size);
if( iobuf_write( a, buf, size ) )
rc = G10ERR_WRITE_FILE;
}
else if( control == IOBUFCTRL_FREE ) {
if( cfx->mdc_hash ) {
byte *hash;
int hashlen = md_digest_length( md_get_algo( cfx->mdc_hash ) );
md_final( cfx->mdc_hash );
hash = md_read( cfx->mdc_hash, 0 );
cipher_encrypt( cfx->cipher_hd, hash, hash, hashlen );
if( iobuf_write( a, hash, hashlen ) )
rc = G10ERR_WRITE_FILE;
md_close( cfx->mdc_hash ); cfx->mdc_hash = NULL;
}
cipher_close(cfx->cipher_hd);
}
else if( control == IOBUFCTRL_DESC ) {
@ -108,5 +129,3 @@ cipher_filter( void *opaque, int control,
}