summary history branches tags files
commit:89fa31382e07f92775738b2cc03cda6b1cac3bce
author:mrmekon
committer:mrmekon
date:Thu Nov 3 17:43:52 2011 -0400
parents:7e8d38dc900a4cfce79fd6b97660059b60d4460d
About to add public structure, saving before hand.
diff --git a/simplepgp.xcodeproj/trevor.mode1v3 b/simplepgp.xcodeproj/trevor.mode1v3
line changes: +3/-3
index 827dfc8..de15309
--- a/simplepgp.xcodeproj/trevor.mode1v3
+++ b/simplepgp.xcodeproj/trevor.mode1v3
@@ -329,7 +329,7 @@
 										<key>_historyCapacity</key>
 										<integer>0</integer>
 										<key>bookmark</key>
-										<string>6926A0C71462E29800F69705</string>
+										<string>6926A0F01463428800F69705</string>
 										<key>history</key>
 										<array>
 											<string>69868BD11460F42D004C5D9B</string>
@@ -338,8 +338,8 @@
 											<string>69269F5214620FC500F69705</string>
 											<string>69269F5314620FC500F69705</string>
 											<string>69269FBE14623A5A00F69705</string>
-											<string>6926A0B01462E1BE00F69705</string>
-											<string>6926A0B11462E1BE00F69705</string>
+											<string>6926A0EE1463428800F69705</string>
+											<string>6926A0EF1463428800F69705</string>
 										</array>
 									</dict>
 									<key>SplitCount</key>

diff --git a/simplepgp.xcodeproj/trevor.pbxuser b/simplepgp.xcodeproj/trevor.pbxuser
line changes: +142/-54
index 4ec7c8e..a19b6ea
--- a/simplepgp.xcodeproj/trevor.pbxuser
+++ b/simplepgp.xcodeproj/trevor.pbxuser
@@ -296,6 +296,14 @@
 			6926A0BB1462E1D900F69705 /* PBXTextBookmark */ = 6926A0BB1462E1D900F69705 /* PBXTextBookmark */;
 			6926A0C21462E20500F69705 /* PBXTextBookmark */ = 6926A0C21462E20500F69705 /* PBXTextBookmark */;
 			6926A0C71462E29800F69705 /* PBXTextBookmark */ = 6926A0C71462E29800F69705 /* PBXTextBookmark */;
+			6926A0CD1462EF4000F69705 /* PBXTextBookmark */ = 6926A0CD1462EF4000F69705 /* PBXTextBookmark */;
+			6926A0DC1462EFBF00F69705 /* PBXTextBookmark */ = 6926A0DC1462EFBF00F69705 /* PBXTextBookmark */;
+			6926A0DF146340CA00F69705 /* PBXTextBookmark */ = 6926A0DF146340CA00F69705 /* PBXTextBookmark */;
+			6926A0E0146340CA00F69705 /* PBXTextBookmark */ = 6926A0E0146340CA00F69705 /* PBXTextBookmark */;
+			6926A0E1146340CA00F69705 /* PBXTextBookmark */ = 6926A0E1146340CA00F69705 /* PBXTextBookmark */;
+			6926A0EE1463428800F69705 /* PBXTextBookmark */ = 6926A0EE1463428800F69705 /* PBXTextBookmark */;
+			6926A0EF1463428800F69705 /* PBXTextBookmark */ = 6926A0EF1463428800F69705 /* PBXTextBookmark */;
+			6926A0F01463428800F69705 /* PBXTextBookmark */ = 6926A0F01463428800F69705 /* PBXTextBookmark */;
 			69868BD11460F42D004C5D9B = 69868BD11460F42D004C5D9B /* PBXTextBookmark */;
 			69868BD91460F468004C5D9B = 69868BD91460F468004C5D9B /* PBXTextBookmark */;
 			69868C931460F7C3004C5D9B = 69868C931460F7C3004C5D9B /* PBXTextBookmark */;
@@ -2036,16 +2044,16 @@
 	};
 	69269F2314620D0F00F69705 /* packet.c */ = {
 		uiCtxt = {
-			sepNavIntBoundsRect = "{{0, 0}, {826, 8879}}";
-			sepNavSelRange = "{15034, 0}";
-			sepNavVisRange = "{14619, 1552}";
+			sepNavIntBoundsRect = "{{0, 0}, {826, 8840}}";
+			sepNavSelRange = "{12828, 0}";
+			sepNavVisRange = "{12198, 1453}";
 		};
 	};
 	69269F2414620D0F00F69705 /* packet.h */ = {
 		uiCtxt = {
-			sepNavIntBoundsRect = "{{0, 0}, {826, 1820}}";
-			sepNavSelRange = "{960, 0}";
-			sepNavVisRange = "{264, 985}";
+			sepNavIntBoundsRect = "{{0, 0}, {826, 1989}}";
+			sepNavSelRange = "{855, 0}";
+			sepNavVisRange = "{865, 740}";
 		};
 	};
 	69269F4E14620FC200F69705 /* packet.c:175 */ = {
@@ -2062,7 +2070,7 @@
 		ignoreCount = 0;
 		lineNumber = 175;
 		location = duckdog;
-		modificationTime = 342024710.159102;
+		modificationTime = 342028224.343937;
 		originalNumberOfMultipleMatches = 1;
 		state = 2;
 	};
@@ -2151,7 +2159,7 @@
 		fRef = 69269F2414620D0F00F69705 /* packet.h */;
 		name = "packet.h: 59";
 		rLen = 7;
-		rLoc = 1307;
+		rLoc = 1663;
 		rType = 0;
 		vrLen = 1144;
 		vrLoc = 313;
@@ -2221,7 +2229,7 @@
 		fRef = 69269F2414620D0F00F69705 /* packet.h */;
 		name = "packet.h: 48";
 		rLen = 0;
-		rLoc = 946;
+		rLoc = 1033;
 		rType = 0;
 		vrLen = 849;
 		vrLoc = 781;
@@ -2231,7 +2239,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 379";
 		rLen = 0;
-		rLoc = 11582;
+		rLoc = 11752;
 		rType = 0;
 		vrLen = 1458;
 		vrLoc = 10100;
@@ -2241,7 +2249,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 382";
 		rLen = 0;
-		rLoc = 12216;
+		rLoc = 12197;
 		rType = 0;
 		vrLen = 1447;
 		vrLoc = 10529;
@@ -2251,7 +2259,7 @@
 		fRef = 69269F2414620D0F00F69705 /* packet.h */;
 		name = "packet.h: 51";
 		rLen = 0;
-		rLoc = 961;
+		rLoc = 1048;
 		rType = 0;
 		vrLen = 872;
 		vrLoc = 870;
@@ -2271,7 +2279,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 369";
 		rLen = 0;
-		rLoc = 11344;
+		rLoc = 11345;
 		rType = 0;
 		vrLen = 1552;
 		vrLoc = 10245;
@@ -2281,7 +2289,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 390";
 		rLen = 0;
-		rLoc = 11582;
+		rLoc = 11752;
 		rType = 0;
 		vrLen = 1554;
 		vrLoc = 10245;
@@ -2291,7 +2299,7 @@
 		fRef = 69269F2414620D0F00F69705 /* packet.h */;
 		name = "packet.h: 51";
 		rLen = 0;
-		rLoc = 961;
+		rLoc = 1048;
 		rType = 0;
 		vrLen = 1003;
 		vrLoc = 162;
@@ -2301,7 +2309,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 376";
 		rLen = 0;
-		rLoc = 11640;
+		rLoc = 11812;
 		rType = 0;
 		vrLen = 1419;
 		vrLoc = 10245;
@@ -2311,7 +2319,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 383";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1448;
 		vrLoc = 10536;
@@ -2331,7 +2339,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 389";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1430;
 		vrLoc = 10361;
@@ -2341,7 +2349,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 389";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1431;
 		vrLoc = 10361;
@@ -2351,7 +2359,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 389";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1431;
 		vrLoc = 10361;
@@ -2361,7 +2369,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 389";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1658;
 		vrLoc = 14213;
@@ -2371,7 +2379,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 389";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1658;
 		vrLoc = 14213;
@@ -2381,7 +2389,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 500";
 		rLen = 0;
-		rLoc = 15909;
+		rLoc = 16147;
 		rType = 0;
 		vrLen = 1664;
 		vrLoc = 14213;
@@ -2391,7 +2399,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 500";
 		rLen = 0;
-		rLoc = 15909;
+		rLoc = 16147;
 		rType = 0;
 		vrLen = 1664;
 		vrLoc = 14213;
@@ -2401,7 +2409,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 500";
 		rLen = 0;
-		rLoc = 15909;
+		rLoc = 16147;
 		rType = 0;
 		vrLen = 1377;
 		vrLoc = 10784;
@@ -2411,7 +2419,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 377";
 		rLen = 0;
-		rLoc = 11380;
+		rLoc = 11381;
 		rType = 0;
 		vrLen = 1425;
 		vrLoc = 10784;
@@ -2431,7 +2439,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 386";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1542;
 		vrLoc = 10812;
@@ -2441,7 +2449,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 385";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1588;
 		vrLoc = 10812;
@@ -2451,7 +2459,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 385";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1590;
 		vrLoc = 10812;
@@ -2461,7 +2469,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 385";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1591;
 		vrLoc = 10812;
@@ -2471,7 +2479,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 385";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1591;
 		vrLoc = 10812;
@@ -2481,7 +2489,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 380";
 		rLen = 0;
-		rLoc = 11657;
+		rLoc = 11829;
 		rType = 0;
 		vrLen = 1542;
 		vrLoc = 10812;
@@ -2491,7 +2499,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 387";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1543;
 		vrLoc = 10812;
@@ -2501,7 +2509,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 387";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1542;
 		vrLoc = 10812;
@@ -2511,7 +2519,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 385";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1578;
 		vrLoc = 10812;
@@ -2521,7 +2529,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 386";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1542;
 		vrLoc = 10812;
@@ -2541,7 +2549,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 379";
 		rLen = 0;
-		rLoc = 11344;
+		rLoc = 11345;
 		rType = 0;
 		vrLen = 1398;
 		vrLoc = 10541;
@@ -2551,7 +2559,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 390";
 		rLen = 0;
-		rLoc = 11931;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1408;
 		vrLoc = 10541;
@@ -2561,7 +2569,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 387";
 		rLen = 0;
-		rLoc = 11778;
+		rLoc = 11951;
 		rType = 0;
 		vrLen = 1395;
 		vrLoc = 10541;
@@ -2571,7 +2579,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 387";
 		rLen = 0;
-		rLoc = 11778;
+		rLoc = 11951;
 		rType = 0;
 		vrLen = 1400;
 		vrLoc = 10541;
@@ -2581,7 +2589,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 388";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1398;
 		vrLoc = 10541;
@@ -2591,7 +2599,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 388";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1412;
 		vrLoc = 10541;
@@ -2601,7 +2609,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 388";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1412;
 		vrLoc = 10541;
@@ -2611,7 +2619,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 388";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1442;
 		vrLoc = 10541;
@@ -2621,7 +2629,7 @@
 		fRef = 69269F2414620D0F00F69705 /* packet.h */;
 		name = "packet.h: 48";
 		rLen = 0;
-		rLoc = 960;
+		rLoc = 1047;
 		rType = 0;
 		vrLen = 1047;
 		vrLoc = 204;
@@ -2631,7 +2639,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 388";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1442;
 		vrLoc = 10541;
@@ -2641,7 +2649,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 394";
 		rLen = 0;
-		rLoc = 11889;
+		rLoc = 12064;
 		rType = 0;
 		vrLen = 1443;
 		vrLoc = 10541;
@@ -2651,7 +2659,7 @@
 		fRef = 69269F2414620D0F00F69705 /* packet.h */;
 		name = "packet.h: 48";
 		rLen = 0;
-		rLoc = 960;
+		rLoc = 1047;
 		rType = 0;
 		vrLen = 985;
 		vrLoc = 264;
@@ -2671,7 +2679,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 408";
 		rLen = 0;
-		rLoc = 12122;
+		rLoc = 12105;
 		rType = 0;
 		vrLen = 1545;
 		vrLoc = 11119;
@@ -2681,7 +2689,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 408";
 		rLen = 0;
-		rLoc = 12207;
+		rLoc = 12188;
 		rType = 0;
 		vrLen = 1553;
 		vrLoc = 11119;
@@ -2691,7 +2699,7 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 520";
 		rLen = 0;
-		rLoc = 15909;
+		rLoc = 16147;
 		rType = 0;
 		vrLen = 1557;
 		vrLoc = 14733;
@@ -2701,11 +2709,91 @@
 		fRef = 69269F2314620D0F00F69705 /* packet.c */;
 		name = "packet.c: 498";
 		rLen = 0;
-		rLoc = 15034;
+		rLoc = 15376;
 		rType = 0;
 		vrLen = 1552;
 		vrLoc = 14619;
 	};
+	6926A0CD1462EF4000F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2314620D0F00F69705 /* packet.c */;
+		name = "packet.c: 402";
+		rLen = 0;
+		rLoc = 11884;
+		rType = 0;
+		vrLen = 1394;
+		vrLoc = 11116;
+	};
+	6926A0DC1462EFBF00F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2314620D0F00F69705 /* packet.c */;
+		name = "packet.c: 421";
+		rLen = 0;
+		rLoc = 12560;
+		rType = 0;
+		vrLen = 1533;
+		vrLoc = 11555;
+	};
+	6926A0DF146340CA00F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2314620D0F00F69705 /* packet.c */;
+		name = "packet.c: 421";
+		rLen = 0;
+		rLoc = 12560;
+		rType = 0;
+		vrLen = 1481;
+		vrLoc = 11607;
+	};
+	6926A0E0146340CA00F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2414620D0F00F69705 /* packet.h */;
+		name = "packet.h: 68";
+		rLen = 0;
+		rLoc = 1717;
+		rType = 0;
+		vrLen = 787;
+		vrLoc = 785;
+	};
+	6926A0E1146340CA00F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2414620D0F00F69705 /* packet.h */;
+		name = "packet.h: 19";
+		rLen = 0;
+		rLoc = 415;
+		rType = 0;
+		vrLen = 934;
+		vrLoc = 36;
+	};
+	6926A0EE1463428800F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2414620D0F00F69705 /* packet.h */;
+		name = "packet.h: 37";
+		rLen = 0;
+		rLoc = 855;
+		rType = 0;
+		vrLen = 740;
+		vrLoc = 865;
+	};
+	6926A0EF1463428800F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2314620D0F00F69705 /* packet.c */;
+		name = "packet.c: 421";
+		rLen = 0;
+		rLoc = 12560;
+		rType = 0;
+		vrLen = 1449;
+		vrLoc = 11882;
+	};
+	6926A0F01463428800F69705 /* PBXTextBookmark */ = {
+		isa = PBXTextBookmark;
+		fRef = 69269F2314620D0F00F69705 /* packet.c */;
+		name = "packet.c: 431";
+		rLen = 0;
+		rLoc = 12828;
+		rType = 0;
+		vrLen = 1453;
+		vrLoc = 12198;
+	};
 	69868AD41460E35F004C5D9B /* Source Control */ = {
 		isa = PBXSourceControlManager;
 		fallbackIsa = XCSourceControlManager;
@@ -2811,7 +2899,7 @@
 		ignoreCount = 0;
 		lineNumber = 9;
 		location = duckdog;
-		modificationTime = 342024710.1573;
+		modificationTime = 342028224.342515;
 		originalNumberOfMultipleMatches = 1;
 		state = 2;
 	};
@@ -2889,7 +2977,7 @@
 		hitCount = 0;
 		ignoreCount = 0;
 		lineNumber = 207;
-		modificationTime = 342024710.158496;
+		modificationTime = 342028224.343386;
 		originalNumberOfMultipleMatches = 0;
 		state = 2;
 	};

diff --git a/src/packet.c b/src/packet.c
line changes: +53/-47
index 764d9ba..186d67a
--- a/src/packet.c
+++ b/src/packet.c
@@ -384,26 +384,26 @@ static uint8_t spgp_parse_header(uint8_t *msg, uint32_t *idx,
 
 static uint8_t spgp_parse_user_id(uint8_t *msg, uint32_t *idx, 
           												uint32_t length, spgp_packet_t *pkt) {
-	spgp_userid_pkt_t userid;
+	spgp_userid_pkt_t *userid;
 
   LOG_PRINT("Parsing user id.\n");
 
 	// Make sure we have enough bytes remaining for the copy
   if (length - *idx < pkt->header->contentLength) RAISE(BUFFER_OVERFLOW);
   
+  // Allocate userid field in packet
+  pkt->c.userid = malloc(sizeof(*(pkt->c.userid)));
+  if (NULL == pkt->c.userid) RAISE(OUT_OF_MEMORY);
+  userid = pkt->c.userid;
+  
   // Allocate space for buffer, plus one byte for NUL terminator
-	userid.data = malloc(sizeof(*(userid.data))*pkt->header->contentLength + 1);
-  if (NULL == userid.data) RAISE(OUT_OF_MEMORY);
+	userid->data = malloc(sizeof(*(userid->data))*pkt->header->contentLength + 1);
+  if (NULL == userid->data) RAISE(OUT_OF_MEMORY);
   
   // Copy bytes from input to structure, and add a NUL terminator
-  memcpy(userid.data, msg+*idx, pkt->header->contentLength);
-  userid.data[pkt->header->contentLength] = '\0';
+  memcpy(userid->data, msg+*idx, pkt->header->contentLength);
+  userid->data[pkt->header->contentLength] = '\0';
   *idx += pkt->header->contentLength - 1;
-  
-  // Copy local structure into packet
-  pkt->c.userid = malloc(sizeof(*(pkt->c.userid)));
-  if (NULL == pkt->c.userid) RAISE(OUT_OF_MEMORY);
-  memcpy(pkt->c.userid, &userid, sizeof(userid));
 
   setlocale(LC_CTYPE, "en_US.UTF-8");
   wprintf(L"USER ID: %s\n", pkt->c.userid->data);
@@ -413,112 +413,118 @@ static uint8_t spgp_parse_user_id(uint8_t *msg, uint32_t *idx,
 
 static uint8_t spgp_parse_secret_key(uint8_t *msg, uint32_t *idx, 
           													 uint32_t length, spgp_packet_t *pkt) {
-  spgp_secret_pkt_t secret;
+  spgp_secret_pkt_t *secret;
+  spgp_public_pkt_t *pub;
   uint32_t startIdx = *idx;
   
   LOG_PRINT("Parsing secret key.\n");
+
+	// Make sure we have enough bytes remaining for parsing
+  if (length - *idx < pkt->header->contentLength) RAISE(BUFFER_OVERFLOW);
+
+	// Allocate secret key in packet  
+  pkt->c.secret = malloc(sizeof(*(pkt->c.secret)));
+  if (NULL == pkt->c.secret) RAISE(OUT_OF_MEMORY);
+	secret = pkt->c.secret;
+  pub = pkt->c.pub;
   
-  secret.version = msg[*idx]; 
+  pub->version = msg[*idx]; 
   SAFE_IDX_INCREMENT(*idx, length);
   
   // First byte is the version.
-  if (secret.version != 4) RAISE(FORMAT_UNSUPPORTED);
+  if (secret->version != 4) RAISE(FORMAT_UNSUPPORTED);
   
   // Next 4 bytes are big-endian 'key creation time'
   if (length - *idx < 4) RAISE(BUFFER_OVERFLOW);
-  memcpy(&(secret.creationTime), msg+*idx, 4);
+  memcpy(&(secret->creationTime), msg+*idx, 4);
   *idx += 3; // this puts us on last byte of creation time
   SAFE_IDX_INCREMENT(*idx, length); // this goes to next byte (safely)
 
 	// Next byte identifies asymmetric algorithm
-	secret.asymAlgo = msg[*idx];
+	secret->asymAlgo = msg[*idx];
 	SAFE_IDX_INCREMENT(*idx, length);
-  LOG_PRINT("Asymmetric algorithm: %d\n", secret.asymAlgo);
+  LOG_PRINT("Asymmetric algorithm: %d\n", secret->asymAlgo);
   
   // Read variable number of MPIs (depends on asymmetric algorithm), each
   // of which are variable size.
-	spgp_read_all_public_mpis(msg, idx, length, &secret);
-  LOG_PRINT("Read %u MPIs\n", secret.mpiCount);
+	spgp_read_all_public_mpis(msg, idx, length, secret);
+  LOG_PRINT("Read %u MPIs\n", secret->mpiCount);
   
   // S2K Type byte tells how to (or if to) decrypt secret exponent
-  secret.s2kType = msg[*idx];
+  secret->s2kType = msg[*idx];
   SAFE_IDX_INCREMENT(*idx, length);
-  switch (secret.s2kType) {
+  switch (secret->s2kType) {
   	case 0:
     	// There is no encryption
-    	secret.s2kEncryption = 0;
+    	secret->s2kEncryption = 0;
       break;
     case 254:
     case 255:
     	// Next byte is encryption type
-		  secret.s2kEncryption = msg[*idx];
+		  secret->s2kEncryption = msg[*idx];
   		SAFE_IDX_INCREMENT(*idx, length);
 			break;
     default:
     	// This byte is encryption type
-    	secret.s2kEncryption = secret.s2kType;
+    	secret->s2kEncryption = secret->s2kType;
     	break;
   }
-  LOG_PRINT("Encryption: %u\n", secret.s2kEncryption);
+  LOG_PRINT("Encryption: %u\n", secret->s2kEncryption);
   
-  if (secret.s2kEncryption) {
+  if (secret->s2kEncryption) {
   	// Secret exponent is encrypted (as it should be).  Time to decrypt.
     
     // S2K specifier tells us if there is a salt, and how to use it
-    if (secret.s2kType >= 254) {
-			secret.s2kSpecifier = msg[*idx];
+    if (secret->s2kType >= 254) {
+			secret->s2kSpecifier = msg[*idx];
   	  SAFE_IDX_INCREMENT(*idx, length);
-   	 LOG_PRINT("S2K Specifier: %u\n", secret.s2kSpecifier);
+   	 LOG_PRINT("S2K Specifier: %u\n", secret->s2kSpecifier);
     }
     
     // S2K hash algorithm specifies how to hash passphrase into a key
-    secret.s2kHashAlgo = msg[*idx];
+    secret->s2kHashAlgo = msg[*idx];
     SAFE_IDX_INCREMENT(*idx, length);
-    LOG_PRINT("Hash algorithm: %u\n", secret.s2kHashAlgo);    
+    LOG_PRINT("Hash algorithm: %u\n", secret->s2kHashAlgo);    
     
     // Read the salt if there is one
-    switch (secret.s2kSpecifier) {
+    switch (secret->s2kSpecifier) {
     	case 1:
-      	spgp_read_salt(msg, idx, length, &secret);
+      	spgp_read_salt(msg, idx, length, secret);
       	break;
       case 3:
-      	spgp_read_salt(msg, idx, length, &secret);
+      	spgp_read_salt(msg, idx, length, secret);
         // S2K Count is number of bytes to hash to make the key
-				secret.s2kCount = msg[*idx];
+				secret->s2kCount = msg[*idx];
     		SAFE_IDX_INCREMENT(*idx, length);
         break;
       default:
       	break;
     }
   }
-  LOG_PRINT("Salt length: %u\n", secret.s2kSaltLength);
+  LOG_PRINT("Salt length: %u\n", secret->s2kSaltLength);
   
   // If it's not encrypted, we can just read the secret MPIs
-  if (!secret.s2kEncryption) {
-  	spgp_read_all_secret_mpis(msg, idx, length, &secret);
+  if (!secret->s2kEncryption) {
+  	spgp_read_all_secret_mpis(msg, idx, length, secret);
   }
   // If it is encrypted, just store it for now.  We'll decrypt later.
   else {
   
   	// There's an initial vector (IV) here:
-  	spgp_read_iv(msg, idx, length, &secret);
-    LOG_PRINT("IV length: %u\n", secret.ivLength);
+  	spgp_read_iv(msg, idx, length, secret);
+    LOG_PRINT("IV length: %u\n", secret->ivLength);
   
   	uint32_t packetOffset = *idx - startIdx;
   	uint32_t remaining = pkt->header->contentLength - packetOffset;
 		if (packetOffset >= pkt->header->contentLength) RAISE(BUFFER_OVERFLOW);
-  	secret.encryptedData = malloc(remaining);
-    if (NULL == secret.encryptedData) RAISE(OUT_OF_MEMORY);
-    memcpy(secret.encryptedData, msg+*idx, remaining);
+  	secret->encryptedData = malloc(remaining);
+    if (NULL == secret->encryptedData) RAISE(OUT_OF_MEMORY);
+    memcpy(secret->encryptedData, msg+*idx, remaining);
     *idx += remaining-1;
     LOG_PRINT("Stored %u encrypted bytes.\n", remaining);
     // This is the end of the data, so we do NOT do a final idx increment
   }
-  
-  pkt->c.secret = malloc(sizeof(*(pkt->c.secret)));
-  if (NULL == pkt->c.secret) RAISE(OUT_OF_MEMORY);
-  memcpy(pkt->c.secret, &secret, sizeof(secret));
-  
+    
 	return 0;
 }
 

diff --git a/src/packet.h b/src/packet.h
line changes: +17/-0
index 52eafae..6aa7a19
--- a/src/packet.h
+++ b/src/packet.h
@@ -16,6 +16,7 @@
 typedef struct spgp_packet_header_struct spgp_pkt_header_t;
 typedef struct spgp_packet_struct spgp_packet_t;
 typedef struct spgp_mpi_struct spgp_mpi_t;
+typedef struct spgp_public_packet_struct spgp_public_pkt_t;
 typedef struct spgp_secret_packet_struct spgp_secret_pkt_t;
 typedef struct spgp_userid_packet_struct spgp_userid_pkt_t;
 
@@ -31,6 +32,7 @@ struct spgp_packet_header_struct {
 struct spgp_packet_struct {
 	spgp_pkt_header_t *header;
   union {
+  	spgp_public_pkt_t *pub;
   	spgp_secret_pkt_t *secret;
     spgp_userid_pkt_t *userid;
   } c;
@@ -48,14 +50,29 @@ struct spgp_userid_packet_struct {
 	uint8_t *data;
 };
 
+struct spgp_public_packet_struct {
+// This is public key stuff
+	uint8_t version;
+  uint32_t creationTime;
+	uint8_t asymAlgo;
+  uint8_t symAlgo;
+  spgp_mpi_t *mpiHead;
+  uint8_t mpiCount;
+  uint8_t *fingerprint;
+};
+
 struct spgp_secret_packet_struct {
 // This is public key stuff
+/*
 	uint8_t version;
   uint32_t creationTime;
 	uint8_t asymAlgo;
   uint8_t symAlgo;
   spgp_mpi_t *mpiHead;
   uint8_t mpiCount;
+  uint8_t *fingerprint;
+*/
+	spgp_public_pkt_t pub;
 // This is secret key stuff  
 	uint8_t isDecrypted;
   uint8_t s2kType;