Browse Source

Fix algorithm version detection

Use a mask so that we detect the correct algorithm version
master
David Lanzendörfer 12 months ago
parent
commit
c5d108cf2f
4 changed files with 3 additions and 22 deletions
  1. +0
    -8
      src/keyring.c
  2. +1
    -2
      src/packet-parse.c
  3. +0
    -5
      src/reader.c
  4. +2
    -7
      src/validate.c

+ 0
- 8
src/keyring.c View File

@ -179,7 +179,6 @@ pgp_keydata_free(pgp_key_t *keydata)
static unsigned siginfo_in_time(pgp_sig_info_t *siginfo)
{
printf("%s...\n",__FUNCTION__);
time_t now;
now = time(NULL);
/* in sig validity time frame */
@ -200,7 +199,6 @@ pgp_key_find_uid_cond(
unsigned checkrevoke,
unsigned checkexpiry)
{
printf("%s...\n",__FUNCTION__);
unsigned uididx = 0;
unsigned uidsigidx = 0;
int32_t res = -1; /* Not found */
@ -276,7 +274,6 @@ pgp_key_find_key_conds(
unsigned checkrevoke,
unsigned checkexpiry)
{
printf("%s...\n",__FUNCTION__);
unsigned subkeyidx = 0;
unsigned subkeysigidx = 0;
unsigned directsigidx = 0;
@ -466,7 +463,6 @@ key_get_seckey_from_subidx(
static unsigned is_signing_role(const pgp_sig_info_t *siginfo, void *arg)
{
printf("%s...\n",__FUNCTION__);
return siginfo->key_flags & PGP_KEYFLAG_SIGN_DATA;
}
@ -490,7 +486,6 @@ pgp_key_get_certkey(pgp_key_t *key)
static unsigned is_encryption_role(const pgp_sig_info_t *siginfo, void *arg)
{
printf("%s...\n",__FUNCTION__);
return siginfo->key_flags & PGP_KEYFLAG_ENC_COMM;
}
@ -514,7 +509,6 @@ pgp_key_get_deckey(pgp_key_t *key, const uint8_t **id)
static unsigned primary_uid_sigcond(const pgp_sig_info_t *siginfo, void *arg)
{
printf("%s...\n",__FUNCTION__);
return siginfo->primary_userid;
}
@ -1353,7 +1347,6 @@ unsigned pgp_add_directsig(
const pgp_subpacket_t *sigpkt,
pgp_sig_info_t *siginfo)
{
printf("%s...\n",__FUNCTION__);
pgp_directsig_t *directsigp;
unsigned directsigidx;
@ -1440,7 +1433,6 @@ unsigned pgp_update_subkey(
const pgp_subpacket_t *sigpkt,
pgp_sig_info_t *siginfo)
{
printf("%s...\n",__FUNCTION__);
unsigned subkeyidx = 0;
unsigned subkeysigidx = 0;
pgp_subkey_t *subkeyp;


+ 1
- 2
src/packet-parse.c View File

@ -1435,8 +1435,7 @@ parse_pubkey_data(pgp_pubkey_t *key, pgp_region_t *region,
if (!limread(&c, 1, region, stream)) {
return 0;
}
key->alg = c;
printf("Public Key algorithm (%x)\n", key->alg);
key->alg = c&0x0f;
switch (key->alg) {
case PGP_PKA_DSA:


+ 0
- 5
src/reader.c View File

@ -2040,12 +2040,9 @@ pgp_setup_file_read(pgp_io_t *io,
return fd;
}
fstat(fd, &st);
printf("%s: Opened file %s, fd=%d, size=%d\n", __FUNCTION__, filename, fd, (uint64_t)st.st_size);
*stream = pgp_new(sizeof(**stream));
(*stream)->io = (*stream)->cbinfo.io = io;
pgp_set_callback(*stream, callback, vp);
#if defined(USE_MMAP_FOR_FILES)
pgp_reader_set_mmap(*stream, fd);
#else
@ -2334,8 +2331,6 @@ pgp_reader_set_mmap(pgp_stream_t *stream, int fd)
} else if ((mem = malloc(sizeof(mmap_reader_t))) == NULL) {
(void) printf("pgp_reader_set_mmap: bad alloc\n");
} else {
printf("fd=%d\n",fd);
printf("File size: %d\n",(uint64_t)st.st_size);
mem->size = (uint64_t)st.st_size;
mem->offset = 0;
mem->fd = fd;


+ 2
- 7
src/validate.c View File

@ -249,16 +249,13 @@ pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
return PGP_KEEP_MEMORY;
case PGP_PTAG_CT_PUBLIC_SUBKEY:
if(vdata->type == PGP_PTAG_CT_PUBLIC_KEY && (
vdata->last_seen == LS_ID ||
vdata->last_seen == LS_ATTRIBUTE)){
if(vdata->type == PGP_PTAG_CT_PUBLIC_KEY && (vdata->last_seen == LS_ID || vdata->last_seen == LS_ATTRIBUTE) ){
pgp_pubkey_free(&vdata->subkey.pubkey);
vdata->subkey.pubkey = content->pubkey;
vdata->last_seen = LS_SUBKEY;
return PGP_KEEP_MEMORY;
}else{
(void) fprintf(io->errs,
"pgp_validate_key_cb: unexpected public subkey packet");
(void) fprintf(io->errs, "pgp_validate_key_cb: unexpected public subkey packet\n");
vdata->last_seen = LS_UNKNOWN;
return PGP_RELEASE_MEMORY;
}
@ -334,8 +331,6 @@ pgp_validate_key_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
/* If no keyring is given to check against
* then this is a self certification check.
* First ensure signature issuer ID is pubkey's ID*/
hexdump(stdout,"vdata->pubkeyid", vdata->pubkeyid, PGP_KEY_ID_SIZE);
hexdump(stdout,"content->sig.info.signer_id", content->sig.info.signer_id, PGP_KEY_ID_SIZE);
if(memcmp(vdata->pubkeyid, content->sig.info.signer_id, PGP_KEY_ID_SIZE) == 0){
sigkey = primary_pubkey;
}


Loading…
Cancel
Save