mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
gpg,ecc: Handle external representation as SOS with opaque MPI.
* g10/pkglue.h (sexp_extract_param_sos): New. * g10/build-packet.c (sos_write): New. (do_key, do_pubkey_enc, do_signature): Use sos_write for ECC. * g10/export.c (cleartext_secret_key_to_openpgp): Use sexp_extract_param_sos. (transfer_format_to_openpgp): Use opaque MPI for ECC. * g10/keygen.c (ecckey_from_sexp): Use sexp_extract_param_sos. * g10/keyid.c (hash_public_key): Handle opaque MPI for SOS. * g10/parse-packet.c (sos_read): New. (parse_pubkeyenc,parse_signature,parse_key): Use sos_read for ECC. * g10/pkglue.c (sexp_extract_param_sos): New. (pk_verify): Handle opaque MPI for SOS. (pk_encrypt): Use sexp_extract_param_sos. * g10/seskey.c (encode_session_key): Use opaque MPI. * g10/sign.c (do_sign): Use sexp_extract_param_sos. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
5c2080f467
commit
f5bc945554
9 changed files with 316 additions and 59 deletions
26
g10/export.c
26
g10/export.c
|
@ -42,6 +42,7 @@
|
|||
#include "trustdb.h"
|
||||
#include "call-agent.h"
|
||||
#include "key-clean.h"
|
||||
#include "pkglue.h"
|
||||
|
||||
|
||||
/* An object to keep track of subkeys. */
|
||||
|
@ -750,10 +751,8 @@ cleartext_secret_key_to_openpgp (gcry_sexp_t s_key, PKT_public_key *pk)
|
|||
err = match_curve_skey_pk (key, pk);
|
||||
if (err)
|
||||
goto leave;
|
||||
if (!err)
|
||||
err = gcry_sexp_extract_param (key, NULL, "q",
|
||||
&pub_params[0],
|
||||
NULL);
|
||||
else
|
||||
err = sexp_extract_param_sos (key, "q", &pub_params[0]);
|
||||
if (!err && (gcry_mpi_cmp(pk->pkey[1], pub_params[0])))
|
||||
err = gpg_error (GPG_ERR_BAD_PUBKEY);
|
||||
|
||||
|
@ -764,9 +763,7 @@ cleartext_secret_key_to_openpgp (gcry_sexp_t s_key, PKT_public_key *pk)
|
|||
{
|
||||
gcry_mpi_release (pk->pkey[sec_start]);
|
||||
pk->pkey[sec_start] = NULL;
|
||||
err = gcry_sexp_extract_param (key, NULL, "d",
|
||||
&pk->pkey[sec_start],
|
||||
NULL);
|
||||
err = sexp_extract_param_sos (key, "d", &pk->pkey[sec_start]);
|
||||
}
|
||||
|
||||
if (!err)
|
||||
|
@ -978,15 +975,16 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk)
|
|||
value = gcry_sexp_nth_data (list, ++idx, &valuelen);
|
||||
if (!value || !valuelen)
|
||||
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);
|
||||
if (!p)
|
||||
goto outofmem;
|
||||
memcpy (p, value, valuelen);
|
||||
skey[skeyidx] = gcry_mpi_set_opaque (NULL, p, valuelen*8);
|
||||
skey[skeyidx] = gcry_mpi_set_opaque_copy (NULL, value, valuelen*8);
|
||||
if (!skey[skeyidx])
|
||||
goto outofmem;
|
||||
if (is_enc)
|
||||
gcry_mpi_set_flag (skey[skeyidx], GCRYMPI_FLAG_USER1);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1144,7 +1142,7 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk)
|
|||
/* Check that the first secret key parameter in SKEY is encrypted
|
||||
and that there are no more secret key parameters. The latter is
|
||||
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;
|
||||
if (npkey+1 < DIM (skey) && skey[npkey+1])
|
||||
goto bad_seckey;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue