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:
@@ -280,10 +280,14 @@ METHOD(key_exchange_t, set_public_key, bool,
|
||||
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_key_exchange_t *this, chunk_t *secret)
|
||||
{
|
||||
if (this->shared_secret.ptr != NULL)
|
||||
{
|
||||
*secret = chunk_clone(this->shared_secret);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_key_exchange_t *this)
|
||||
|
||||
@@ -941,10 +941,14 @@ METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_key_exchange_t *this, chunk_t *secret)
|
||||
{
|
||||
if (this->shared_secret.ptr != NULL)
|
||||
{
|
||||
*secret = chunk_clone(this->shared_secret);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef TESTABLE_KE
|
||||
|
||||
|
||||
@@ -240,10 +240,14 @@ METHOD(key_exchange_t, set_public_key, bool,
|
||||
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_key_exchange_t *this, chunk_t *secret)
|
||||
{
|
||||
if (this->shared_secret.ptr != NULL)
|
||||
{
|
||||
*secret = chunk_clone(this->shared_secret);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
METHOD(key_exchange_t, get_method, key_exchange_method_t,
|
||||
private_key_exchange_t *this)
|
||||
|
||||
Reference in New Issue
Block a user