[PATCH] Notation data - take 2

Matthew Byng-Maddick gnupg at lists.colondot.net
Sat Aug 4 03:56:01 CEST 2001


here is the second attempt, attached:

:-)

MBM

-- 
Matthew Byng-Maddick         <mbm at colondot.net>           http://colondot.net/
-------------- next part --------------
The following patch is against gnupg-1.0.6. It causes gnupg to be able to
display the notation packets in signatures, either with a:
|             [notation] key=value
or
| not::3t:5t:key:value:

This patch is (c) Copyright A L Digital Ltd, and released under the GNU GPL

The format of the colon based format is:
 * "not"
 * potential char indicating that an error occurred in decoding the packet
 * <length of key>[xt]
 * <length of value>[xt]
 * key
 * value

The 'x' or 't' after the key and value lengths indicate that they are
either displayed in hex, or in plaintext. Because the length is included,
it doesn't matter if these contain colons. The length is the length in
bytes, so a field with eg. 12x will be 24 chars long as displayed.

The option is off by default, and turned on with a --show-notation, and
off with a --no-show-notation


diff -uNr gnupg-1.0.6/g10/g10.c gnupg-1.0.6-notation/g10/g10.c
--- gnupg-1.0.6/g10/g10.c	Mon May 28 08:02:14 2001
+++ gnupg-1.0.6-notation/g10/g10.c	Fri Aug  3 18:15:56 2001
@@ -208,6 +208,8 @@
     oNoSigCreateCheck,
     oEmu3DESS2KBug,  /* will be removed in 1.1 */
     oEmuMDEncodeBug,
+    oShowNotation,
+    oNoShowNotation,
 aTest };
 
 
@@ -406,6 +408,8 @@
     { aDeleteSecretAndPublicKey, "delete-secret-and-public-key",256, "@" },
     { oEmu3DESS2KBug,  "emulate-3des-s2k-bug", 0, "@"},
     { oEmuMDEncodeBug,	"emulate-md-encode-bug", 0, "@"},
+    { oShowNotation,	"show-notation", 0, "@"},
+    { oNoShowNotation,	"no-show-notation", 0, "@"},
 {0} };
 
 
@@ -652,6 +656,7 @@
     opt.max_cert_depth = 5;
     opt.pgp2_workarounds = 1;
     opt.auto_key_retrieve = 1;
+    opt.show_notation = 0; /* don't show notation by default as it breaks PGP compat */
   #ifdef __MINGW32__
     opt.homedir = read_w32_registry_string( NULL, "Software\\GNU\\GnuPG", "HomeDir" );
   #else
@@ -991,6 +996,8 @@
             iobuf_enable_special_filenames (1);
             break;
           case oNoExpensiveTrustChecks: opt.no_expensive_trust_checks=1; break;
+          case oShowNotation: opt.show_notation=1; break;
+          case oNoShowNotation: opt.show_notation=0; break;
 
 	  default : pargs.err = configfp? 1:2; break;
 	}
diff -uNr gnupg-1.0.6/g10/keylist.c gnupg-1.0.6-notation/g10/keylist.c
--- gnupg-1.0.6/g10/keylist.c	Sun May 27 15:31:07 2001
+++ gnupg-1.0.6-notation/g10/keylist.c	Fri Aug  3 18:47:47 2001
@@ -39,6 +39,7 @@
 static void list_one( STRLIST names, int secret);
 static void list_keyblock( KBNODE keyblock, int secret );
 static void fingerprint( PKT_public_key *pk, PKT_secret_key *sk );
+static void sig_pkt_note( PKT_signature *sig, int with_colon );
 
 
 /****************
@@ -363,6 +364,8 @@
 		m_free(p);
 	    }
 	    putchar('\n');
+	    if(opt.show_notation)
+		sig_pkt_note(sig,0);
 	    /* fixme: check or list other sigs here */
 	}
     }
@@ -640,6 +643,8 @@
 		m_free(p);
 	    }
             printf(":%02x%c:\n", sig->sig_class, get_lsign_letter (sig) );
+	    if(opt.show_notation)
+		sig_pkt_note(sig,1);
 	    /* fixme: check or list other sigs here */
 	}
     }
@@ -648,6 +653,95 @@
         putchar(':');
         print_capabilities (pk, sk, keyblock);
 	putchar('\n');
+    }
+}
+
+static void
+sig_pkt_note(PKT_signature *sig, int with_colon)
+{
+    const byte *buf;
+    size_t size;
+    int pos;
+
+    /* since this probably breaks compatibility with some things,
+       make absolutely sure we've enabled this. It might even be
+       sensible for it to be an assertion failure.
+       */
+    if(!opt.show_notation) return;
+
+    buf=NULL;
+    size=0;
+    pos=0;
+
+    while((buf=enum_sig_subpkt(sig->hashed_data, SIGSUBPKT_NOTATION, &size, &pos))) {
+	const byte *s = buf, *t;
+	size_t n1,n1o,n2;
+
+	if(with_colon)
+	    printf("not:");
+	else {
+	    for(n1=0;n1<32;n1++)
+		putchar(' ');
+	    printf("[notation] ");
+	}
+
+	if(size<8) {
+	    if(with_colon)
+		printf("%%::::::");
+	    else
+		printf("[too short]");
+	} else {
+	    n1 = (s[4] << 8) | s[5];
+	    n2 = (s[6] << 8) | s[7];
+	    if(size != (8 + n1 + n2)) {
+		if(with_colon)
+		    printf("-::::::");
+		else
+		    printf("[length mismatch]");
+	    } else {
+		char human_readable;
+
+		human_readable=(!(*buf & 0x80))?'x':'t';
+		s+=8;
+
+		if(with_colon) {
+		printf(":%d%c:%d%c:",n1,human_readable,n2,human_readable);
+
+		t=s;
+
+		n1o=n1;
+		while(n1--) {
+		    if(human_readable=='t')
+			putchar(*t++);
+		    else
+			printf("%02X",*t++);
+		}
+		putchar(':');
+		t=s+n1o;
+		while(n2--) {
+		    if(human_readable=='t')
+			putchar(*t++);
+		    else
+			printf("%02X",*t++);
+		}
+
+		printf(":");
+		} else if(human_readable=='t') {
+		    t=s;
+
+		    n1o = n1;
+		    while(n1--)
+			putchar(*t++);
+		    putchar('=');
+		    t= s + n1o;
+		    while(n2--)
+			putchar(*t++);
+		} else {
+		    printf("[not human readable]");
+		}
+	    }
+	}
+	printf("\n");
     }
 }
 
diff -uNr gnupg-1.0.6/g10/options.h gnupg-1.0.6-notation/g10/options.h
--- gnupg-1.0.6/g10/options.h	Tue Mar 27 15:24:39 2001
+++ gnupg-1.0.6-notation/g10/options.h	Fri Aug  3 17:58:11 2001
@@ -103,6 +103,7 @@
     int no_expensive_trust_checks;
     int no_sig_cache;
     int no_sig_create_check;
+    int show_notation;
 } opt;
 
 
-------------- next part --------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQA7auhZiGjP99nB6xERAsXuAJ9bR8ngbiD+mdeDTDy3uOBJlFdfkACfVmtj
lTDlyv7wkKAmBg68eMmcP6Y=
=cTvY
-----END PGP SIGNATURE-----


More information about the Gnupg-devel mailing list