Example of using function mcuxClRsa_sign to perform the RSA signature generation with EMSA-PSS-SIGN padding scheme according to PKCS #1 v2.2.
Example of using function mcuxClRsa_sign to perform the RSA signature generation with EMSA-PSS-SIGN padding scheme according to PKCS #1 v2.2.
#include <mcuxClToolchain.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_ELS_Helper.h>
#define RSA_KEY_BIT_LENGTH (2048u)
#define RSA_KEY_BYTE_LENGTH (RSA_KEY_BIT_LENGTH / 8u)
#define RSA_MESSAGE_DIGEST_LENGTH (32u)
#define RSA_PSS_SALT_LENGTH (0u)
0xd3U, 0x24U, 0x96U, 0xe6U, 0x2dU, 0x16U, 0x34U, 0x6eU, 0x06U, 0xe7U, 0xa3U, 0x1cU, 0x12U, 0x0aU, 0x21U, 0xb5U,
0x45U, 0x32U, 0x32U, 0x35U, 0xeeU, 0x1dU, 0x90U, 0x72U, 0x1dU, 0xceU, 0xaaU, 0xd4U, 0x6dU, 0xc4U, 0xceU, 0xbdU,
0x80U, 0xc1U, 0x34U, 0x5aU, 0xffU, 0x95U, 0xb1U, 0xddU, 0xf8U, 0x71U, 0xebU, 0xb7U, 0xf2U, 0x0fU, 0xedU, 0xb6U,
0xe4U, 0x2eU, 0x67U, 0xa0U, 0xccU, 0x59U, 0xb3U, 0x9fU, 0xfdU, 0x31U, 0xe9U, 0x83U, 0x42U, 0xf4U, 0x0aU, 0xd9U,
0xafU, 0xf9U, 0x3cU, 0x3cU, 0x51U, 0xcfU, 0x5fU, 0x3cU, 0x8aU, 0xd0U, 0x64U, 0xb8U, 0x33U, 0xf9U, 0xacU, 0x34U,
0x22U, 0x9aU, 0x3eU, 0xd3U, 0xddU, 0x29U, 0x41U, 0xbeU, 0x12U, 0x5bU, 0xc5U, 0xa2U, 0x0cU, 0xb6U, 0xd2U, 0x31U,
0xb6U, 0xd1U, 0x84U, 0x7eU, 0xc4U, 0xfeU, 0xaeU, 0x2bU, 0x88U, 0x46U, 0xcfU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U, 0xabU, 0x65U, 0x48U, 0x02U, 0x11U, 0x02U, 0x4bU,
0xacU, 0x3cU, 0xa5U, 0x93U, 0xa5U, 0xd4U, 0x4aU, 0x7dU, 0xa7U, 0xb8U, 0x69U, 0x6eU, 0xb6U, 0xe2U, 0xa1U, 0xd2U,
0xfcU, 0xa1U, 0x89U, 0x44U, 0x50U, 0xc9U, 0x01U, 0x5eU, 0xbdU, 0xafU, 0x25U, 0xadU, 0xd0U, 0x0cU, 0xb4U, 0x4fU,
0xb3U, 0x99U, 0x44U, 0x28U, 0xb2U, 0x45U, 0x1cU, 0x92U, 0x6bU, 0xbfU, 0xfcU, 0xfdU, 0x72U, 0xecU, 0x44U, 0xdaU,
0xaaU, 0xdaU, 0x65U, 0x19U, 0xc3U, 0x41U, 0x46U, 0xb6U, 0x01U, 0x67U, 0xdeU, 0x98U, 0xd8U, 0x1bU, 0x15U, 0x94U
};
MCUXCLEXAMPLE_FUNCTION(mcuxClRsa_sign_pss_sha2_256_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")
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_DISCARD_CONST()
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()
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_MESSAGE_DIGEST_LENGTH
The example uses a Sha2-256 digest, which is 32 bytes long.
Definition mcuxClRsa_verify_pssverify_sha2_256_example.c:44
#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 exponent[RSA_PUBLIC_EXP_BYTE_LENGTH]
Example value for public RSA exponent e.
Definition mcuxClRsa_verify_pssverify_sha2_256_example.c:72
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
#define RSA_PSS_SALT_LENGTH
The salt for the PSS padding is 32 bytes long.
Definition mcuxClRsa_verify_pssverify_sha2_256_example.c:45
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
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_Pss_Sha2_256
Mode definition for RSASSA-PSS-SIGN using SHA-2/256.
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_2048_WAPKC_SIZE
Definition of PKC workarea size for the mcuxClRsa_sign function for 2048-bit private plain keys.
Definition mcuxClRsa_MemoryConsumption.h:147
#define MCUXCLRSA_SIGN_PLAIN_PSSENCODE_2048_WACPU_SIZE
Definition of CPU workarea size for the mcuxClRsa_sign function for 2048-bit private plain keys using...
Definition mcuxClRsa_MemoryConsumption.h:119
#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
#define MCUXCLRSA_OPTION_MESSAGE_DIGEST
Option passing a message digest as input to the sign or verify operation.
Definition mcuxClRsa_Types.h:92
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