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 */;
};
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 */ = {
ignoreCount = 0;
lineNumber = 175;
location = duckdog;
- modificationTime = 342024710.159102;
+ modificationTime = 342028224.343937;
originalNumberOfMultipleMatches = 1;
state = 2;
};
fRef = 69269F2414620D0F00F69705 /* packet.h */;
name = "packet.h: 59";
rLen = 7;
- rLoc = 1307;
+ rLoc = 1663;
rType = 0;
vrLen = 1144;
vrLoc = 313;
fRef = 69269F2414620D0F00F69705 /* packet.h */;
name = "packet.h: 48";
rLen = 0;
- rLoc = 946;
+ rLoc = 1033;
rType = 0;
vrLen = 849;
vrLoc = 781;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 379";
rLen = 0;
- rLoc = 11582;
+ rLoc = 11752;
rType = 0;
vrLen = 1458;
vrLoc = 10100;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 382";
rLen = 0;
- rLoc = 12216;
+ rLoc = 12197;
rType = 0;
vrLen = 1447;
vrLoc = 10529;
fRef = 69269F2414620D0F00F69705 /* packet.h */;
name = "packet.h: 51";
rLen = 0;
- rLoc = 961;
+ rLoc = 1048;
rType = 0;
vrLen = 872;
vrLoc = 870;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 369";
rLen = 0;
- rLoc = 11344;
+ rLoc = 11345;
rType = 0;
vrLen = 1552;
vrLoc = 10245;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 390";
rLen = 0;
- rLoc = 11582;
+ rLoc = 11752;
rType = 0;
vrLen = 1554;
vrLoc = 10245;
fRef = 69269F2414620D0F00F69705 /* packet.h */;
name = "packet.h: 51";
rLen = 0;
- rLoc = 961;
+ rLoc = 1048;
rType = 0;
vrLen = 1003;
vrLoc = 162;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 376";
rLen = 0;
- rLoc = 11640;
+ rLoc = 11812;
rType = 0;
vrLen = 1419;
vrLoc = 10245;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 383";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1448;
vrLoc = 10536;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 389";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1430;
vrLoc = 10361;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 389";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1431;
vrLoc = 10361;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 389";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1431;
vrLoc = 10361;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 389";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1658;
vrLoc = 14213;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 389";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1658;
vrLoc = 14213;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 500";
rLen = 0;
- rLoc = 15909;
+ rLoc = 16147;
rType = 0;
vrLen = 1664;
vrLoc = 14213;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 500";
rLen = 0;
- rLoc = 15909;
+ rLoc = 16147;
rType = 0;
vrLen = 1664;
vrLoc = 14213;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 500";
rLen = 0;
- rLoc = 15909;
+ rLoc = 16147;
rType = 0;
vrLen = 1377;
vrLoc = 10784;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 377";
rLen = 0;
- rLoc = 11380;
+ rLoc = 11381;
rType = 0;
vrLen = 1425;
vrLoc = 10784;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 386";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1542;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 385";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1588;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 385";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1590;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 385";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1591;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 385";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1591;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 380";
rLen = 0;
- rLoc = 11657;
+ rLoc = 11829;
rType = 0;
vrLen = 1542;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 387";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1543;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 387";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1542;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 385";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1578;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 386";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1542;
vrLoc = 10812;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 379";
rLen = 0;
- rLoc = 11344;
+ rLoc = 11345;
rType = 0;
vrLen = 1398;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 390";
rLen = 0;
- rLoc = 11931;
+ rLoc = 12105;
rType = 0;
vrLen = 1408;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 387";
rLen = 0;
- rLoc = 11778;
+ rLoc = 11951;
rType = 0;
vrLen = 1395;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 387";
rLen = 0;
- rLoc = 11778;
+ rLoc = 11951;
rType = 0;
vrLen = 1400;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 388";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1398;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 388";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1412;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 388";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1412;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 388";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1442;
vrLoc = 10541;
fRef = 69269F2414620D0F00F69705 /* packet.h */;
name = "packet.h: 48";
rLen = 0;
- rLoc = 960;
+ rLoc = 1047;
rType = 0;
vrLen = 1047;
vrLoc = 204;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 388";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1442;
vrLoc = 10541;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 394";
rLen = 0;
- rLoc = 11889;
+ rLoc = 12064;
rType = 0;
vrLen = 1443;
vrLoc = 10541;
fRef = 69269F2414620D0F00F69705 /* packet.h */;
name = "packet.h: 48";
rLen = 0;
- rLoc = 960;
+ rLoc = 1047;
rType = 0;
vrLen = 985;
vrLoc = 264;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 408";
rLen = 0;
- rLoc = 12122;
+ rLoc = 12105;
rType = 0;
vrLen = 1545;
vrLoc = 11119;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 408";
rLen = 0;
- rLoc = 12207;
+ rLoc = 12188;
rType = 0;
vrLen = 1553;
vrLoc = 11119;
fRef = 69269F2314620D0F00F69705 /* packet.c */;
name = "packet.c: 520";
rLen = 0;
- rLoc = 15909;
+ rLoc = 16147;
rType = 0;
vrLen = 1557;
vrLoc = 14733;
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;
ignoreCount = 0;
lineNumber = 9;
location = duckdog;
- modificationTime = 342024710.1573;
+ modificationTime = 342028224.342515;
originalNumberOfMultipleMatches = 1;
state = 2;
};
hitCount = 0;
ignoreCount = 0;
lineNumber = 207;
- modificationTime = 342024710.158496;
+ modificationTime = 342028224.343386;
originalNumberOfMultipleMatches = 0;
state = 2;
};
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);
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;
}
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;
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;
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;