Example of using function mcuxClRsa_sign to perform the RSA signature generation primitive RSASP1 (private exponentiation and NO padding) according to PKCS #1 v2.2, using a key in plain format.
Example of using function mcuxClRsa_sign to perform the RSA signature generation primitive RSASP1 (private exponentiation and NO padding) according to PKCS #1 v2.2, using a key in plain format.
#include <mcuxClToolchain.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClToolchain.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_ELS_Helper.h>
#define RSA_KEY_BIT_LENGTH (1024U)
#define RSA_KEY_BYTE_LENGTH (RSA_KEY_BIT_LENGTH / 8U)
0xd0u, 0xb7u, 0x50u, 0xc8u, 0x55u, 0x4bu, 0x64u, 0xc7u,
0xa9u, 0xd3u, 0x4du, 0x06u, 0x8eu, 0x02u, 0x0fu, 0xb5u,
0x2fu, 0xeau, 0x1bu, 0x39u, 0xc4u, 0x79u, 0x71u, 0xa3u,
0x59u, 0xf0u, 0xeeu, 0xc5u, 0xdau, 0x04u, 0x37u, 0xeau,
0x3fu, 0xc9u, 0x45u, 0x97u, 0xd8u, 0xdbu, 0xffu, 0x54u,
0x44u, 0xf6u, 0xceu, 0x5au, 0x32u, 0x93u, 0xacu, 0x89u,
0xb1u, 0xeeu, 0xbbu, 0x3fu, 0x71u, 0x2bu, 0x3au, 0xd6u,
0xa0u, 0x63u, 0x86u, 0xe6u, 0x40u, 0x19u, 0x85u, 0xe1u,
0x98u, 0x98u, 0x71u, 0x5bu, 0x1eu, 0xa3u, 0x2au, 0xc0u,
0x34u, 0x56u, 0xfeu, 0x17u, 0x96u, 0xd3u, 0x1eu, 0xd4u,
0xafu, 0x38u, 0x9fu, 0x4fu, 0x67u, 0x5cu, 0x23u, 0xc4u,
0x21u, 0xa1u, 0x25u, 0x49u, 0x1eu, 0x74u, 0x0fu, 0xdau,
0xc4u, 0x32u, 0x2eu, 0xc2u, 0xd4u, 0x6eu, 0xc9u, 0x45u,
0xddu, 0xc3u, 0x49u, 0x22u, 0x7bu, 0x49u, 0x21u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u, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu, 0xffu,
0xffu, 0xffu, 0xffu, 0xffu, 0x00u, 0x30u, 0x31u, 0x30u,
0x0du, 0x06u, 0x09u, 0x60u, 0x86u, 0x48u, 0x01u, 0x65u,
0x03u, 0x04u, 0x02u, 0x01u, 0x05u, 0x00u, 0x04u, 0x20u,
0x7cu, 0x50u, 0xbdu, 0xf5u, 0xafu, 0x92u, 0x3du, 0x43u,
0x2cu, 0xefu, 0x56u, 0x84u, 0xfdu, 0xfau, 0x9du, 0xbau,
0x18u, 0x9au, 0xaeu, 0x69u, 0x98u, 0x92u, 0xb9u, 0xa6u,
0x86u, 0x3au, 0x35u, 0xeeu, 0xcfu, 0x54u, 0x6du, 0xecu
};
0x02u, 0x3au, 0x8du, 0x88u, 0x87u, 0xd3u, 0x81u, 0x4fu,
0xb6u, 0xceu, 0xb1u, 0x2cu, 0xf9u, 0x87u, 0x9cu, 0x49u,
0xebu, 0xf2u, 0x16u, 0xd0u, 0x6cu, 0x32u, 0x2du, 0xa7u,
0x72u, 0xb2u, 0xe5u, 0x1fu, 0x7au, 0x70u, 0xc1u, 0x30u,
0x74u, 0x3au, 0xacu, 0xebu, 0x0cu, 0x81u, 0x01u, 0x6cu,
0x55u, 0xe1u, 0x1cu, 0x7eu, 0x93u, 0x1fu, 0x1au, 0x28u,
0xcau, 0xe9u, 0xe1u, 0x70u, 0xa9u, 0xf9u, 0x7bu, 0x2du,
0xfcu, 0xc0u, 0xbfu, 0x3cu, 0x56u, 0xbdu, 0x8fu, 0xe1u,
0xd3u, 0xa1u, 0xb4u, 0xe3u, 0xe5u, 0xd2u, 0xb2u, 0x51u,
0x88u, 0xe9u, 0x9au, 0x90u, 0x19u, 0x33u, 0xb8u, 0xa6u,
0xd4u, 0x55u, 0x3du, 0xcbu, 0xc3u, 0x0cu, 0xdbu, 0x27u,
0xdcu, 0x86u, 0x55u, 0xe2u, 0x0du, 0x1du, 0x59u, 0xc5u,
0xb4u, 0x23u, 0xcbu, 0xaau, 0xcau, 0x1bu, 0x7bu, 0x8au,
0xe7u, 0x30u, 0x64u, 0xc8u, 0x42u, 0x28u, 0xd9u, 0xd3u,
0xdbu, 0x6au, 0x54u, 0x7fu, 0x21u, 0x95u, 0x12u, 0x58u,
0xf3u, 0xc9u, 0x98u, 0x54u, 0x1du, 0x6au, 0x15u, 0x96u
};
MCUXCLEXAMPLE_FUNCTION(mcuxClRsa_sign_NoEncode_example)
{
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(session,
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
MCUX_CSSL_ANALYSIS_START_SUPPRESS_DISCARD_CONST("Required by API function")
.pKeyEntryData = (uint8_t *)
modulus,
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DISCARD_CONST()
MCUX_CSSL_ANALYSIS_START_SUPPRESS_DISCARD_CONST("Required by API function")
.pKeyEntryData = (uint8_t *)
d,
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DISCARD_CONST()
.keyEntryLength =
sizeof(
d) };
MCUX_CSSL_ANALYSIS_START_SUPPRESS_DISCARD_CONST("Required by API function")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DISCARD_CONST()
.pMod2 = NULL,
.pQInv = NULL,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_DISCARD_CONST("Required by API function")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DISCARD_CONST()
.pExp2 = NULL,
.pExp3 = NULL };
session,
&private_key,
messageBuf,
MCUX_CSSL_ANALYSIS_START_SUPPRESS_DISCARD_CONST("Required by API function")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DISCARD_CONST()
0u,
0u,
signatureBuf));
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
{
{
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
#define RSA_KEY_BYTE_LENGTH
Converting the key-bitlength to bytelength.
Definition mcuxClRsa_verify_pssverify_sha2_256_example.c:42
static const ALIGNED uint8_t modulus[RSA_KEY_BYTE_LENGTH]
Example value for public RSA modulus N.
Definition mcuxClRsa_verify_pssverify_sha2_256_example.c:50
static const ALIGNED uint8_t message[RSA_MESSAGE_DIGEST_LENGTH]
Example value for Sha2-256 message digest.
Definition mcuxClRsa_verify_pssverify_sha2_256_example.c:79
static const ALIGNED uint8_t referenceSignature[RSA_KEY_BYTE_LENGTH]
Expected signature.
Definition mcuxClRsa_sign_pss_sha2_256_example.c:100
static const ALIGNED uint8_t d[RSA_KEY_BYTE_LENGTH]
Example value for private RSA exponent d.
Definition mcuxClRsa_sign_NoEncode_example.c:70
Provides the API for the CL buffer types.
Definition of function identifiers for the flow protection mechanism.
Top-level include file for the ELS driver.
Top level header of mcuxClRandom component.
Top-level include file for the mcuxClRsa component.
Top-level include file for the mcuxClSession component.
Provides the API for the CSSL flow protection mechanism.
#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
#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
mcuxClRandom_Status_t mcuxClRandom_ncInit(mcuxClSession_Handle_t pSession)
Non-cryptographic PRNG initialization function.
const mcuxClRsa_SignVerifyMode_t mcuxClRsa_Mode_Sign_NoEncode
Mode definition for RSASP1.
mcuxClRsa_Status_t mcuxClRsa_sign(mcuxClSession_Handle_t pSession, const mcuxClRsa_Key *const pKey, mcuxCl_InputBuffer_t pMessageOrDigest, const uint32_t messageLength, const mcuxClRsa_SignVerifyMode pPaddingMode, const uint32_t saltLength, const uint32_t options, mcuxCl_Buffer_t pSignature)
RSA sign operation.
#define MCUXCLRSA_SIGN_PLAIN_1024_WAPKC_SIZE
Definition of PKC workarea size for the mcuxClRsa_sign function for 1024-bit private plain keys.
Definition mcuxClRsa_MemoryConsumption.h:146
#define MCUXCLRSA_SIGN_PLAIN_NOENCODE_1024_WACPU_SIZE
Definition of CPU workarea size for the mcuxClRsa_sign function for 1024-bit private plain keys using...
Definition mcuxClRsa_MemoryConsumption.h:103
#define MCUXCLRSA_STATUS_SIGN_OK
RSA sign operation successful.
Definition mcuxClRsa_Types.h:51
#define MCUXCLRSA_KEY_PRIVATEPLAIN
RSA key type private plain.
Definition mcuxClRsa_Types.h:76
struct mcuxClRsa_SignVerifyMode_t mcuxClRsa_SignVerifyMode_t
Forward declaration of Sign/Verify mode struct.
Definition mcuxClRsa_Types.h:180
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:113
#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 MCUXCLRANDOM_STATUS_OK
Random function returned successfully.
Definition mcuxClRandom_Constants.h:46
Structure type for Rsa key entries, specifying key entry length and data.
Definition mcuxClRsa_Types.h:130
Structure type for Rsa key, specifying key type and key entries.
Definition mcuxClRsa_Types.h:145
uint32_t keytype
Key type specifier:
Definition mcuxClRsa_Types.h:146
Structure for mcuxClSession Descriptor.
Definition mcuxClSession_Types.h:121