summaryrefslogtreecommitdiffstats
path: root/common/openpgp-oid.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2020-02-11 14:38:03 +0100
committerWerner Koch <wk@gnupg.org>2020-02-11 14:40:54 +0100
commit24095101a5069f15a9aea7512498ac436a76814a (patch)
tree58b6e8f20ed4332599cba202003c52062d800b70 /common/openpgp-oid.c
parentdoc: Improve the warning section of the gpg man page. (diff)
downloadgnupg2-24095101a5069f15a9aea7512498ac436a76814a.tar.xz
gnupg2-24095101a5069f15a9aea7512498ac436a76814a.zip
common: Extend the openpgp_curve_to_oid function.
* common/openpgp-oid.c (openpgp_curve_to_oid): Add optional arg R_NBITS. Change all callers. -- In particular for ed25519 and cv25519 it is quite useful to have an ability to get the required algorithm.
Diffstat (limited to 'common/openpgp-oid.c')
-rw-r--r--common/openpgp-oid.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/openpgp-oid.c b/common/openpgp-oid.c
index 925384f3e..8fda23028 100644
--- a/common/openpgp-oid.c
+++ b/common/openpgp-oid.c
@@ -351,13 +351,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)
{
@@ -367,6 +371,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)
@@ -378,6 +383,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;
}
}
@@ -385,6 +391,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;
}