aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/openpgp-oid.c12
-rw-r--r--common/sexputil.c2
-rw-r--r--common/util.h3
3 files changed, 13 insertions, 4 deletions
diff --git a/common/openpgp-oid.c b/common/openpgp-oid.c
index 18c5710bd..943fe3ea6 100644
--- a/common/openpgp-oid.c
+++ b/common/openpgp-oid.c
@@ -337,13 +337,17 @@ openpgp_oid_is_cv25519 (gcry_mpi_t a)
/* Map the Libgcrypt ECC curve NAME to an OID. If R_NBITS is not NULL
store the bit size of the curve there. Returns NULL for unknown
- curve names. */
+ 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. */
const char *
-openpgp_curve_to_oid (const char *name, unsigned int *r_nbits)
+openpgp_curve_to_oid (const char *name, unsigned int *r_nbits, int *r_algo)
{
int i;
unsigned int nbits = 0;
const char *oidstr = NULL;
+ int algo = 0;
if (name)
{
@@ -353,6 +357,7 @@ openpgp_curve_to_oid (const char *name, unsigned int *r_nbits)
{
oidstr = oidtable[i].oidstr;
nbits = oidtable[i].nbits;
+ algo = oidtable[i].pubkey_algo;
break;
}
if (!oidtable[i].name)
@@ -364,6 +369,7 @@ openpgp_curve_to_oid (const char *name, unsigned int *r_nbits)
{
oidstr = oidtable[i].oidstr;
nbits = oidtable[i].nbits;
+ algo = oidtable[i].pubkey_algo;
break;
}
}
@@ -371,6 +377,8 @@ openpgp_curve_to_oid (const char *name, unsigned int *r_nbits)
if (r_nbits)
*r_nbits = nbits;
+ if (r_algo)
+ *r_algo = algo;
return oidstr;
}
diff --git a/common/sexputil.c b/common/sexputil.c
index 4e091b34b..3c5abbe16 100644
--- a/common/sexputil.c
+++ b/common/sexputil.c
@@ -1095,7 +1095,7 @@ pubkey_algo_string (gcry_sexp_t s_pkey, enum gcry_pk_algos *r_algoid)
{
const char *curve = gcry_pk_get_curve (s_pkey, 0, NULL);
const char *name = openpgp_oid_to_curve
- (openpgp_curve_to_oid (curve, NULL), 0);
+ (openpgp_curve_to_oid (curve, NULL, NULL), 0);
if (name)
result = xtrystrdup (name);
diff --git a/common/util.h b/common/util.h
index f53c5d2a7..f0933888d 100644
--- a/common/util.h
+++ b/common/util.h
@@ -244,7 +244,8 @@ int openpgp_oidbuf_is_ed25519 (const void *buf, size_t len);
int openpgp_oid_is_ed25519 (gcry_mpi_t a);
int openpgp_oidbuf_is_cv25519 (const void *buf, size_t len);
int openpgp_oid_is_cv25519 (gcry_mpi_t a);
-const char *openpgp_curve_to_oid (const char *name, unsigned int *r_nbits);
+const char *openpgp_curve_to_oid (const char *name,
+ unsigned int *r_nbits, int *r_algo);
const char *openpgp_oid_to_curve (const char *oid, int canon);
const char *openpgp_enum_curves (int *idxp);
const char *openpgp_is_curve_supported (const char *name,