summaryrefslogtreecommitdiff
path: root/lib/algorithms/ecc.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-04-27 12:12:06 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-04-27 16:14:16 +0200
commitd95d4a4f3abbc54c7d03872d7bf0987be61c1051 (patch)
tree97161051903b1b3039876335c5a2f30cd1f81da4 /lib/algorithms/ecc.c
parentcacb61d6885eef58f09da7fd958496a11e2000c5 (diff)
downloadgnutls-eddsa2.tar.gz
Added support for generating and reading EdDSA/Ed25519 keyseddsa2
This adds support for draft-ietf-curdle-pkix-00
Diffstat (limited to 'lib/algorithms/ecc.c')
-rw-r--r--lib/algorithms/ecc.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/algorithms/ecc.c b/lib/algorithms/ecc.c
index 9d0c584b0a..bac5466c99 100644
--- a/lib/algorithms/ecc.c
+++ b/lib/algorithms/ecc.c
@@ -77,6 +77,14 @@ static const gnutls_ecc_curve_entry_st ecc_curves[] = {
.pk = GNUTLS_PK_ECDHX,
.size = 32,
},
+ {
+ .name = "Ed25519ph",
+ .oid = "1.3.101.112",
+ .id = GNUTLS_ECC_CURVE_ED25519PH,
+ .pk = GNUTLS_PK_EDDSA,
+ .size = 32,
+ .sig_size = 64
+ },
{0, 0, 0}
};
@@ -159,7 +167,7 @@ gnutls_ecc_curve_t gnutls_oid_to_ecc_curve(const char *oid)
gnutls_ecc_curve_t ret = GNUTLS_ECC_CURVE_INVALID;
GNUTLS_ECC_CURVE_LOOP(
- if (strcasecmp(p->oid, oid) == 0 && _gnutls_pk_curve_exists(p->id)) {
+ if (p->oid != NULL && strcasecmp(p->oid, oid) == 0 && _gnutls_pk_curve_exists(p->id)) {
ret = p->id;
break;
}
@@ -200,12 +208,17 @@ gnutls_ecc_curve_t gnutls_ecc_curve_get_id(const char *name)
* Returns: return a #gnutls_ecc_curve_t value corresponding to
* the specified bit length, or %GNUTLS_ECC_CURVE_INVALID on error.
-*/
-gnutls_ecc_curve_t _gnutls_ecc_bits_to_curve(int bits)
+gnutls_ecc_curve_t _gnutls_ecc_bits_to_curve(gnutls_pk_algorithm_t pk, int bits)
{
- gnutls_ecc_curve_t ret = GNUTLS_ECC_CURVE_SECP256R1;
+ gnutls_ecc_curve_t ret;
+
+ if (pk == GNUTLS_PK_ECDSA)
+ ret = GNUTLS_ECC_CURVE_SECP256R1;
+ else
+ ret = GNUTLS_ECC_CURVE_ED25519PH;
GNUTLS_ECC_CURVE_LOOP(
- if (8 * p->size >= bits && _gnutls_pk_curve_exists(p->id)) {
+ if (pk == p->pk && 8 * p->size >= (unsigned)bits && _gnutls_pk_curve_exists(p->id)) {
ret = p->id;
break;
}