[PATCH] Display notifications in key signatures
Matthew Byng-Maddick
gnupg@lists.colondot.net
Wed Aug 1 11:49:01 2001
--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
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 );
=20
=20
/****************
@@ -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=3Dparse_sig_subpkt2(sig, SIGSUBPKT_NOTATION, &size);
+ if(buf) {
+ const byte *s =3D buf, *t;
+ size_t n1,n1o,n2;
+
+ if(with_colon)
+ printf("not:");
+ else {
+ for(n1=3D0;n1<32;n1++)
+ putchar(' ');
+ printf("[notation] ");
+ }
+
+ if(size<8) {
+ if(with_colon)
+ printf("%%::::::");
+ else
+ printf("[too short]");
+ } else {
+ n1 =3D (s[4] << 8) | s[5];
+ n2 =3D (s[6] << 8) | s[7];
+ if(size !=3D (8 + n1 + n2)) {
+ if(with_colon)
+ printf("-::::::");
+ else
+ printf("[length mismatch]");
+ } else {
+ char human_readable;
+
+ human_readable=3D(!(*buf & 0x80))?'x':'t';
+ s+=3D8;
+
+ if(with_colon) {
+ printf("!:%d%c:%d%c:",n1,human_readable,n2,human_readable);
+
+ t=3Ds;
+
+ n1o=3Dn1;
+ while(n1--) {
+ if(human_readable=3D=3D't')
+ putchar(*t++);
+ else
+ printf("%02X",*t++);
+ }
+ putchar(':');
+ t=3Ds+n1o;
+ while(n2--) {
+ if(human_readable=3D=3D't')
+ putchar(*t++);
+ else
+ printf("%02X",*t++);
+ }
+
+ printf(":\n");
+ } else if(human_readable=3D=3D't') {
+ t=3Ds;
+
+ n1o =3D n1;
+ while(n1--)
+ putchar(*t++);
+ putchar('=3D');
+ t=3D 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 usefu=
l.
Cheers
MBM
--=20
Matthew Byng-Maddick <mbm@colondot.net> http://colondot.n=
et/
--bp/iNruPH9dso1Pn
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org
iD8DBQE7Z9AuiGjP99nB6xERAo9CAJ9OVLTNgPCwWt1BEl4gSNrS/IbOPQCfbmkD
84Iq8RvURUL4uOy4oPeYwbI=
=eRQG
-----END PGP SIGNATURE-----
--bp/iNruPH9dso1Pn--