mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-25 15:27:03 +01:00
* parse-packet.c (parse_key): Allow to parse the gnu-divert-to-s2k
mode.
This commit is contained in:
parent
1ddb705ee4
commit
bf244e9aeb
@ -1,3 +1,8 @@
|
|||||||
|
2003-07-28 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* parse-packet.c (parse_key): Allow to parse the gnu-divert-to-s2k
|
||||||
|
mode.
|
||||||
|
|
||||||
2003-07-27 David Shaw <dshaw@jabberwocky.com>
|
2003-07-27 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* packet.h, sig-check.c (signature_check2, do_check,
|
* packet.h, sig-check.c (signature_check2, do_check,
|
||||||
|
@ -60,6 +60,8 @@ do_fingerprint_md( PKT_public_key *pk )
|
|||||||
int npkey = pubkey_get_npkey( pk->pubkey_algo );
|
int npkey = pubkey_get_npkey( pk->pubkey_algo );
|
||||||
|
|
||||||
md = md_open( pk->version < 4 ? DIGEST_ALGO_RMD160 : DIGEST_ALGO_SHA1, 0);
|
md = md_open( pk->version < 4 ? DIGEST_ALGO_RMD160 : DIGEST_ALGO_SHA1, 0);
|
||||||
|
md_start_debug (md,"keyid");
|
||||||
|
#warning fffff
|
||||||
n = pk->version < 4 ? 8 : 6;
|
n = pk->version < 4 ? 8 : 6;
|
||||||
for(i=0; i < npkey; i++ ) {
|
for(i=0; i < npkey; i++ ) {
|
||||||
nb[i] = mpi_get_nbits(pk->pkey[i]);
|
nb[i] = mpi_get_nbits(pk->pkey[i]);
|
||||||
|
@ -1559,6 +1559,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
if( pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY ) {
|
if( pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY ) {
|
||||||
PKT_secret_key *sk = pkt->pkt.secret_key;
|
PKT_secret_key *sk = pkt->pkt.secret_key;
|
||||||
byte temp[16];
|
byte temp[16];
|
||||||
|
size_t snlen = 0;
|
||||||
|
|
||||||
if( !npkey ) {
|
if( !npkey ) {
|
||||||
sk->skey[0] = mpi_set_opaque( NULL,
|
sk->skey[0] = mpi_set_opaque( NULL,
|
||||||
@ -1631,6 +1632,8 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
break;
|
break;
|
||||||
case 1001: if( list_mode ) printf( "\tgnu-dummy S2K" );
|
case 1001: if( list_mode ) printf( "\tgnu-dummy S2K" );
|
||||||
break;
|
break;
|
||||||
|
case 1002: if (list_mode) printf("\tgnu-divert-to-card S2K");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if( list_mode )
|
if( list_mode )
|
||||||
printf( "\tunknown %sS2K %d\n",
|
printf( "\tunknown %sS2K %d\n",
|
||||||
@ -1666,6 +1669,19 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
printf("\tprotect count: %lu\n",
|
printf("\tprotect count: %lu\n",
|
||||||
(ulong)sk->protect.s2k.count);
|
(ulong)sk->protect.s2k.count);
|
||||||
}
|
}
|
||||||
|
else if( sk->protect.s2k.mode == 1002 ) {
|
||||||
|
/* Read the serial number. */
|
||||||
|
if (pktlen < 1) {
|
||||||
|
rc = G10ERR_INVALID_PACKET;
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
snlen = iobuf_get (inp);
|
||||||
|
pktlen--;
|
||||||
|
if (pktlen < snlen || snlen == -1) {
|
||||||
|
rc = G10ERR_INVALID_PACKET;
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* Note that a sk->protect.algo > 110 is illegal, but I'm
|
/* Note that a sk->protect.algo > 110 is illegal, but I'm
|
||||||
not erroring on it here as otherwise there would be no
|
not erroring on it here as otherwise there would be no
|
||||||
@ -1695,6 +1711,8 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
}
|
}
|
||||||
if( sk->protect.s2k.mode == 1001 )
|
if( sk->protect.s2k.mode == 1001 )
|
||||||
sk->protect.ivlen = 0;
|
sk->protect.ivlen = 0;
|
||||||
|
else if( sk->protect.s2k.mode == 1002 )
|
||||||
|
sk->protect.ivlen = snlen < 16? snlen : 16;
|
||||||
|
|
||||||
if( pktlen < sk->protect.ivlen ) {
|
if( pktlen < sk->protect.ivlen ) {
|
||||||
rc = G10ERR_INVALID_PACKET;
|
rc = G10ERR_INVALID_PACKET;
|
||||||
@ -1703,7 +1721,8 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
for(i=0; i < sk->protect.ivlen && pktlen; i++, pktlen-- )
|
for(i=0; i < sk->protect.ivlen && pktlen; i++, pktlen-- )
|
||||||
temp[i] = iobuf_get_noeof(inp);
|
temp[i] = iobuf_get_noeof(inp);
|
||||||
if( list_mode ) {
|
if( list_mode ) {
|
||||||
printf( "\tprotect IV: ");
|
printf( sk->protect.s2k.mode == 1002? "\tserial-number: "
|
||||||
|
: "\tprotect IV: ");
|
||||||
for(i=0; i < sk->protect.ivlen; i++ )
|
for(i=0; i < sk->protect.ivlen; i++ )
|
||||||
printf(" %02x", temp[i] );
|
printf(" %02x", temp[i] );
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
@ -1716,7 +1735,8 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
* If the user is so careless, not to protect his secret key,
|
* If the user is so careless, not to protect his secret key,
|
||||||
* we can assume, that he operates an open system :=(.
|
* we can assume, that he operates an open system :=(.
|
||||||
* So we put the key into secure memory when we unprotect it. */
|
* So we put the key into secure memory when we unprotect it. */
|
||||||
if( sk->protect.s2k.mode == 1001 ) {
|
if( sk->protect.s2k.mode == 1001
|
||||||
|
|| sk->protect.s2k.mode == 1002 ) {
|
||||||
/* better set some dummy stuff here */
|
/* better set some dummy stuff here */
|
||||||
sk->skey[npkey] = mpi_set_opaque(NULL, m_strdup("dummydata"), 10);
|
sk->skey[npkey] = mpi_set_opaque(NULL, m_strdup("dummydata"), 10);
|
||||||
pktlen = 0;
|
pktlen = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user