From 57dce1ee62c2b900b852877c1c9754126b87ed0f Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 8 Oct 2024 15:25:41 +0900 Subject: common,gpg,scd,sm: Fix for Curve25519 OID supporting new and old. * common/util.h (openpgp_curve_to_oid): Add new argument to select OID by OpenPGP version. * common/openpgp-oid.c (openpgp_curve_to_oid): Implement returning selected OID for Curve25519. * common/openpgp-fpr.c (compute_openpgp_fpr_ecc): Follow the change, selecting by the version. * g10/export.c (match_curve_skey_pk): Likewise. (transfer_format_to_openpgp): Likewise. * g10/gpg.c (list_config): Likewise, print new OID. * g10/keygen.c (ecckey_from_sexp): Likewise, selecting by the version. * sm/encrypt.c (ecdh_encrypt): Likewise, don't care. * sm/minip12.c (build_ecc_key_sequence): Likewise, new OID. * scd/app-openpgp.c (ecdh_params, gen_challenge): Likewise, don't care. (ecc_read_pubkey, change_keyattr_from_string, ecc_writekey): Likewise, old OID. -- GnuPG-bug-id: 7316 Signed-off-by: NIIBE Yutaka --- common/openpgp-oid.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'common/openpgp-oid.c') diff --git a/common/openpgp-oid.c b/common/openpgp-oid.c index 0a7aae000..c4161ece1 100644 --- a/common/openpgp-oid.c +++ b/common/openpgp-oid.c @@ -443,9 +443,11 @@ openpgp_oid_is_cv448 (gcry_mpi_t a) curve names. If R_ALGO is not NULL and a specific ECC algorithm is required for this curve its OpenPGP algorithm number is stored there; otherwise 0 is stored which indicates that ECDSA or ECDH can - be used. */ + be used. SELECTOR specifies which OID should be returned: -1 for + don't care, 0 for old OID, 1 for new OID. */ const char * -openpgp_curve_to_oid (const char *name, unsigned int *r_nbits, int *r_algo) +openpgp_curve_to_oid (const char *name, unsigned int *r_nbits, int *r_algo, + int selector) { int i; unsigned int nbits = 0; @@ -479,6 +481,14 @@ openpgp_curve_to_oid (const char *name, unsigned int *r_nbits, int *r_algo) } } + /* Special handling for Curve25519, where we have two valid OIDs. */ + if (algo && i == 0) + { + /* Select new OID, if wanted. */ + if (selector > 0) + oidstr = oidtable[2].oidstr; + } + if (r_nbits) *r_nbits = nbits; if (r_algo) -- cgit v1.2.3