aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--g10/ChangeLog15
-rw-r--r--g10/armor.c5
-rw-r--r--g10/getkey.c25
-rw-r--r--g10/keylist.c4
-rw-r--r--g10/mainproc.c12
-rw-r--r--g10/misc.c2
-rw-r--r--g10/packet.h7
-rw-r--r--g10/parse-packet.c3
-rw-r--r--g10/pipemode.c2
9 files changed, 54 insertions, 21 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index adaabc9b9..abb9005ec 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,18 @@
+2001-03-27 Werner Koch <[email protected]>
+
+ * 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 <[email protected]>
+
+ * 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 <[email protected]>
* sign.c (do_sign): Verify the signature right after creation.
diff --git a/g10/armor.c b/g10/armor.c
index 03d52b1fe..e84fb3709 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -753,6 +753,9 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn,
}
else {
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
for(rc=0;!rc;) {
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 */
n++; /* see below */
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 */
if( hashes & 1 )
buf[n++] = DIGEST_ALGO_RMD160;
diff --git a/g10/getkey.c b/g10/getkey.c
index 96dd8ee89..d0ec1e368 100644
--- a/g10/getkey.c
+++ b/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.
* if pk/sk has the pubkey algo set, the function will only return
* a pubkey with that algo.
- * The caller must provide storage for either the pk or the sk.
- * If ret_kb is not NULL the funtion will return the keyblock there.
+ * The caller should provide storage for either the pk or the sk.
+ * If ret_kb is not NULL the function will return the keyblock there.
*/
static int
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 n;
@@ -862,9 +863,11 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
if ( !ret_kb )
ret_kb = &help_kb;
- if( sk ) {
- ctx->req_algo = sk->req_algo;
- ctx->req_usage = sk->req_usage;
+ if( secmode ) {
+ if (sk) {
+ ctx->req_algo = sk->req_algo;
+ ctx->req_usage = sk->req_usage;
+ }
rc = lookup( ctx, ret_kb, 1 );
if ( !rc && sk ) {
sk_from_block ( ctx, sk, *ret_kb );
@@ -905,7 +908,7 @@ get_pubkey_byname( GETKEY_CTX *retctx, PKT_public_key *pk,
STRLIST namelist = NULL;
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 );
return rc;
}
@@ -914,7 +917,7 @@ int
get_pubkey_bynames( GETKEY_CTX *retctx, PKT_public_key *pk,
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
@@ -1053,7 +1056,7 @@ get_seckey_byname2( GETKEY_CTX *retctx,
if( !name && opt.def_secret_key && *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 */
struct getkey_ctx_s ctx;
@@ -1073,7 +1076,7 @@ get_seckey_byname2( GETKEY_CTX *retctx,
}
else {
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 );
@@ -1095,7 +1098,7 @@ int
get_seckey_bynames( GETKEY_CTX *retctx, PKT_secret_key *sk,
STRLIST names, KBNODE *ret_keyblock )
{
- return key_byname( retctx, names, NULL, sk, ret_keyblock );
+ return key_byname( retctx, names, NULL, sk, 1, ret_keyblock );
}
diff --git a/g10/keylist.c b/g10/keylist.c
index 4f26dc27d..22f578b0d 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -696,7 +696,11 @@ reorder_keyblock (KBNODE keyblock)
static void
list_keyblock( KBNODE keyblock, int secret )
{
+ log_debug ("before reorder:\n");
+ dump_kbnode (keyblock);
reorder_keyblock (keyblock);
+ log_debug ("after reorder:\n");
+ dump_kbnode (keyblock);
if (opt.with_colons)
list_keyblock_colon (keyblock, secret );
else
diff --git a/g10/mainproc.c b/g10/mainproc.c
index 40d6258b1..948643f05 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -136,12 +136,12 @@ add_onepass_sig( CTX c, PACKET *pkt )
static int
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.
* Process the last one and reset everything */
release_list(c);
}
- else if ( pkt->pkt.gpg_control->control == 2 ) {
+ else if ( pkt->pkt.gpg_control->control == CTRLPKT_PIPEMODE ) {
/* Pipemode control packet */
#warning the --pipemode does not yet work
/* 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;
}
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;
const byte *data = n->pkt->pkt.gpg_control->data;
/* check that we have at least the sigclass and one hash */
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
* documents */
clearsig = (*data == 0x01);
@@ -1380,7 +1381,8 @@ proc_tree( CTX c, KBNODE node )
check_sig_and_print( c, n1 );
}
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 */
if( !c->have_data ) {
log_error("cleartext signature without data\n" );
diff --git a/g10/misc.c b/g10/misc.c
index 573ff1b50..53dfd0fac 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -257,7 +257,7 @@ get_session_marker( size_t *rlen )
static int 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;
initialized = 1;
diff --git a/g10/packet.h b/g10/packet.h
index 034ebdd47..1033c7b88 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -55,6 +55,13 @@ typedef enum {
typedef struct packet_struct PACKET;
+/* PKT_GPG_CONTROL types */
+enum {
+ CTRLPKT_CLEARSIGN_START = 1,
+ CTRLPKT_PIPEMODE = 2
+} ctrlpkttype_t;
+
+
typedef struct {
int mode;
byte hash_algo;
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 32b33bec8..191c0f13e 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -1840,8 +1840,7 @@ parse_mdc( IOBUF inp, int pkttype, unsigned long pktlen,
* we first check that tehre is a unique tag in it.
* The format of such a control packet is:
* n byte session marker
- * 1 byte control type: 1 = Clearsign hash info
- * 2 = Pipemode control
+ * 1 byte control type CTRLPKT_xxxxx
* m byte control data
*/
diff --git a/g10/pipemode.c b/g10/pipemode.c
index 54e461f46..eb69995e3 100644
--- a/g10/pipemode.c
+++ b/g10/pipemode.c
@@ -72,7 +72,7 @@ make_control ( byte *buf, int code, int operation )
buf[n++] = 0xff; /* new format, type 63, 1 length byte */
n++; /* length will fixed below */
memcpy(buf+n, sesmark, sesmarklen ); n+= sesmarklen;
- buf[n++] = 2; /* control type: pipemode marker */
+ buf[n++] = CTRLPKT_PIPEMODE;
buf[n++] = code;
buf[n++] = operation;
buf[1] = n-2;