Remove the ecp_x_coordinate_only option
This was for compatibility with very old releases and only complicates things unnecessarily nowadays.
This commit is contained in:
@@ -129,9 +129,6 @@ charon.dns2
|
|||||||
charon.dos_protection = yes
|
charon.dos_protection = yes
|
||||||
Enable Denial of Service protection using cookies and aggressiveness checks.
|
Enable Denial of Service protection using cookies and aggressiveness checks.
|
||||||
|
|
||||||
charon.ecp_x_coordinate_only = yes
|
|
||||||
Compliance with the errata for RFC 4753.
|
|
||||||
|
|
||||||
charon.flush_auth_cfg = no
|
charon.flush_auth_cfg = no
|
||||||
Free objects during authentication (might conflict with plugins).
|
Free objects during authentication (might conflict with plugins).
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ error:
|
|||||||
* the point. This function allocates memory for the chunk.
|
* the point. This function allocates memory for the chunk.
|
||||||
*/
|
*/
|
||||||
static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
|
static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
|
||||||
chunk_t *chunk, bool x_coordinate_only)
|
chunk_t *chunk)
|
||||||
{
|
{
|
||||||
BN_CTX *ctx;
|
BN_CTX *ctx;
|
||||||
BIGNUM *x, *y;
|
BIGNUM *x, *y;
|
||||||
@@ -145,10 +145,6 @@ static bool ecp2chunk(const EC_GROUP *group, const EC_POINT *point,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x_coordinate_only)
|
|
||||||
{
|
|
||||||
y = NULL;
|
|
||||||
}
|
|
||||||
if (!openssl_bn_cat(EC_FIELD_ELEMENT_LEN(group), x, y, chunk))
|
if (!openssl_bn_cat(EC_FIELD_ELEMENT_LEN(group), x, y, chunk))
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
@@ -167,66 +163,18 @@ error:
|
|||||||
static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this,
|
static bool compute_shared_key(private_openssl_ec_diffie_hellman_t *this,
|
||||||
chunk_t *shared_secret)
|
chunk_t *shared_secret)
|
||||||
{
|
{
|
||||||
const BIGNUM *priv_key;
|
|
||||||
EC_POINT *secret = NULL;
|
|
||||||
bool x_coordinate_only, ret = FALSE;
|
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
/*
|
*shared_secret = chunk_alloc(EC_FIELD_ELEMENT_LEN(this->ec_group));
|
||||||
* The default setting ecp_x_coordinate_only = TRUE
|
len = ECDH_compute_key(shared_secret->ptr, shared_secret->len,
|
||||||
* applies the following errata for RFC 4753:
|
this->pub_key, this->key, NULL);
|
||||||
* http://www.rfc-editor.org/errata_search.php?eid=9
|
if (len <= 0)
|
||||||
* ECDH_compute_key() is used under this setting as
|
|
||||||
* it also facilitates hardware offload through the use of
|
|
||||||
* dynamic engines in OpenSSL.
|
|
||||||
*/
|
|
||||||
x_coordinate_only = lib->settings->get_bool(lib->settings,
|
|
||||||
"%s.ecp_x_coordinate_only", TRUE, lib->ns);
|
|
||||||
if (x_coordinate_only)
|
|
||||||
{
|
{
|
||||||
*shared_secret = chunk_alloc(EC_FIELD_ELEMENT_LEN(this->ec_group));
|
chunk_free(shared_secret);
|
||||||
len = ECDH_compute_key(shared_secret->ptr, shared_secret->len,
|
return FALSE;
|
||||||
this->pub_key, this->key, NULL);
|
|
||||||
if (len <= 0)
|
|
||||||
{
|
|
||||||
chunk_free(shared_secret);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
shared_secret->len = len;
|
|
||||||
}
|
}
|
||||||
else
|
shared_secret->len = len;
|
||||||
{
|
return TRUE;
|
||||||
priv_key = EC_KEY_get0_private_key(this->key);
|
|
||||||
if (!priv_key)
|
|
||||||
{
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
secret = EC_POINT_new(this->ec_group);
|
|
||||||
if (!secret)
|
|
||||||
{
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!EC_POINT_mul(this->ec_group, secret, NULL, this->pub_key, priv_key,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ecp2chunk(this->ec_group, secret, shared_secret, x_coordinate_only))
|
|
||||||
{
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = TRUE;
|
|
||||||
error:
|
|
||||||
if (secret)
|
|
||||||
{
|
|
||||||
EC_POINT_clear_free(secret);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||||
@@ -257,7 +205,7 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
|||||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||||
private_openssl_ec_diffie_hellman_t *this,chunk_t *value)
|
private_openssl_ec_diffie_hellman_t *this,chunk_t *value)
|
||||||
{
|
{
|
||||||
ecp2chunk(this->ec_group, EC_KEY_get0_public_key(this->key), value, FALSE);
|
ecp2chunk(this->ec_group, EC_KEY_get0_public_key(this->key), value);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -139,12 +139,6 @@ METHOD(diffie_hellman_t, set_other_public_value, bool,
|
|||||||
pubkey.len,
|
pubkey.len,
|
||||||
pubkey.ptr,
|
pubkey.ptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!lib->settings->get_bool(lib->settings,
|
|
||||||
"%s.ecp_x_coordinate_only", TRUE, lib->ns))
|
|
||||||
{ /* we only get the x coordinate back */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
value = chunk_from_thing(params);
|
value = chunk_from_thing(params);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,6 @@ static bool compute_shared_key(private_wolfssl_ec_diffie_hellman_t *this,
|
|||||||
ecc_point *pub_key, chunk_t *shared_secret)
|
ecc_point *pub_key, chunk_t *shared_secret)
|
||||||
{
|
{
|
||||||
ecc_point* secret;
|
ecc_point* secret;
|
||||||
bool x_coordinate_only;
|
|
||||||
bool success = FALSE;
|
bool success = FALSE;
|
||||||
|
|
||||||
if ((secret = wc_ecc_new_point()) == NULL)
|
if ((secret = wc_ecc_new_point()) == NULL)
|
||||||
@@ -163,15 +162,7 @@ static bool compute_shared_key(private_wolfssl_ec_diffie_hellman_t *this,
|
|||||||
|
|
||||||
if (wolfssl_ecc_multiply(this->key.dp, &this->key.k, pub_key, secret))
|
if (wolfssl_ecc_multiply(this->key.dp, &this->key.k, pub_key, secret))
|
||||||
{
|
{
|
||||||
/*
|
success = ecp2chunk(this->keysize, secret, shared_secret, TRUE);
|
||||||
* The default setting ecp_x_coordinate_only = TRUE
|
|
||||||
* applies the following errata for RFC 4753:
|
|
||||||
* http://www.rfc-editor.org/errata_search.php?eid=9
|
|
||||||
*/
|
|
||||||
x_coordinate_only = lib->settings->get_bool(lib->settings,
|
|
||||||
"%s.ecp_x_coordinate_only", TRUE, lib->ns);
|
|
||||||
success = ecp2chunk(this->keysize, secret, shared_secret,
|
|
||||||
x_coordinate_only);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wc_ecc_del_point(secret);
|
wc_ecc_del_point(secret);
|
||||||
|
|||||||
Reference in New Issue
Block a user