Permalink
Browse files

* Adding the "-p" option.

* Adding some tags and algorithms.
* A serious bug fix of Public_Key_Packet(). "len" was wrong.
* A serious bug fix of Getc(). Defined Getc1().
  • Loading branch information...
kazu-yamamoto committed Feb 19, 2010
1 parent 5677a4a commit 181549386247cf7eaf36a4a27c5a91d2c853982d
Showing with 185 additions and 19 deletions.
  1. +7 −0 CHANGES
  2. +3 −3 README
  3. +18 −6 keys.c
  4. +104 −5 packet.c
  5. +18 −3 pgpdump.c
  6. +5 −0 pgpdump.h
  7. +27 −0 tagfuncs.c
  8. +3 −2 types.c
View
@@ -1,5 +1,12 @@
Change Log
+0.05 2001/03/22
+
+* Adding the "-p" option.
+* Adding some tags and algorithms.
+* A serious bug fix of Public_Key_Packet(). "len" was wrong.
+* A serious bug fix of Getc(). Defined Getc1().
+
0.04 2000/10/18
* configure support.
View
6 README
@@ -1,13 +1,13 @@
pgpdump: a PGP packet visualizer
Kazu Yamamoto <kazu@iijlab.net>
- October 18, 2000
+ March 22, 2001
<Overview>
"pgpdump" is a PGP packet visualizer which displays the packet format
-of OpenPGP (RFC 2440) and PGP version 2 (RFC 1991).
+of OpenPGP (RFC 2440 + bis) and PGP version 2 (RFC 1991).
Here is an example:
@@ -66,7 +66,7 @@ following options(see src/pgp/{keydb/pgpPrefs.c,utils/pgpConf.c}):
+hashnum
1 - MD5 (default)
2 - SHA-1
- 3 - PIPEMD160
+ 3 - RIPEMD160
note : compress is 1 (RFC1950 ZIP ZEFLATE) only.
View
24 keys.c
@@ -7,8 +7,8 @@
private int PUBLIC;
private int VERSION;
+private void old_Public_Key_Packet(void);
private void new_Public_Key_Packet(int);
-private void old_Public_Key_Packet(int);
private void IV(void);
private void encrypted_Secret_Key(int);
@@ -27,21 +27,21 @@ Public_Key_Packet(int len)
case 2:
case 3:
printf("old\n");
- old_Public_Key_Packet(len);
+ old_Public_Key_Packet();
break;
case 4:
printf("new\n");
- new_Public_Key_Packet(len);
+ new_Public_Key_Packet(len - 1);
break;
default:
- printf("unknown\n");
+ printf("unknown ver(%d)\n", VERSION);
skip(len - 1);
break;
}
}
private void
-old_Public_Key_Packet(int len)
+old_Public_Key_Packet()
{
time4("Public key creation time");
printf("\tValid days - %d[0 is forever]\n", Getc() * 256 + Getc());
@@ -59,10 +59,13 @@ new_Public_Key_Packet(int len)
pub_algs(PUBLIC);
switch (PUBLIC) {
case 1:
+ case 2:
+ case 3:
multi_precision_integer("RSA n");
multi_precision_integer("RSA e");
break;
case 16:
+ case 20:
multi_precision_integer("ElGamal p");
multi_precision_integer("ElGamal g");
multi_precision_integer("ElGamal y");
@@ -106,20 +109,23 @@ Secret_Key_Packet(int len)
/* 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("\t\tunknown(%d)\n", PUBLIC);
- skip(len - 5);
+ skip(len - Getc_getlen());
}
printf("\t\t-> m = sym alg(1) + checksum(2) + PKCS-1 block type 02\n");
break;
@@ -144,12 +150,15 @@ encrypted_Secret_Key(int len)
case 3:
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");
break;
case 16:
+ case 20:
multi_precision_integer("Encrypted ElGamal x");
break;
case 17:
@@ -166,9 +175,12 @@ encrypted_Secret_Key(int len)
case 4:
switch (PUBLIC) {
case 1:
+ case 2:
+ case 3:
printf("\tEncrypted RSA d, p, q, u, checksum\n");
break;
case 16:
+ case 20:
printf("\tEncrypted ElGamal x, checksum\n");
break;
case 17:
View
109 packet.c
@@ -14,7 +14,7 @@
#define OLD_TAG_SHIFT 2
#define OLD_LEN_MASK 0x03
-#define TAG_NUM 15
+#define TAG_NUM 64
private char *
TAG[TAG_NUM] = {
"Reserved",
@@ -31,7 +31,56 @@ TAG[TAG_NUM] = {
"Literal Data Packet",
"Trust Packet",
"User ID Packet",
- "Public Subkey Packet",
+ "Public Subkey Packet",
+ "Symmetrically Encrypted and MDC Packet", /* xxx */
+ "Modification Detection Code Packet", /* xxx */
+ "unknown", /* xxx PHOTO */
+ "Symmetrically Encrypted and MDC Packet", /* xxx GPG */
+ "Modification Detection Code Packet", /* xxx GPG */
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "unknown",
+ "Private",
+ "Private",
+ "Private",
+ "Private",
};
private void
@@ -51,6 +100,56 @@ private void
Trust_Packet,
User_ID_Packet,
Public_Subkey_Packet,
+ NULL, /* xxx */
+ NULL, /* xxx */
+ NULL, /* xxx */
+ Symmetrically_Encrypted_and_MDC_Packet, /* xxx */
+ Modification_Detection_Code_Packet, /* xxx */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ Private_Packet,
+ Private_Packet,
+ Private_Packet,
+ Private_Packet,
};
#define SUB_NUM 30
@@ -142,7 +241,7 @@ parse_packet(void)
}
partial = 0;
- while ((c = Getc()) != EOF) {
+ while ((c = Getc1()) != EOF) {
if (partial)
tag = PARTIAL;
else
@@ -204,7 +303,7 @@ parse_packet(void)
if (tag < TAG_NUM && tag_func[tag] != NULL)
(*tag_func[tag])(len);
else {
- printf("KNOWN TAG\n");
+ printf("\tUNKNOWN TAG\n");
skip(len);
}
}
@@ -239,7 +338,7 @@ parse_subpacket (char *prefix, int tlen)
if (sub < SUB_NUM && sub_func[sub] != NULL)
(*sub_func[sub])(len);
else {
- printf("KNOWN SUB PARCKET\n");
+ printf("\tUNKNOWN SUB PARCKET\n");
skip(len);
}
}
View
@@ -4,7 +4,7 @@
#include "pgpdump.h"
-private char *pgpdump_version = "0.04, Copyright (C) 1998-2000 Kazu Yamamoto";
+private char *pgpdump_version = "0.05, Copyright (C) 1998-2001 Kazu Yamamoto";
private char *prog;
private void usage(void);
@@ -13,10 +13,11 @@ private void version(void);
private void
usage(void)
{
- fprintf(stderr, "%s [-h|-m|-l|-i] PGPfile\n", prog);
+ fprintf(stderr, "%s [-h|-m|-l|-i|-p] PGPfile\n", prog);
fprintf(stderr, "\t -h -- displays this help\n");
fprintf(stderr, "\t -m -- prints marker\n");
fprintf(stderr, "\t -l -- prints literal\n");
+ fprintf(stderr, "\t -p -- dump private\n");
fprintf(stderr, "\t -i -- dump integer\n");
exit(ERROR);
}
@@ -44,6 +45,7 @@ main (int argc, char *argv[])
iflag = 0;
mflag = 0;
lflag = 0;
+ pflag = 0;
if ((prog = strrchr(argv[0], '/')) == NULL)
prog = argv[0];
@@ -67,6 +69,9 @@ main (int argc, char *argv[])
case 'm':
mflag++;
break;
+ case 'p':
+ pflag++;
+ break;
default:
usage();
}
@@ -77,7 +82,7 @@ main (int argc, char *argv[])
}
if (target == NULL)
- error("can't open null stream.");
+ error("no file specified.");
if ((input_stream = fopen(target, "r")) == NULL)
error("can't open the file.");
Set_input_file(input_stream);
@@ -103,6 +108,16 @@ Get_input_file(void)
public int
Getc(void)
+{
+ int c = getc(input);
+
+ MAGIC_COUNT++;
+ if (c == EOF) exit(ERROR);
+ return c;
+}
+
+public int
+Getc1(void)
{
MAGIC_COUNT++;
return getc(input);
View
@@ -29,6 +29,7 @@
int mflag;
int lflag;
int iflag;
+int pflag;
/*
* pgpdump.c
@@ -38,6 +39,7 @@ public void error(char *);
public void Set_input_file(FILE *);
public FILE *Get_input_file(void);
public int Getc(void);
+public int Getc1(void);
public int Getc_getlen(void);
public void Getc_resetlen(void);
public FILE * Get_temp_file(char **);
@@ -78,6 +80,9 @@ public void Marker_Packet(int);
public void Literal_Data_Packet(int);
public void Trust_Packet(int);
public void User_ID_Packet(int);
+public void Symmetrically_Encrypted_and_MDC_Packet(int);
+public void Modification_Detection_Code_Packet(int);
+public void Private_Packet(int);
/*
* keys.c
Oops, something went wrong.

0 comments on commit 1815493

Please sign in to comment.