summaryrefslogtreecommitdiffstats
path: root/g10/build-packet.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1999-05-06 14:26:10 +0200
committerWerner Koch <wk@gnupg.org>1999-05-06 14:26:10 +0200
commit7cb8838061a641c7f507a79fccc5e9a2f7a9c32f (patch)
tree2caf26a1ff44b3153de4daaa6ae61207af95c9d2 /g10/build-packet.c
parentSee ChangeLog: Tue May 4 15:49:29 CEST 1999 Werner Koch (diff)
downloadgnupg2-7cb8838061a641c7f507a79fccc5e9a2f7a9c32f.tar.xz
gnupg2-7cb8838061a641c7f507a79fccc5e9a2f7a9c32f.zip
See ChangeLog: Thu May 6 14:18:17 CEST 1999 Werner Koch
Diffstat (limited to 'g10/build-packet.c')
-rw-r--r--g10/build-packet.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 285f115f4..7a2c1062a 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -258,38 +258,42 @@ hash_public_key( MD_HANDLE md, PKT_public_key *pk )
pkt.pkt.public_key = pk;
if( (rc = build_packet( a, &pkt )) )
log_fatal("build public_key for hashing failed: %s\n", g10_errstr(rc));
- /* skip the constructed header */
- ctb = iobuf_get_noeof(a);
- pktlen = 0;
- if( (ctb & 0x40) ) {
- c = iobuf_get_noeof(a);
- if( c < 192 )
- pktlen = c;
- else if( c < 224 ) {
- pktlen = (c - 192) * 256;
+
+ if( !(pk->version == 3 && pk->pubkey_algo == 16) ) {
+ /* skip the constructed header but don't do this for our very old
+ * v3 ElG keys */
+ ctb = iobuf_get_noeof(a);
+ pktlen = 0;
+ if( (ctb & 0x40) ) {
c = iobuf_get_noeof(a);
- pktlen += c + 192;
- }
- else if( c == 255 ) {
- pktlen = iobuf_get_noeof(a) << 24;
- pktlen |= iobuf_get_noeof(a) << 16;
- pktlen |= iobuf_get_noeof(a) << 8;
- pktlen |= iobuf_get_noeof(a);
+ if( c < 192 )
+ pktlen = c;
+ else if( c < 224 ) {
+ pktlen = (c - 192) * 256;
+ c = iobuf_get_noeof(a);
+ pktlen += c + 192;
+ }
+ else if( c == 255 ) {
+ pktlen = iobuf_get_noeof(a) << 24;
+ pktlen |= iobuf_get_noeof(a) << 16;
+ pktlen |= iobuf_get_noeof(a) << 8;
+ pktlen |= iobuf_get_noeof(a);
+ }
}
- }
- else {
- int lenbytes = ((ctb&3)==3)? 0 : (1<<(ctb & 3));
- for( ; lenbytes; lenbytes-- ) {
- pktlen <<= 8;
- pktlen |= iobuf_get_noeof(a);
+ else {
+ int lenbytes = ((ctb&3)==3)? 0 : (1<<(ctb & 3));
+ for( ; lenbytes; lenbytes-- ) {
+ pktlen <<= 8;
+ pktlen |= iobuf_get_noeof(a);
+ }
}
+ /* hash a header */
+ md_putc( md, 0x99 );
+ pktlen &= 0xffff; /* can't handle longer packets */
+ md_putc( md, pktlen >> 8 );
+ md_putc( md, pktlen & 0xff );
}
- /* hash a header */
- md_putc( md, 0x99 );
- pktlen &= 0xffff; /* can't handle longer packets */
- md_putc( md, pktlen >> 8 );
- md_putc( md, pktlen & 0xff );
- /* hash the packet body (don't use pktlen here!) */
+ /* hash the packet body */
while( (c=iobuf_get(a)) != -1 ) {
#if 0
fprintf( fp," %02x", c );