mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-02 16:43:03 +01:00
Fixed a bugs; e.g. in --list-secret-keys
This commit is contained in:
parent
3b866e74a8
commit
e2c88461fc
@ -1,3 +1,18 @@
|
|||||||
|
2001-03-27 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* getkey.c (key_byname): Add new arg secmode and changed all
|
||||||
|
callers to request explicitly the mode. Deriving this information
|
||||||
|
from the other supplied parameters does not work if neither pk nor
|
||||||
|
sk are supplied.
|
||||||
|
|
||||||
|
2001-03-25 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
|
* packet.h (ctrlpkttype_t): New.
|
||||||
|
* mainproc.c (add_gpg_control,proc_plaintext,proc_tree): Use the
|
||||||
|
new enum values.
|
||||||
|
* pipemode.c (make_control): Ditto.
|
||||||
|
* armor.c (armor_filter): Ditto.
|
||||||
|
|
||||||
2001-03-24 Werner Koch <wk@gnupg.org>
|
2001-03-24 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* sign.c (do_sign): Verify the signature right after creation.
|
* sign.c (do_sign): Verify the signature right after creation.
|
||||||
|
@ -753,6 +753,9 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
/* FIXME: Here we should emit another control packet,
|
||||||
|
* so that we know in mainproc that we are processing
|
||||||
|
* a clearsign message */
|
||||||
#if 0
|
#if 0
|
||||||
for(rc=0;!rc;) {
|
for(rc=0;!rc;) {
|
||||||
rc = 0 /*check_trailer( &fhdr, c )*/;
|
rc = 0 /*check_trailer( &fhdr, c )*/;
|
||||||
@ -866,7 +869,7 @@ armor_filter( void *opaque, int control,
|
|||||||
buf[n++] = 0xff; /* new format, type 63, 1 length byte */
|
buf[n++] = 0xff; /* new format, type 63, 1 length byte */
|
||||||
n++; /* see below */
|
n++; /* see below */
|
||||||
memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
|
memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
|
||||||
buf[n++] = 1; /* control type */
|
buf[n++] = CTRLPKT_CLEARSIGN_START;
|
||||||
buf[n++] = afx->not_dash_escaped? 0:1; /* sigclass */
|
buf[n++] = afx->not_dash_escaped? 0:1; /* sigclass */
|
||||||
if( hashes & 1 )
|
if( hashes & 1 )
|
||||||
buf[n++] = DIGEST_ALGO_RMD160;
|
buf[n++] = DIGEST_ALGO_RMD160;
|
||||||
|
25
g10/getkey.c
25
g10/getkey.c
@ -811,13 +811,14 @@ classify_user_id( const char *name, u32 *keyid, byte *fprint,
|
|||||||
* first pubkey certificate which has the given name in a user_id.
|
* first pubkey certificate which has the given name in a user_id.
|
||||||
* if pk/sk has the pubkey algo set, the function will only return
|
* if pk/sk has the pubkey algo set, the function will only return
|
||||||
* a pubkey with that algo.
|
* a pubkey with that algo.
|
||||||
* The caller must provide storage for either the pk or the sk.
|
* The caller should provide storage for either the pk or the sk.
|
||||||
* If ret_kb is not NULL the funtion will return the keyblock there.
|
* If ret_kb is not NULL the function will return the keyblock there.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
||||||
PKT_public_key *pk, PKT_secret_key *sk, KBNODE *ret_kb )
|
PKT_public_key *pk, PKT_secret_key *sk, int secmode,
|
||||||
|
KBNODE *ret_kb )
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int n;
|
int n;
|
||||||
@ -862,9 +863,11 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
|
|||||||
if ( !ret_kb )
|
if ( !ret_kb )
|
||||||
ret_kb = &help_kb;
|
ret_kb = &help_kb;
|
||||||
|
|
||||||
if( sk ) {
|
if( secmode ) {
|
||||||
ctx->req_algo = sk->req_algo;
|
if (sk) {
|
||||||
ctx->req_usage = sk->req_usage;
|
ctx->req_algo = sk->req_algo;
|
||||||
|
ctx->req_usage = sk->req_usage;
|
||||||
|
}
|
||||||
rc = lookup( ctx, ret_kb, 1 );
|
rc = lookup( ctx, ret_kb, 1 );
|
||||||
if ( !rc && sk ) {
|
if ( !rc && sk ) {
|
||||||
sk_from_block ( ctx, sk, *ret_kb );
|
sk_from_block ( ctx, sk, *ret_kb );
|
||||||
@ -905,7 +908,7 @@ get_pubkey_byname( GETKEY_CTX *retctx, PKT_public_key *pk,
|
|||||||
STRLIST namelist = NULL;
|
STRLIST namelist = NULL;
|
||||||
|
|
||||||
add_to_strlist( &namelist, name );
|
add_to_strlist( &namelist, name );
|
||||||
rc = key_byname( retctx, namelist, pk, NULL, ret_keyblock );
|
rc = key_byname( retctx, namelist, pk, NULL, 0, ret_keyblock );
|
||||||
free_strlist( namelist );
|
free_strlist( namelist );
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@ -914,7 +917,7 @@ int
|
|||||||
get_pubkey_bynames( GETKEY_CTX *retctx, PKT_public_key *pk,
|
get_pubkey_bynames( GETKEY_CTX *retctx, PKT_public_key *pk,
|
||||||
STRLIST names, KBNODE *ret_keyblock )
|
STRLIST names, KBNODE *ret_keyblock )
|
||||||
{
|
{
|
||||||
return key_byname( retctx, names, pk, NULL, ret_keyblock );
|
return key_byname( retctx, names, pk, NULL, 0, ret_keyblock );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -1053,7 +1056,7 @@ get_seckey_byname2( GETKEY_CTX *retctx,
|
|||||||
|
|
||||||
if( !name && opt.def_secret_key && *opt.def_secret_key ) {
|
if( !name && opt.def_secret_key && *opt.def_secret_key ) {
|
||||||
add_to_strlist( &namelist, opt.def_secret_key );
|
add_to_strlist( &namelist, opt.def_secret_key );
|
||||||
rc = key_byname( retctx, namelist, NULL, sk, retblock );
|
rc = key_byname( retctx, namelist, NULL, sk, 1, retblock );
|
||||||
}
|
}
|
||||||
else if( !name ) { /* use the first one as default key */
|
else if( !name ) { /* use the first one as default key */
|
||||||
struct getkey_ctx_s ctx;
|
struct getkey_ctx_s ctx;
|
||||||
@ -1073,7 +1076,7 @@ get_seckey_byname2( GETKEY_CTX *retctx,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
add_to_strlist( &namelist, name );
|
add_to_strlist( &namelist, name );
|
||||||
rc = key_byname( retctx, namelist, NULL, sk, retblock );
|
rc = key_byname( retctx, namelist, NULL, sk, 1, retblock );
|
||||||
}
|
}
|
||||||
|
|
||||||
free_strlist( namelist );
|
free_strlist( namelist );
|
||||||
@ -1095,7 +1098,7 @@ int
|
|||||||
get_seckey_bynames( GETKEY_CTX *retctx, PKT_secret_key *sk,
|
get_seckey_bynames( GETKEY_CTX *retctx, PKT_secret_key *sk,
|
||||||
STRLIST names, KBNODE *ret_keyblock )
|
STRLIST names, KBNODE *ret_keyblock )
|
||||||
{
|
{
|
||||||
return key_byname( retctx, names, NULL, sk, ret_keyblock );
|
return key_byname( retctx, names, NULL, sk, 1, ret_keyblock );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -696,7 +696,11 @@ reorder_keyblock (KBNODE keyblock)
|
|||||||
static void
|
static void
|
||||||
list_keyblock( KBNODE keyblock, int secret )
|
list_keyblock( KBNODE keyblock, int secret )
|
||||||
{
|
{
|
||||||
|
log_debug ("before reorder:\n");
|
||||||
|
dump_kbnode (keyblock);
|
||||||
reorder_keyblock (keyblock);
|
reorder_keyblock (keyblock);
|
||||||
|
log_debug ("after reorder:\n");
|
||||||
|
dump_kbnode (keyblock);
|
||||||
if (opt.with_colons)
|
if (opt.with_colons)
|
||||||
list_keyblock_colon (keyblock, secret );
|
list_keyblock_colon (keyblock, secret );
|
||||||
else
|
else
|
||||||
|
@ -136,12 +136,12 @@ add_onepass_sig( CTX c, PACKET *pkt )
|
|||||||
static int
|
static int
|
||||||
add_gpg_control( CTX c, PACKET *pkt )
|
add_gpg_control( CTX c, PACKET *pkt )
|
||||||
{
|
{
|
||||||
if ( pkt->pkt.gpg_control->control == 1 ) {
|
if ( pkt->pkt.gpg_control->control == CTRLPKT_CLEARSIGN_START ) {
|
||||||
/* New clear text signature.
|
/* New clear text signature.
|
||||||
* Process the last one and reset everything */
|
* Process the last one and reset everything */
|
||||||
release_list(c);
|
release_list(c);
|
||||||
}
|
}
|
||||||
else if ( pkt->pkt.gpg_control->control == 2 ) {
|
else if ( pkt->pkt.gpg_control->control == CTRLPKT_PIPEMODE ) {
|
||||||
/* Pipemode control packet */
|
/* Pipemode control packet */
|
||||||
#warning the --pipemode does not yet work
|
#warning the --pipemode does not yet work
|
||||||
/* FIXME: We have to do more sanity checks all over the place */
|
/* FIXME: We have to do more sanity checks all over the place */
|
||||||
@ -485,13 +485,14 @@ proc_plaintext( CTX c, PACKET *pkt )
|
|||||||
only_md5 = 0;
|
only_md5 = 0;
|
||||||
}
|
}
|
||||||
else if( n->pkt->pkttype == PKT_GPG_CONTROL
|
else if( n->pkt->pkttype == PKT_GPG_CONTROL
|
||||||
&& n->pkt->pkt.gpg_control->control == 1 ) {
|
&& n->pkt->pkt.gpg_control->control
|
||||||
|
== CTRLPKT_CLEARSIGN_START ) {
|
||||||
size_t datalen = n->pkt->pkt.gpg_control->datalen;
|
size_t datalen = n->pkt->pkt.gpg_control->datalen;
|
||||||
const byte *data = n->pkt->pkt.gpg_control->data;
|
const byte *data = n->pkt->pkt.gpg_control->data;
|
||||||
|
|
||||||
/* check that we have at least the sigclass and one hash */
|
/* check that we have at least the sigclass and one hash */
|
||||||
if ( datalen < 2 )
|
if ( datalen < 2 )
|
||||||
log_fatal("invalid control packet of type 1\n");
|
log_fatal("invalid control packet CTRLPKT_CLEARSIGN_START\n");
|
||||||
/* Note that we don't set the clearsig flag for not-dash-escaped
|
/* Note that we don't set the clearsig flag for not-dash-escaped
|
||||||
* documents */
|
* documents */
|
||||||
clearsig = (*data == 0x01);
|
clearsig = (*data == 0x01);
|
||||||
@ -1380,7 +1381,8 @@ proc_tree( CTX c, KBNODE node )
|
|||||||
check_sig_and_print( c, n1 );
|
check_sig_and_print( c, n1 );
|
||||||
}
|
}
|
||||||
else if( node->pkt->pkttype == PKT_GPG_CONTROL
|
else if( node->pkt->pkttype == PKT_GPG_CONTROL
|
||||||
&& node->pkt->pkt.gpg_control->control == 1 ) {
|
&& node->pkt->pkt.gpg_control->control
|
||||||
|
== CTRLPKT_CLEARSIGN_START ) {
|
||||||
/* clear text signed message */
|
/* clear text signed message */
|
||||||
if( !c->have_data ) {
|
if( !c->have_data ) {
|
||||||
log_error("cleartext signature without data\n" );
|
log_error("cleartext signature without data\n" );
|
||||||
|
@ -257,7 +257,7 @@ get_session_marker( size_t *rlen )
|
|||||||
static int initialized;
|
static int initialized;
|
||||||
|
|
||||||
if ( !initialized ) {
|
if ( !initialized ) {
|
||||||
volatile ulong aa, bb; /* we really want the unitialized value */
|
volatile ulong aa, bb; /* we really want the uninitialized value */
|
||||||
ulong a, b;
|
ulong a, b;
|
||||||
|
|
||||||
initialized = 1;
|
initialized = 1;
|
||||||
|
@ -55,6 +55,13 @@ typedef enum {
|
|||||||
|
|
||||||
typedef struct packet_struct PACKET;
|
typedef struct packet_struct PACKET;
|
||||||
|
|
||||||
|
/* PKT_GPG_CONTROL types */
|
||||||
|
enum {
|
||||||
|
CTRLPKT_CLEARSIGN_START = 1,
|
||||||
|
CTRLPKT_PIPEMODE = 2
|
||||||
|
} ctrlpkttype_t;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int mode;
|
int mode;
|
||||||
byte hash_algo;
|
byte hash_algo;
|
||||||
|
@ -1840,8 +1840,7 @@ parse_mdc( IOBUF inp, int pkttype, unsigned long pktlen,
|
|||||||
* we first check that tehre is a unique tag in it.
|
* we first check that tehre is a unique tag in it.
|
||||||
* The format of such a control packet is:
|
* The format of such a control packet is:
|
||||||
* n byte session marker
|
* n byte session marker
|
||||||
* 1 byte control type: 1 = Clearsign hash info
|
* 1 byte control type CTRLPKT_xxxxx
|
||||||
* 2 = Pipemode control
|
|
||||||
* m byte control data
|
* m byte control data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ make_control ( byte *buf, int code, int operation )
|
|||||||
buf[n++] = 0xff; /* new format, type 63, 1 length byte */
|
buf[n++] = 0xff; /* new format, type 63, 1 length byte */
|
||||||
n++; /* length will fixed below */
|
n++; /* length will fixed below */
|
||||||
memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
|
memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
|
||||||
buf[n++] = 2; /* control type: pipemode marker */
|
buf[n++] = CTRLPKT_PIPEMODE;
|
||||||
buf[n++] = code;
|
buf[n++] = code;
|
||||||
buf[n++] = operation;
|
buf[n++] = operation;
|
||||||
buf[1] = n-2;
|
buf[1] = n-2;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user