summaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>1998-12-14 21:22:42 +0100
committerWerner Koch <wk@gnupg.org>1998-12-14 21:22:42 +0100
commit7a7a5630aff7f539fd68de6c34d82a0fa240cc8c (patch)
treec0b8587dd3ef4e434ae03b043a52ad8ec645bc3f /g10
parentSee ChangeLog: Sun Dec 13 14:10:56 CET 1998 Werner Koch (diff)
downloadgnupg2-7a7a5630aff7f539fd68de6c34d82a0fa240cc8c.tar.xz
gnupg2-7a7a5630aff7f539fd68de6c34d82a0fa240cc8c.zip
See ChangeLog: Mon Dec 14 21:18:49 CET 1998 Werner Koch
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog7
-rw-r--r--g10/helptext.c5
-rw-r--r--g10/options.skel13
-rw-r--r--g10/packet.h1
-rw-r--r--g10/parse-packet.c134
-rw-r--r--g10/sig-check.c4
6 files changed, 109 insertions, 55 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 410630521..77990ae6d 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,10 @@
+Mon Dec 14 21:18:49 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
+
+ * parse-packet.c (parse_signature): Now checks for critical bit
+ (parse_sig_subpkt): Splitted.
+ (parse_one_sig_subpkt): New.
+ * sig-check.c (do_check): handle critical bit.
+
Sun Dec 13 14:10:56 CET 1998 Werner Koch <wk@isil.d.shuttle.de>
* pcklist.c (select_algo_from_prefs): Preferences should
diff --git a/g10/helptext.c b/g10/helptext.c
index ee5565e81..6ff88a710 100644
--- a/g10/helptext.c
+++ b/g10/helptext.c
@@ -35,9 +35,12 @@
* as response to a prompt) we can use a simple search through the list.
* Translators should use the key as msgid, this is to keep the msgid short
* and to allow for easy changing of the helptexts.
+ *
+ * Mini gloassary:
+ *
+ * "user ID", "trustdb", "NOTE" and "WARNING".
*/
-
static struct helptexts { const char *key; const char *help; } helptexts[] = {
/* begin of list */
diff --git a/g10/options.skel b/g10/options.skel
index 9fe89b1fb..0e53339d5 100644
--- a/g10/options.skel
+++ b/g10/options.skel
@@ -28,13 +28,6 @@ $Id$
force-v3-sigs
-# Default is to use the newer compress algo 2, but PGP 5 does not
-# like this, so we use the old one
-# Hmm: Do we really need this ... preferences should decide which compress
-# algo to use.
-
-compress-algo 1
-
# If you do not use the Latin-1 (ISO-8859-1) charset, you should
# tell GnuPG which is the native character set. Please check
# the man page for supported character sets.
@@ -45,10 +38,14 @@ compress-algo 1
# alias mynames -u 0x12345678 -u 0x456789ab -z 9
# everytime you use --mynames, it will be expanded to the options
# in the above defintion. The name of the alias may not be abbreviated.
+# NOTE: This is not yet implemented
-# lock tthe file only once for the lifetime of a process.
+# lock the file only once for the lifetime of a process.
# if you do not define this, the lock will be obtained and released
# every time it is needed - normally this is not needed.
lock-once
+# If you are not running one of the free operation systems
+# you probably have to uncomment the next line:
+#load-extension rndunix
diff --git a/g10/packet.h b/g10/packet.h
index 7d1e63150..e047fd944 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -200,6 +200,7 @@ struct packet_struct {
} while(0)
typedef enum {
+ SIGSUBPKT_TEST_CRITICAL=-3,
SIGSUBPKT_LIST_UNHASHED=-2,
SIGSUBPKT_LIST_HASHED =-1,
SIGSUBPKT_NONE = 0,
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 2d82308dd..29e4fc4e6 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -714,21 +714,60 @@ dump_sig_subpkt( int hashed, int type, int critical,
printf("%s)\n", p? p: "");
}
+/****************
+ * Returns: >= 0 offset into buffer
+ * -1 unknown type
+ * -2 unsupported type
+ * -3 subpacket too short
+ */
+static int
+parse_one_sig_subpkt( const byte *buffer, size_t n, int type )
+{
+ switch( type ) {
+ case SIGSUBPKT_SIG_CREATED:
+ case SIGSUBPKT_SIG_EXPIRE:
+ case SIGSUBPKT_KEY_EXPIRE:
+ if( n < 4 )
+ break;
+ return 0;
+ case SIGSUBPKT_EXPORTABLE:
+ if( !n )
+ break;
+ return 0;
+ case SIGSUBPKT_ISSUER:/* issuer key ID */
+ if( n < 8 )
+ break;
+ return 0;
+ case SIGSUBPKT_PREF_SYM:
+ case SIGSUBPKT_PREF_HASH:
+ case SIGSUBPKT_PREF_COMPR:
+ return 0;
+ case SIGSUBPKT_PRIV_ADD_SIG:
+ /* because we use private data, we check the GNUPG marker */
+ if( n < 24 )
+ break;
+ if( buffer[0] != 'G' || buffer[1] != 'P' || buffer[2] != 'G' )
+ return -2;
+ return 3;
+ default: return -1;
+ }
+ return -3;
+}
+
const byte *
parse_sig_subpkt( const byte *buffer, sigsubpkttype_t reqtype, size_t *ret_n )
{
int buflen;
int type;
int critical;
+ int offset;
size_t n;
if( !buffer )
return NULL;
buflen = (*buffer << 8) | buffer[1];
buffer += 2;
- for(;;) {
- if( !buflen )
- return NULL; /* end of packets; not found */
+ while( buflen ) {
n = *buffer++; buflen--;
if( n == 255 ) {
if( buflen < 4 )
@@ -754,49 +793,47 @@ parse_sig_subpkt( const byte *buffer, sigsubpkttype_t reqtype, size_t *ret_n )
}
else
critical = 0;
- if( reqtype < 0 ) /* list packets */
+ if( reqtype == SIGSUBPKT_TEST_CRITICAL ) {
+ if( critical ) {
+ if( n-1 > buflen+1 )
+ goto too_short;
+ if( parse_one_sig_subpkt(buffer+1, n-1, type ) < 0 ) {
+ log_info(_("subpacket of type %d has critical bit set\n"),
+ type);
+ return NULL; /* this is an error */
+ }
+ }
+ }
+ else if( reqtype < 0 ) /* list packets */
dump_sig_subpkt( reqtype == SIGSUBPKT_LIST_HASHED,
type, critical, buffer, buflen, n );
- else if( type == reqtype )
- break; /* found */
+ else if( type == reqtype ) { /* found */
+ buffer++;
+ n--;
+ if( n > buflen )
+ goto too_short;
+ if( ret_n )
+ *ret_n = n;
+ offset = parse_one_sig_subpkt(buffer, n, type );
+ switch( offset ) {
+ case -3:
+ log_error("subpacket of type %d too short\n", type);
+ return NULL;
+ case -2:
+ return NULL;
+ case -1:
+ BUG(); /* not yet needed */
+ default:
+ break;
+ }
+ return buffer+offset;
+ }
buffer += n; buflen -=n;
}
- buffer++;
- n--;
- if( n > buflen )
- goto too_short;
- if( ret_n )
- *ret_n = n;
- switch( type ) {
- case SIGSUBPKT_SIG_CREATED:
- case SIGSUBPKT_SIG_EXPIRE:
- case SIGSUBPKT_KEY_EXPIRE:
- if( n < 4 )
- break;
- return buffer;
- case SIGSUBPKT_EXPORTABLE:
- if( !n )
- break;
- return buffer;
- case SIGSUBPKT_ISSUER:/* issuer key ID */
- if( n < 8 )
- break;
- return buffer;
- case SIGSUBPKT_PREF_SYM:
- case SIGSUBPKT_PREF_HASH:
- case SIGSUBPKT_PREF_COMPR:
- return buffer;
- case SIGSUBPKT_PRIV_ADD_SIG:
- /* because we use private data, we check the GNUPG marker */
- if( n < 24 )
- break;
- if( buffer[0] != 'G' || buffer[1] != 'P' || buffer[2] != 'G' )
- return NULL;
- return buffer+3;
- default: BUG(); /* not yet needed */
- }
- log_error("subpacket of type %d too short\n", type);
- return NULL;
+ if( reqtype == SIGSUBPKT_TEST_CRITICAL )
+ return buffer; /* as value true to indicate that there is no
+ /* critical bit we don't understand */
+ return NULL; /* end of packets; not found */
too_short:
log_error("buffer shorter than subpacket\n");
@@ -899,10 +936,15 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen,
if( is_v4 ) { /*extract required information */
const byte *p;
- /* FIXME: set sig->flags.unknown_critical is there is a
- * critical bit set for packets which are not understood
- * It does only make sense for hashed data.
- */
+ /* set sig->flags.unknown_critical if there is a
+ * critical bit set for packets which we do not understand */
+ if( !parse_sig_subpkt( sig->hashed_data, SIGSUBPKT_TEST_CRITICAL, NULL)
+ || !parse_sig_subpkt( sig->unhashed_data, SIGSUBPKT_TEST_CRITICAL,
+ NULL) )
+ {
+ sig->flags.unknown_critical = 1;
+ }
+
p = parse_sig_subpkt( sig->hashed_data, SIGSUBPKT_SIG_CREATED, NULL );
if( !p )
log_error("signature packet without timestamp\n");
diff --git a/g10/sig-check.c b/g10/sig-check.c
index 106355550..63bdda220 100644
--- a/g10/sig-check.c
+++ b/g10/sig-check.c
@@ -222,6 +222,10 @@ do_check( PKT_public_key *pk, PKT_signature *sig, MD_HANDLE digest )
rc = pubkey_verify( pk->pubkey_algo, result, sig->data, pk->pkey,
cmp_help, &ctx );
mpi_free( result );
+ if( !rc && sig->flags.unknown_critical ) {
+ log_info(_("assuming bad signature due to an unknown critical bit\n"));
+ rc = G10ERR_BAD_SIGN;
+ }
sig->flags.checked = 1;
sig->flags.valid = !rc;