Permalink
Browse files

The first release

  • Loading branch information...
0 parents commit 0e639f7a17bd5e1bf3a2d9263005e77cd51f03ce @kazu-yamamoto committed Feb 19, 2010
@@ -0,0 +1,27 @@
+Copyright (C) 1998 Kazuhiko Yamamoto
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+3. Neither the name of the author nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,28 @@
+INCS = pgpdump.h
+SRCS = pgpdump.c types.c tagfuncs.c packet.c subfunc.c signature.c keys.c \
+ armor.c uncompress.c
+OBJS = pgpdump.o types.o tagfuncs.o packet.o subfunc.o signature.o keys.o \
+ armor.o uncompress.o
+PROG = pgpdump
+
+#LIBS = -lz
+#DEFS = -DHAVE_ZLIB
+CFLAGS = -O -Wall
+
+BINDIR = /usr/local/bin
+
+RM = rm -f
+
+.c.o:
+ $(CC) -c $(CFLAGS) $(DEFS) $<
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(CC) $(CFLAGS) -o $(PROG) $(OBJS) $(LIBS)
+
+clean:
+ $(RM) $(OBJS) $(PROG)
+
+install:
+ install -c -m 555 $(PROG) $(BINDIR)
63 README
@@ -0,0 +1,63 @@
+ pgpdump: a PGP packet visualizer
+
+ Kazu Yamamoto <kazu@iijlab.net>
+
+ December 4, 1998
+
+"pgpdump" is a PGP packet visualizer which displays the packet format
+of OpenPGP (RFC2440) and PGP version 2 (RFC 1991).
+
+Here is an example:
+
+ % pgpdump sig.pgp
+ Old: Marker Packet(tag 10)(3 bytes)
+ String - ...
+ New: One-Pass Signature Packet(tag 4)(13 bytes)
+ New version(3)
+ Sig type - Signature of a binary document(0x00).
+ Hash alg - SHA1(hash 2)
+ Pub alg - DSA Digital Signature Standard(pub 17)
+ Key ID - a7 97 78 e2 47 b6 30 37
+ Next packet - other than one pass signature
+ New: Signature Packet(tag 2)(63 bytes)
+ Ver 3 - old
+ Hash material(5 bytes):
+ Sig type - Signature of a binary document(0x00).
+ Creation time - Fri Nov 27 22:35:02 1998
+ Key ID - a7 97 78 e2 47 b6 30 37
+ Pub alg - DSA Digital Signature Standard(pub 17)
+ Hash alg - SHA1(hash 2)
+ Hash left 2 bytes - 8f 82
+ DSA r(160 bits) - ...
+ DSA s(157 bits) - ...
+ -> hash(160 bits)
+
+To know how to use pgpdump, type "pgpdump -h".
+
+Some examples are stored in the "data" directory. Also, you can
+visualize your pubring and secring.
+
+You can create various packets by using PGP version 5 with the
+following options:
+
+ +version=num
+ 3 - old
+ 4 - new
+ +ciphernum
+ 0 - null
+ 1 - IDEA
+ 2 - Triple DES
+ 3 - CAST5
+ +hashnum
+ 1 - MD5
+ 2 - SHA-1
+ 3 - PIPEMD160
+
+Also, try GNUPG which is an excellent alternative of PGP version 5.
+Its options are easy-to-understand.
+
+Bugs:
+ - Uncompression has not been implemented yet.
+ Create PGP packets with the "+compress=off" option.
+ - Some sub-packets for the signature packet have not been
+ implemented yet.
153 armor.c
@@ -0,0 +1,153 @@
+/*
+ * armor.c
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include "pgpdump.h"
+
+#define YES 1
+#define NO 1
+
+#define ON 1
+#define OFF 0
+
+#define CR 13
+#define LF 10
+
+#define PADDING '='
+#define EOP -2
+
+#define OOB -1
+
+private int GetChar(FILE *, int);
+private void base64_decode(FILE *, FILE *);
+
+private char
+base256[] = {
+ OOB,OOB,OOB,OOB, OOB,OOB,OOB,OOB, OOB,OOB,OOB,OOB, OOB,OOB,OOB,OOB,
+
+ OOB,OOB,OOB,OOB, OOB,OOB,OOB,OOB, OOB,OOB,OOB,OOB, OOB,OOB,OOB,OOB,
+ /* - / */
+ OOB,OOB,OOB,OOB, OOB,OOB,OOB,OOB, OOB,OOB,OOB, 62, OOB,OOB,OOB, 63,
+ /* 0 1 2 3 4 5 6 7 8 9 = */
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61,OOB,OOB, OOB,OOB,OOB,OOB,
+ /* A B C D E F G H I J K L M N O*/
+ OOB, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ /* P Q R S T U V W X Y Z */
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,OOB, OOB,OOB,OOB,OOB,
+ /* a b c d e f g h i j k l m n o*/
+ OOB, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ /* p q r s t u v w x y z */
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,OOB, OOB,OOB,OOB,OOB,
+};
+
+
+private int
+GetChar(FILE *stream, int cannot_be_eof)
+{
+ int c, ret;
+ static int Ineof = OFF;
+
+ if (Ineof == ON)
+ return EOF;
+
+ do {
+ c = getc(stream);
+ } while ( c == CR || c == LF);
+
+ if (c == EOF) {
+ if (cannot_be_eof == YES)
+ error("base64 decoder saw premature EOF.");
+ Ineof = ON;
+ return(EOF);
+ }
+
+ if (c == PADDING)
+ return(EOP);
+
+ if ((ret = base256[c]) == OOB)
+ error("base64 decoder saw an illegal character.");
+
+ return(ret);
+}
+
+private void
+base64_decode(FILE *infile, FILE *outfile)
+{
+ int c1, c2, c3, c4;
+
+ while ((c1 = GetChar(infile, NO)) != EOF) {
+ if (c1 == EOP)
+ break;
+ if ((c2 = GetChar(infile, YES)) == EOP)
+ break;
+ putc(((c1 << 2) | ((c2 & 0x30) >> 4)), outfile);
+
+ if ((c3 = GetChar(infile, YES)) == EOP)
+ break;
+ putc((((c2 & 0x0f) << 4) | ((c3 & 0x3c) >> 2)), outfile);
+
+ if ((c4 = GetChar(infile, YES)) == EOP)
+ break;
+ putc((((c3 & 0x03) << 6) | c4), outfile);
+ }
+}
+
+public void
+armor_decode(void)
+{
+
+ FILE *input = Get_input_file();
+ FILE *output;
+ char buffer[BUFSIZ], outfile[BUFSIZ];
+
+ strcpy(outfile, "/tmp/pgpdump.XXXX");
+
+ if (mktemp(outfile) == NULL)
+ error("can't open null stream.");
+ output = fopen(outfile, "w");
+ if (output == NULL)
+ error("can't open the file.");
+
+ do {
+ fgets(buffer, BUFSIZ, input);
+ } while (buffer[0] != CR && buffer[0] != LF);
+
+ base64_decode(input, output);
+
+ fclose(input);
+ fclose(output);
+ Set_input_file(outfile);
+ unlink(outfile);
+}
+
+/*
+ * Copyright (C) 1998 Kazuhiko Yamamoto
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
BIN data/enc
Binary file not shown.
BIN data/enc1
Binary file not shown.
BIN data/enc2
Binary file not shown.
BIN data/enc3
Binary file not shown.
BIN data/gpg1
Binary file not shown.
BIN data/gpg2
Binary file not shown.
BIN data/gpg3
Binary file not shown.
BIN data/pub
Binary file not shown.
BIN data/pub1
Binary file not shown.
BIN data/sig
Binary file not shown.
BIN data/sig1
Binary file not shown.
BIN data/sig2
Binary file not shown.
BIN data/sig4
Binary file not shown.
Oops, something went wrong.

0 comments on commit 0e639f7

Please sign in to comment.