Example for the mcuxClFfdh component.
#include <mcuxClToolchain.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClExample_RNG_Helper.h>
#define MAX_CPUWA_SIZE (MCUXCLKEY_AGREEMENT_FFDH_WACPU_SIZE_2048)
#define MAX_PKCWA_SIZE (MCUXCLKEY_AGREEMENT_FFDH_WAPKC_SIZE_2048)
static const ALIGNED uint8_t pAlicePrivKeyData[MCUXCLFFDH_FFDHE2048_SIZE_PRIVATEKEY] = {
0x04U, 0x88U, 0xEBU, 0x17U, 0x58U, 0x28U, 0x96U, 0xAEU, 0x35U, 0x5EU, 0x1AU, 0x4BU, 0x38U, 0x85U, 0x2AU, 0xBCU,
0xCDU, 0x03U, 0xC6U, 0xC2U, 0xEBU, 0x51U, 0x6CU, 0x50U, 0x40U, 0xD2U, 0x68U, 0xCFU, 0x62U, 0x18U, 0x32U, 0x70U,
0x75U, 0x5DU, 0xA4U, 0xDBU, 0xE9U, 0xAFU, 0xACU, 0x3DU, 0x0DU, 0x32U, 0x52U, 0x6AU, 0x1CU, 0xAFU, 0x2FU, 0xDAU,
0x17U, 0xBEU, 0x7AU, 0xDAU, 0x30U, 0x12U, 0x11U, 0x73U, 0x36U, 0xFCU, 0xFAU, 0x12U, 0xFEU, 0xB1U, 0x34U, 0x99U,
0x00U, 0x7DU, 0xDEU, 0xCCU, 0x08U, 0xA3U, 0xE5U, 0x37U, 0x92U, 0x6BU, 0xE2U, 0xF8U, 0x15U, 0x1FU, 0x19U, 0x0DU,
0x18U, 0x70U, 0xBBU, 0xD8U, 0x54U, 0xA1U, 0x54U, 0x3BU, 0x69U, 0x1DU, 0x2BU, 0xAAU, 0xC2U, 0x82U, 0x2BU, 0x89U,
0x40U, 0x47U, 0xE5U, 0x14U, 0x81U, 0x06U, 0xF0U, 0x25U, 0xACU, 0x9AU, 0x7AU, 0x50U, 0x76U, 0x09U, 0xD8U, 0xD9U,
0xDDU, 0xC2U, 0x52U, 0x5FU, 0x61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, 0x5EU, 0x1BU, 0x18U, 0xC6U
};
MCUXCLEXAMPLE_FUNCTION(mcuxClFfdh_KeyAgreement_ffdhe2048_example)
{
mcuxClSession_Descriptor_t sessionDesc;
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(session, MAX_CPUWA_SIZE, MAX_PKCWA_SIZE);
uint32_t alicePrivKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE_IN_WORDS];
MCUX_CSSL_ANALYSIS_START_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
MCUX_CSSL_ANALYSIS_STOP_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
session,
alicePrivKey,
pAlicePrivKeyData,
MCUXCLFFDH_FFDHE2048_SIZE_PRIVATEKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t alicePubKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE_IN_WORDS];
MCUX_CSSL_ANALYSIS_START_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
MCUX_CSSL_ANALYSIS_STOP_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
session,
alicePubKey,
pAlicePubKeyData,
MCUXCLFFDH_FFDHE2048_SIZE_PUBLICKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t bobPrivKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE_IN_WORDS];
MCUX_CSSL_ANALYSIS_START_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
MCUX_CSSL_ANALYSIS_STOP_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
session,
bobPrivKey,
pBobPrivKeyData,
MCUXCLFFDH_FFDHE2048_SIZE_PRIVATEKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t bobPubKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE_IN_WORDS];
MCUX_CSSL_ANALYSIS_START_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
MCUX_CSSL_ANALYSIS_STOP_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
session,
bobPubKey,
pBobPubKeyData,
MCUXCLFFDH_FFDHE2048_SIZE_PUBLICKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
MCUXCLEXAMPLE_INITIALIZE_PRNG(session);
uint8_t aliceSharedSecret[MCUXCLFFDH_FFDHE2048_SIZE_SHAREDSECRET];
uint32_t aliceSharedSecretSize = 0u;
session,
alicePrivKey,
bobPubKey,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_NULL_POINTER_CONSTANT("NULL is used in code")
NULL,
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_NULL_POINTER_CONSTANT()
0U,
aliceSharedSecret,
&aliceSharedSecretSize));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint8_t bobSharedSecret[MCUXCLFFDH_FFDHE2048_SIZE_SHAREDSECRET];
uint32_t bobSharedSecretSize = 0u;
session,
bobPrivKey,
alicePubKey,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_NULL_POINTER_CONSTANT("NULL is used in code")
NULL,
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_NULL_POINTER_CONSTANT()
0U,
bobSharedSecret,
&bobSharedSecretSize));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(!mcuxClCore_assertEqual(bobSharedSecret, aliceSharedSecret, MCUXCLFFDH_FFDHE2048_SIZE_SHAREDSECRET))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(!mcuxClExample_Session_Clean(session))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
return MCUXCLEXAMPLE_STATUS_OK;
}
Definition of function identifiers for the flow protection mechanism.
Top level header of mcuxClFfdh component.
Top-level include file for the mcuxClKey component.
Top level header of mcuxClRandom component.
Top-level include file for the mcuxClSession component.
Provides the API for the CSSL flow protection mechanism.
static const mcuxClKey_Type_t mcuxClKey_Type_Ffdh_ffdhe2048_Priv
Key type pointer for private FFDHE2048 keys.
Definition mcuxClFfdh_KeyTypes.h:66
static const mcuxClKey_Type_t mcuxClKey_Type_Ffdh_ffdhe2048_Pub
Key type pointer for public FFDHE2048 keys.
Definition mcuxClFfdh_KeyTypes.h:52
static mcuxClKey_Agreement_t mcuxClKey_Agreement_FFDH
FFDH Key agreement algorithm.
Definition mcuxClFfdh_KeyTypes.h:222
#define MCUXCLKEY_STATUS_OK
Key operation successful.
Definition mcuxClKey_Constants.h:40
mcuxClKey_Status_t mcuxClKey_init(mcuxClSession_Handle_t session, mcuxClKey_Handle_t key, mcuxClKey_Type_t type, const uint8_t *pKeyData, uint32_t keyDataLength)
Initializes a key handle.
mcuxClKey_Status_t mcuxClKey_agreement(mcuxClSession_Handle_t session, mcuxClKey_Agreement_t agreement, mcuxClKey_Handle_t key, mcuxClKey_Handle_t otherKey, mcuxClKey_Agreement_AdditionalInput_t additionalInputs[], uint32_t numberOfInputs, uint8_t *pOut, uint32_t *const pOutLength)
Key agreement function.
mcuxClKey_Descriptor_t *const mcuxClKey_Handle_t
Key handle type.
Definition mcuxClKey_Types.h:91
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:98
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition mcuxCsslFlowProtection.h:623
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:777
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition mcuxCsslFlowProtection.h:658