Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* parse_subpacket() are split into parse_signature_subpacket() and

  parse_userattr_subpacket(). A bug of length calculation is fixed.
* The critical bit of the signature subpackets are supported.
        Peter Palfrader <peter>
  • Loading branch information...
commit 96e36c32f0852bafa2a9f005a78e3f028dc2a8ed 1 parent 82dafed
Kazu Yamamoto authored
7 CHANGES
View
@@ -1,5 +1,12 @@
Change Log
+0.22 2004/01/23
+
+* parse_subpacket() are split into parse_signature_subpacket() and
+ parse_userattr_subpacket(). A bug of length calculation is fixed.
+* The critical bit of the signature subpackets are supported.
+ Peter Palfrader <peter>
+
0.21 2004/01/13
* Removing compiler warnings.
84 packet.c
View
@@ -18,6 +18,9 @@ private int is_partial(int);
#define OLD_TAG_SHIFT 2
#define OLD_LEN_MASK 0x03
+#define CRITICAL_BIT 0x80
+#define CRITICAL_MASK 0x7f
+
private char *
TAG[] = {
"Reserved",
@@ -366,33 +369,57 @@ parse_packet(void)
}
public void
-parse_subpacket(char *prefix, int tlen, int type)
+parse_signature_subpacket(char *prefix, int tlen)
{
- int len, sub, slen;
- char **exptbl;
- funcptr *sw;
+ int len, subtype, critical;
- 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();
+ if (len < 192)
+ tlen--;
+ else if (len < 255) {
+ len = ((len - 192) << 8) + Getc() + 192;
+ tlen -= 2;
+ } else if (len == 255) {
+ len = Getc() << 24;
+ len |= Getc() << 16;
+ len |= Getc() << 8;
+ len |= Getc();
+ tlen -= 5;
+ }
+ tlen -= len;
+ subtype = Getc(); /* len includes this field byte */
+ len--;
+
+ /* Handle critical bit of subpacket type */
+ critical = NO;
+ if (subtype & CRITICAL_BIT) {
+ critical = YES;
+ subtype &= CRITICAL_MASK;
+ }
+
+ if (subtype < SIGSUB_NUM)
+ printf("\t%s: %s%s", prefix, SIGSUB[subtype], critical ? "(critical)" : "");
+ else
+ printf("\t%s: unknown(sub %d%s)", prefix, subtype, critical ? ", critical" : "");
+ printf("(%d bytes)\n", len);
+ if (subtype < SIGSUB_NUM && sigsub_func[subtype] != NULL)
+ (*sigsub_func[subtype])(len);
+ else
+ skip(len);
}
-
+}
+
+public void
+parse_userattr_subpacket(char *prefix, int tlen)
+{
+ int len, subtype;
+
while (tlen > 0) {
len = Getc();
if (len < 192)
- tlen --;
- else if (len < 223) {
+ tlen--;
+ else if (len < 255) {
len = ((len - 192) << 8) + Getc() + 192;
tlen -= 2;
} else if (len == 255) {
@@ -403,15 +430,16 @@ parse_subpacket(char *prefix, int tlen, int type)
tlen -= 5;
}
tlen -= len;
- sub = Getc(); /* len includes this field byte */
- len --;
- if (sub < slen)
- printf("\t%s: %s", prefix, exptbl[sub]);
+ subtype = Getc();
+ len--; /* len includes this field byte */
+
+ if (subtype < UATSUB_NUM)
+ printf("\t%s: %s", prefix, UATSUB[subtype]);
else
- printf("\t%s: unknown(sub %d)", prefix, sub);
+ printf("\t%s: unknown(sub %d)", prefix, subtype);
printf("(%d bytes)\n", len);
- if (sub < slen && sw[sub] != NULL)
- (*sw[sub])(len);
+ if (subtype < UATSUB_NUM && uatsub_func[subtype] != NULL)
+ (*uatsub_func[subtype])(len);
else
skip(len);
}
2  pgpdump.c
View
@@ -13,7 +13,7 @@ int mflag;
int pflag;
int uflag;
-private char *pgpdump_version = "0.21, Copyright (C) 1998-2004 Kazu Yamamoto";
+private char *pgpdump_version = "0.22, Copyright (C) 1998-2004 Kazu Yamamoto";
private char *prog;
private char *getprog(void);
3  pgpdump.h
View
@@ -66,7 +66,8 @@ public void Getc_resetlen(void);
*/
public void parse_packet(void);
-public void parse_subpacket(char *, int, int);
+public void parse_signature_subpacket(char *, int);
+public void parse_userattr_subpacket(char *, int);
/*
* types.c
4 signature.c
View
@@ -168,10 +168,10 @@ new_Signature_Packet(int len)
hash_algs(Getc());
hsplen = Getc() * 256;
hsplen += Getc();
- parse_subpacket("Hashed Sub", hsplen, 1);
+ parse_signature_subpacket("Hashed Sub", hsplen);
usplen = Getc() * 256;
usplen += Getc();
- parse_subpacket("Sub", usplen, 1);
+ parse_signature_subpacket("Sub", usplen);
hash2();
signature_multi_precision_integer(pub, len - 9 - hsplen - usplen);
}
2  tagfuncs.c
View
@@ -178,7 +178,7 @@ User_ID_Packet(int len)
public void
User_Attribute_Packet(int len)
{
- parse_subpacket("Sub", len, 2);
+ parse_userattr_subpacket("Sub", len);
}
public void
2  uatfunc.c
View
@@ -15,7 +15,7 @@ image_attribute(int len)
if (hver == 1) {
int enc = Getc();
printf("\t\tImage encoding - %s(enc %d)\n",
- enc==1 ? "JPEG" : "Unknown",
+ enc == 1 ? "JPEG" : "Unknown",
enc);
printf("\t\tImage data(%d bytes)\n", len - hlen);
skip(len - 4);
Please sign in to comment.
Something went wrong with that request. Please try again.