Permalink
Browse files

* Defining the SHA-1 hash for Secret Key Packet.

* Defining the -a and -g option.
* Catching up to 2440bis-05.
* Implementing User_Attribute_Packet.
* Implementing features and revocation_target.
* Removing macros to avoid side-effects.
* Most modifications above come from:
        "Stefan H. Holek" <stefan>
  • Loading branch information...
1 parent c5db791 commit c67ae9745ddb98eadaa50cab6577b75d4bfdd05b @kazu-yamamoto committed Feb 19, 2010
Showing with 326 additions and 112 deletions.
  1. +11 −1 CHANGES
  2. +2 −2 Makefile.in
  3. +64 −45 keys.c
  4. +53 −15 packet.c
  5. +10 −4 pgpdump.1
  6. +71 −13 pgpdump.c
  7. +17 −19 pgpdump.h
  8. +4 −4 signature.c
  9. +21 −0 subfunc.c
  10. +16 −9 tagfuncs.c
  11. +57 −0 uatfunc.c
View
@@ -1,5 +1,15 @@
Change Log
+0.17 2002/06/28
+
+* Defining the SHA-1 hash for Secret Key Packet.
+* Defining the -a and -g option.
+* Catching up to 2440bis-05.
+* Implementing User_Attribute_Packet.
+* Implementing features and revocation_target.
+* Removing macros to avoid side-effects.
+* Most modifications above come from:
+ "Stefan H. Holek" <stefan>
0.16 2001/12/06
@@ -9,7 +19,7 @@
0.15 2001/11/13
* Old man style for pgpdump.1.
-* The symmetric encryption algorism is displayed more user-friendly.
+* The symmetric encryption algorithm is displayed more user-friendly.
0.14 2001/11/09
View
@@ -10,9 +10,9 @@ INSTALL = install -c -m
INCS = pgpdump.h
SRCS = pgpdump.c types.c tagfuncs.c packet.c subfunc.c signature.c keys.c \
- buffer.c
+ buffer.c uatfunc.c
OBJS = pgpdump.o types.o tagfuncs.o packet.o subfunc.o signature.o keys.o \
- buffer.o
+ buffer.o uatfunc.o
PROG = pgpdump
MAN = pgpdump.1
View
@@ -10,7 +10,8 @@ private int VERSION;
private void old_Public_Key_Packet(void);
private void new_Public_Key_Packet(int);
private void IV(unsigned int);
-private void encrypted_Secret_Key(int);
+private void plain_Secret_Key(int);
+private void encrypted_Secret_Key(int, int);
public void
Public_Subkey_Packet(int len)
@@ -34,8 +35,7 @@ Public_Key_Packet(int len)
new_Public_Key_Packet(len - 1);
break;
default:
- printf("unknown ver(%d)\n", VERSION);
- skip(len - 1);
+ warn_exit("unknown version (%d).", VERSION);
break;
}
}
@@ -49,7 +49,7 @@ old_Public_Key_Packet(void)
days += Getc() * 256;
printf("\tValid days - %d[0 is forever]\n", days);
PUBLIC = Getc();
- pub_algs(PUBLIC);
+ pub_algs(PUBLIC); /* PUBLIC should be 1 */
multi_precision_integer("RSA n");
multi_precision_integer("RSA e");
}
@@ -110,76 +110,95 @@ Secret_Key_Packet(int len)
s2k = Getc();
switch (s2k) {
case 0:
- /* not encrypted */
- switch (PUBLIC) {
- case 1:
- case 2:
- case 3:
- multi_precision_integer("RSA d");
- multi_precision_integer("RSA p");
- multi_precision_integer("RSA q");
- multi_precision_integer("RSA u");
- break;
- case 16:
- case 20:
- multi_precision_integer("ElGamal x");
- break;
- case 17:
- multi_precision_integer("DSA x");
- break;
- default:
- printf("\tUnknown secret key(pub %d)\n", PUBLIC);
- skip(len - Getc_getlen());
- break;
- }
- printf("\t\t-> m = sym alg(1 byte) + checksum(2 bytes) + PKCS-1 block type 02\n");
+ plain_Secret_Key(len - Getc_getlen());
+ break;
+ case 254:
+ sym = Getc();
+ sym_algs(sym);
+ string_to_key();
+ IV(iv_len(sym));
+ encrypted_Secret_Key(len - Getc_getlen(), YES);
break;
case 255:
sym = Getc();
sym_algs(sym);
string_to_key();
IV(iv_len(sym));
- encrypted_Secret_Key(len - Getc_getlen());
+ encrypted_Secret_Key(len - Getc_getlen(), NO);
break;
default:
- sym_algs(s2k);
- IV(iv_len(s2k));
- encrypted_Secret_Key(len - Getc_getlen());
+ sym = s2k;
+ sym_algs(sym);
+ IV(iv_len(sym));
+ encrypted_Secret_Key(len - Getc_getlen(), NO);
break;
}
}
private void
-encrypted_Secret_Key(int len)
+plain_Secret_Key(int len)
{
switch (VERSION) {
case 2:
case 3:
+ /* PUBLIC should be 1. */
+ multi_precision_integer("Encrypted RSA d");
+ multi_precision_integer("Encrypted RSA p");
+ multi_precision_integer("Encrypted RSA q");
+ multi_precision_integer("Encrypted RSA u");
+ printf("\tChecksum - ");
+ dump(2);
+ printf("\n");
+ break;
+ case 4:
switch (PUBLIC) {
case 1:
case 2:
case 3:
- multi_precision_integer("Encrypted RSA d");
- multi_precision_integer("Encrypted RSA p");
- multi_precision_integer("Encrypted RSA q");
- multi_precision_integer("Encrypted RSA u");
+ multi_precision_integer("RSA d");
+ multi_precision_integer("RSA p");
+ multi_precision_integer("RSA q");
+ multi_precision_integer("RSA u");
break;
case 16:
case 20:
- multi_precision_integer("Encrypted ElGamal x");
+ multi_precision_integer("ElGamal x");
break;
case 17:
- multi_precision_integer("Encrypted DSA x");
+ multi_precision_integer("DSA x");
break;
default:
- printf("\t\tUnknown encrypted key(pub %d)\n", PUBLIC);
- skip(len);
+ printf("\tUnknown secret key(pub %d)\n", PUBLIC);
+ skip(len - 2);
break;
}
printf("\tChecksum - ");
dump(2);
printf("\n");
break;
+ default:
+ printf("\tunknown version (%d)\n", VERSION);
+ skip(len);
+ break;
+ }
+}
+
+private void
+encrypted_Secret_Key(int len, int sha1)
+{
+ switch (VERSION) {
+ case 2:
+ case 3:
+ /* PUBLIC should be 1.
+ MPI prefix count is not encrypted. */
+ multi_precision_integer("Encrypted RSA d");
+ multi_precision_integer("Encrypted RSA p");
+ multi_precision_integer("Encrypted RSA q");
+ multi_precision_integer("Encrypted RSA u");
+ printf("\tChecksum - ");
+ dump(2);
+ printf("\n");
+ break;
case 4:
switch (PUBLIC) {
case 1:
@@ -189,26 +208,26 @@ encrypted_Secret_Key(int len)
printf("\tEncrypted RSA p\n");
printf("\tEncrypted RSA q\n");
printf("\tEncrypted RSA u\n");
- printf("\tEncrypted checksum\n");
break;
case 16:
case 20:
printf("\tEncrypted ElGamal x\n");
- printf("\tEncrypted checksum\n");
break;
case 17:
printf("\tEncrypted DSA x\n");
- printf("\tEncrypted checksum\n");
break;
default:
printf("\tUnknown encrypted key(pub %d)\n", PUBLIC);
- printf("\tEncrypted checksum\n");
break;
}
+ if (sha1 == YES)
+ printf("\tEncrypted SHA1 hash\n");
+ else
+ printf("\tEncrypted checksum\n");
skip(len);
break;
default:
- printf("\tUnknown encrypted key\n");
+ printf("\tunknown version (%d)\n", VERSION);
skip(len);
break;
}
View
@@ -4,6 +4,8 @@
#include "pgpdump.h"
+typedef void (*funcptr)();
+
private int get_new_len(int);
private int is_partial(int);
@@ -36,7 +38,7 @@ TAG[TAG_NUM] = {
"Public Subkey Packet",
"unknown",
"unknown",
- "unknown",
+ "User Attribute Packet",
"Symmetrically Encrypted and MDC Packet",
"Modification Detection Code Packet",
"unknown",
@@ -104,7 +106,7 @@ private void
Public_Subkey_Packet,
NULL,
NULL,
- NULL,
+ User_Attribute_Packet,
Symmetrically_Encrypted_and_MDC_Packet,
Modification_Detection_Code_Packet,
NULL,
@@ -154,9 +156,9 @@ private void
Private_Packet,
};
-#define SUB_NUM 30
+#define SIGSUB_NUM 32
private char *
-SUB[SUB_NUM] = {
+SIGSUB[SIGSUB_NUM] = {
"unknown(sub 0)",
"unknown(sub 1)",
"signature creation time(sub 2)",
@@ -187,10 +189,12 @@ SUB[SUB_NUM] = {
"key flags(sub 27)",
"signer's user id(sub 28)",
"reason for revocation(sub 29)",
+ "features(sub 30)",
+ "revocation target(sub 31)",
};
-private void
-(*sub_func[])() = {
+private funcptr
+sigsub_func[] = {
NULL,
NULL,
signature_creation_time,
@@ -221,6 +225,21 @@ private void
key_flags,
signer_user_id,
reason_for_revocation,
+ features,
+ revocation_target,
+};
+
+#define UATSUB_NUM 2
+private char *
+UATSUB[UATSUB_NUM] = {
+ "unknown(sub 0)",
+ "image attribute(sub 1)",
+};
+
+private funcptr
+uatsub_func[] = {
+ NULL,
+ image_attribute,
};
private int
@@ -266,9 +285,11 @@ parse_packet(void)
* it is the binary raw form. Otherwise, let's assume
* it is encoded with radix64.
*/
- if (c & BINARY_TAG_FLAG)
+ if (c & BINARY_TAG_FLAG) {
+ if (aflag)
+ warn_exit("binary input is not allowed.");
set_binary();
- else
+ } else
set_armor();
while ((c = Getc1()) != EOF) {
@@ -345,9 +366,27 @@ parse_packet(void)
}
public void
-parse_subpacket(char *prefix, int tlen)
+parse_subpacket(char *prefix, int tlen, int type)
{
- int len, sub;
+ int len, sub, slen;
+ char **exptbl;
+ funcptr *sw;
+
+ switch (type) {
+ case 1:
+ slen = SIGSUB_NUM;
+ exptbl = SIGSUB;
+ sw = sigsub_func;
+ break;
+ case 2:
+ slen = UATSUB_NUM;
+ exptbl = UATSUB;
+ sw = uatsub_func;
+ break;
+ default:
+ warn_exit("unknown type (%d) for subpacket.", type);
+ break;
+ }
while (tlen > 0) {
len = Getc();
@@ -366,19 +405,18 @@ parse_subpacket(char *prefix, int tlen)
tlen -= len;
sub = Getc(); /* len includes this field byte */
len --;
- if (sub < SUB_NUM)
- printf("\t%s: %s", prefix, SUB[sub]);
+ if (sub < slen)
+ printf("\t%s: %s", prefix, exptbl[sub]);
else
printf("\t%s: unknown(sub %d)", prefix, sub);
printf("(%d bytes)\n", len);
- if (sub < SUB_NUM && sub_func[sub] != NULL)
- (*sub_func[sub])(len);
+ if (sub < slen && sw[sub] != NULL)
+ (*sw[sub])(len);
else
skip(len);
}
}
-
/*
* Copyright (C) 1998 Kazuhiko Yamamoto
* All rights reserved.
Oops, something went wrong. Retry.

0 comments on commit c67ae97

Please sign in to comment.