Make sure KEM implementations don't return an empty shared secret
If `set_public_key` is never called we won't have a shared secret to return. This aligns the implementations with the one in the openssl plugin.
This commit is contained in:
@@ -281,8 +281,12 @@ METHOD(key_exchange_t, set_public_key, bool,
|
|||||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||||
private_key_exchange_t *this, chunk_t *secret)
|
private_key_exchange_t *this, chunk_t *secret)
|
||||||
{
|
{
|
||||||
*secret = chunk_clone(this->shared_secret);
|
if (this->shared_secret.ptr != NULL)
|
||||||
return TRUE;
|
{
|
||||||
|
*secret = chunk_clone(this->shared_secret);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||||
|
|||||||
@@ -942,8 +942,12 @@ METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
|||||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||||
private_key_exchange_t *this, chunk_t *secret)
|
private_key_exchange_t *this, chunk_t *secret)
|
||||||
{
|
{
|
||||||
*secret = chunk_clone(this->shared_secret);
|
if (this->shared_secret.ptr != NULL)
|
||||||
return TRUE;
|
{
|
||||||
|
*secret = chunk_clone(this->shared_secret);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TESTABLE_KE
|
#ifdef TESTABLE_KE
|
||||||
|
|||||||
@@ -241,8 +241,12 @@ METHOD(key_exchange_t, set_public_key, bool,
|
|||||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||||
private_key_exchange_t *this, chunk_t *secret)
|
private_key_exchange_t *this, chunk_t *secret)
|
||||||
{
|
{
|
||||||
*secret = chunk_clone(this->shared_secret);
|
if (this->shared_secret.ptr != NULL)
|
||||||
return TRUE;
|
{
|
||||||
|
*secret = chunk_clone(this->shared_secret);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||||
|
|||||||
Reference in New Issue
Block a user