diff options
author | Werner Koch <[email protected]> | 2002-08-30 16:34:13 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2002-08-30 16:34:13 +0000 |
commit | 5dfd5a6dac4d1e5fa5857f68f79dfea7f77bf526 (patch) | |
tree | 63791e9a52eddbadff543c0bb6704e5e09b51cf7 /g10/build-packet.c | |
parent | * random.c: Automagically detect the entrop gatherer when (diff) | |
download | gnupg-5dfd5a6dac4d1e5fa5857f68f79dfea7f77bf526.tar.gz gnupg-5dfd5a6dac4d1e5fa5857f68f79dfea7f77bf526.zip |
* pkclist.c (do_we_trust_pre): Changed the wording of a warning.
* encode.c (encode_simple,encode_crypt): Use new style CTB for
compressssed packets when using MDC. We need to do this so that
concatenated messages are properly decrypted. Old style
compression assumes that it is the last packet; given that we
can't determine the length in advance, the uncompressor does not
know where to start. Actually we should use the new CTB always
but this would break PGP 2 compatibility.
* parse-packet.c (parse): Special treatment for new style CTB
compressed packets.
* build-packet.c (do_mdc): Removed. Was not used.
(do_encrypted_mdc): Count the version number and the MDC packet.
Diffstat (limited to 'g10/build-packet.c')
-rw-r--r-- | g10/build-packet.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c index e7bc3f638..c4508116c 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -44,7 +44,6 @@ static u32 calc_plaintext( PKT_plaintext *pt ); static int do_plaintext( IOBUF out, int ctb, PKT_plaintext *pt ); static int do_encrypted( IOBUF out, int ctb, PKT_encrypted *ed ); static int do_encrypted_mdc( IOBUF out, int ctb, PKT_encrypted *ed ); -static int do_mdc( IOBUF out, PKT_mdc *mdc ); static int do_compressed( IOBUF out, int ctb, PKT_compressed *cd ); static int do_signature( IOBUF out, int ctb, PKT_signature *sig ); static int do_onepass_sig( IOBUF out, int ctb, PKT_onepass_sig *ops ); @@ -122,9 +121,6 @@ build_packet( IOBUF out, PACKET *pkt ) case PKT_ENCRYPTED_MDC: rc = do_encrypted_mdc( out, ctb, pkt->pkt.encrypted ); break; - case PKT_MDC: - rc = do_mdc( out, pkt->pkt.mdc ); - break; case PKT_COMPRESSED: rc = do_compressed( out, ctb, pkt->pkt.compressed ); break; @@ -136,6 +132,7 @@ build_packet( IOBUF out, PACKET *pkt ) break; case PKT_RING_TRUST: break; /* ignore it (keyring.c does write it directly)*/ + case PKT_MDC: /* we write it directly, so we should never see it here. */ default: log_bug("invalid packet type in build_packet()\n"); break; @@ -580,7 +577,8 @@ do_encrypted_mdc( IOBUF out, int ctb, PKT_encrypted *ed ) assert( ed->mdc_method ); - n = ed->len ? (ed->len + ed->extralen) : 0; + /* Take version number and the following MDC packet in account. */ + n = ed->len ? (ed->len + ed->extralen + 1 + 22) : 0; write_header(out, ctb, n ); iobuf_put(out, 1 ); /* version */ @@ -591,22 +589,15 @@ do_encrypted_mdc( IOBUF out, int ctb, PKT_encrypted *ed ) static int -do_mdc( IOBUF out, PKT_mdc *mdc ) -{ - /* This packet requires a fixed header encoding */ - iobuf_put( out, 0xd3 ); /* packet ID and 1 byte length */ - iobuf_put( out, 0x14 ); /* length = 20 */ - if( iobuf_write( out, mdc->hash, sizeof(mdc->hash) ) ) - return G10ERR_WRITE_FILE; - return 0; -} - -static int do_compressed( IOBUF out, int ctb, PKT_compressed *cd ) { int rc = 0; - /* we must use the old convention and don't use blockmode */ + /* We must use the old convention and don't use blockmode for tyhe + sake of PGP 2 compatibility. However if the new_ctb flag was + set, CTB is already formatted as new style and write_header2 + does create a partial length encoding using new the new + style. */ write_header2(out, ctb, 0, 0, 0 ); iobuf_put(out, cd->algorithm ); |