const char rcsid_pgpdump_c[] = "$Id: pgpdump.c,v 1.2 2003/02/07 01:01:21 rlaager Exp $"; /* * Copyright (c) 1996, 1997, 1998, 1999, Marc Horowitz. All rights reserved. * See the LICENSE file in the release for redistribution information. */ /* * XXX this file isn't completely 5.0 compatible yet */ #include #include #include "pgputil.h" #include "md5.h" #include "util.h" #include "pgpfile.h" int unparse_packet(ddesc *packet, void *c) { long ptype, plen; if (!decode_psf(packet, &ptype, &plen)) return(0); printf("type=%ld, len=%ld\n", ptype, plen); switch (ptype) { case 6: /* public key packet */ { mpidesc modulus, exponent; unsigned char keyid[8]; unsigned char keytype; time_t dummy; int keyversion = 4; /* Assume v4 keys. */ MD5_CTX md5ctx; unsigned char hash[16]; int i; if (!decode_pubkey(packet, plen, &modulus, &exponent, keyid, &keytype, &dummy, &keyversion)) return(0); if (keytype == 1) { /* RSA */ MD5Init(&md5ctx); MD5Update(&md5ctx, modulus.number.data, modulus.number.size); MD5Update(&md5ctx, exponent.number.data, exponent.number.size); MD5Final(hash, &md5ctx); printf(" Public key packet alg %d\n Key ID = ", keytype); for (i=modulus.number.size-4; i