|
|
|
@ -125,16 +125,14 @@ pgp_key_free(pgp_key_t *keydata)
|
|
|
|
|
for (n = 0; n < keydata->uidc; ++n) {
|
|
|
|
|
pgp_userid_free(&keydata->uids[n]);
|
|
|
|
|
}
|
|
|
|
|
free(keydata->uids);
|
|
|
|
|
keydata->uids = NULL;
|
|
|
|
|
keydata->uidc = 0;
|
|
|
|
|
|
|
|
|
|
FREE_ARRAY(keydata, uid);
|
|
|
|
|
|
|
|
|
|
for (n = 0; n < keydata->packetc; ++n) {
|
|
|
|
|
pgp_subpacket_free(&keydata->packets[n]);
|
|
|
|
|
}
|
|
|
|
|
free(keydata->packets);
|
|
|
|
|
keydata->packets = NULL;
|
|
|
|
|
keydata->packetc = 0;
|
|
|
|
|
|
|
|
|
|
FREE_ARRAY(keydata, packet);
|
|
|
|
|
|
|
|
|
|
/* XXX subsigs revokes ? */
|
|
|
|
|
|
|
|
|
@ -169,8 +167,15 @@ pgp_keydata_dup(pgp_key_t *dst, pgp_key_t *src, unsigned make_public)
|
|
|
|
|
int res = 0;
|
|
|
|
|
unsigned pktcpyof = 0;
|
|
|
|
|
|
|
|
|
|
/* XXX quite hazardous copy */
|
|
|
|
|
memcpy(dst, src, sizeof(pgp_key_t));
|
|
|
|
|
|
|
|
|
|
/* reset DYNARRAYs */
|
|
|
|
|
INIT_ARRAY(dst, uid);
|
|
|
|
|
INIT_ARRAY(dst, packet);
|
|
|
|
|
INIT_ARRAY(dst, subsig);
|
|
|
|
|
INIT_ARRAY(dst, revoke);
|
|
|
|
|
|
|
|
|
|
if (src->type == PGP_PTAG_CT_PUBLIC_KEY) {
|
|
|
|
|
res = pgp_pubkey_dup(&dst->key.pubkey, &src->key.pubkey);
|
|
|
|
|
} else if (make_public && (
|
|
|
|
@ -1289,13 +1294,13 @@ pgp_add_to_pubring(pgp_keyring_t *keyring, const pgp_pubkey_t *pubkey, pgp_conte
|
|
|
|
|
case PGP_PTAG_CT_PUBLIC_KEY:
|
|
|
|
|
EXPAND_ARRAY(keyring, key);
|
|
|
|
|
key = &keyring->keys[keyring->keyc++];
|
|
|
|
|
duration = key->key.pubkey.duration;
|
|
|
|
|
/* WTF? duration = key->key.pubkey.duration; */
|
|
|
|
|
(void) memset(key, 0x0, sizeof(*key));
|
|
|
|
|
key->type = tag;
|
|
|
|
|
pgp_keyid(key->sigid, PGP_KEY_ID_SIZE, pubkey, keyring->hashtype);
|
|
|
|
|
pgp_fingerprint(&key->sigfingerprint, pubkey, keyring->hashtype);
|
|
|
|
|
key->key.pubkey = *pubkey;
|
|
|
|
|
key->key.pubkey.duration = duration;
|
|
|
|
|
/* WTF? key->key.pubkey.duration = duration; */
|
|
|
|
|
return 1;
|
|
|
|
|
case PGP_PTAG_CT_PUBLIC_SUBKEY:
|
|
|
|
|
/* subkey is not the first */
|
|
|
|
|