diffie-hellman: Add a bool return value to set_other_public_value()
This commit is contained in:
@@ -81,7 +81,7 @@ struct private_pkcs11_dh_t {
|
||||
*
|
||||
* If this succeeds the shared secret is stored in this->secret.
|
||||
*/
|
||||
static void derive_secret(private_pkcs11_dh_t *this, chunk_t other)
|
||||
static bool derive_secret(private_pkcs11_dh_t *this, chunk_t other)
|
||||
{
|
||||
CK_OBJECT_CLASS klass = CKO_SECRET_KEY;
|
||||
CK_KEY_TYPE type = CKK_GENERIC_SECRET;
|
||||
@@ -102,17 +102,18 @@ static void derive_secret(private_pkcs11_dh_t *this, chunk_t other)
|
||||
if (rv != CKR_OK)
|
||||
{
|
||||
DBG1(DBG_CFG, "C_DeriveKey() error: %N", ck_rv_names, rv);
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
if (!this->lib->get_ck_attribute(this->lib, this->session, secret,
|
||||
CKA_VALUE, &this->secret))
|
||||
{
|
||||
chunk_free(&this->secret);
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, set_other_public_value, void,
|
||||
METHOD(diffie_hellman_t, set_other_public_value, bool,
|
||||
private_pkcs11_dh_t *this, chunk_t value)
|
||||
{
|
||||
switch (this->group)
|
||||
@@ -137,7 +138,7 @@ METHOD(diffie_hellman_t, set_other_public_value, void,
|
||||
if (!lib->settings->get_bool(lib->settings,
|
||||
"%s.ecp_x_coordinate_only", TRUE, lib->ns))
|
||||
{ /* we only get the x coordinate back */
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
value = chunk_from_thing(params);
|
||||
break;
|
||||
@@ -145,7 +146,7 @@ METHOD(diffie_hellman_t, set_other_public_value, void,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
derive_secret(this, value);
|
||||
return derive_secret(this, value);
|
||||
}
|
||||
|
||||
METHOD(diffie_hellman_t, get_my_public_value, bool,
|
||||
@@ -444,4 +445,3 @@ pkcs11_dh_t *pkcs11_dh_create(diffie_hellman_group_t group,
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user