Browse Source

Various small changes, paving the way for more picky key importing.

Changed:
 pgp_subsig_t.pgp_sig_t -> pgp_uidsig_t.pgp_sig_info_t
 copy_sig_info : also duplicate sig's BNs
 pgp_validate_key_cb :
    - accepts NULL validate_key_cb_t,  in case result's
      siglists are discarded (i.e. for filtering).
    - relase packet eventualy copied by on_valid.

Renamed:
 pgp_key_t.subsigs -> pgp_key_t.uidsigs
 pgp_subsig_t -> pgp_uidsig_t
master
Edouard Tisserant 7 years ago
parent
commit
2d26a1791e
7 changed files with 155 additions and 106 deletions
  1. +19
    -21
      dist/src/lib/keyring.c
  2. +90
    -25
      dist/src/lib/packet-parse.c
  3. +3
    -0
      dist/src/lib/packet-parse.h
  4. +30
    -30
      dist/src/lib/packet-print.c
  5. +6
    -12
      dist/src/lib/packet.h
  6. +6
    -18
      dist/src/lib/validate.c
  7. +1
    -0
      dist/src/lib/validate.h

+ 19
- 21
dist/src/lib/keyring.c View File

@ -134,7 +134,7 @@ pgp_key_free(pgp_key_t *keydata)
FREE_ARRAY(keydata, packet);
/* XXX subsigs revokes ? */
/* XXX uidsigs revokes ? */
if (keydata->type == PGP_PTAG_CT_PUBLIC_KEY) {
pgp_pubkey_free(&keydata->key.pubkey);
@ -176,7 +176,7 @@ pgp_keydata_dup(pgp_key_t *dst, pgp_key_t *src, unsigned make_public)
/* reset DYNARRAYs */
INIT_ARRAY(dst, uid);
INIT_ARRAY(dst, packet);
INIT_ARRAY(dst, subsig);
INIT_ARRAY(dst, uidsig);
INIT_ARRAY(dst, revoke);
if (src->type == PGP_PTAG_CT_PUBLIC_KEY) {
@ -216,7 +216,7 @@ pgp_keydata_dup(pgp_key_t *dst, pgp_key_t *src, unsigned make_public)
res = (pgp_add_userid(dst,src->uids[n]) != NULL);
}
/* TODO subsigs revokes ? */
/* TODO uidsigs revokes ? */
return res;
}
@ -678,24 +678,22 @@ cb_keyring_read(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
break;
case PGP_PTAG_CT_SIGNATURE_HEADER:
key = &keyring->keys[keyring->keyc - 1];
EXPAND_ARRAY(key, subsig);
key->subsigs[key->subsigc].uid = key->uidc - 1;
(void) memcpy(&key->subsigs[key->subsigc].sig, &pkt->u.sig,
sizeof(pkt->u.sig));
key->subsigc += 1;
EXPAND_ARRAY(key, uidsig);
key->uidsigs[key->uidsigc].uid = key->uidc - 1;
copy_sig_info(&key->uidsigs[key->uidsigc].siginfo, &pkt->u.sig.info);
key->uidsigc += 1;
break;
case PGP_PTAG_CT_SIGNATURE:
key = &keyring->keys[keyring->keyc - 1];
EXPAND_ARRAY(key, subsig);
key->subsigs[key->subsigc].uid = key->uidc - 1;
(void) memcpy(&key->subsigs[key->subsigc].sig, &pkt->u.sig,
sizeof(pkt->u.sig));
key->subsigc += 1;
EXPAND_ARRAY(key, uidsig);
key->uidsigs[key->uidsigc].uid = key->uidc - 1;
copy_sig_info(&key->uidsigs[key->uidsigc].siginfo, &pkt->u.sig.info);
key->uidsigc += 1;
break;
case PGP_PTAG_CT_TRUST:
key = &keyring->keys[keyring->keyc - 1];
key->subsigs[key->subsigc - 1].trustlevel = pkt->u.ss_trust.level;
key->subsigs[key->subsigc - 1].trustamount = pkt->u.ss_trust.amount;
key->uidsigs[key->uidsigc - 1].trustlevel = pkt->u.ss_trust.level;
key->uidsigs[key->uidsigc - 1].trustamount = pkt->u.ss_trust.amount;
break;
case PGP_PTAG_SS_KEY_EXPIRY:
EXPAND_ARRAY(keyring, key);
@ -705,20 +703,20 @@ cb_keyring_read(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
break;
case PGP_PTAG_SS_ISSUER_KEY_ID:
key = &keyring->keys[keyring->keyc - 1];
(void) memcpy(&key->subsigs[key->subsigc - 1].sig.info.signer_id,
(void) memcpy(&key->uidsigs[key->uidsigc - 1].siginfo.signer_id,
pkt->u.ss_issuer,
sizeof(pkt->u.ss_issuer));
key->subsigs[key->subsigc - 1].sig.info.signer_id_set = 1;
key->uidsigs[key->uidsigc - 1].siginfo.signer_id_set = 1;
break;
case PGP_PTAG_SS_CREATION_TIME:
key = &keyring->keys[keyring->keyc - 1];
key->subsigs[key->subsigc - 1].sig.info.birthtime = pkt->u.ss_time;
key->subsigs[key->subsigc - 1].sig.info.birthtime_set = 1;
key->uidsigs[key->uidsigc - 1].siginfo.birthtime = pkt->u.ss_time;
key->uidsigs[key->uidsigc - 1].siginfo.birthtime_set = 1;
break;
case PGP_PTAG_SS_EXPIRATION_TIME:
key = &keyring->keys[keyring->keyc - 1];
key->subsigs[key->subsigc - 1].sig.info.duration = pkt->u.ss_time;
key->subsigs[key->subsigc - 1].sig.info.duration_set = 1;
key->uidsigs[key->uidsigc - 1].siginfo.duration = pkt->u.ss_time;
key->uidsigs[key->uidsigc - 1].siginfo.duration_set = 1;
break;
case PGP_PTAG_SS_PRIMARY_USER_ID:
key = &keyring->keys[keyring->keyc - 1];


+ 90
- 25
dist/src/lib/packet-parse.c View File

@ -845,6 +845,14 @@ pgp_data_free(pgp_data_t *data)
data->len = 0;
}
void
pgp_data_dup(pgp_data_t *dst, const pgp_data_t *src)
{
dst->contents = calloc(1, src->len);
memcpy(dst->contents, src->contents, src->len);
dst->len = src->len;
}
/**
\ingroup Core_Create
\brief Free allocated memory
@ -921,9 +929,55 @@ free_BN(BIGNUM **pp)
}
static void
dup_BN(BIGNUM **dst, BIGNUM **src)
dup_BN(BIGNUM *dst, const BIGNUM *src)
{
dst = BN_dup(src);
}
void
copy_sig_info(pgp_sig_info_t *dst, const pgp_sig_info_t *src)
{
*dst = BN_dup(*src);
(void) memcpy(dst, src, sizeof(*src));
if ((dst->v4_hashed = calloc(1, src->v4_hashlen)) == NULL) {
(void) fprintf(stderr, "copy_sig_info: bad alloc\n");
} else {
(void) memcpy(dst->v4_hashed, src->v4_hashed, src->v4_hashlen);
}
switch (src->key_alg) {
case PGP_PKA_RSA:
case PGP_PKA_RSA_SIGN_ONLY:
dup_BN(dst->sig.rsa.sig, src->sig.rsa.sig);
break;
case PGP_PKA_DSA:
dup_BN(dst->sig.dsa.r, src->sig.dsa.r);
dup_BN(dst->sig.dsa.s, src->sig.dsa.s);
break;
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN:
dup_BN(dst->sig.elgamal.r, src->sig.elgamal.r);
dup_BN(dst->sig.elgamal.s, src->sig.elgamal.s);
break;
case PGP_PKA_PRIVATE00:
case PGP_PKA_PRIVATE01:
case PGP_PKA_PRIVATE02:
case PGP_PKA_PRIVATE03:
case PGP_PKA_PRIVATE04:
case PGP_PKA_PRIVATE05:
case PGP_PKA_PRIVATE06:
case PGP_PKA_PRIVATE07:
case PGP_PKA_PRIVATE08:
case PGP_PKA_PRIVATE09:
case PGP_PKA_PRIVATE10:
pgp_data_dup(&dst->sig.unknown, &src->sig.unknown);
break;
default:
(void) fprintf(stderr, "sig_dup: bad sig type\n");
}
}
/**
* \ingroup Core_Create
@ -931,22 +985,24 @@ dup_BN(BIGNUM **dst, BIGNUM **src)
* \param sig
*/
static void
sig_free(pgp_sig_t *sig)
sig_info_free(pgp_sig_info_t *info)
{
switch (sig->info.key_alg) {
free(info->v4_hashed);
switch (info->key_alg) {
case PGP_PKA_RSA:
case PGP_PKA_RSA_SIGN_ONLY:
free_BN(&sig->info.sig.rsa.sig);
free_BN(&info->sig.rsa.sig);
break;
case PGP_PKA_DSA:
free_BN(&sig->info.sig.dsa.r);
free_BN(&sig->info.sig.dsa.s);
free_BN(&info->sig.dsa.r);
free_BN(&info->sig.dsa.s);
break;
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN:
free_BN(&sig->info.sig.elgamal.r);
free_BN(&sig->info.sig.elgamal.s);
free_BN(&info->sig.elgamal.r);
free_BN(&info->sig.elgamal.s);
break;
case PGP_PKA_PRIVATE00:
@ -960,14 +1016,21 @@ sig_free(pgp_sig_t *sig)
case PGP_PKA_PRIVATE08:
case PGP_PKA_PRIVATE09:
case PGP_PKA_PRIVATE10:
pgp_data_free(&sig->info.sig.unknown);
pgp_data_free(&info->sig.unknown);
break;
default:
(void) fprintf(stderr, "sig_free: bad sig type\n");
(void) fprintf(stderr, "info-free: bad info-type\n");
}
}
static void
sig_free(pgp_sig_t *sig)
{
sig_info_free(&sig->info);
}
/**
\ingroup Core_Create
\brief Free allocated memory
@ -1198,26 +1261,28 @@ pgp_pubkey_free(pgp_pubkey_t *p)
int
pgp_pubkey_dup(pgp_pubkey_t *dst, pgp_pubkey_t *src)
{
memcpy(dst, src, sizeof(*src));
switch (src->alg) {
case PGP_PKA_RSA:
case PGP_PKA_RSA_ENCRYPT_ONLY:
case PGP_PKA_RSA_SIGN_ONLY:
dup_BN(&dst->key.rsa.n, &src->key.rsa.n);
dup_BN(&dst->key.rsa.e, &src->key.rsa.e);
dup_BN(dst->key.rsa.n, src->key.rsa.n);
dup_BN(dst->key.rsa.e, src->key.rsa.e);
break;
case PGP_PKA_DSA:
dup_BN(&dst->key.dsa.p, &src->key.dsa.p);
dup_BN(&dst->key.dsa.q, &src->key.dsa.q);
dup_BN(&dst->key.dsa.g, &src->key.dsa.g);
dup_BN(&dst->key.dsa.y, &src->key.dsa.y);
dup_BN(dst->key.dsa.p, src->key.dsa.p);
dup_BN(dst->key.dsa.q, src->key.dsa.q);
dup_BN(dst->key.dsa.g, src->key.dsa.g);
dup_BN(dst->key.dsa.y, src->key.dsa.y);
break;
case PGP_PKA_ELGAMAL:
case PGP_PKA_ELGAMAL_ENCRYPT_OR_SIGN:
dup_BN(&dst->key.elgamal.p, &src->key.elgamal.p);
dup_BN(&dst->key.elgamal.g, &src->key.elgamal.g);
dup_BN(&dst->key.elgamal.y, &src->key.elgamal.y);
dup_BN(dst->key.elgamal.p, src->key.elgamal.p);
dup_BN(dst->key.elgamal.g, src->key.elgamal.g);
dup_BN(dst->key.elgamal.y, src->key.elgamal.y);
break;
case PGP_PKA_NOTHING:
@ -2368,14 +2433,14 @@ pgp_seckey_dup(pgp_seckey_t *dst, pgp_seckey_t *src)
case PGP_PKA_RSA:
case PGP_PKA_RSA_ENCRYPT_ONLY:
case PGP_PKA_RSA_SIGN_ONLY:
dup_BN(&src->key.rsa.d, &src->key.rsa.d);
dup_BN(&src->key.rsa.p, &src->key.rsa.p);
dup_BN(&src->key.rsa.q, &src->key.rsa.q);
dup_BN(&src->key.rsa.u, &src->key.rsa.u);
dup_BN(src->key.rsa.d, src->key.rsa.d);
dup_BN(src->key.rsa.p, src->key.rsa.p);
dup_BN(src->key.rsa.q, src->key.rsa.q);
dup_BN(src->key.rsa.u, src->key.rsa.u);
break;
case PGP_PKA_DSA:
dup_BN(&src->key.dsa.x, &src->key.dsa.x);
dup_BN(src->key.dsa.x, src->key.dsa.x);
break;
default:


+ 3
- 0
dist/src/lib/packet-parse.h View File

@ -166,4 +166,7 @@ int pgp_decompress(pgp_region_t *, pgp_stream_t *,
unsigned pgp_writez(pgp_output_t *, const uint8_t *,
const unsigned);
void
copy_sig_info(pgp_sig_info_t *dst, const pgp_sig_info_t *src);
#endif /* PACKET_PARSE_H_ */

+ 30
- 30
dist/src/lib/packet-print.c View File

@ -436,28 +436,28 @@ pgp_sprint_keydata(pgp_io_t *io, const pgp_keyring_t *keyring,
(psigs) ? " " : " ",
key->uids[i],
(isrevoked(key, i) >= 0) ? " [REVOKED]" : "");
for (j = 0 ; j < key->subsigc ; j++) {
for (j = 0 ; j < key->uidsigc ; j++) {
if (psigs) {
if (key->subsigs[j].uid != i) {
if (key->uidsigs[j].uid != i) {
continue;
}
} else {
if (!(key->subsigs[j].sig.info.version == 4 &&
key->subsigs[j].sig.info.type == PGP_SIG_SUBKEY &&
if (!(key->uidsigs[j].siginfo.version == 4 &&
key->uidsigs[j].siginfo.type == PGP_SIG_SUBKEY &&
i == key->uidc - 1)) {
continue;
}
}
from = 0;
trustkey = pgp_getkeybyid(io, keyring, key->subsigs[j].sig.info.signer_id, &from, NULL);
if (key->subsigs[j].sig.info.version == 4 &&
key->subsigs[j].sig.info.type == PGP_SIG_SUBKEY) {
trustkey = pgp_getkeybyid(io, keyring, key->uidsigs[j].siginfo.signer_id, &from, NULL);
if (key->uidsigs[j].siginfo.version == 4 &&
key->uidsigs[j].siginfo.type == PGP_SIG_SUBKEY) {
psubkeybinding(&uidbuf[n], sizeof(uidbuf) - n, key, expired);
} else {
n += snprintf(&uidbuf[n], sizeof(uidbuf) - n,
"sig %s %s %s\n",
strhexdump(keyid, key->subsigs[j].sig.info.signer_id, PGP_KEY_ID_SIZE, ""),
ptimestr(t, sizeof(t), key->subsigs[j].sig.info.birthtime),
strhexdump(keyid, key->uidsigs[j].siginfo.signer_id, PGP_KEY_ID_SIZE, ""),
ptimestr(t, sizeof(t), key->uidsigs[j].siginfo.birthtime),
(trustkey) ? (char *)trustkey->uids[trustkey->uid0] : "[unknown]");
}
}
@ -512,22 +512,22 @@ pgp_sprint_mj(pgp_io_t *io, const pgp_keyring_t *keyring,
mj_append(&sub_obj, "string", (r >= 0) ? "[REVOKED]" : "", -1);
mj_append_field(keyjson, "uid", "array", &sub_obj);
mj_delete(&sub_obj);
for (j = 0 ; j < key->subsigc ; j++) {
for (j = 0 ; j < key->uidsigc ; j++) {
if (psigs) {
if (key->subsigs[j].uid != i) {
if (key->uidsigs[j].uid != i) {
continue;
}
} else {
if (!(key->subsigs[j].sig.info.version == 4 &&
key->subsigs[j].sig.info.type == PGP_SIG_SUBKEY &&
if (!(key->uidsigs[j].siginfo.version == 4 &&
key->uidsigs[j].siginfo.type == PGP_SIG_SUBKEY &&
i == key->uidc - 1)) {
continue;
}
}
(void) memset(&sub_obj, 0x0, sizeof(sub_obj));
mj_create(&sub_obj, "array");
if (key->subsigs[j].sig.info.version == 4 &&
key->subsigs[j].sig.info.type == PGP_SIG_SUBKEY) {
if (key->uidsigs[j].siginfo.version == 4 &&
key->uidsigs[j].siginfo.type == PGP_SIG_SUBKEY) {
mj_append(&sub_obj, "integer", (int64_t)numkeybits(&key->enckey));
mj_append(&sub_obj, "string",
(const char *)pgp_show_pka(key->enckey.alg), -1);
@ -538,11 +538,11 @@ pgp_sprint_mj(pgp_io_t *io, const pgp_keyring_t *keyring,
mj_delete(&sub_obj);
} else {
mj_append(&sub_obj, "string",
strhexdump(keyid, key->subsigs[j].sig.info.signer_id, PGP_KEY_ID_SIZE, ""), -1);
strhexdump(keyid, key->uidsigs[j].siginfo.signer_id, PGP_KEY_ID_SIZE, ""), -1);
mj_append(&sub_obj, "integer",
(int64_t)(key->subsigs[j].sig.info.birthtime));
(int64_t)(key->uidsigs[j].siginfo.birthtime));
from = 0;
trustkey = pgp_getkeybyid(io, keyring, key->subsigs[j].sig.info.signer_id, &from, NULL);
trustkey = pgp_getkeybyid(io, keyring, key->uidsigs[j].siginfo.signer_id, &from, NULL);
mj_append(&sub_obj, "string",
(trustkey) ? (char *)trustkey->uids[trustkey->uid0] : "[unknown]", -1);
mj_append_field(keyjson, "sig", "array", &sub_obj);
@ -583,33 +583,33 @@ pgp_hkp_sprint_keydata(pgp_io_t *io, const pgp_keyring_t *keyring,
(long long)pubkey->birthtime,
(long long)pubkey->duration,
key->uids[i]);
for (j = 0 ; j < key->subsigc ; j++) {
for (j = 0 ; j < key->uidsigc ; j++) {
if (psigs) {
if (key->subsigs[j].uid != i) {
if (key->uidsigs[j].uid != i) {
continue;
}
} else {
if (!(key->subsigs[j].sig.info.version == 4 &&
key->subsigs[j].sig.info.type == PGP_SIG_SUBKEY &&
if (!(key->uidsigs[j].siginfo.version == 4 &&
key->uidsigs[j].siginfo.type == PGP_SIG_SUBKEY &&
i == key->uidc - 1)) {
continue;
}
}
from = 0;
trustkey = pgp_getkeybyid(io, keyring, key->subsigs[j].sig.info.signer_id, &from, NULL);
if (key->subsigs[j].sig.info.version == 4 &&
key->subsigs[j].sig.info.type == PGP_SIG_SUBKEY) {
trustkey = pgp_getkeybyid(io, keyring, key->uidsigs[j].siginfo.signer_id, &from, NULL);
if (key->uidsigs[j].siginfo.version == 4 &&
key->uidsigs[j].siginfo.type == PGP_SIG_SUBKEY) {
n += snprintf(&uidbuf[n], sizeof(uidbuf) - n, "sub:%d:%d:%s:%lld:%lld\n",
numkeybits(pubkey),
key->subsigs[j].sig.info.key_alg,
strhexdump(keyid, key->subsigs[j].sig.info.signer_id, PGP_KEY_ID_SIZE, ""),
(long long)(key->subsigs[j].sig.info.birthtime),
key->uidsigs[j].siginfo.key_alg,
strhexdump(keyid, key->uidsigs[j].siginfo.signer_id, PGP_KEY_ID_SIZE, ""),
(long long)(key->uidsigs[j].siginfo.birthtime),
(long long)pubkey->duration);
} else {
n += snprintf(&uidbuf[n], sizeof(uidbuf) - n,
"sig:%s:%lld:%s\n",
strhexdump(keyid, key->subsigs[j].sig.info.signer_id, PGP_KEY_ID_SIZE, ""),
(long long)key->subsigs[j].sig.info.birthtime,
strhexdump(keyid, key->uidsigs[j].siginfo.signer_id, PGP_KEY_ID_SIZE, ""),
(long long)key->uidsigs[j].siginfo.birthtime,
(trustkey) ? (char *)trustkey->uids[trustkey->uid0] : "");
}
}


+ 6
- 12
dist/src/lib/packet.h View File

@ -948,13 +948,6 @@ typedef union {
pgp_seckey_t seckey;
} pgp_keydata_key_t;
/* sigpacket_t */
typedef struct {
uint8_t **userid;
pgp_subpacket_t *packet;
} sigpacket_t;
/* user revocation info */
typedef struct pgp_revoke_t {
uint32_t uid; /* index in uid array */
@ -963,19 +956,20 @@ typedef struct pgp_revoke_t {
} pgp_revoke_t;
/** signature subpackets */
typedef struct pgp_subsig_t {
typedef struct pgp_uidsig_t {
uint32_t uid; /* index in userid array in key */
pgp_sig_t sig; /* trust signature */
pgp_sig_info_t siginfo; /* trust signature */
uint8_t trustlevel; /* level of trust */
uint8_t trustamount; /* amount of trust */
} pgp_subsig_t;
pgp_subpacket_t *packet;
} pgp_uidsig_t;
/* describes a user's key */
struct pgp_key_t {
/* TODO make uid a struct with siginfo and dynarrays of pkts */
DYNARRAY(uint8_t *, uid); /* array of user ids */
/* TODO remove */
DYNARRAY(pgp_subpacket_t, packet); /* array of raw subpackets */
DYNARRAY(pgp_subsig_t, subsig); /* array of signature subkeys */
DYNARRAY(pgp_uidsig_t, uidsig); /* array of signature subkeys */
DYNARRAY(pgp_revoke_t, revoke); /* array of signature revocations */
pgp_content_enum type; /* type of key */
pgp_keydata_key_t key; /* pubkey/seckey data */


+ 6
- 18
dist/src/lib/validate.c View File

@ -137,16 +137,6 @@ free_sig_info(pgp_sig_info_t *sig)
free(sig);
}
static void
copy_sig_info(pgp_sig_info_t *dst, const pgp_sig_info_t *src)
{
(void) memcpy(dst, src, sizeof(*src));
if ((dst->v4_hashed = calloc(1, src->v4_hashlen)) == NULL) {
(void) fprintf(stderr, "copy_sig_info: bad alloc\n");
} else {
(void) memcpy(dst->v4_hashed, src->v4_hashed, src->v4_hashlen);
}
}
static int
add_sig_to_list(const pgp_sig_info_t *sig, pgp_sig_info_t **sigs,
@ -358,7 +348,7 @@ pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
}
}
if (!sigkey) {
if (!add_sig_to_list(&content->sig.info,
if (&vdata->result && !add_sig_to_list(&content->sig.info,
&vdata->result->unknown_sigs,
&vdata->result->unknownc)) {
(void) fprintf(io->errs,
@ -430,7 +420,7 @@ pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
}
if (valid) {
if (!add_sig_to_list(&content->sig.info,
if (&vdata->result && !add_sig_to_list(&content->sig.info,
&vdata->result->valid_sigs,
&vdata->result->validc)) {
PGP_ERROR_1(errors, PGP_E_UNIMPLEMENTED, "%s",
@ -442,7 +432,7 @@ pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
} else {
PGP_ERROR_1(errors, PGP_E_V_BAD_SIGNATURE, "%s",
"Bad Sig");
if (!add_sig_to_list(&content->sig.info,
if (&vdata->result && !add_sig_to_list(&content->sig.info,
&vdata->result->invalid_sigs,
&vdata->result->invalidc)) {
PGP_ERROR_1(errors, PGP_E_UNIMPLEMENTED, "%s",
@ -458,7 +448,7 @@ pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
pgp_copy_packet(&vdata->last_pkt, &content->packet);
vdata->store_pkt = 0;
}else if(vdata->sig_is_valid){
pgp_cb_ret_t ret = PGP_KEEP_MEMORY;
pgp_cb_ret_t ret = PGP_RELEASE_MEMORY;
if(vdata->on_valid){
ret = vdata->on_valid(vdata, &content->packet);
}
@ -466,7 +456,7 @@ pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
vdata->not_commited = 0;
return ret;
}
return PGP_KEEP_MEMORY;
return PGP_RELEASE_MEMORY;
/* ignore these */
case PGP_PARSER_PTAG:
@ -829,7 +819,6 @@ pgp_filter_keys_from_mem(pgp_io_t *io,
const unsigned armour,
pgp_memory_t *mem)
{
pgp_validation_t vresult;
pgp_stream_t *stream;
const unsigned noaccum = 0;
validate_key_cb_t vdata;
@ -837,9 +826,8 @@ pgp_filter_keys_from_mem(pgp_io_t *io,
const int printerrors = 1;
unsigned res;
(void) memset(&vresult, 0x0, sizeof(vresult));
(void) memset(&vdata, 0x0, sizeof(vdata));
vdata.result = &vresult;
vdata.result = NULL;
vdata.getpassphrase = NULL;
(void) memset(&filter, 0x0, sizeof(filter));


+ 1
- 0
dist/src/lib/validate.h View File

@ -76,6 +76,7 @@ typedef struct validate_key_cb_t{
pgp_cb_ret_t(*getpassphrase) (const pgp_packet_t *,
pgp_cbdata_t *);
/* TODO strip packet store */
pgp_subpacket_t last_pkt; /* last non-signature packet met */
unsigned store_pkt; /* request to store packet at packet end */
unsigned not_commited; /* tells on_valid it is first commit of that key */


Loading…
Cancel
Save