summaryrefslogtreecommitdiff
path: root/lib/nettle/pk.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nettle/pk.c')
-rw-r--r--lib/nettle/pk.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/lib/nettle/pk.c b/lib/nettle/pk.c
index 794a2c99be..826c27b064 100644
--- a/lib/nettle/pk.c
+++ b/lib/nettle/pk.c
@@ -89,11 +89,12 @@ _ecc_params_to_privkey(const gnutls_pk_params_st * pk_params,
memcpy(&priv->prime, pk_params->params[0], sizeof(mpz_t));
memcpy(&priv->order, pk_params->params[1], sizeof(mpz_t));
memcpy(&priv->A, pk_params->params[2], sizeof(mpz_t));
- memcpy(&priv->Gx, pk_params->params[3], sizeof(mpz_t));
- memcpy(&priv->Gy, pk_params->params[4], sizeof(mpz_t));
- memcpy(&priv->pubkey.x, pk_params->params[5], sizeof(mpz_t));
- memcpy(&priv->pubkey.y, pk_params->params[6], sizeof(mpz_t));
- memcpy(&priv->k, pk_params->params[7], sizeof(mpz_t));
+ memcpy(&priv->B, pk_params->params[3], sizeof(mpz_t));
+ memcpy(&priv->Gx, pk_params->params[4], sizeof(mpz_t));
+ memcpy(&priv->Gy, pk_params->params[5], sizeof(mpz_t));
+ memcpy(&priv->pubkey.x, pk_params->params[6], sizeof(mpz_t));
+ memcpy(&priv->pubkey.y, pk_params->params[7], sizeof(mpz_t));
+ memcpy(&priv->k, pk_params->params[8], sizeof(mpz_t));
mpz_init_set_ui(priv->pubkey.z, 1);
}
@@ -110,10 +111,11 @@ _ecc_params_to_pubkey(const gnutls_pk_params_st * pk_params,
memcpy(&pub->prime, pk_params->params[0], sizeof(mpz_t));
memcpy(&pub->order, pk_params->params[1], sizeof(mpz_t));
memcpy(&pub->A, pk_params->params[2], sizeof(mpz_t));
- memcpy(&pub->Gx, pk_params->params[3], sizeof(mpz_t));
- memcpy(&pub->Gy, pk_params->params[4], sizeof(mpz_t));
- memcpy(&pub->pubkey.x, pk_params->params[5], sizeof(mpz_t));
- memcpy(&pub->pubkey.y, pk_params->params[6], sizeof(mpz_t));
+ memcpy(&pub->B, pk_params->params[3], sizeof(mpz_t));
+ memcpy(&pub->Gx, pk_params->params[4], sizeof(mpz_t));
+ memcpy(&pub->Gy, pk_params->params[5], sizeof(mpz_t));
+ memcpy(&pub->pubkey.x, pk_params->params[6], sizeof(mpz_t));
+ memcpy(&pub->pubkey.y, pk_params->params[7], sizeof(mpz_t));
mpz_init_set_ui(pub->pubkey.z, 1);
}
@@ -138,6 +140,12 @@ static int _wrap_nettle_pk_derive(gnutls_pk_algorithm_t algo, gnutls_datum_t * o
_ecc_params_to_pubkey(pub, &ecc_pub);
_ecc_params_to_privkey(priv, &ecc_priv);
+
+ if (ecc_projective_check_point(&ecc_pub.pubkey, pub->params[3], pub->params[0]) != 0)
+ {
+ ret = gnutls_assert_val(GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER);
+ goto ecc_cleanup;
+ }
sz = ECC_BUF_SIZE;
out->data = gnutls_malloc(sz);
@@ -792,6 +800,7 @@ rsa_fail:
tls_ecc_set.Gx = st->Gx;
tls_ecc_set.Gy = st->Gy;
tls_ecc_set.A = st->A;
+ tls_ecc_set.B = st->B;
ret = ecc_make_key(NULL, rnd_func, &key, &tls_ecc_set);
if (ret != 0)
@@ -813,11 +822,12 @@ rsa_fail:
mpz_set(TOMPZ(params->params[0]), key.prime);
mpz_set(TOMPZ(params->params[1]), key.order);
mpz_set(TOMPZ(params->params[2]), key.A);
- mpz_set(TOMPZ(params->params[3]), key.Gx);
- mpz_set(TOMPZ(params->params[4]), key.Gy);
- mpz_set(TOMPZ(params->params[5]), key.pubkey.x);
- mpz_set(TOMPZ(params->params[6]), key.pubkey.y);
- mpz_set(TOMPZ(params->params[7]), key.k);
+ mpz_set(TOMPZ(params->params[3]), key.B);
+ mpz_set(TOMPZ(params->params[4]), key.Gx);
+ mpz_set(TOMPZ(params->params[5]), key.Gy);
+ mpz_set(TOMPZ(params->params[6]), key.pubkey.x);
+ mpz_set(TOMPZ(params->params[7]), key.pubkey.y);
+ mpz_set(TOMPZ(params->params[8]), key.k);
ecc_fail:
ecc_free(&key);