Browse files

* More secure programming style.

* Adding GnuPG string-to-key.
* Adding a missing key flag.
  • Loading branch information...
1 parent 792ad89 commit ff8db9a2feb55f9df1751da49b1affc0cb0b4031 @kazu-yamamoto committed Feb 19, 2010
Showing with 37 additions and 23 deletions.
  1. +6 −0 CHANGES
  2. +1 −1 README
  3. +4 −4 keys.c
  4. +6 −3 pgpdump.c
  5. +1 −1 pgpdump.h
  6. +4 −6 subfunc.c
  7. +15 −8 types.c
View
6 CHANGES
@@ -1,5 +1,11 @@
Change Log
+0.24 2004/12/24
+
+* More secure programming style.
+* Adding GnuPG string-to-key.
+* Adding a missing key flag.
+
0.23 2004/10/27
* Catching up to 2440bis-10/11.
View
2 README
@@ -1,6 +1,6 @@
pgpdump: a PGP packet visualizer
- Kazu Yamamoto <kazu@iijlab.net>
+ Kazu Yamamoto <kazu@iij.ad.jp>
Jun 5, 2003
View
8 keys.c
@@ -115,15 +115,15 @@ Secret_Key_Packet(int len)
case 254:
sym = Getc();
sym_algs(sym);
- string_to_key();
- IV(iv_len(sym));
+ if (string_to_key() == YES)
+ 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));
+ if (string_to_key() == YES)
+ IV(iv_len(sym));
encrypted_Secret_Key(len - Getc_getlen(), NO);
break;
default:
View
9 pgpdump.c
@@ -14,7 +14,7 @@ int mflag;
int pflag;
int uflag;
-private string pgpdump_version = "0.23, Copyright (C) 1998-2004 Kazu Yamamoto";
+private string pgpdump_version = "0.24, Copyright (C) 1998-2004 Kazu Yamamoto";
private string prog;
private string getprog(void);
@@ -198,12 +198,15 @@ kdump(int len)
}
public void
-gdump(int len) /* mixed dump (like gnupg) */
+gdump(int len) /* mixed dump (like GnuPG) */
{
int i;
for (i = 0; i < len; i++) {
int c = Getc();
- printf(isprint(c)?"%c":"\\x%02x", c);
+ if (isprint(c) == NO)
+ printf("\\x%02x", c);
+ else
+ printf("%c", c);
}
}
View
2 pgpdump.h
@@ -90,7 +90,7 @@ public void sig_expiration_time4(string);
public void key_creation_time4(string);
public void key_expiration_time4(string);
public void ver(int, int, int);
-public void string_to_key(void);
+public int string_to_key(void);
public void multi_precision_integer(string);
/*
View
10 subfunc.c
@@ -256,13 +256,11 @@ key_flags(int len)
if (c & 0x08)
printf("\t\tFlag - This key may be used to encrypt storage\n");
if (c & 0x10)
- printf("\t\tFlag - The private component of this key may have been split by "
- "a secret-sharing mechanism\n");
+ printf("\t\tFlag - The private component of this key may have been split by a secret-sharing mechanism\n");
+ if (c & 0x20)
+ printf("\t\tFlag - This key may be used for authentication\n");
if (c & 0x80)
- printf("\t\tFlag - The private component of this key may be in the "
- "possession of more than one person\n");
- if ((c & ~0x60) == 0)
- printf("\t\tFlag - \n");
+ printf("\t\tFlag - The private component of this key may be in the possession of more than one person\n");
skip(len-1);
}
View
23 types.c
@@ -64,7 +64,7 @@ pub_algs(unsigned int type)
{
printf("\tPub alg - ");
if (type < PUB_ALGS_NUM)
- printf(PUB_ALGS[type]);
+ printf("%s", PUB_ALGS[type]);
else
printf("unknown(pub %d)", type);
printf("\n");
@@ -98,7 +98,7 @@ public void
sym_algs2(unsigned int type)
{
if (type < SYM_ALGS_NUM)
- printf(SYM_ALGS[type]);
+ printf("%s", SYM_ALGS[type]);
else
printf("unknown(sym %d)", type);
}
@@ -141,7 +141,7 @@ comp_algs(unsigned int type)
{
printf("\tComp alg - ");
if (type < COMP_ALGS_NUM)
- printf(COMP_ALGS[type]);
+ printf("%s", COMP_ALGS[type]);
else
printf("unknown(comp %d)", type);
printf("\n");
@@ -168,7 +168,7 @@ hash_algs(unsigned int type)
{
printf("\tHash alg - ");
if (type < HASH_ALGS_NUM)
- printf(HASH_ALGS[type]);
+ printf("%s", HASH_ALGS[type]);
else
printf("unknown(hash %d)", type);
printf("\n");
@@ -297,26 +297,27 @@ ver(int old, int new, int ver)
#define EXPBIAS 6
-public void
+public int
string_to_key(void)
{
+ int has_iv = YES;
int type = Getc();
switch (type) {
- case 0x00:
+ case 0:
printf("\tSimple string-to-key(s2k %d):\n", type);
printf("\t");
hash_algs(Getc());
break;
- case 0x01:
+ case 1:
printf("\tSalted string-to-key(s2k %d):\n", type);
printf("\t");
hash_algs(Getc());
printf("\t\tSalt - ");
dump(8);
printf("\n");
break;
- case 0x03:
+ case 3:
printf("\tIterated and salted string-to-key(s2k %d):\n", type);
printf("\t");
hash_algs(Getc());
@@ -329,9 +330,15 @@ string_to_key(void)
printf("\t\tCount - %d(coded count %d)\n", count, c);
}
break;
+ case 101:
+ printf("\tGnuPG string-to-key(s2k %d)\n", type);
+ has_iv = NO;
+ skip(5);
+ break;
default:
printf("\tUnknown string-to-key(s2k %d)\n", type);
}
+ return has_iv;
}
public void

0 comments on commit ff8db9a

Please sign in to comment.