summaryrefslogtreecommitdiff
path: root/rpmio/tkey.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2001-09-29 13:42:58 +0000
committerjbj <devnull@localhost>2001-09-29 13:42:58 +0000
commit9390fb8bff283960b6b0fb675007cd3d0fc9f20a (patch)
tree3fb0db602c72b58874ba5c786909faaaab6e1585 /rpmio/tkey.c
parent690d53d79ec6947a0730cb8ff65b360a8995c293 (diff)
downloadrpm-9390fb8bff283960b6b0fb675007cd3d0fc9f20a.tar.gz
rpm-9390fb8bff283960b6b0fb675007cd3d0fc9f20a.tar.bz2
rpm-9390fb8bff283960b6b0fb675007cd3d0fc9f20a.zip
Sanity.
CVS patchset: 5089 CVS date: 2001/09/29 13:42:58
Diffstat (limited to 'rpmio/tkey.c')
-rw-r--r--rpmio/tkey.c500
1 files changed, 181 insertions, 319 deletions
diff --git a/rpmio/tkey.c b/rpmio/tkey.c
index af20e7a13..a37d6048a 100644
--- a/rpmio/tkey.c
+++ b/rpmio/tkey.c
@@ -20,11 +20,6 @@ static inline int grab(const byte *s, int nbytes)
return i;
}
-typedef struct {
- byte nbits[2];
- byte bits[1];
-} MPI_t;
-
static inline int mpi_nbits(const byte *p) { return ((p[0] << 8) | p[1]); }
static inline int mpi_len(const byte *p) { return (2 + ((mpi_nbits(p)+7)>>3)); }
@@ -59,298 +54,156 @@ static const char * pr_mpi(const byte *p)
return prbuf;
}
-static const char * pr_sigtype(pgpSigType sigtype) {
- switch (sigtype) {
- case PGPSIGTYPE_BINARY:
- return("Signature of a binary document");
- break;
- case PGPSIGTYPE_TEXT:
- return("Signature of a canonical text document");
- break;
- case PGPSIGTYPE_STANDALONE:
- return("Standalone signature");
- break;
- case PGPSIGTYPE_GENERIC_CERT:
- return("Generic certification of a User ID and Public Key");
- break;
- case PGPSIGTYPE_PERSONA_CERT:
- return("Persona certification of a User ID and Public Key");
- break;
- case PGPSIGTYPE_CASUAL_CERT:
- return("Casual certification of a User ID and Public Key");
- break;
- case PGPSIGTYPE_POSITIVE_CERT:
- return("Positive certification of a User ID and Public Key");
- break;
- case PGPSIGTYPE_SUBKEY_BINDING:
- return("Subkey Binding Signature");
- break;
- case PGPSIGTYPE_SIGNED_KEY:
- return("Signature directly on a key");
- break;
- case PGPSIGTYPE_KEY_REVOKE:
- return("Key revocation signature");
- break;
- case PGPSIGTYPE_SUBKEY_REVOKE:
- return("Subkey revocation signature");
- break;
- case PGPSIGTYPE_CERT_REVOKE:
- return("Certification revocation signature");
- break;
- case PGPSIGTYPE_TIMESTAMP:
- return("Timestamp signature");
- break;
- }
- return "Unknown signature type";
+static const char * valstr(pgpValStr vs, byte val)
+{
+ do {
+ if (vs->val == val)
+ break;
+ } while ((++vs)->val != -1);
+ return vs->str;
}
-static const char * pr_pubkey_algo(byte pubkey_algo) {
- switch (pubkey_algo) {
- case PGPPUBKEYALGO_RSA:
- return("RSA");
- break;
- case PGPPUBKEYALGO_RSA_ENCRYPT:
- return("RSA(Encrypt-Only)");
- break;
- case PGPPUBKEYALGO_RSA_SIGN :
- return("RSA(Sign-Only)");
- break;
- case PGPPUBKEYALGO_ELGAMAL_ENCRYPT:
- return("Elgamal(Encrypt-Only)");
- break;
- case PGPPUBKEYALGO_DSA:
- return("DSA");
- break;
- case PGPPUBKEYALGO_EC:
- return("Elliptic Curve");
- break;
- case PGPPUBKEYALGO_ECDSA:
- return("ECDSA");
- break;
- case PGPPUBKEYALGO_ELGAMAL:
- return("Elgamal");
- break;
- case PGPPUBKEYALGO_DH:
- return("Diffie-Hellman (X9.42)");
- break;
- }
- return "Unknown public key algorithm";
+static void pr_valstr(const char * pre, pgpValStr vs, byte val)
+{
+ if (pre && *pre)
+ fprintf(stderr, "%s", pre);
+ fprintf(stderr, "%s(%d)", valstr(vs, val), val);
}
-static const char * pr_symkey_algo(byte symkey_algo) {
- switch (symkey_algo) {
- case PGPSYMKEYALGO_PLAINTEXT:
- return("Plaintext");
- break;
- case PGPSYMKEYALGO_IDEA:
- return("IDEA");
- break;
- case PGPSYMKEYALGO_TRIPLE_DES:
- return("Triple-DES");
- break;
- case PGPSYMKEYALGO_CAST5:
- return("CAST5");
- break;
- case PGPSYMKEYALGO_BLOWFISH:
- return("BLOWFISH");
- break;
- case PGPSYMKEYALGO_SAFER:
- return("SAFER");
- break;
- case PGPSYMKEYALGO_DES_SK:
- return("DES/SK");
- break;
- case PGPSYMKEYALGO_AES_128:
- return("AES(128-bit key)");
- break;
- case PGPSYMKEYALGO_AES_192:
- return("AES(192-bit key)");
- break;
- case PGPSYMKEYALGO_AES_256:
- return("AES(256-bit key)");
- break;
- case PGPSYMKEYALGO_TWOFISH:
- return("TWOFISH");
- break;
- }
- return "Unknown symmetric key algorithm";
+static struct pgpValStr_s sigtypeVals[] = {
+ { PGPSIGTYPE_BINARY, "Signature of a binary document" },
+ { PGPSIGTYPE_TEXT, "Signature of a canonical text document" },
+ { PGPSIGTYPE_STANDALONE, "Standalone signature" },
+ { PGPSIGTYPE_GENERIC_CERT, "Generic certification of a User ID and Public Key" },
+ { PGPSIGTYPE_PERSONA_CERT, "Persona certification of a User ID and Public Key" },
+ { PGPSIGTYPE_CASUAL_CERT, "Casual certification of a User ID and Public Key" },
+ { PGPSIGTYPE_POSITIVE_CERT, "Positive certification of a User ID and Public Key" },
+ { PGPSIGTYPE_SUBKEY_BINDING,"Subkey Binding Signature" },
+ { PGPSIGTYPE_SIGNED_KEY, "Signature directly on a key" },
+ { PGPSIGTYPE_KEY_REVOKE, "Key revocation signature" },
+ { PGPSIGTYPE_SUBKEY_REVOKE, "Subkey revocation signature" },
+ { PGPSIGTYPE_CERT_REVOKE, "Certification revocation signature" },
+ { PGPSIGTYPE_TIMESTAMP, "Timestamp signature" },
+ { -1, "Unknown signature type" },
};
-static const char * pr_compression_algo(byte compression_algo) {
- switch (compression_algo) {
- case PGPCOMPRESSALGO_NONE:
- return("Uncompressed");
- break;
- case PGPCOMPRESSALGO_ZIP:
- return("ZIP");
- break;
- case PGPCOMPRESSALGO_ZLIB:
- return("ZLIB");
- break;
- }
- return "Unknown compression algorithm";
+static struct pgpValStr_s pubkeyVals[] = {
+ { PGPPUBKEYALGO_RSA, "RSA" },
+ { PGPPUBKEYALGO_RSA_ENCRYPT,"RSA(Encrypt-Only)" },
+ { PGPPUBKEYALGO_RSA_SIGN, "RSA(Sign-Only)" },
+ { PGPPUBKEYALGO_ELGAMAL_ENCRYPT,"Elgamal(Encrypt-Only)" },
+ { PGPPUBKEYALGO_DSA, "DSA" },
+ { PGPPUBKEYALGO_EC, "Elliptic Curve" },
+ { PGPPUBKEYALGO_ECDSA, "ECDSA" },
+ { PGPPUBKEYALGO_ELGAMAL, "Elgamal" },
+ { PGPPUBKEYALGO_DH, "Diffie-Hellman (X9.42)" },
+ { -1, "Unknown public key algorithm" },
};
-static const char * pr_hash_algo(byte hash_algo) {
- switch (hash_algo) {
- case PGPHASHALGO_MD5:
- return("MD5");
- break;
- case PGPHASHALGO_SHA1:
- return("SHA1");
- break;
- case PGPHASHALGO_RIPEMD160:
- return("RIPEMD160");
- break;
- case PGPHASHALGO_MD2:
- return("MD2");
- break;
- case PGPHASHALGO_TIGER192:
- return("TIGER192");
- break;
- case PGPHASHALGO_HAVAL_5_160:
- return("HAVAL-5-160");
- break;
- }
- return "Unknown hash algorithm";
-}
+static struct pgpValStr_s symkeyVals[] = {
+ { PGPSYMKEYALGO_PLAINTEXT, "Plaintext" },
+ { PGPSYMKEYALGO_IDEA, "IDEA" },
+ { PGPSYMKEYALGO_TRIPLE_DES, "Triple-DES" },
+ { PGPSYMKEYALGO_CAST5, "CAST5" },
+ { PGPSYMKEYALGO_BLOWFISH, "BLOWFISH" },
+ { PGPSYMKEYALGO_SAFER, "SAFER" },
+ { PGPSYMKEYALGO_DES_SK, "DES/SK" },
+ { PGPSYMKEYALGO_AES_128, "AES(128-bit key)" },
+ { PGPSYMKEYALGO_AES_192, "AES(192-bit key)" },
+ { PGPSYMKEYALGO_AES_256, "AES(256-bit key)" },
+ { PGPSYMKEYALGO_TWOFISH, "TWOFISH" },
+ { -1, "Unknown symmetric key algorithm" },
+};
-static const char * pr_keyserv_pref (byte keyserv_pref) {
- switch(keyserv_pref) {
- case 0x80: return("No-modify"); break;
- }
- return "Unknown key server preference";
+static struct pgpValStr_s compressionVals[] = {
+ { PGPCOMPRESSALGO_NONE, "Uncompressed" },
+ { PGPCOMPRESSALGO_ZIP, "ZIP" },
+ { PGPCOMPRESSALGO_ZLIB, "ZLIB" },
+ { -1, "Unknown compression algorithm" },
};
-static const char * pr_sigsubkeytype (byte sigsubkeytype) {
- switch(sigsubkeytype) {
- case PGPSUBTYPE_SIG_CREATE_TIME:
- return("signature creation time");
- break;
- case PGPSUBTYPE_SIG_EXPIRE_TIME:
- return("signature expiration time");
- break;
- case PGPSUBTYPE_EXPORTABLE_CERT:
- return("exportable certification");
- break;
- case PGPSUBTYPE_TRUST_SIG:
- return("trust signature");
- break;
- case PGPSUBTYPE_REGEX:
- return("regular expression");
- break;
- case PGPSUBTYPE_REVOCABLE:
- return("revocable");
- break;
- case PGPSUBTYPE_KEY_EXPIRE_TIME:
- return("key expiration time");
- break;
- case PGPSUBTYPE_BACKWARD_COMPAT:
- return("placeholder for backward compatibility");
- break;
- case PGPSUBTYPE_PREFER_SYMKEY:
- return("preferred symmetric algorithms");
- break;
- case PGPSUBTYPE_REVOKE_KEY:
- return("revocation key");
- break;
- case PGPSUBTYPE_ISSUER_KEYID:
- return("issuer key ID");
- break;
- case PGPSUBTYPE_NOTATION:
- return("notation data");
- break;
- case PGPSUBTYPE_PREFER_HASH:
- return("preferred hash algorithms");
- break;
- case PGPSUBTYPE_PREFER_COMPRESS:
- return("preferred compression algorithms");
- break;
- case PGPSUBTYPE_KEYSERVER_PREFERS:
- return("key server preferences");
- break;
- case PGPSUBTYPE_PREFER_KEYSERVER:
- return("preferred key server");
- break;
- case PGPSUBTYPE_PRIMARY_USERID:
- return("primary user id");
- break;
- case PGPSUBTYPE_POLICY_URL:
- return("policy URL");
- break;
- case PGPSUBTYPE_KEY_FLAGS:
- return("key flags");
- break;
- case PGPSUBTYPE_SIGNER_USERID:
- return("signer's user id");
- break;
- case PGPSUBTYPE_REVOKE_REASON:
- return("reason for revocation");
- break;
- case PGPSUBTYPE_INTERNAL_100:
- return("internal subpkt type 100");
- break;
- case PGPSUBTYPE_INTERNAL_101:
- return("internal subpkt type 101");
- break;
- case PGPSUBTYPE_INTERNAL_102:
- return("internal subpkt type 102");
- break;
- case PGPSUBTYPE_INTERNAL_103:
- return("internal subpkt type 103");
- break;
- case PGPSUBTYPE_INTERNAL_104:
- return("internal subpkt type 104");
- break;
- case PGPSUBTYPE_INTERNAL_105:
- return("internal subpkt type 105");
- break;
- case PGPSUBTYPE_INTERNAL_106:
- return("internal subpkt type 106");
- break;
- case PGPSUBTYPE_INTERNAL_107:
- return("internal subpkt type 107");
- break;
- case PGPSUBTYPE_INTERNAL_108:
- return("internal subpkt type 108");
- break;
- case PGPSUBTYPE_INTERNAL_109:
- return("internal subpkt type 109");
- break;
- case PGPSUBTYPE_INTERNAL_110:
- return("internal subpkt type 110");
- break;
- }
- return "Unknown signature subkey type";
-}
+static struct pgpValStr_s hashVals[] = {
+ { PGPHASHALGO_MD5, "MD5" },
+ { PGPHASHALGO_SHA1, "SHA1" },
+ { PGPHASHALGO_RIPEMD160, "RIPEMD160" },
+ { PGPHASHALGO_MD2, "MD2" },
+ { PGPHASHALGO_TIGER192, "TIGER192" },
+ { PGPHASHALGO_HAVAL_5_160, "HAVAL-5-160" },
+ { -1, "Unknown hash algorithm" },
+};
+
+static struct pgpValStr_s keyservPrefVals[] = {
+ { 0x80, "No-modify" },
+ { -1, "Unknown key server preference" },
+};
-const char *ptags[] = {
- "Reserved - a packet tag must not have this value",
- "Public-Key Encrypted Session Key",
- "Signature",
- "Symmetric-Key Encrypted Session Key",
- "One-Pass Signature",
- "Secret Key",
- "Public Key",
- "Secret Subkey",
- "Compressed Data",
- "Symmetrically Encrypted Data",
- "Marker",
- "Literal Data",
- "Trust",
- "User ID",
- "Public Subkey",
- "??? TAG15 ???",
+static struct pgpValStr_s subtypeVals[] = {
+ { PGPSUBTYPE_SIG_CREATE_TIME,"signature creation time" },
+ { PGPSUBTYPE_SIG_EXPIRE_TIME,"signature expiration time" },
+ { PGPSUBTYPE_EXPORTABLE_CERT,"exportable certification" },
+ { PGPSUBTYPE_TRUST_SIG, "trust signature" },
+ { PGPSUBTYPE_REGEX, "regular expression" },
+ { PGPSUBTYPE_REVOCABLE, "revocable" },
+ { PGPSUBTYPE_KEY_EXPIRE_TIME,"key expiration time" },
+ { PGPSUBTYPE_BACKWARD_COMPAT,"placeholder for backward compatibility" },
+ { PGPSUBTYPE_PREFER_SYMKEY, "preferred symmetric algorithms" },
+ { PGPSUBTYPE_REVOKE_KEY, "revocation key" },
+ { PGPSUBTYPE_ISSUER_KEYID, "issuer key ID" },
+ { PGPSUBTYPE_NOTATION, "notation data" },
+ { PGPSUBTYPE_PREFER_HASH, "preferred hash algorithms" },
+ { PGPSUBTYPE_PREFER_COMPRESS,"preferred compression algorithms" },
+ { PGPSUBTYPE_KEYSERVER_PREFERS,"key server preferences" },
+ { PGPSUBTYPE_PREFER_KEYSERVER,"preferred key server" },
+ { PGPSUBTYPE_PRIMARY_USERID,"primary user id" },
+ { PGPSUBTYPE_POLICY_URL, "policy URL" },
+ { PGPSUBTYPE_KEY_FLAGS, "key flags" },
+ { PGPSUBTYPE_SIGNER_USERID, "signer's user id" },
+ { PGPSUBTYPE_REVOKE_REASON, "reason for revocation" },
+ { PGPSUBTYPE_INTERNAL_100, "internal subpkt type 100" },
+ { PGPSUBTYPE_INTERNAL_101, "internal subpkt type 101" },
+ { PGPSUBTYPE_INTERNAL_102, "internal subpkt type 102" },
+ { PGPSUBTYPE_INTERNAL_103, "internal subpkt type 103" },
+ { PGPSUBTYPE_INTERNAL_104, "internal subpkt type 104" },
+ { PGPSUBTYPE_INTERNAL_105, "internal subpkt type 105" },
+ { PGPSUBTYPE_INTERNAL_106, "internal subpkt type 106" },
+ { PGPSUBTYPE_INTERNAL_107, "internal subpkt type 107" },
+ { PGPSUBTYPE_INTERNAL_108, "internal subpkt type 108" },
+ { PGPSUBTYPE_INTERNAL_109, "internal subpkt type 109" },
+ { PGPSUBTYPE_INTERNAL_110, "internal subpkt type 110" },
+ { -1, "Unknown signature subkey type" },
};
-static int pr_signature_v3(pgpKeyPkt ptag, const byte *h, unsigned hlen)
+static struct pgpValStr_s keypktVals[] = {
+ { PGPKEYPKT_PUBLIC_SESSION_KEY,"Public-Key Encrypted Session Key" },
+ { PGPKEYPKT_SIGNATURE, "Signature" },
+ { PGPKEYPKT_SYMMETRIC_SESSION_KEY,"Symmetric-Key Encrypted Session Key" },
+ { PGPKEYPKT_ONEPASS_SIGNATURE, "One-Pass Signature" },
+ { PGPKEYPKT_SECRET_KEY, "Secret Key" },
+ { PGPKEYPKT_PUBLIC_KEY, "Public Key" },
+ { PGPKEYPKT_SECRET_SUBKEY, "Secret Subkey" },
+ { PGPKEYPKT_COMPRESSED_DATA,"Compressed Data" },
+ { PGPKEYPKT_SYMMETRIC_DATA, "Symmetrically Encrypted Data" },
+ { PGPKEYPKT_MARKER, "Marker" },
+ { PGPKEYPKT_LITERAL_DATA, "Literal Data" },
+ { PGPKEYPKT_TRUST, "Trust" },
+ { PGPKEYPKT_USER_ID, "User ID" },
+ { PGPKEYPKT_PUBLIC_SUBKEY, "Public Subkey" },
+ { PGPKEYPKT_PRIVATE_60, "Private #60" },
+ { PGPKEYPKT_PRIVATE_61, "Private #61" },
+ { PGPKEYPKT_PRIVATE_62, "Private #62" },
+ { PGPKEYPKT_PRIVATE_63, "Private #63" },
+ { -1, "Unknown packet tag" },
+};
+
+static int pr_signature_v3(pgpKeyPkt keypkt, const byte *h, unsigned hlen)
{
pgpSigPktV3 v = (pgpSigPktV3)h;
byte *p;
unsigned plen;
+ time_t t;
int i;
-fprintf(stderr, "%s(%d)", ptags[ptag], ptag);
+ pr_valstr("", keypktVals, keypkt);
if (v->version != 3) {
fprintf(stderr, " version(%d) != 3\n", v->version);
return 1;
@@ -359,13 +212,13 @@ fprintf(stderr, "%s(%d)", ptags[ptag], ptag);
fprintf(stderr, " hashlen(%d) != 5\n", v->hashlen);
return 1;
}
-fprintf(stderr, " %s(%d)", pr_pubkey_algo(v->pubkey_algo), v->pubkey_algo);
-fprintf(stderr, " %s(%d)", pr_hash_algo(v->hash_algo), v->hash_algo);
+ pr_valstr(" ", pubkeyVals, v->pubkey_algo);
+ pr_valstr(" ", hashVals, v->hash_algo);
-fprintf(stderr, " %s(%d)", pr_sigtype(v->sigtype), v->sigtype);
+ pr_valstr(" ", sigtypeVals, v->sigtype);
- plen = grab(v->time, sizeof(v->time));
-fprintf(stderr, " time %08x", plen);
+ t = grab(v->time, sizeof(v->time));
+fprintf(stderr, " time %08x %-24.24s", (unsigned)t, ctime(&t));
fprintf(stderr, " signer keyid %02x%02x%02x%02x%02x%02x%02x%02x",
v->signer[0], v->signer[1], v->signer[2], v->signer[3],
v->signer[4], v->signer[5], v->signer[6], v->signer[7]);
@@ -400,36 +253,44 @@ static int pr_sigsubkeys(const byte *h, unsigned hlen)
p += 4;
hlen -= 5;
}
-fprintf(stderr, " %s(%d)", pr_sigsubkeytype(*p), *p);
+ pr_valstr(" ", subtypeVals, p[0]);
switch (*p) {
case PGPSUBTYPE_PREFER_SYMKEY: /* preferred symmetric algorithms */
for (i = 1; i < plen; i++)
- fprintf(stderr, " %s(%d)", pr_symkey_algo(p[i]), p[i]);
+ pr_valstr(" ", symkeyVals, p[i]);
fprintf(stderr, "\n");
break;
case PGPSUBTYPE_PREFER_HASH: /* preferred hash algorithms */
for (i = 1; i < plen; i++)
- fprintf(stderr, " %s(%d)", pr_hash_algo(p[i]), p[i]);
+ pr_valstr(" ", hashVals, p[i]);
fprintf(stderr, "\n");
break;
case PGPSUBTYPE_PREFER_COMPRESS:/* preferred compression algorithms */
for (i = 1; i < plen; i++)
- fprintf(stderr, " %s(%d)", pr_compression_algo(p[i]), p[i]);
+ pr_valstr(" ", compressionVals, p[i]);
fprintf(stderr, "\n");
break;
case PGPSUBTYPE_KEYSERVER_PREFERS:/* key server preferences */
for (i = 1; i < plen; i++)
- fprintf(stderr, " %s(%d)", pr_keyserv_pref(p[i]), p[i]);
+ pr_valstr(" ", keyservPrefVals, p[i]);
fprintf(stderr, "\n");
break;
- case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */
case PGPSUBTYPE_SIG_CREATE_TIME:
case PGPSUBTYPE_SIG_EXPIRE_TIME:
+ case PGPSUBTYPE_KEY_EXPIRE_TIME:
+ fprintf(stderr, " %s", pr_hex(p+1, plen-1));
+ if ((plen - 1) == 4) {
+ time_t t = grab(p+1, plen-1);
+ fprintf(stderr, " %-24.24s", ctime(&t));
+ }
+ fprintf(stderr, "\n");
+ break;
+
+ case PGPSUBTYPE_ISSUER_KEYID: /* issuer key ID */
case PGPSUBTYPE_EXPORTABLE_CERT:
case PGPSUBTYPE_TRUST_SIG:
case PGPSUBTYPE_REGEX:
case PGPSUBTYPE_REVOCABLE:
- case PGPSUBTYPE_KEY_EXPIRE_TIME:
case PGPSUBTYPE_BACKWARD_COMPAT:
case PGPSUBTYPE_REVOKE_KEY:
case PGPSUBTYPE_NOTATION:
@@ -461,22 +322,22 @@ fprintf(stderr, " %s(%d)", pr_sigsubkeytype(*p), *p);
return 0;
}
-static int pr_signature_v4(pgpKeyPkt ptag, const byte *h, unsigned hlen)
+static int pr_signature_v4(pgpKeyPkt keypkt, const byte *h, unsigned hlen)
{
pgpSigPktV4 v = (pgpSigPktV4)h;
byte * p;
unsigned plen;
int i;
-fprintf(stderr, "%s(%d)", ptags[ptag], ptag);
+ pr_valstr("", keypktVals, keypkt);
if (v->version != 4) {
fprintf(stderr, " version(%d) != 4\n", v->version);
return 1;
}
-fprintf(stderr, " %s(%d)", pr_pubkey_algo(v->pubkey_algo), v->pubkey_algo);
-fprintf(stderr, " %s(%d)", pr_hash_algo(v->hash_algo), v->hash_algo);
+ pr_valstr(" ", pubkeyVals, v->pubkey_algo);
+ pr_valstr(" ", hashVals, v->hash_algo);
-fprintf(stderr, " %s(%d)", pr_sigtype(v->sigtype), v->sigtype);
+ pr_valstr(" ", sigtypeVals, v->sigtype);
fprintf(stderr, "\n");
p = &v->hashlen[0];
@@ -500,35 +361,36 @@ fprintf(stderr, " signhash16 %04x\n", plen);
return 0;
}
-static int pr_signature(pgpKeyPkt ptag, const byte *h, unsigned hlen)
+static int pr_signature(pgpKeyPkt keypkt, const byte *h, unsigned hlen)
{
byte version = *h;
switch (version) {
case 3:
- pr_signature_v3(ptag, h, hlen);
+ pr_signature_v3(keypkt, h, hlen);
break;
case 4:
- pr_signature_v4(ptag, h, hlen);
+ pr_signature_v4(keypkt, h, hlen);
break;
}
return 0;
}
-static int pr_key_v3(pgpKeyPkt ptag, const byte *h, unsigned hlen)
+static int pr_key_v3(pgpKeyPkt keypkt, const byte *h, unsigned hlen)
{
pgpKeyV3 v = (pgpKeyV3)h;
byte * p;
unsigned plen;
+ time_t t;
int i;
-fprintf(stderr, "%s(%d)", ptags[ptag], ptag);
+ pr_valstr("", keypktVals, keypkt);
if (v->version != 3) {
fprintf(stderr, " version(%d) != 3\n", v->version);
return 1;
}
plen = grab(v->time, sizeof(v->time));
-fprintf(stderr, " time %08x", plen);
-fprintf(stderr, " %s(%d)", pr_pubkey_algo(v->pubkey_algo), v->pubkey_algo);
+fprintf(stderr, " time %08x %-24.24s", (unsigned)t, ctime(&t));
+ pr_valstr(" ", pubkeyVals, v->pubkey_algo);
plen = grab(v->valid, sizeof(v->valid));
if (plen != 0)
@@ -543,21 +405,21 @@ fprintf(stderr, "\n");
return 0;
}
-static int pr_key_v4(pgpKeyPkt ptag, const byte *h, unsigned hlen)
+static int pr_key_v4(pgpKeyPkt keypkt, const byte *h, unsigned hlen)
{
pgpKeyV4 v = (pgpKeyV4)h;
byte * p;
- unsigned plen;
+ time_t t;
int i;
-fprintf(stderr, "%s(%d)", ptags[ptag], ptag);
+ pr_valstr("", keypktVals, keypkt);
if (v->version != 4) {
fprintf(stderr, " version(%d) != 4\n", v->version);
return 1;
}
- plen = grab(v->time, sizeof(v->time));
-fprintf(stderr, " time %08x", plen);
-fprintf(stderr, " %s(%d)", pr_pubkey_algo(v->pubkey_algo), v->pubkey_algo);
+ t = grab(v->time, sizeof(v->time));
+fprintf(stderr, " time %08x %-24.24s", (unsigned)t, ctime(&t));
+ pr_valstr(" ", pubkeyVals, v->pubkey_algo);
fprintf(stderr, "\n");
p = &v->data[0];
@@ -567,23 +429,23 @@ fprintf(stderr, "\n");
return 0;
}
-static int pr_key(pgpKeyPkt ptag, const byte *h, unsigned hlen)
+static int pr_key(pgpKeyPkt keypkt, const byte *h, unsigned hlen)
{
byte version = *h;
switch (version) {
case 3:
- pr_key_v3(ptag, h, hlen);
+ pr_key_v3(keypkt, h, hlen);
break;
case 4:
- pr_key_v4(ptag, h, hlen);
+ pr_key_v4(keypkt, h, hlen);
break;
}
return 0;
}
-static int pr_user_id(pgpKeyPkt ptag, const byte *h, unsigned hlen)
+static int pr_user_id(pgpKeyPkt keypkt, const byte *h, unsigned hlen)
{
-fprintf(stderr, "%s(%d)", ptags[ptag], ptag);
+ pr_valstr("", keypktVals, keypkt);
fprintf(stderr, " \"%*s\"\n", hlen, h);
return 0;
}
@@ -593,7 +455,7 @@ static int pr_keypkt(const byte *p)
unsigned int val = *p;
unsigned int mark = (val >> 7) & 0x1;
unsigned int new = (val >> 6) & 0x1;
- pgpKeyPkt ptag = (val >> 2) & 0xf;
+ pgpKeyPkt keypkt = (val >> 2) & 0xf;
unsigned int plen = (1 << (val & 0x3));
const byte *h;
unsigned int hlen = 0;
@@ -607,18 +469,18 @@ static int pr_keypkt(const byte *p)
hlen = (hlen << 8) | p[i];
h = p + plen + 1;
- switch (ptag) {
+ switch (keypkt) {
case PGPKEYPKT_SIGNATURE:
- pr_signature(ptag, h, hlen);
+ pr_signature(keypkt, h, hlen);
break;
case PGPKEYPKT_PUBLIC_KEY:
case PGPKEYPKT_PUBLIC_SUBKEY:
case PGPKEYPKT_SECRET_KEY:
case PGPKEYPKT_SECRET_SUBKEY:
- pr_key(ptag, h, hlen);
+ pr_key(keypkt, h, hlen);
break;
case PGPKEYPKT_USER_ID:
- pr_user_id(ptag, h, hlen);
+ pr_user_id(keypkt, h, hlen);
break;
case PGPKEYPKT_RESERVED:
case PGPKEYPKT_PUBLIC_SESSION_KEY:
@@ -633,8 +495,8 @@ static int pr_keypkt(const byte *p)
case PGPKEYPKT_PRIVATE_62:
case PGPKEYPKT_PRIVATE_63:
default:
- fprintf(stderr, "%s(%d) plen %02x hlen %x\n",
- ptags[ptag], ptag, plen, hlen);
+ pr_valstr("", keypktVals, keypkt);
+ fprintf(stderr, " plen %02x hlen %x\n", plen, hlen);
break;
}