3. CMOX_RSA_PKCS1V22

3.1. CMOX RSA PKCS1V22 HASH

group CMOX_RSA_PKCS1V22_HASH

Hash algorithms to use with RSA PKCS#1 API.

Variables

const cmox_rsa_pkcs1v22_hash_t CMOX_RSA_PKCS1V22_HASH_SHA1

SHA1 Hash structure for the RSA PKCS#1 v2.2 functions.

const cmox_rsa_pkcs1v22_hash_t CMOX_RSA_PKCS1V22_HASH_SHA224

SHA224 Hash structure for the RSA PKCS#1 v2.2 functions.

const cmox_rsa_pkcs1v22_hash_t CMOX_RSA_PKCS1V22_HASH_SHA256

SHA256 Hash structure for the RSA PKCS#1 v2.2 functions.

const cmox_rsa_pkcs1v22_hash_t CMOX_RSA_PKCS1V22_HASH_SHA384

SHA384 Hash structure for the RSA PKCS#1 v2.2 functions.

const cmox_rsa_pkcs1v22_hash_t CMOX_RSA_PKCS1V22_HASH_SHA512

SHA512 Hash structure for the RSA PKCS#1 v2.2 functions.

const cmox_rsa_pkcs1v22_hash_t CMOX_RSA_PKCS1V22_HASH_SHA512_224

SHA512/224 Hash structure for the RSA PKCS#1 v2.2 functions.

const cmox_rsa_pkcs1v22_hash_t CMOX_RSA_PKCS1V22_HASH_SHA512_256

SHA512/256 Hash structure for the RSA PKCS#1 v2.2 functions.

3.2. CMOX RSA PKCS1V22 PUBLIC METHODS

group CMOX_RSA_PKCS1V22_PUBLIC_METHODS

Functions

cmox_rsa_retval_t cmox_rsa_pkcs1v22_sign ( cmox_rsa_handle_t * P_pRsaCtx , const cmox_rsa_key_t * P_pPrivKey , const uint8_t * P_pDigest , const cmox_rsa_pkcs1v22_hash_t P_HashId , const uint8_t * P_pRandom , size_t P_RandomLen , uint8_t * P_pSignature , size_t * P_pSignatureLen )

Sign a message using PKCS#1 v2.2.

Parameters :
  • P_pRsaCtx[in] Context for RSA operations

  • P_pPrivKey[in] Private Key (standard or CRT)

  • P_pDigest[in] Message to sign

  • P_HashId[in] Hash to use

  • P_pRandom[in] Random buffer

  • P_RandomLen[in] Random Length (in Bytes)

  • P_pSignature[out] Output signature

  • P_pSignatureLen[out] Output signature Length (in Bytes)

Return values :
  • CMOX_RSA_SUCCESS – Everything OK

  • CMOX_RSA_ERR_MATH_ALGO_MISMATCH – Mathematical function set is incompatible with current functionality

  • CMOX_RSA_ERR_MEXP_ALGO_MISMATCH – Modexp function set is not compatible with current functionality

  • CMOX_RSA_ERR_BAD_PARAMETER – Some NULL/wrong/empty parameter

  • CMOX_RSA_ERR_MEMORY_FAIL – Not enough memory

  • CMOX_RSA_ERR_MODULUS_TOO_SHORT – Modulus too short for the message to sign

cmox_rsa_retval_t cmox_rsa_pkcs1v22_verify ( cmox_rsa_handle_t * P_pRsaCtx , const cmox_rsa_key_t * P_pPubKey , const uint8_t * P_pDigest , const cmox_rsa_pkcs1v22_hash_t P_HashId , size_t P_RandomLen , const uint8_t * P_pSignature , size_t P_SignatureLen , uint32_t * P_pFaultCheck )

Verify a message signed with PKCS#1 v2.2.

Note

P_pFaultCheck value, if the parameter is provided, MUST be checked to be equal to the retval, and both MUST be equal to the successful value. P_pFaultCheck MUST be checked only if the main result is successful, and has no relevance if the main result is not successful. Every comparison (both for the return value and for P_pFaultCheck) must be done against the success value, and not comparing the value with the failure value. Indeed, in presence of faults, especially P_pFaultCheck, could be a dirty value.

Parameters :
  • P_pRsaCtx[in] Context for RSA operations

  • P_pPubKey[in] Public Key

  • P_pDigest[in] Message to verify

  • P_HashId[in] Hash to use

  • P_RandomLen[in] Random Length (in Bytes)

  • P_pSignature[in] Signature

  • P_SignatureLen[in] Signature Length (in Bytes)

  • P_pFaultCheck[out] Optional value to check, together with the retval, to verify if some fault happened

Return values :
  • CMOX_RSA_AUTH_SUCCESS – Signature verified

  • CMOX_RSA_AUTH_FAIL – Signature NOT verified

  • CMOX_RSA_ERR_MATH_ALGO_MISMATCH – Mathematical function set is incompatible with current functionality

  • CMOX_RSA_ERR_MEXP_ALGO_MISMATCH – Modexp function set is not compatible with current functionality

  • CMOX_RSA_ERR_BAD_PARAMETER – Some NULL/wrong/empty parameter

  • CMOX_RSA_ERR_INVALID_SIGNATURE – Input signature corrupted or not in the expected format

  • CMOX_RSA_ERR_MEMORY_FAIL – Not enough memory

  • CMOX_RSA_ERR_INTERNAL – Something went wrong during internal computations (e.g. hash)

cmox_rsa_retval_t cmox_rsa_pkcs1v22_encrypt ( cmox_rsa_handle_t * P_pRsaCtx , const cmox_rsa_key_t * P_pPubKey , const uint8_t * P_pInput , size_t P_InputLen , const cmox_rsa_pkcs1v22_hash_t P_HashId , const uint8_t * P_pRandom , size_t P_RandomLen , const uint8_t * P_pLabel , size_t P_LabelLen , uint8_t * P_pOutput , size_t * P_pOutputLen )

Encrypt a message using PKCS#1 v2.2.

Parameters :
  • P_pRsaCtx[in] Context for RSA operations

  • P_pPubKey[in] Public Key

  • P_pInput[in] Message to encrypt

  • P_InputLen[in] Message Length (in Bytes)

  • P_HashId[in] Hash to use

  • P_pRandom[in] Random buffer

  • P_RandomLen[in] Random Length (in Bytes)

  • P_pLabel[in] Label (Optional)

  • P_LabelLen[in] Label Length (in Bytes)

  • P_pOutput[out] Output encrypted buffer

  • P_pOutputLen[out] Output Length (in Bytes)

Return values :
  • CMOX_RSA_SUCCESS – Everything OK

  • CMOX_RSA_ERR_MATH_ALGO_MISMATCH – Mathematical function set is incompatible with current functionality

  • CMOX_RSA_ERR_MEXP_ALGO_MISMATCH – Modexp function set is not compatible with current functionality

  • CMOX_RSA_ERR_BAD_PARAMETER – Some NULL/wrong/empty parameter

  • CMOX_RSA_ERR_MODULUS_TOO_SHORT – Modulus too short for the message to encrypt

  • CMOX_RSA_ERR_MEMORY_FAIL – Not enough memory

  • CMOX_RSA_ERR_INTERNAL – Something went wrong during internal computations (e.g. hash)

cmox_rsa_retval_t cmox_rsa_pkcs1v22_decrypt ( cmox_rsa_handle_t * P_pRsaCtx , const cmox_rsa_key_t * P_pPrivKey , const uint8_t * P_pInput , size_t P_InputLen , const cmox_rsa_pkcs1v22_hash_t P_HashId , const uint8_t * P_pLabel , size_t P_LabelLen , uint8_t * P_pOutput , size_t * P_pOutputLen )

Decrypt a message using PKCS#1 v2.2.

Parameters :
  • P_pRsaCtx[in] Context for RSA operations

  • P_pPrivKey[in] Private Key (standard or CRT)

  • P_pInput[in] Message to decrypt

  • P_InputLen[in] Message Length (in Bytes)

  • P_HashId[in] Hash to use

  • P_pLabel[in] Label (Optional)

  • P_LabelLen[in] Label Length (in Bytes)

  • P_pOutput[out] Output decrypted buffer

  • P_pOutputLen[out] Output Length (in Bytes)

Return values :
  • CMOX_RSA_SUCCESS – Everything OK

  • CMOX_RSA_ERR_MATH_ALGO_MISMATCH – Mathematical function set is incompatible with current functionality

  • CMOX_RSA_ERR_MEXP_ALGO_MISMATCH – Modexp function set is not compatible with current functionality

  • CMOX_RSA_ERR_BAD_PARAMETER – Some NULL/wrong/empty parameter

  • CMOX_RSA_ERR_MEMORY_FAIL – Not enough memory

  • CMOX_RSA_ERR_INTERNAL – Something went wrong during internal computations (e.g. hash)

  • CMOX_RSA_ERR_WRONG_DECRYPTION – Decryption failed, probably due to a wrong private key

  • CMOX_RSA_ERR_MODULUS_TOO_SHORT – Modulus too short for the message to decrypt