summaryrefslogtreecommitdiff
path: root/lib/nettle
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2018-06-07 13:19:55 +0300
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2019-11-07 18:41:28 +0300
commitcdc4fc288d87f91f974aa23b6e8595a53970ce00 (patch)
tree7f18ae166bbe8cde4234e5331ced83c774898047 /lib/nettle
parente9f9d34e276804b2cb721c95032d2aa5c96577b9 (diff)
downloadgnutls-cdc4fc288d87f91f974aa23b6e8595a53970ce00.tar.gz
nettle: add support for GOST key derivation
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Diffstat (limited to 'lib/nettle')
-rw-r--r--lib/nettle/pk.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c
index bfa6ae4372..42d540cb46 100644
--- a/lib/nettle/pk.c
+++ b/lib/nettle/pk.c
@@ -417,6 +417,57 @@ dh_cleanup:
}
break;
}
+#if ENABLE_GOST
+ case GNUTLS_PK_GOST_01:
+ case GNUTLS_PK_GOST_12_256:
+ case GNUTLS_PK_GOST_12_512:
+ {
+ struct ecc_scalar ecc_priv;
+ struct ecc_point ecc_pub;
+ const struct ecc_curve *curve;
+
+ out->data = NULL;
+
+ curve = get_supported_gost_curve(priv->curve);
+ if (curve == NULL)
+ return
+ gnutls_assert_val
+ (GNUTLS_E_ECC_UNSUPPORTED_CURVE);
+
+ if (nonce == NULL)
+ return gnutls_assert_val(GNUTLS_E_INVALID_REQUEST);
+
+ ret = _gost_params_to_pubkey(pub, &ecc_pub, curve);
+ if (ret < 0)
+ return gnutls_assert_val(ret);
+
+ ret = _gost_params_to_privkey(priv, &ecc_priv, curve);
+ if (ret < 0) {
+ ecc_point_clear(&ecc_pub);
+ return gnutls_assert_val(ret);
+ }
+
+ out->size = 2 * gnutls_ecc_curve_get_size(priv->curve);
+ out->data = gnutls_malloc(out->size);
+ if (out->data == NULL) {
+ ret = gnutls_assert_val(GNUTLS_E_MEMORY_ERROR);
+ goto gost_cleanup;
+ }
+
+ out->size = gostdsa_vko(&ecc_priv, &ecc_pub,
+ nonce->size, nonce->data,
+ out->size, out->data);
+ if (out->size == 0)
+ ret = GNUTLS_E_INVALID_REQUEST;
+
+ gost_cleanup:
+ ecc_point_clear(&ecc_pub);
+ ecc_scalar_zclear(&ecc_priv);
+ if (ret < 0)
+ goto cleanup;
+ break;
+ }
+#endif
default:
gnutls_assert();
ret = GNUTLS_E_INTERNAL_ERROR;