2. CMOX_RSA_PKCS1V15 ¶
2.1. Hash functions to use in RSA PKCS#1 v1.5 ¶
- group CMOX_RSA_PKCS1V15_HASH
-
Hash algorithms to use with RSA PKCS#1 API.
Variables
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA1
-
SHA1 Hash structure for the RSA PKCS#1 v1.5 functions.
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA224
-
SHA224 Hash structure for the RSA PKCS#1 v1.5 functions.
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA256
-
SHA256 Hash structure for the RSA PKCS#1 v1.5 functions.
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA384
-
SHA384 Hash structure for the RSA PKCS#1 v1.5 functions.
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA512
-
SHA512 Hash structure for the RSA PKCS#1 v1.5 functions.
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA512_224
-
SHA512/224 Hash structure for the RSA PKCS#1 v1.5 functions.
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA512_256
-
SHA512/256 Hash structure for the RSA PKCS#1 v1.5 functions.
-
const
cmox_rsa_pkcs1v15_hash_t
CMOX_RSA_PKCS1V15_HASH_SHA1
2.2. RSA PKCS#1 v1.5 public method prototypes ¶
- group CMOX_RSA_PKCS1V15_PUBLIC_METHODS
-
Functions
-
cmox_rsa_retval_t
cmox_rsa_pkcs1v15_sign
(
cmox_rsa_handle_t
*
P_pRsaCtx
,
const
cmox_rsa_key_t
*
P_pPrivKey
,
const
uint8_t
*
P_pDigest
,
const
cmox_rsa_pkcs1v15_hash_t
P_HashId
,
uint8_t
*
P_pSignature
,
size_t
*
P_pSignatureLen
)
-
Sign a message using PKCS#1 v1.5.
- 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_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_pkcs1v15_verify
(
cmox_rsa_handle_t
*
P_pRsaCtx
,
const
cmox_rsa_key_t
*
P_pPubKey
,
const
uint8_t
*
P_pDigest
,
const
cmox_rsa_pkcs1v15_hash_t
P_HashId
,
const
uint8_t
*
P_pSignature
,
size_t
P_SignatureLen
,
uint32_t
*
P_pFaultCheck
)
-
Verify a message signed with PKCS#1 v1.5.
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_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_MODULUS_TOO_SHORT – Modulus too short for the message to verify
-
cmox_rsa_retval_t
cmox_rsa_pkcs1v15_encrypt
(
cmox_rsa_handle_t
*
P_pRsaCtx
,
const
cmox_rsa_key_t
*
P_pPubKey
,
const
uint8_t
*
P_pInput
,
size_t
P_InputLen
,
const
uint8_t
*
P_pRandom
,
size_t
P_RandomLen
,
uint8_t
*
P_pOutput
,
size_t
*
P_pOutputLen
)
-
Encrypt a message using PKCS#1 v1.5.
- 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_pRandom – [in] Random buffer
P_RandomLen – [in] Random 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_WRONG_RANDOM – Random material too short or not valid for the functionality
-
cmox_rsa_retval_t
cmox_rsa_pkcs1v15_decrypt
(
cmox_rsa_handle_t
*
P_pRsaCtx
,
const
cmox_rsa_key_t
*
P_pPrivKey
,
const
uint8_t
*
P_pInput
,
size_t
P_InputLen
,
uint8_t
*
P_pOutput
,
size_t
*
P_pOutputLen
)
-
Decrypt a message using PKCS#1 v1.5.
- 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_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_WRONG_DECRYPTION – Decryption failed, probably due to a wrong private key
-
cmox_rsa_retval_t
cmox_rsa_pkcs1v15_sign
(
cmox_rsa_handle_t
*
P_pRsaCtx
,
const
cmox_rsa_key_t
*
P_pPrivKey
,
const
uint8_t
*
P_pDigest
,
const
cmox_rsa_pkcs1v15_hash_t
P_HashId
,
uint8_t
*
P_pSignature
,
size_t
*
P_pSignatureLen
)