1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

experiment: Rename the names of functions.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
NIIBE Yutaka 2021-11-25 14:17:31 +09:00
parent 16fe6cdf72
commit a461eae58d
9 changed files with 34 additions and 32 deletions

View File

@ -103,7 +103,7 @@ get_keygrip (int pubkey_algo, const char *curve, gcry_mpi_t *pkey,
if (pkalgo)
{
pubkey = openpgp_ecc_parse_key (pkalgo, curve, pkey[0]);
pubkey = openpgp_to_libgcrypt (pkalgo, curve, pkey[0]);
err = gcry_sexp_build (&s_pkey, NULL, format, curve, pubkey);
gcry_mpi_release (pubkey);
}
@ -189,8 +189,8 @@ convert_secret_key (gcry_sexp_t *r_key, int pubkey_algo, gcry_mpi_t *skey,
if (pkalgo)
{
pubkey = openpgp_ecc_parse_key (pkalgo, curve, skey[0]);
seckey = openpgp_ecc_parse_key (pkalgo, curve, skey[1]);
pubkey = openpgp_to_libgcrypt (pkalgo, curve, skey[0]);
seckey = openpgp_to_libgcrypt (pkalgo, curve, skey[1]);
err = gcry_sexp_build (&s_skey, NULL, format, curve, pubkey, seckey);
gcry_mpi_release (pubkey);
gcry_mpi_release (seckey);
@ -500,7 +500,7 @@ do_unprotect (const char *passphrase,
actual_csum += checksum (buffer, nbytes);
tmpmpi = skey[i];
skey[i] = openpgp_ecc_parse_key (pubkey_algo, curve, tmpmpi);
skey[i] = openpgp_to_libgcrypt (pubkey_algo, curve, tmpmpi);
gcry_mpi_release (tmpmpi);
}
else
@ -642,7 +642,7 @@ do_unprotect (const char *passphrase,
{
if (scan_pgp_format (&tmpmpi, pubkey_algo, p, ndata, &nbytes))
break;
skey[i] = openpgp_ecc_parse_key (pubkey_algo, curve, tmpmpi);
skey[i] = openpgp_to_libgcrypt (pubkey_algo, curve, tmpmpi);
gcry_mpi_release (tmpmpi);
ndata -= nbytes;
p += nbytes;
@ -1494,8 +1494,8 @@ convert_to_openpgp (ctrl_t ctrl, gcry_sexp_t s_key, const char *passphrase,
if (pubkey_algo)
{
err = openpgp_fixup_key_448 (pubkey_algo, &array[0]);
err = openpgp_fixup_key_448 (pubkey_algo, &array[1]);
err = openpgp_from_libgcrypt (pubkey_algo, &array[0]);
err = openpgp_from_libgcrypt (pubkey_algo, &array[1]);
}
}

View File

@ -24,11 +24,12 @@
#include "openpgpdefs.h"
/*
* Parse the key (pubkey or seckey), and return real version of the
* key; That is, for Ed448/X448, return key with prefix removed.
* Convert from OpenPGP-format with possible prefix, return
* libgcrypt-format of the key; That is, for Ed448/X448, return key
* with prefix removed, if any.
*/
gcry_mpi_t
openpgp_ecc_parse_key (pubkey_algo_t pkalgo, const char *curve,
openpgp_to_libgcrypt (pubkey_algo_t pkalgo, const char *curve,
gcry_mpi_t key)
{
unsigned int nbits = 0;
@ -53,10 +54,11 @@ openpgp_ecc_parse_key (pubkey_algo_t pkalgo, const char *curve,
/*
* Fix up public/sec key for OpenPGP adding the prefix.
* Convert from libgcrypt-format with no-prefix, return OpenPGP-format
* of the key; That is, for Ed448/X448, return key with prefix added.
*/
gpg_error_t
openpgp_fixup_key_448 (int algo, gcry_mpi_t *r_key)
openpgp_from_libgcrypt (int algo, gcry_mpi_t *r_key)
{
gcry_mpi_t key_mpi;
gcry_mpi_t a;

View File

@ -240,8 +240,8 @@ enum gcry_pk_algos map_openpgp_pk_to_gcry (pubkey_algo_t algo);
/*-- openpgp-misc.c --*/
gcry_mpi_t openpgp_ecc_parse_key (pubkey_algo_t pkalgo, const char *curve,
gcry_mpi_t openpgp_to_libgcrypt (pubkey_algo_t pkalgo, const char *curve,
gcry_mpi_t key);
gpg_error_t openpgp_fixup_key_448 (int algo, gcry_mpi_t *p_pubkey);
gpg_error_t openpgp_from_libgcrypt (int algo, gcry_mpi_t *p_pubkey);
#endif /*GNUPG_COMMON_OPENPGPDEFS_H*/

View File

@ -760,7 +760,7 @@ cleartext_secret_key_to_openpgp (gcry_sexp_t s_key, PKT_public_key *pk)
err = sexp_extract_param_sos (key, "q", &pub_params[0]);
if (!err && is_448)
err = openpgp_fixup_key_448 (pk->pubkey_algo, &pub_params[0]);
err = openpgp_from_libgcrypt (pk->pubkey_algo, &pub_params[0]);
if (!err && (gcry_mpi_cmp(pk->pkey[1], pub_params[0])))
err = gpg_error (GPG_ERR_BAD_PUBKEY);
@ -774,7 +774,7 @@ cleartext_secret_key_to_openpgp (gcry_sexp_t s_key, PKT_public_key *pk)
pk->pkey[sec_start] = NULL;
err = sexp_extract_param_sos (key, "d", &pk->pkey[sec_start]);
if (!err && is_448)
err = openpgp_fixup_key_448 (pk->pubkey_algo,
err = openpgp_from_libgcrypt (pk->pubkey_algo,
&pk->pkey[sec_start]);
}

View File

@ -2573,7 +2573,7 @@ transfer_secret_keys (ctrl_t ctrl, struct import_stats_s *stats,
j = 0;
/* Append the public key element Q. */
put_membuf_str (&mbuf, " _ %m");
ecc_pubkey = openpgp_ecc_parse_key (pk->pubkey_algo,
ecc_pubkey = openpgp_to_libgcrypt (pk->pubkey_algo,
curvename, pk->pkey[1]);
format_args[j++] = &ecc_pubkey;

View File

@ -1338,7 +1338,7 @@ ecckey_from_sexp (gcry_mpi_t *array, gcry_sexp_t sexp, int algo)
if (openpgp_oid_is_ed448 (array[0])
|| openpgp_oid_is_cv448 (array[0]))
{
err = openpgp_fixup_key_448 (algo, &array[1]);
err = openpgp_from_libgcrypt (algo, &array[1]);
if (err)
goto leave;
}

View File

@ -1069,7 +1069,7 @@ keygrip_from_pk (PKT_public_key *pk, unsigned char *array)
else
{
const char *curve = openpgp_oid_to_curve (curve_oid, 1);
gcry_mpi_t pubkey = openpgp_ecc_parse_key (pk->pubkey_algo,
gcry_mpi_t pubkey = openpgp_to_libgcrypt (pk->pubkey_algo,
curve, pk->pkey[1]);
err = gcry_sexp_build (&s_pkey, NULL,

View File

@ -1806,7 +1806,7 @@ pubkey_nbits( int algo, gcry_mpi_t *key )
else
{
const char *curve_name = openpgp_oid_to_curve (curve, 1);
gcry_mpi_t pubkey = openpgp_ecc_parse_key (algo, curve_name, key[1]);
gcry_mpi_t pubkey = openpgp_to_libgcrypt (algo, curve_name, key[1]);
rc = gcry_sexp_build (&sexp, NULL,
"(public-key(ecc(curve%s)(q%m)))",

View File

@ -194,7 +194,7 @@ pk_verify (pubkey_algo_t pkalgo, gcry_mpi_t hash,
gcry_mpi_t pubkey;
const char *curve_name = openpgp_oid_to_curve (curve, 1);
pubkey = openpgp_ecc_parse_key (pkalgo, curve_name, pkey[1]);
pubkey = openpgp_to_libgcrypt (pkalgo, curve_name, pkey[1]);
if (openpgp_oid_is_ed25519 (pkey[0]))
fmt = "(public-key(ecc(curve %s)(flags eddsa)(q%m)))";
else
@ -418,7 +418,7 @@ pk_encrypt (pubkey_algo_t algo, gcry_mpi_t *resarr, gcry_mpi_t data,
gcry_mpi_t pubkey;
const char *curve_name = openpgp_oid_to_curve (curve, 1);
pubkey = openpgp_ecc_parse_key (algo, curve_name, pkey[1]);
pubkey = openpgp_to_libgcrypt (algo, curve_name, pkey[1]);
/* Now use the ephemeral secret to compute the shared point. */
rc = gcry_sexp_build (&s_pkey, NULL,
with_djb_tweak_flag ?
@ -465,7 +465,7 @@ pk_encrypt (pubkey_algo_t algo, gcry_mpi_t *resarr, gcry_mpi_t data,
s_ciph = NULL;
if (openpgp_oid_is_cv448 (pkey[0]))
{
rc = openpgp_fixup_key_448 (algo, &public);
rc = openpgp_from_libgcrypt (algo, &public);
if (rc)
goto leave;
}
@ -550,8 +550,8 @@ pk_check_secret_key (pubkey_algo_t pkalgo, gcry_mpi_t *skey)
gcry_mpi_t seckey;
const char *curve_name = openpgp_oid_to_curve (curve, 1);
pubkey = openpgp_ecc_parse_key (pkalgo, curve_name, skey[1]);
seckey = openpgp_ecc_parse_key (pkalgo, curve_name, skey[2]);
pubkey = openpgp_to_libgcrypt (pkalgo, curve_name, skey[1]);
seckey = openpgp_to_libgcrypt (pkalgo, curve_name, skey[2]);
rc = gcry_sexp_build (&s_skey, NULL,
"(private-key(ecc(curve%s)(q%m)(d%m)))",
curve_name, pubkey, seckey);
@ -572,8 +572,8 @@ pk_check_secret_key (pubkey_algo_t pkalgo, gcry_mpi_t *skey)
gcry_mpi_t seckey;
const char *curve_name = openpgp_oid_to_curve (curve, 1);
pubkey = openpgp_ecc_parse_key (pkalgo, curve_name, skey[1]);
seckey = openpgp_ecc_parse_key (pkalgo, curve_name, skey[2]);
pubkey = openpgp_to_libgcrypt (pkalgo, curve_name, skey[1]);
seckey = openpgp_to_libgcrypt (pkalgo, curve_name, skey[2]);
if (openpgp_oid_is_ed25519 (skey[0]))
fmt = "(private-key(ecc(curve %s)(flags eddsa)(q%m)(d%m)))";
else