diff options
Diffstat (limited to 'kbx')
-rw-r--r-- | kbx/ChangeLog | 25 | ||||
-rw-r--r-- | kbx/keybox-openpgp.c | 53 |
2 files changed, 38 insertions, 40 deletions
diff --git a/kbx/ChangeLog b/kbx/ChangeLog index 388991995..701e41197 100644 --- a/kbx/ChangeLog +++ b/kbx/ChangeLog @@ -1,3 +1,8 @@ +2011-08-04 Werner Koch <[email protected]> + + * keybox-openpgp.c (parse_key): Remove set but unused vars + EXPIREDATE and NDAYS. + 2010-07-23 Werner Koch <[email protected]> * keybox-blob.c (_keybox_create_x509_blob): Fix reallocation bug. @@ -40,7 +45,7 @@ * keybox-init.c (keybox_new, keybox_release): Track used handles. (_keybox_close_file): New. - * keybox-update.c (keybox_insert_cert, keybox_set_flags) + * keybox-update.c (keybox_insert_cert, keybox_set_flags) (keybox_delete, keybox_compress): Use the new close function. 2008-03-13 Werner Koch <[email protected]> @@ -123,7 +128,7 @@ 2005-06-15 Werner Koch <[email protected]> * keybox-file.c (_keybox_read_blob2): Make IMAGE unsigned. - (_keybox_write_blob): + (_keybox_write_blob): * keybox-blob.c (create_blob_finish, _keybox_create_x509_blob): Fixed warnings about signed/unsigned pointer mismatches. @@ -180,7 +185,7 @@ * keybox-blob.c (_keybox_update_header_blob): New. * keybox-update.c (blob_filecopy): Handle header blob. * keybox-file.c (_keybox_read_blob2): New. Moved code from - _keybox_read_blob to there. + _keybox_read_blob to there. * keybox-dump.c (dump_header_blob): Print header info. 2004-04-21 Werner Koch <[email protected]> @@ -189,11 +194,11 @@ KEYBOX_FLAG_CREATED_AT. * keybox-update.c (keybox_compress): New. - * keybox-search.c (get32, get16, blob_get_type) - (blob_get_blob_flags, has_short_kid, has_long_kid) - (has_fingerprint, has_issuer, has_issuer_sn, has_sn, has_subject) + * keybox-search.c (get32, get16, blob_get_type) + (blob_get_blob_flags, has_short_kid, has_long_kid) + (has_fingerprint, has_issuer, has_issuer_sn, has_sn, has_subject) (has_subject_or_alt, has_mail): inline them. - + * keybox-update.c (blob_filecopy): Fixed an error/eof check (s/if(fread)/if(nread)/). @@ -217,17 +222,17 @@ * keybox-blob.c: Include time.h 2003-06-03 Werner Koch <[email protected]> - + Changed all error codes in all files to the new libgpg-error scheme. * keybox-defs.h: Include gpg-error.h . - (KeyboxError): Removed. + (KeyboxError): Removed. * Makefile.am: Removed keybox-error.c stuff. 2002-11-14 Werner Koch <[email protected]> * keybox-search.c (blob_cmp_name) <compare all names>: Fixed - length compare; there is no 0 stored since nearly a year. + length compare; there is no 0 stored since nearly a year. 2002-10-31 Neal H. Walfield <[email protected]> diff --git a/kbx/keybox-openpgp.c b/kbx/keybox-openpgp.c index 0968cf8b3..e5f9f3352 100644 --- a/kbx/keybox-openpgp.c +++ b/kbx/keybox-openpgp.c @@ -72,8 +72,8 @@ enum packet_types follwing data on success: R_DATAPKT = Pointer to the begin of the packet data. - R_DATALEN = Length of this data. This has already been checked to fit - into the buffer. + R_DATALEN = Length of this data. This has already been checked to fit + into the buffer. R_PKTTYPE = The packet type. R_NTOTAL = The total number of bytes of this packet @@ -91,11 +91,11 @@ next_packet (unsigned char const **bufptr, size_t *buflen, if (!len) return gpg_error (GPG_ERR_NO_DATA); - + ctb = *buf++; len--; if ( !(ctb & 0x80) ) return gpg_error (GPG_ERR_INV_PACKET); /* Invalid CTB. */ - + pktlen = 0; if ((ctb & 0x40)) /* New style (OpenPGP) CTB. */ { @@ -108,7 +108,7 @@ next_packet (unsigned char const **bufptr, size_t *buflen, if ( c < 192 ) pktlen = c; else if ( c < 224 ) - { + { pktlen = (c - 192) * 256; if (!len) return gpg_error (GPG_ERR_INV_PACKET); /* No 2nd length byte. */ @@ -150,7 +150,7 @@ next_packet (unsigned char const **bufptr, size_t *buflen, switch (pkttype) { case PKT_SIGNATURE: - case PKT_SECRET_KEY: + case PKT_SECRET_KEY: case PKT_PUBLIC_KEY: case PKT_SECRET_SUBKEY: case PKT_MARKER: @@ -166,9 +166,9 @@ next_packet (unsigned char const **bufptr, size_t *buflen, return gpg_error (GPG_ERR_UNEXPECTED); } - if (pktlen == 0xffffffff) + if (pktlen == 0xffffffff) return gpg_error (GPG_ERR_INV_PACKET); - + if (pktlen > len) return gpg_error (GPG_ERR_INV_PACKET); /* Packet length header too long. */ @@ -195,7 +195,7 @@ parse_key (const unsigned char *data, size_t datalen, const unsigned char *data_start = data; int i, version, algorithm; size_t n; - unsigned long timestamp, expiredate; + /*unsigned long timestamp;*/ int npkey; unsigned char hashbuffer[768]; const unsigned char *mpi_n = NULL; @@ -207,23 +207,16 @@ parse_key (const unsigned char *data, size_t datalen, version = *data++; datalen--; if (version < 2 || version > 4 ) return gpg_error (GPG_ERR_INV_PACKET); /* Invalid version. */ - - timestamp = ((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|(data[3])); + + /*timestamp = ((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|(data[3]));*/ data +=4; datalen -=4; if (version < 4) { - unsigned short ndays; - if (datalen < 2) return gpg_error (GPG_ERR_INV_PACKET); - ndays = ((data[0]<<8)|(data[1])); - data +=2; datalen -= 2; - if (ndays) - expiredate = ndays? (timestamp + ndays * 86400L) : 0; + data += 2; datalen -= 2; } - else - expiredate = 0; /* This is stored in the self-signature. */ if (!datalen) return gpg_error (GPG_ERR_INV_PACKET); @@ -234,7 +227,7 @@ parse_key (const unsigned char *data, size_t datalen, case 1: case 2: case 3: /* RSA */ - npkey = 2; + npkey = 2; break; case 16: case 20: /* Elgamal */ @@ -250,7 +243,7 @@ parse_key (const unsigned char *data, size_t datalen, for (i=0; i < npkey; i++ ) { unsigned int nbits, nbytes; - + if (datalen < 2) return gpg_error (GPG_ERR_INV_PACKET); nbits = ((data[0]<<8)|(data[1])); @@ -260,14 +253,14 @@ parse_key (const unsigned char *data, size_t datalen, return gpg_error (GPG_ERR_INV_PACKET); /* For use by v3 fingerprint calculation we need to know the RSA modulus and exponent. */ - if (i==0) + if (i==0) { - mpi_n = data; + mpi_n = data; mpi_n_len = nbytes; } else if (i==1) mpi_e_len = nbytes; - + data += nbytes; datalen -= nbytes; } n = data - data_start; @@ -287,12 +280,12 @@ parse_key (const unsigned char *data, size_t datalen, memcpy (ki->fpr, gcry_md_read (md, 0), 16); gcry_md_close (md); ki->fprlen = 16; - + if (mpi_n_len < 8) { /* Moduli less than 64 bit are out of the specs scope. Zero them out becuase this is what gpg does too. */ - memset (ki->keyid, 0, 8); + memset (ki->keyid, 0, 8); } else memcpy (ki->keyid, mpi_n + mpi_n_len - 8, 8); @@ -353,7 +346,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen, int first = 1; struct _keybox_openpgp_key_info *k, **ktail = NULL; struct _keybox_openpgp_uid_info *u, **utail = NULL; - + memset (info, 0, sizeof *info); if (nparsed) *nparsed = 0; @@ -380,7 +373,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen, } else if (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY) break; /* Next keyblock encountered - ready. */ - + if (nparsed) *nparsed += n; @@ -418,7 +411,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen, if (err) break; } - else if( pkttype == PKT_PUBLIC_SUBKEY && datalen && *data == '#' ) + else if( pkttype == PKT_PUBLIC_SUBKEY && datalen && *data == '#' ) { /* Early versions of GnuPG used old PGP comment packets; * luckily all those comments are prefixed by a hash @@ -482,7 +475,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen, if (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY) break; /* Next keyblock encountered - ready. */ - + if (nparsed) *nparsed += n; } |