mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-14 21:47:19 +02:00
gpg: Pass ECDH parameters to OpenPGP smartcards
* g10/call-agent.c (agent_keytocard): Add arg ecdh_param_str.
* g10/keyid.c (ecdh_param_str_from_pk): New.
* g10/card-util.c (card_store_subkey): Pass ECDH params to writekey.
* g10/keygen.c (card_store_key_with_backup): Ditto.
--
Backported from 2.4 - here the gpg part.
See-commit: c03ba92576
This is related to
GnuPG-bug-id: 6378
This commit is contained in:
parent
d03d0add12
commit
92af3f88a9
6 changed files with 68 additions and 11 deletions
26
g10/keygen.c
26
g10/keygen.c
|
@ -5128,22 +5128,41 @@ card_store_key_with_backup (ctrl_t ctrl, PKT_public_key *sub_psk,
|
|||
char *cache_nonce = NULL;
|
||||
void *kek = NULL;
|
||||
size_t keklen;
|
||||
char *ecdh_param_str = NULL;
|
||||
|
||||
sk = copy_public_key (NULL, sub_psk);
|
||||
if (!sk)
|
||||
return gpg_error_from_syserror ();
|
||||
|
||||
epoch2isotime (timestamp, (time_t)sk->timestamp);
|
||||
if (sk->pubkey_algo == PUBKEY_ALGO_ECDH)
|
||||
{
|
||||
ecdh_param_str = ecdh_param_str_from_pk (sk);
|
||||
if (!ecdh_param_str)
|
||||
{
|
||||
free_public_key (sk);
|
||||
return gpg_error_from_syserror ();
|
||||
}
|
||||
}
|
||||
err = hexkeygrip_from_pk (sk, &hexgrip);
|
||||
if (err)
|
||||
return err;
|
||||
{
|
||||
xfree (ecdh_param_str);
|
||||
free_public_key (sk);
|
||||
return err;
|
||||
}
|
||||
|
||||
memset(&info, 0, sizeof (info));
|
||||
rc = agent_scd_getattr ("SERIALNO", &info);
|
||||
if (rc)
|
||||
return (gpg_error_t)rc;
|
||||
{
|
||||
xfree (ecdh_param_str);
|
||||
free_public_key (sk);
|
||||
return (gpg_error_t)rc;
|
||||
}
|
||||
|
||||
rc = agent_keytocard (hexgrip, 2, 1, info.serialno, timestamp);
|
||||
rc = agent_keytocard (hexgrip, 2, 1, info.serialno,
|
||||
timestamp, ecdh_param_str);
|
||||
xfree (info.serialno);
|
||||
if (rc)
|
||||
{
|
||||
|
@ -5186,6 +5205,7 @@ card_store_key_with_backup (ctrl_t ctrl, PKT_public_key *sub_psk,
|
|||
agent_scd_learn (NULL, 1);
|
||||
|
||||
leave:
|
||||
xfree (ecdh_param_str);
|
||||
xfree (cache_nonce);
|
||||
gcry_cipher_close (cipherhd);
|
||||
xfree (kek);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue