summaryrefslogtreecommitdiff
path: root/lib/pubkey.c
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2019-04-22 08:27:43 +0200
committerDaiki Ueno <dueno@redhat.com>2020-01-23 07:07:22 +0100
commit07596231f2e4b3c28d1587907ce51fe15c2d990a (patch)
treebc1b94b9ad3c1fe5548510580d05ca00b280b30d /lib/pubkey.c
parentaf5e42aba4294ce09a263573febe840e804cf1ed (diff)
downloadgnutls-07596231f2e4b3c28d1587907ce51fe15c2d990a.tar.gz
algorithms: implement X448 key exchange and Ed448 signature scheme
Signed-off-by: Daiki Ueno <dueno@redhat.com>
Diffstat (limited to 'lib/pubkey.c')
-rw-r--r--lib/pubkey.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/pubkey.c b/lib/pubkey.c
index 3b4d7f9003..eb7fdbaa82 100644
--- a/lib/pubkey.c
+++ b/lib/pubkey.c
@@ -61,6 +61,7 @@ unsigned pubkey_to_bits(const gnutls_pk_params_st * params)
return _gnutls_mpi_get_nbits(params->params[DSA_P]);
case GNUTLS_PK_ECDSA:
case GNUTLS_PK_EDDSA_ED25519:
+ case GNUTLS_PK_EDDSA_ED448:
case GNUTLS_PK_GOST_01:
case GNUTLS_PK_GOST_12_256:
case GNUTLS_PK_GOST_12_512:
@@ -316,6 +317,12 @@ gnutls_pubkey_get_preferred_hash_algorithm(gnutls_pubkey_t key,
ret = 0;
break;
+ case GNUTLS_PK_EDDSA_ED448:
+ if (hash)
+ *hash = GNUTLS_DIG_SHAKE_256;
+
+ ret = 0;
+ break;
case GNUTLS_PK_GOST_01:
case GNUTLS_PK_GOST_12_256:
case GNUTLS_PK_GOST_12_512:
@@ -891,7 +898,8 @@ gnutls_pubkey_export_ecc_raw2(gnutls_pubkey_t key,
if (curve)
*curve = key->params.curve;
- if (key->params.algo == GNUTLS_PK_EDDSA_ED25519) {
+ if (key->params.algo == GNUTLS_PK_EDDSA_ED25519 ||
+ key->params.algo == GNUTLS_PK_EDDSA_ED448) {
if (x) {
ret = _gnutls_set_datum(x, key->params.raw_pub.data, key->params.raw_pub.size);
if (ret < 0)
@@ -1429,7 +1437,16 @@ gnutls_pubkey_import_ecc_raw(gnutls_pubkey_t key,
goto cleanup;
}
- key->params.algo = GNUTLS_PK_EDDSA_ED25519;
+ switch (curve) {
+ case GNUTLS_ECC_CURVE_ED25519:
+ key->params.algo = GNUTLS_PK_EDDSA_ED25519;
+ break;
+ case GNUTLS_ECC_CURVE_ED448:
+ key->params.algo = GNUTLS_PK_EDDSA_ED448;
+ break;
+ default:
+ break;
+ }
key->params.curve = curve;
key->bits = pubkey_to_bits(&key->params);
@@ -2232,6 +2249,7 @@ pubkey_verify_data(const gnutls_sign_entry_st *se,
break;
case GNUTLS_PK_EDDSA_ED25519:
+ case GNUTLS_PK_EDDSA_ED448:
if (_gnutls_pk_verify(se->pk, data, signature, params, sign_params) != 0) {
gnutls_assert();
return GNUTLS_E_PK_SIG_VERIFY_FAILED;