Example for the mcuxClEcc component EdDsa related functions.
#include <mcuxClToolchain.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_RNG_Helper.h>
#include <mcuxClExample_ELS_Helper.h>
#define MAX_CPUWA_SIZE MCUXCLCORE_MAX(MCUXCLCORE_MAX(\
MCUXCLECC_EDDSA_GENERATEKEYPAIR_ED25519_WACPU_SIZE,\
MCUXCLECC_EDDSA_GENERATESIGNATURE_ED25519_WACPU_SIZE),\
MCUXCLECC_EDDSA_VERIFYSIGNATURE_ED25519_WACPU_SIZE)
#define MAX_PKCWA_SIZE MCUXCLCORE_MAX(MCUXCLCORE_MAX(\
MCUXCLECC_EDDSA_GENERATEKEYPAIR_ED25519_WAPKC_SIZE,\
MCUXCLECC_EDDSA_GENERATESIGNATURE_ED25519_WAPKC_SIZE),\
MCUXCLECC_EDDSA_VERIFYSIGNATURE_ED25519_WAPKC_SIZE)
static const ALIGNED uint8_t pMessage[] =
{
0xf7u, 0x26u, 0x93u, 0x6du, 0x19u, 0xc8u, 0x00u, 0x49u,
0x4eu, 0x3fu, 0xdau, 0xffu, 0x20u, 0xb2u, 0x76u, 0xa8u,
};
static const ALIGNED uint8_t pContext[] =
{
0x66u, 0x6fu, 0x6fu
};
{
0x55u, 0xa4u, 0xccu, 0x2fu, 0x70u, 0xa5u, 0x4eu, 0x04u,
0x28u, 0x8cu, 0x5fu, 0x4cu, 0xd1u, 0xe4u, 0x5au, 0x7bu,
0xb5u, 0x20u, 0xb3u, 0x62u, 0x92u, 0x91u, 0x18u, 0x76u,
0xcau, 0xdau, 0x73u, 0x23u, 0x19u, 0x8du, 0xd8u, 0x7au,
0x8bu, 0x36u, 0x95u, 0x0bu, 0x95u, 0x13u, 0x00u, 0x22u,
0x90u, 0x7au, 0x7fu, 0xb7u, 0xc4u, 0xe9u, 0xb2u, 0xd5u,
0xf6u, 0xccu, 0xa6u, 0x85u, 0xa5u, 0x87u, 0xb4u, 0xb2u,
0x1fu, 0x4bu, 0x88u, 0x8eu, 0x4eu, 0x7eu, 0xdbu, 0x0du
};
{
0x03u, 0x05u, 0x33u, 0x4eu, 0x38u, 0x1au, 0xf7u, 0x8fu,
0x14u, 0x1cu, 0xb6u, 0x66u, 0xf6u, 0x19u, 0x9fu, 0x57u,
0xbcu, 0x34u, 0x95u, 0x33u, 0x5au, 0x25u, 0x6au, 0x95u,
0xbdu, 0x2au, 0x55u, 0xbfu, 0x54u, 0x66u, 0x63u, 0xf6u
};
MCUXCLEXAMPLE_FUNCTION(mcuxClEcc_EdDSA_Ed25519ctx_example)
{
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(&session, MAX_CPUWA_SIZE, MAX_PKCWA_SIZE);
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_RNG(&session, 0u, mcuxClRandomModes_Mode_ELS_Drbg);
ALIGNED uint8_t privKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE];
&session,
privKey,
pPrivKeyData,
sizeof(pPrivKeyData)));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
ALIGNED uint8_t pubKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE];
&session,
pubKey,
pPubKeyData,
sizeof(pPubKeyData)));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
&session,
pPrivateKey));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
&session,
privKey,
pubKey));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
&session,
&mcuxClEcc_EdDSA_DomainParams_Ed25519,
pProtocolDesc,
MCUXCLECC_EDDSA_PHFLAG_ZERO,
buffContext,
sizeof(pContext)));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t signatureSize = 0u;
&session,
privKey,
pProtocolDesc,
buffIn,
sizeof(pMessage),
buffSignature,
&signatureSize));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
&session,
pubKey,
pProtocolDesc,
buffIn,
sizeof(pMessage),
buffSignature,
signatureSize
));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(!mcuxClCore_assertEqual((
const uint8_t*)
signature, pRefSignature,
sizeof(pRefSignature)))
{
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
static const ALIGNED uint8_t signature[RSA_KEY_BYTE_LENGTH]
Example value for RSA signature s.
Definition mcuxClRsa_verify_pssverify_sha2_256_example.c:87
Provides the API for the CL buffer types.
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.
#define MCUXCLBUFFER_INIT(name, info, ptr, size)
Initialize an input/output buffer (mcuxCl_Buffer_t).
Definition mcuxClBuffer.h:71
#define MCUXCLBUFFER_INIT_RO(name, info, ptr, size)
Initialize an input buffer (mcuxCl_InputBuffer_t) with plain CPU handling.
Definition mcuxClBuffer.h:88
mcuxClEcc_Status_t mcuxClEcc_EdDSA_GenerateKeyPair(mcuxClSession_Handle_t pSession, const mcuxClEcc_EdDSA_GenerateKeyPairDescriptor_t *mode, mcuxClKey_Handle_t privKey, mcuxClKey_Handle_t pubKey)
This function implements the EdDSA key pair generation for Ed25519 and Ed448 as specified in rfc8032 ...
mcuxClEcc_Status_t mcuxClEcc_EdDSA_GenerateProtocolDescriptor(mcuxClSession_Handle_t pSession, const mcuxClEcc_EdDSA_DomainParams_t *pDomainParams, mcuxClEcc_EdDSA_SignatureProtocolDescriptor_t *pProtocolDescriptor, uint32_t phflag, mcuxCl_InputBuffer_t pContext, uint32_t contextLen)
This function implements the protocol descriptor generation for Ed25519ctx, Ed25519ph,...
mcuxClEcc_Status_t mcuxClEcc_EdDSA_InitPrivKeyInputMode(mcuxClSession_Handle_t pSession, mcuxClEcc_EdDSA_GenerateKeyPairDescriptor_t *mode, const uint8_t *pPrivKey)
This function initializes an EdDSA mode descriptor for EdDSA key pair generation with private key inp...
mcuxClEcc_Status_t mcuxClEcc_EdDSA_VerifySignature(mcuxClSession_Handle_t session, mcuxClKey_Handle_t key, const mcuxClEcc_EdDSA_SignatureProtocolDescriptor_t *mode, mcuxCl_InputBuffer_t pIn, uint32_t inSize, mcuxCl_InputBuffer_t pSignature, uint32_t signatureSize)
This function implements the EdDSA signature verification for Ed25519 and Ed448 as specified in rfc80...
mcuxClEcc_Status_t mcuxClEcc_EdDSA_GenerateSignature(mcuxClSession_Handle_t pSession, mcuxClKey_Handle_t key, const mcuxClEcc_EdDSA_SignatureProtocolDescriptor_t *mode, mcuxCl_InputBuffer_t pIn, uint32_t inSize, mcuxCl_Buffer_t pSignature, uint32_t *const pSignatureSize)
This function implements the EdDSA signature generation for Ed25519 and Ed448 as specified in rfc8032...
static const mcuxClKey_Type_t mcuxClKey_Type_EdDSA_Ed25519_Priv
Key type pointer for ECC EdDSA Ed25519 private keys.
Definition mcuxClEcc_KeyTypes.h:975
static const mcuxClKey_Type_t mcuxClKey_Type_EdDSA_Ed25519_Pub
Key type pointer for ECC EdDSA Ed25519 public keys.
Definition mcuxClEcc_KeyTypes.h:989
struct mcuxClEcc_EdDSA_GenerateKeyPairDescriptor mcuxClEcc_EdDSA_GenerateKeyPairDescriptor_t
EdDSA GenerateKeyPair variant descriptor type.
Definition mcuxClEcc_Types.h:68
struct mcuxClEcc_EdDSA_SignatureProtocolDescriptor mcuxClEcc_EdDSA_SignatureProtocolDescriptor_t
EdDSA SignatureProtocol variant descriptor type.
Definition mcuxClEcc_Types.h:78
#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
#define MCUXCLECC_EDDSA_ED25519_SIZE_PRIVATEKEYDATA
Byte length of an Ed25519 private key handle data buffer.
Definition mcuxClEcc_Constants.h:480
#define MCUXCLECC_EDDSA_ED25519_SIZE_PRIVATEKEY
Byte length of an Ed25519 private key.
Definition mcuxClEcc_Constants.h:479
#define MCUXCLECC_EDDSA_ED25519_SIZE_PUBLICKEY
Byte length of an Ed25519 public key.
Definition mcuxClEcc_Constants.h:481
#define MCUXCLECC_EDDSA_ED25519_SIZE_SIGNATURE
Byte length of an Ed25519 signature.
Definition mcuxClEcc_Constants.h:482
#define MCUXCLECC_EDDSA_GENERATEKEYPAIR_DESCRIPTOR_SIZE
EdDSA key pair generation descriptor size.
Definition mcuxClEcc_MemoryConsumption.h:208
#define MCUXCLECC_EDDSA_ED25519_SIZE_SIGNATURE_PROTOCOL_DESCRIPTOR(contextLen)
Byte length of an Ed25519 signature protocol descriptor.
Definition mcuxClEcc_MemoryConsumption.h:220
Structure for mcuxClSession Descriptor.
Definition mcuxClSession_Types.h:121