Changeset View
Changeset View
Standalone View
Standalone View
g10/export.c
Context not available. | |||||
#include "trustdb.h" | #include "trustdb.h" | ||||
#include "call-agent.h" | #include "call-agent.h" | ||||
#include "key-clean.h" | #include "key-clean.h" | ||||
#include "pkglue.h" | |||||
/* An object to keep track of subkeys. */ | /* An object to keep track of subkeys. */ | ||||
Context not available. | |||||
err = match_curve_skey_pk (key, pk); | err = match_curve_skey_pk (key, pk); | ||||
if (err) | if (err) | ||||
goto leave; | goto leave; | ||||
if (!err) | else | ||||
err = gcry_sexp_extract_param (key, NULL, "q", | err = sexp_extract_param_sos (key, "q", &pub_params[0]); | ||||
&pub_params[0], | |||||
NULL); | |||||
if (!err && (gcry_mpi_cmp(pk->pkey[1], pub_params[0]))) | if (!err && (gcry_mpi_cmp(pk->pkey[1], pub_params[0]))) | ||||
err = gpg_error (GPG_ERR_BAD_PUBKEY); | err = gpg_error (GPG_ERR_BAD_PUBKEY); | ||||
Context not available. | |||||
{ | { | ||||
gcry_mpi_release (pk->pkey[sec_start]); | gcry_mpi_release (pk->pkey[sec_start]); | ||||
pk->pkey[sec_start] = NULL; | pk->pkey[sec_start] = NULL; | ||||
err = gcry_sexp_extract_param (key, NULL, "d", | err = sexp_extract_param_sos (key, "d", &pk->pkey[sec_start]); | ||||
&pk->pkey[sec_start], | |||||
NULL); | |||||
} | } | ||||
if (!err) | if (!err) | ||||
Context not available. | |||||
value = gcry_sexp_nth_data (list, ++idx, &valuelen); | value = gcry_sexp_nth_data (list, ++idx, &valuelen); | ||||
if (!value || !valuelen) | if (!value || !valuelen) | ||||
goto bad_seckey; | goto bad_seckey; | ||||
if (is_enc) | if (is_enc | ||||
|| pk->pubkey_algo == PUBKEY_ALGO_ECDSA | |||||
|| pk->pubkey_algo == PUBKEY_ALGO_EDDSA | |||||
|| pk->pubkey_algo == PUBKEY_ALGO_ECDH) | |||||
{ | { | ||||
void *p = xtrymalloc (valuelen); | skey[skeyidx] = gcry_mpi_set_opaque_copy (NULL, value, valuelen*8); | ||||
if (!p) | |||||
goto outofmem; | |||||
memcpy (p, value, valuelen); | |||||
skey[skeyidx] = gcry_mpi_set_opaque (NULL, p, valuelen*8); | |||||
if (!skey[skeyidx]) | if (!skey[skeyidx]) | ||||
goto outofmem; | goto outofmem; | ||||
if (is_enc) | |||||
gcry_mpi_set_flag (skey[skeyidx], GCRYMPI_FLAG_USER1); | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
Context not available. | |||||
/* Check that the first secret key parameter in SKEY is encrypted | /* Check that the first secret key parameter in SKEY is encrypted | ||||
and that there are no more secret key parameters. The latter is | and that there are no more secret key parameters. The latter is | ||||
guaranteed by the v4 packet format. */ | guaranteed by the v4 packet format. */ | ||||
if (!gcry_mpi_get_flag (skey[npkey], GCRYMPI_FLAG_OPAQUE)) | if (!gcry_mpi_get_flag (skey[npkey], GCRYMPI_FLAG_USER1)) | ||||
goto bad_seckey; | goto bad_seckey; | ||||
if (npkey+1 < DIM (skey) && skey[npkey+1]) | if (npkey+1 < DIM (skey) && skey[npkey+1]) | ||||
goto bad_seckey; | goto bad_seckey; | ||||
Context not available. |