1. CMOX_RSA ¶
1.1. RSA public method prototypes ¶
- group CMOX_RSA_PUBLIC_METHODS
-
Functions
-
void
cmox_rsa_construct
(
cmox_rsa_handle_t
*
P_pRsaCtx
,
const
cmox_math_funcs_t
P_Math
,
const
cmox_modexp_func_t
P_Modexp
,
uint8_t
*
P_pBuf
,
size_t
P_BufLen
)
-
Mandatory function to set Low Level Mathematical Functions, and working memory buffer, for RSA.
- Parameters :
-
P_pRsaCtx – [inout] Context for RSA operations
P_Math – [in] Structure pointer with the Low-level Mathematical functions This parameter can be one of the following:
CMOX_MATH_FUNCS_SMALL
CMOX_MATH_FUNCS_FAST
P_Modexp – [in] Structure pointer with the Modular Exponentiation function This parameter can be one of the following:
CMOX_MODEXP_PUBLIC
CMOX_MODEXP_PRIVATE_LOWMEM
CMOX_MODEXP_PRIVATE_MIDMEM
CMOX_MODEXP_PRIVATE_HIGHMEM
P_pBuf – [in] The preallocated static buffer that will be used
P_BufLen – [in] The size in bytes of the P_pBuf buffer
-
void
cmox_rsa_cleanup
(
cmox_rsa_handle_t
*
P_pRsaCtx
)
-
Clean the RSA context and the internal temporary buffer.
- Parameters :
-
P_pRsaCtx – [inout] Context for RSA operations
-
cmox_rsa_retval_t
cmox_rsa_setKey
(
cmox_rsa_key_t
*
P_pKey
,
const
uint8_t
*
P_pModulus
,
size_t
P_ModulusLen
,
const
uint8_t
*
P_pExp
,
size_t
P_ExpLen
)
-
Set the key (public or private) in the key structure.
- Parameters :
-
P_pKey – [out] Key to set
P_pModulus – [in] Modulus
P_ModulusLen – [in] Modulus Length (in Bytes)
P_pExp – [in] Exponent (private or public)
P_ExpLen – [in] Exponent Length (in Bytes)
- Return values :
-
CMOX_RSA_SUCCESS –
CMOX_RSA_ERR_BAD_PARAMETER –
-
cmox_rsa_retval_t
cmox_rsa_setKeyCRT
(
cmox_rsa_key_t
*
P_pPrivKey
,
size_t
P_ModulusBitLen
,
const
uint8_t
*
P_pExpP
,
size_t
P_ExpPLen
,
const
uint8_t
*
P_pExpQ
,
size_t
P_ExpQLen
,
const
uint8_t
*
P_pP
,
size_t
P_PLen
,
const
uint8_t
*
P_pQ
,
size_t
P_QLen
,
const
uint8_t
*
P_pIq
,
size_t
P_IqLen
)
-
Set the private CRT key in the key structure.
- Parameters :
-
P_pPrivKey – [out] Private Key to set
P_ModulusBitLen – [in] Modulus Length (in bits)
P_pExpP – [in] Secret exponent (mod P) dP
P_ExpPLen – [in] dP Length (in Bytes)
P_pExpQ – [in] Secret exponent (mod Q) dQ
P_ExpQLen – [in] dQ Length (in Bytes)
P_pP – [in] First secret prime P
P_PLen – [in] P Length (in Bytes)
P_pQ – [in] Second secret prime Q
P_QLen – [in] Q Length (in Bytes)
P_pIq – [in] Inverse of Q (mod P) invQ
P_IqLen – [in] invQ Length (in Bytes)
- Return values :
-
CMOX_RSA_SUCCESS –
CMOX_RSA_ERR_BAD_PARAMETER –
-
cmox_rsa_retval_t
cmox_rsa_setKeyCRTwithFACM
(
cmox_rsa_key_t
*
P_pPrivKey
,
size_t
P_ModulusBitLen
,
const
uint8_t
*
P_pExpP
,
size_t
P_ExpPLen
,
const
uint8_t
*
P_pExpQ
,
size_t
P_ExpQLen
,
const
uint8_t
*
P_pP
,
size_t
P_PLen
,
const
uint8_t
*
P_pQ
,
size_t
P_QLen
,
const
uint8_t
*
P_pIq
,
size_t
P_IqLen
,
const
uint8_t
*
P_pPubKey
,
size_t
P_PubKeyLen
)
-
Set the private CRT key in the key structure, enabling the Fault Attacks Countermeasure.
Note
This function enables the protection against the Bellcore attack for RSA-CRT computation. This countermeasure is useful to protect RSA-CRT using PKCS#1 v1.5 for Signature Creation. Indeed, PKCS#1 v2.2 Signature Creation is not vulnerable because of the presence of an input random, and Decryption processes (both for PKCS#1 v1.5 and v2.2) are not vulnerable because the plaintext is not returned if not correct (therefore not exploitable by an attacker).
- Parameters :
-
P_pPrivKey – [out] Private Key to set
P_ModulusBitLen – [in] Modulus Length (in bits)
P_pExpP – [in] Secret exponent (mod P) dP
P_ExpPLen – [in] dP Length (in Bytes)
P_pExpQ – [in] Secret exponent (mod Q) dQ
P_ExpQLen – [in] dQ Length (in Bytes)
P_pP – [in] First secret prime P
P_PLen – [in] P Length (in Bytes)
P_pQ – [in] Second secret prime Q
P_QLen – [in] Q Length (in Bytes)
P_pIq – [in] Inverse of Q (mod P) invQ
P_IqLen – [in] invQ Length (in Bytes)
P_pPubKey – [in] Public Key
P_PubKeyLen – [in] Public Key Length (in Bytes)
- Return values :
-
CMOX_RSA_SUCCESS –
CMOX_RSA_ERR_BAD_PARAMETER –
-
void
cmox_rsa_construct
(
cmox_rsa_handle_t
*
P_pRsaCtx
,
const
cmox_math_funcs_t
P_Math
,
const
cmox_modexp_func_t
P_Modexp
,
uint8_t
*
P_pBuf
,
size_t
P_BufLen
)