gpg: Initialize the primary key when generating a key.

* g10/keygen.c (do_generate_keypair): Initialize
pri_psk->flags.primary, pri_psk->keyid and pri_psk->main_keyid.

--
Signed-off-by: Neal H. Walfield <neal@g10code.com>
This commit is contained in:
Neal H. Walfield 2016-02-19 14:53:29 +01:00
parent c45633a571
commit bf9d1248c8
1 changed files with 7 additions and 0 deletions

View File

@ -4079,6 +4079,13 @@ do_generate_keypair (ctrl_t ctrl, struct para_data_s *para,
assert (pri_psk);
}
/* Make sure a few fields are correctly set up before going further. */
pri_psk->flags.primary = 1;
keyid_from_pk (pri_psk, NULL);
/* We don't use pk_keyid to get keyid, because it also asserts that
main_keyid is set! */
keyid_copy (pri_psk->main_keyid, pri_psk->keyid);
if (!err && (revkey = get_parameter_revkey (para, pREVOKER)))
err = write_direct_sig (pub_root, pri_psk, revkey, timestamp, cache_nonce);