Browse Source

Added public key parameter to pgp_add_selfsigned_userid, to add userid to both secret anf public key simultaneously.

master
Edouard Tisserant 7 years ago
parent
commit
bf97027d73
3 changed files with 9 additions and 7 deletions
  1. +7
    -5
      dist/src/lib/keyring.c
  2. +1
    -1
      dist/src/lib/keyring.h
  3. +1
    -1
      dist/src/lib/openssl_crypto.c

+ 7
- 5
dist/src/lib/keyring.c View File

@ -825,7 +825,7 @@ void print_packet_hex(const pgp_subpacket_t *pkt);
\return 1 if OK; else 0
*/
unsigned
pgp_add_selfsigned_userid(pgp_key_t *key, uint8_t *userid)
pgp_add_selfsigned_userid(pgp_key_t *skey, pgp_key_t *pkey, uint8_t *userid)
{
pgp_create_sig_t *sig;
pgp_subpacket_t sigpacket;
@ -838,21 +838,23 @@ pgp_add_selfsigned_userid(pgp_key_t *key, uint8_t *userid)
/* create sig for this pkt */
sig = pgp_create_sig_new();
pgp_sig_start_key_sig(sig, &key->key.seckey.pubkey, userid, PGP_CERT_POSITIVE);
pgp_sig_start_key_sig(sig, &skey->key.seckey.pubkey, userid, PGP_CERT_POSITIVE);
pgp_add_time(sig, (int64_t)time(NULL), "birth");
pgp_add_issuer_keyid(sig, key->pubkeyid);
pgp_add_issuer_keyid(sig, skey->pubkeyid);
pgp_add_primary_userid(sig, 1);
pgp_end_hashed_subpkts(sig);
pgp_setup_memory_write(&sigoutput, &mem_sig, 128);
pgp_write_sig(sigoutput, sig, &key->key.seckey.pubkey, &key->key.seckey);
pgp_write_sig(sigoutput, sig, &skey->key.seckey.pubkey, &skey->key.seckey);
/* add this packet to key */
sigpacket.length = pgp_mem_len(mem_sig);
sigpacket.raw = pgp_mem_data(mem_sig);
/* add user id and signature to key */
pgp_update_userid(key, userid, &sigpacket, &sig->sig.info);
pgp_update_userid(skey, userid, &sigpacket, &sig->sig.info);
if(pkey)
pgp_update_userid(pkey, userid, &sigpacket, &sig->sig.info);
/* cleanup */
pgp_create_sig_delete(sig);


+ 1
- 1
dist/src/lib/keyring.h View File

@ -143,7 +143,7 @@ unsigned pgp_update_userid(
// const pgp_subpacket_t *,
// unsigned );
unsigned pgp_add_selfsigned_userid(pgp_key_t *, uint8_t *);
unsigned pgp_add_selfsigned_userid(pgp_key_t *skey, pgp_key_t *pkey, uint8_t *userid);
pgp_key_t *pgp_keydata_new(void);
void pgp_keydata_init(pgp_key_t *, const pgp_content_enum);


+ 1
- 1
dist/src/lib/openssl_crypto.c View File

@ -808,7 +808,7 @@ pgp_rsa_new_selfsign_key(const int numbits,
keydata = pgp_keydata_new();
if (!pgp_rsa_generate_keypair(keydata, numbits, e, hashalg, cipher,
(const uint8_t *) "", (const size_t) 0) ||
!pgp_add_selfsigned_userid(keydata, userid)) {
!pgp_add_selfsigned_userid(keydata, NULL, userid)) {
pgp_keydata_free(keydata);
return NULL;
}


Loading…
Cancel
Save