aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/openpgp-fpr.c3
-rw-r--r--common/openpgp-oid.c14
-rw-r--r--common/util.h3
3 files changed, 16 insertions, 4 deletions
diff --git a/common/openpgp-fpr.c b/common/openpgp-fpr.c
index 7860d3872..699eee9ee 100644
--- a/common/openpgp-fpr.c
+++ b/common/openpgp-fpr.c
@@ -231,7 +231,8 @@ compute_openpgp_fpr_ecc (int keyversion, unsigned long timestamp,
unsigned char nbits_q[2];
unsigned int n;
- curveoidstr = openpgp_curve_to_oid (curvename, &curvebits, &pgpalgo);
+ curveoidstr = openpgp_curve_to_oid (curvename, &curvebits, &pgpalgo,
+ (keyversion > 4));
err = openpgp_oid_from_str (curveoidstr, &curveoid);
if (err)
goto leave;
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)
diff --git a/common/util.h b/common/util.h
index 671ffbcb7..acda2646e 100644
--- a/common/util.h
+++ b/common/util.h
@@ -230,7 +230,8 @@ int openpgp_oid_is_cv448 (gcry_mpi_t a);
int openpgp_oid_is_ed448 (gcry_mpi_t a);
enum gcry_kem_algos openpgp_oid_to_kem_algo (const char *oidname);
const char *openpgp_curve_to_oid (const char *name,
- unsigned int *r_nbits, int *r_algo);
+ unsigned int *r_nbits, int *r_algo,
+ int selector);
const char *openpgp_oid_to_curve (const char *oid, int mode);
const char *openpgp_oid_or_name_to_curve (const char *oidname, int canon);
const char *openpgp_enum_curves (int *idxp);