[PATCH] Display notifications in key signatures
Matthew Byng-Maddick
gnupg at lists.colondot.net
Wed Aug 1 12:49:01 CEST 2001
I have been involved with a project which will probably want to use
notifications (as per RFC2440 5.2.3.15). I note that GnuPG will sign with
these, but currently will only display them if you do a --list-packets on
the public keyring.
The attached patch (against gnupg-1.0.6) will display them as part of the
signature.
---8<---
diff -uNr g10/keylist.c.old g10/keylist.c
--- g10/keylist.c.old Sun May 27 15:31:07 2001
+++ g10/keylist.c Tue Jul 31 11:58:40 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,7 @@
m_free(p);
}
putchar('\n');
+ sig_pkt_note(sig,0);
/* fixme: check or list other sigs here */
}
}
@@ -640,6 +642,7 @@
m_free(p);
}
printf(":%02x%c:\n", sig->sig_class, get_lsign_letter (sig) );
+ sig_pkt_note(sig,1);
/* fixme: check or list other sigs here */
}
}
@@ -648,6 +651,85 @@
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;
+
+ buf=parse_sig_subpkt2(sig, SIGSUBPKT_NOTATION, &size);
+ if(buf) {
+ 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(":\n");
+ } 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");
}
}
---8<---
I couldn't find anything like this in the archives, so I hope this is useful.
Cheers
MBM
--
Matthew Byng-Maddick <mbm at colondot.net> http://colondot.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 238 bytes
Desc: not available
Url : /pipermail/attachments/20010801/dcd9c115/attachment.bin
More information about the Gnupg-devel
mailing list