Browse Source

z/OS support: char -> uint8_t

master
David Lanzendörfer 12 months ago
parent
commit
ccf7ec4346
1 changed files with 21 additions and 119 deletions
  1. +21
    -119
      src/keyring.c

+ 21
- 119
src/keyring.c View File

@ -290,9 +290,7 @@ pgp_key_find_key_conds(
youngest = 0;
/* check pubkey first */
if(!keycond || keycond(pgp_key_get_pubkey(key),
key->pubkeyid, keycondarg)){
if(!keycond || keycond(pgp_key_get_pubkey(key), key->pubkeyid, keycondarg)){
int32_t uidres;
/* Loop over key's direct sigs */
@ -422,6 +420,7 @@ pgp_key_get_subseckey(pgp_key_t *key, int32_t subkeyidx)
&key->subkeys[subkeyidx].key.seckey :
NULL;
}
static pgp_pubkey_t *
key_get_pubkey_from_subidx(
pgp_key_t *key,
@ -554,13 +553,13 @@ unsigned key_bit_len(const pgp_pubkey_t *key)
return BN_num_bits(key->key.elgamal.p);
#elif defined(HAVE_GSKSSL)
case PGP_PKA_DSA:
return key->key.dsa.p.length*8;
return key->key.dsa.p->length*8-1;
case PGP_PKA_RSA:
return key->key.rsa.n.length*8;
return key->key.rsa.n->length*8-1;
case PGP_PKA_ELGAMAL:
return key->key.elgamal.p.length*8;
return key->key.elgamal.p->length*8-1;
#endif
default:
return 0;
@ -678,99 +677,6 @@ typedef struct {
pgp_seckey_t *seckey;
} decrypt_t;
// FIXME : support encrypted seckeys again
// static pgp_cb_ret_t
// decrypt_cb(const pgp_packet_t *pkt, pgp_cbdata_t *cbinfo)
// {
// const pgp_contents_t *content = &pkt->u;
// decrypt_t *decrypt;
// char pass[MAX_PASSPHRASE_LENGTH];
//
// decrypt = pgp_callback_arg(cbinfo);
// switch (pkt->tag) {
// case PGP_PARSER_PTAG:
// case PGP_PTAG_CT_USER_ID:
// case PGP_PTAG_CT_SIGNATURE:
// case PGP_PTAG_CT_SIGNATURE_HEADER:
// case PGP_PTAG_CT_SIGNATURE_FOOTER:
// case PGP_PTAG_CT_TRUST:
// break;
//
// case PGP_GET_PASSPHRASE:
// (void) pgp_getpassphrase(decrypt->passfp, pass, sizeof(pass));
// *content->skey_passphrase.passphrase = netpgp_strdup(pass);
// pgp_forget(pass, (unsigned)sizeof(pass));
// return PGP_KEEP_MEMORY;
//
// case PGP_PARSER_ERRCODE:
// switch (content->errcode.errcode) {
// case PGP_E_P_MPI_FORMAT_ERROR:
// /* Generally this means a bad passphrase */
// fprintf(stderr, "Bad passphrase!\n");
// return PGP_RELEASE_MEMORY;
//
// case PGP_E_P_PACKET_CONSUMED:
// /* And this is because of an error we've accepted */
// return PGP_RELEASE_MEMORY;
// default:
// break;
// }
// (void) fprintf(stderr, "parse error: %s\n",
// pgp_errcode(content->errcode.errcode));
// return PGP_FINISHED;
//
// case PGP_PARSER_ERROR:
// fprintf(stderr, "parse error: %s\n", content->error);
// return PGP_FINISHED;
//
// case PGP_PTAG_CT_SECRET_KEY:
// if ((decrypt->seckey = calloc(1, sizeof(*decrypt->seckey))) == NULL) {
// (void) fprintf(stderr, "decrypt_cb: bad alloc\n");
// return PGP_FINISHED;
// }
// decrypt->seckey->checkhash = calloc(1, PGP_CHECKHASH_SIZE);
// *decrypt->seckey = content->seckey; /* XXX WTF ? */
// return PGP_KEEP_MEMORY;
//
// case PGP_PARSER_PACKET_END:
// /* nothing to do */
// break;
//
// default:
// fprintf(stderr, "Unexpected tag %d (0x%x)\n", pkt->tag,
// pkt->tag);
// return PGP_FINISHED;
// }
//
// return PGP_RELEASE_MEMORY;
// }
// FIXME : support encrypted seckeys again
// /**
// \ingroup Core_Keys
// \brief Decrypts secret key from given keydata with given passphrase
// \param key Key from which to get secret key
// \param passphrase Passphrase to use to decrypt secret key
// \return secret key
// */
// pgp_seckey_t *
// pgp_decrypt_seckey(const pgp_key_t *key, void *passfp)
// {
// pgp_stream_t *stream;
// const int printerrors = 1;
// decrypt_t decrypt;
//
// (void) memset(&decrypt, 0x0, sizeof(decrypt));
// decrypt.key = key;
// decrypt.passfp = passfp;
// stream = pgp_new(sizeof(*stream));
// pgp_keydata_reader_set(stream, key);
// pgp_set_callback(stream, decrypt_cb, &decrypt);
// stream->readinfo.accumulate = 1;
// pgp_parse(stream, !printerrors);
// return decrypt.seckey;
// }
/* \todo check where userid pointers are copied */
/**
\ingroup Core_Keys
@ -905,9 +811,7 @@ pgp_key_revoke(pgp_key_t *skey, pgp_key_t *pkey, uint8_t code, const char *reaso
pgp_output_t *sigoutput = NULL;
sig = pgp_create_sig_new();
pgp_sig_start_key_rev(
sig, &skey->key.seckey.pubkey,
PGP_SIG_REV_KEY);
pgp_sig_start_key_rev(sig, &skey->key.seckey.pubkey, PGP_SIG_REV_KEY);
pgp_add_creation_time(sig, time(NULL));
pgp_add_issuer_keyid(sig, skey->pubkeyid);
@ -1080,6 +984,7 @@ deletekey( pgp_keyring_t *keyring, pgp_key_t *key, unsigned from)
unsigned key_id_match(const pgp_pubkey_t *key, const uint8_t *keyid, void *refidarg)
{
printf("%s:%d\n",__FILE__,__LINE__);
uint8_t *refid = refidarg;
return (memcmp(keyid, refid, PGP_KEY_ID_SIZE) == 0);
}
@ -1105,6 +1010,7 @@ pgp_getkeybyid(pgp_io_t *io, const pgp_keyring_t *keyring,
unsigned checkrevoke,
unsigned checkexpiry)
{
printf("%s:%d\n",__FILE__,__LINE__);
uint8_t nullid[PGP_KEY_ID_SIZE];
(void) memset(nullid, 0x0, sizeof(nullid));
@ -1116,9 +1022,7 @@ pgp_getkeybyid(pgp_io_t *io, const pgp_keyring_t *keyring,
hexdump(io->errs, "keyid", keyid, PGP_KEY_ID_SIZE);
}
subkeyidx = pgp_key_find_key_conds(key, &key_id_match,
(void*)keyid, NULL, NULL,
checkrevoke, checkexpiry);
subkeyidx = pgp_key_find_key_conds(key, &key_id_match, (void*)keyid, NULL, NULL, checkrevoke, checkexpiry);
if (subkeyidx != -2) {
if (pubkey) {
@ -1256,6 +1160,7 @@ getkeybyname(pgp_io_t *io,
const char *name,
unsigned *from)
{
printf("%s:%d\n",__FILE__,__LINE__);
//const pgp_key_t *kp;
uint8_t **uidp;
unsigned i = 0;
@ -1390,11 +1295,9 @@ pgp_keyring_add(pgp_keyring_t *dst, const pgp_key_t *src)
return 1;
}
pgp_key_t *pgp_ensure_pubkey(
pgp_keyring_t *keyring,
pgp_pubkey_t *pubkey,
uint8_t *pubkeyid)
pgp_key_t *pgp_ensure_pubkey(pgp_keyring_t *keyring, pgp_pubkey_t *pubkey, uint8_t *pubkeyid)
{
printf("%s:%d\n",__FILE__,__LINE__);
pgp_key_t *key;
unsigned c;
@ -1403,6 +1306,7 @@ pgp_key_t *pgp_ensure_pubkey(
/* try to find key in keyring */
for (c = 0; c < keyring->keyc; c += 1) {
if (memcmp(keyring->keys[c].pubkeyid, pubkeyid, PGP_KEY_ID_SIZE) == 0) {
printf("%s:%d\n",__FILE__,__LINE__);
return &keyring->keys[c];
}
}
@ -1415,17 +1319,16 @@ pgp_key_t *pgp_ensure_pubkey(
/* fill in what we already know */
key->type = PGP_PTAG_CT_PUBLIC_KEY;
pgp_pubkey_dup(&key->key.pubkey, pubkey);
(void) memcpy(&key->pubkeyid, pubkeyid, PGP_KEY_ID_SIZE);
memcpy(&key->pubkeyid, pubkeyid, PGP_KEY_ID_SIZE);
pgp_fingerprint(&key->pubkeyfpr, pubkey, keyring->hashtype);
return key;
}
pgp_key_t *pgp_ensure_seckey(
pgp_keyring_t *keyring,
pgp_seckey_t *seckey,
uint8_t *pubkeyid)
pgp_key_t *pgp_ensure_seckey(pgp_keyring_t *keyring, pgp_seckey_t *seckey, uint8_t *pubkeyid)
{
printf("%s:%d\n",__FILE__,__LINE__);
pgp_key_t *key;
unsigned c;
@ -1433,8 +1336,8 @@ pgp_key_t *pgp_ensure_seckey(
/* try to find key in keyring */
for (c = 0; c < keyring->keyc; c += 1) {
if (memcmp(keyring->keys[c].pubkeyid,
pubkeyid, PGP_KEY_ID_SIZE) == 0) {
if (memcmp(keyring->keys[c].pubkeyid, pubkeyid, PGP_KEY_ID_SIZE) == 0) {
printf("%s:%d\n",__FILE__,__LINE__);
return &keyring->keys[c];
}
}
@ -1447,7 +1350,7 @@ pgp_key_t *pgp_ensure_seckey(
/* fill in what we already know */
key->type = PGP_PTAG_CT_SECRET_KEY;
pgp_seckey_dup(&key->key.seckey, seckey);
(void) memcpy(&key->pubkeyid, pubkeyid, PGP_KEY_ID_SIZE);
memcpy(&key->pubkeyid, pubkeyid, PGP_KEY_ID_SIZE);
pgp_fingerprint(&key->pubkeyfpr, &seckey->pubkey, keyring->hashtype);
return key;
@ -1492,7 +1395,7 @@ unsigned pgp_update_userid(
{
unsigned uididx = 0;
unsigned uidsigidx = 0;
unsigned char **uidp;
uint8_t **uidp;
pgp_uidsig_t *uidsigp;
/* Try to find identical userID */
@ -1524,7 +1427,6 @@ unsigned pgp_update_userid(
uidp = &key->uids[key->uidc++];
*uidp = NULL;
pgp_copy_userid(uidp, userid);
printf("%s: uid %s\n",__FUNCTION__,*uidp);
}
/* Add uid sig info, pointing to that uid */


Loading…
Cancel
Save