Send crypto tokens after handshake is completely finished

Signed-off-by: Marcel Jordense <marcel.jordense@adlinktech.com>
This commit is contained in:
Marcel Jordense 2020-03-26 18:51:01 +01:00 committed by eboasson
parent a77fe10a04
commit 9175f44273
6 changed files with 86 additions and 21 deletions

View file

@ -1998,3 +1998,27 @@ invalid_handle:
CRYPTO_OBJECT_RELEASE(obj);
return result;
}
master_key_material *
crypto_factory_get_master_key_material_for_test(
const dds_security_crypto_key_factory *factory,
DDS_Security_ParticipantCryptoHandle local_id,
DDS_Security_ParticipantCryptoHandle remote_id)
{
dds_security_crypto_key_factory_impl *impl = (dds_security_crypto_key_factory_impl *)factory;
remote_participant_crypto *rmt_cr = (remote_participant_crypto *)crypto_object_table_find(impl->crypto_objects, remote_id);
participant_key_material *keymat;
master_key_material *master_keymat = NULL;
if (rmt_cr)
{
keymat = crypto_remote_participant_lookup_keymat(rmt_cr, local_id);
if (keymat)
{
master_keymat = keymat->local_P2P_key_material;
CRYPTO_OBJECT_RELEASE(keymat);
}
}
return master_keymat;
}

View file

@ -14,6 +14,7 @@
#include "dds/security/dds_security_api.h"
#include "crypto_objects.h"
#include "dds/security/export.h"
/**
* @brief Allocation function for implementer structure (with internal variables) transparently.
@ -158,4 +159,10 @@ crypto_factory_get_specific_keymat(
uint32_t *index,
master_key_material **key_mat);
SECURITY_EXPORT master_key_material *
crypto_factory_get_master_key_material_for_test(
const dds_security_crypto_key_factory *factory,
DDS_Security_ParticipantCryptoHandle local_id,
DDS_Security_ParticipantCryptoHandle remote_id);
#endif /* CRYPTO_KEY_FACTORY_H */

View file

@ -28,6 +28,7 @@
#include "CUnit/Test.h"
#include "common/src/loader.h"
#include "common/src/crypto_helper.h"
#include "crypto_key_factory.h"
#include "crypto_objects.h"
#include "crypto_utils.h"
@ -571,18 +572,7 @@ static session_key_material * get_local_participant_session(DDS_Security_Partici
static master_key_material * get_remote_participant_key_material(DDS_Security_ParticipantCryptoHandle participant_crypto)
{
participant_key_material *key_material;
master_key_material * master_keymat = NULL;
remote_participant_crypto *participant_crypto_impl = (remote_participant_crypto *)participant_crypto;
key_material = crypto_remote_participant_lookup_keymat(participant_crypto_impl, local_particpant_crypto);
if (key_material)
{
master_keymat = key_material->local_P2P_key_material;
CRYPTO_OBJECT_RELEASE(key_material);
}
return master_keymat;
return crypto_factory_get_master_key_material_for_test(crypto->crypto_key_factory, local_particpant_crypto, participant_crypto);
}
static void set_protection_kind(DDS_Security_ParticipantCryptoHandle participant_crypto, DDS_Security_ProtectionKind protection_kind)