Example for the mcuxClEcc component curve448 related functions.
#include <mcuxClToolchain.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClExample_RNG_Helper.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_ELS_Helper.h>
#if MCUXCLECC_MONTDH_GENERATEKEYPAIR_CURVE448_WACPU_SIZE >= MCUXCLECC_MONTDH_KEYAGREEMENT_CURVE448_WACPU_SIZE
#define MAX_CPUWA_SIZE MCUXCLECC_MONTDH_GENERATEKEYPAIR_CURVE448_WACPU_SIZE
#else
#define MAX_CPUWA_SIZE MCUXCLECC_MONTDH_KEYAGREEMENT_CURVE448_WACPU_SIZE
#endif
#if MCUXCLECC_MONTDH_GENERATEKEYPAIR_CURVE448_WAPKC_SIZE >= MCUXCLECC_MONTDH_KEYAGREEMENT_CURVE448_WAPKC_SIZE
#define MAX_PKCWA_SIZE MCUXCLECC_MONTDH_GENERATEKEYPAIR_CURVE448_WAPKC_SIZE
#else
#define MAX_PKCWA_SIZE MCUXCLECC_MONTDH_KEYAGREEMENT_CURVE448_WAPKC_SIZE
#endif
MCUXCLEXAMPLE_FUNCTION(mcuxClEcc_MontDH_Curve448_example)
{
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(&session, MAX_CPUWA_SIZE, MAX_PKCWA_SIZE);
#if defined(MCUXCL_FEATURE_RANDOMMODES_SECSTRENGTH_256) && defined(MCUXCL_FEATURE_RANDOMMODES_CTRDRBG) && defined(MCUXCL_FEATURE_RANDOMMODES_PR_DISABLED) && defined(MCUXCL_FEATURE_RANDOMMODES_NORMALMODE)
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_RNG(&session, MCUXCLRANDOMMODES_CTR_DRBG_AES256_CONTEXT_SIZE, mcuxClRandomModes_Mode_CtrDrbg_AES256_DRG3);
#else
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_RNG(&session, 0u, mcuxClRandomModes_Mode_ELS_Drbg);
#endif
ALIGNED uint8_t alicePrivKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE];
ALIGNED uint8_t alicePrivKeyBuffer[MCUXCLECC_MONTDH_CURVE448_SIZE_PRIVATEKEY]={0};
&session,
alicePrivKeyHandler,
alicePrivKeyBuffer,
MCUXCLECC_MONTDH_CURVE448_SIZE_PRIVATEKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
ALIGNED uint8_t alicePubKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE];
ALIGNED uint8_t alicePubKeyBuffer[MCUXCLECC_MONTDH_CURVE448_SIZE_PUBLICKEY]={0};
&session,
alicePubKeyHandler,
alicePubKeyBuffer,
MCUXCLECC_MONTDH_CURVE448_SIZE_PUBLICKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
ALIGNED uint8_t bobPrivKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE];
ALIGNED uint8_t bobPrivKeyBuffer[MCUXCLECC_MONTDH_CURVE448_SIZE_PRIVATEKEY]={0};
&session,
bobPrivKeyHandler,
bobPrivKeyBuffer,
MCUXCLECC_MONTDH_CURVE448_SIZE_PRIVATEKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
ALIGNED uint8_t bobPubKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE];
ALIGNED uint8_t bobPubKeyBuffer[MCUXCLECC_MONTDH_CURVE448_SIZE_PUBLICKEY]={0};
&session,
bobPubKeyHandler,
bobPubKeyBuffer,
MCUXCLECC_MONTDH_CURVE448_SIZE_PUBLICKEY));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
alicePrivKeyHandler,
alicePubKeyHandler) );
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
bobPrivKeyHandler,
bobPubKeyHandler) );
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
ALIGNED uint8_t aliceSharedSecret[MCUXCLECC_MONTDH_CURVE448_SIZE_SHAREDSECRET];
uint32_t aliceSharedSecretSize;
alicePrivKeyHandler,
bobPubKeyHandler,
aliceSharedSecret,
&aliceSharedSecretSize)
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
ALIGNED uint8_t bobSharedSecret[MCUXCLECC_MONTDH_CURVE448_SIZE_SHAREDSECRET];
uint32_t bobSharedSecretSize;
bobPrivKeyHandler,
alicePubKeyHandler,
bobSharedSecret,
&bobSharedSecretSize)
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
for(size_t i = 0u; i < MCUXCLECC_MONTDH_CURVE448_SIZE_SHAREDSECRET; i++)
{
if(bobSharedSecret[i] != aliceSharedSecret[i])
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
}
if(!mcuxClExample_Session_Clean(&session))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(!mcuxClExample_Els_Disable())
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
return MCUXCLEXAMPLE_STATUS_OK;
}
static mcuxClEls_EccByte_t ecc_public_key_client[MCUXCLELS_ECC_PUBLICKEY_SIZE] ALIGNED
Destination buffer to receive the public key of the mcuxClEls_EccKeyGen_Async operation.
Definition mcuxClEls_Tls_Master_Key_Session_Keys_example.c:33
Definition of function identifiers for the flow protection mechanism.
Top level header of mcuxClEcc component.
Top-level include file for the mcuxClKey component.
Type definitions of mcuxClPkc component.
Top level header of mcuxClRandomModes component.
Provides the API for the CSSL flow protection mechanism.
mcuxClEcc_Status_t mcuxClEcc_MontDH_KeyAgreement(mcuxClSession_Handle_t pSession, mcuxClKey_Handle_t key, mcuxClKey_Handle_t otherKey, uint8_t *pOut, uint32_t *const pOutLength)
Implements the MontDH key agreement according to rfc7748.
mcuxClEcc_Status_t mcuxClEcc_MontDH_GenerateKeyPair(mcuxClSession_Handle_t pSession, mcuxClKey_Handle_t privKey, mcuxClKey_Handle_t pubKey)
implements ECC key pair generation step for a MontDH key agreement according to rfc7748.
static const mcuxClKey_Type_t mcuxClKey_Type_Ecc_MontDH_Curve448_PrivateKey
Private key type pointer for ECC MontDH Curve448.
Definition mcuxClEcc_KeyTypes.h:1048
static const mcuxClKey_Type_t mcuxClKey_Type_Ecc_MontDH_Curve448_PublicKey
Public key type pointer for ECC MontDH Curve448.
Definition mcuxClEcc_KeyTypes.h:1056
#define MCUXCLELS_RESET_DO_NOT_CANCEL
Set this option at mcuxClEls_ResetOption_t to abort the requested command if another ELS operation is...
Definition mcuxClEls_Common.h:119
#define MCUXCLKEY_STATUS_OK
Key operation successful.
Definition mcuxClKey_Constants.h:39
mcuxClKey_Status_t mcuxClKey_init(mcuxClSession_Handle_t pSession, mcuxClKey_Handle_t key, mcuxClKey_Type_t type, const uint8_t *pKeyData, uint32_t keyDataLength)
Initializes a key handle.
mcuxClKey_Descriptor_t *const mcuxClKey_Handle_t
Key handle type.
Definition mcuxClKey_Types.h:88
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition mcuxCsslFlowProtection.h:581
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:735
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition mcuxCsslFlowProtection.h:616
#define MCUXCLECC_STATUS_OK
Operation was successful.
Definition mcuxClEcc_Constants.h:47
Structure for mcuxClSession Descriptor.
Definition mcuxClSession_Types.h:121