diff options
author | Werner Koch <wk@gnupg.org> | 2003-07-01 10:34:45 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2003-07-01 10:34:45 +0200 |
commit | 39046ea7ec221efa9db946230ddc9fb3e65d19ab (patch) | |
tree | aa251dc190129aef89d82597f7ffb53ba6486fc9 /g10/parse-packet.c | |
parent | Key generation and signing using the OpenPGP card does rudimentary work. (diff) | |
download | gnupg2-39046ea7ec221efa9db946230ddc9fb3e65d19ab.tar.xz gnupg2-39046ea7ec221efa9db946230ddc9fb3e65d19ab.zip |
* app-openpgp.c (store_fpr): Fixed fingerprint calculation.
* keygen.c (gen_card_key): Obviously we should use the creation
date received from SCDAEMON, so that the fingerprints will match.
* sign.c (do_sign): Pass the serialno to the sign code.
* keyid.c (serialno_and_fpr_from_sk): New.
Diffstat (limited to 'g10/parse-packet.c')
-rw-r--r-- | g10/parse-packet.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/g10/parse-packet.c b/g10/parse-packet.c index fc9e2559f..57a6d3d7b 100644 --- a/g10/parse-packet.c +++ b/g10/parse-packet.c @@ -1562,6 +1562,7 @@ parse_key( iobuf_t inp, int pkttype, unsigned long pktlen, if( pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY ) { PKT_secret_key *sk = pkt->pkt.secret_key; byte temp[16]; + size_t snlen = 0; if( !npkey ) { sk->skey[0] = mpi_set_opaque( NULL, @@ -1672,7 +1673,6 @@ parse_key( iobuf_t inp, int pkttype, unsigned long pktlen, (ulong)sk->protect.s2k.count); } else if( sk->protect.s2k.mode == 1002 ) { - size_t snlen; /* Read the serial number. */ if (pktlen < 1) { rc = GPG_ERR_INV_PACKET; @@ -1684,17 +1684,6 @@ parse_key( iobuf_t inp, int pkttype, unsigned long pktlen, rc = GPG_ERR_INV_PACKET; goto leave; } - - if( list_mode ) { - printf("\tserial-number: "); - for (;snlen; snlen--) - printf ("%02X", (unsigned int)iobuf_get_noeof (inp)); - putchar ('\n'); - } - else { - for (;snlen; snlen--) - iobuf_get_noeof (inp); - } } } /* Note that a sk->protect.algo > 110 is illegal, but I'm @@ -1725,9 +1714,12 @@ parse_key( iobuf_t inp, int pkttype, unsigned long pktlen, } if( sk->protect.s2k.mode == 1001 ) sk->protect.ivlen = 0; - else if( sk->protect.s2k.mode == 1002 ) - sk->protect.ivlen = 0; + else if( sk->protect.s2k.mode == 1002 ) { + if (snlen > 16) + log_info ("WARNING: serial number of card truncated\n"); + sk->protect.ivlen = snlen < 16? snlen : 16; + } if( pktlen < sk->protect.ivlen ) { rc = GPG_ERR_INV_PACKET; goto leave; @@ -1735,7 +1727,8 @@ parse_key( iobuf_t inp, int pkttype, unsigned long pktlen, for(i=0; i < sk->protect.ivlen && pktlen; i++, pktlen-- ) temp[i] = iobuf_get_noeof(inp); if( list_mode ) { - printf( "\tprotect IV: "); + printf( sk->protect.s2k.mode == 1002? "\tserial-number: " + : "\tprotect IV: "); for(i=0; i < sk->protect.ivlen; i++ ) printf(" %02x", temp[i] ); putchar('\n'); |