mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
agent:kem:ecc: Support a key on smartcard.
* agent/agent.h (agent_card_ecc_kem): New. * agent/divert-scd.c (agent_card_ecc_kem): New. * agent/pkdecrypt.c (ecc_extract_pk_from_key): New. (ecc_extract_sk_from_key): New. (ecc_raw_kem, get_cardkey, ecc_get_curve): New. (ecc_pgp_kem_decrypt): Support a key on smartcard for ECC. (composite_pgp_kem_decrypt): Handle a case of a key on smartcard. * common/sexputil.c (get_ecc_curve_from_key): New. * common/util.h (get_ecc_curve_from_key): New. -- GnuPG-bug-id: 7097 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
83e2dede0a
commit
9128d81bb7
5 changed files with 288 additions and 74 deletions
|
@ -486,6 +486,34 @@ divert_pkdecrypt (ctrl_t ctrl,
|
|||
return rc;
|
||||
}
|
||||
|
||||
gpg_error_t
|
||||
agent_card_ecc_kem (ctrl_t ctrl, const unsigned char *ecc_ct,
|
||||
size_t ecc_point_len, unsigned char *ecc_ecdh)
|
||||
{
|
||||
gpg_error_t err = 0;
|
||||
char *ecdh = NULL;
|
||||
size_t len;
|
||||
int rc;
|
||||
|
||||
rc = agent_card_pkdecrypt (ctrl, ctrl->keygrip, getpin_cb, ctrl, NULL,
|
||||
ecc_ct, ecc_point_len, &ecdh, &len, NULL);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (len != ecc_point_len)
|
||||
{
|
||||
if (opt.verbose)
|
||||
log_info ("%s: ECC result length invalid (%zu != %zu)\n",
|
||||
__func__, len, ecc_point_len);
|
||||
return gpg_error (GPG_ERR_INV_DATA);
|
||||
}
|
||||
else
|
||||
memcpy (ecc_ecdh, ecdh, len);
|
||||
|
||||
xfree (ecdh);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
gpg_error_t
|
||||
divert_writekey (ctrl_t ctrl, int force, const char *serialno,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue