6. CMOX_ECDSA ¶
6.1. ECDSA public method prototypes ¶
- group CMOX_ECC_ECDSA_PUBLIC_METHODS
-
Functions
-
cmox_ecc_retval_t
cmox_ecdsa_keyGen
(
cmox_ecc_handle_t
*
P_pEccCtx
,
const
cmox_ecc_impl_t
P_CurveParams
,
const
uint8_t
*
P_pRandom
,
size_t
P_RandomLen
,
uint8_t
*
P_pPrivKey
,
size_t
*
P_pPrivKeyLen
,
uint8_t
*
P_pPubKey
,
size_t
*
P_pPubKeyLen
)
-
Generate private and public keys to use with ECDSA.
Note
the private key is derived from the random in the following way:
, where: random is the input random buffer (interpreted as a big-endian integer), WORD_NBIT is the bitsize of a cpu word, N_MSW_NBIT is the bitlength of the most significant word of the parameter N of the curve.privkey = (random >> ((WORD_NBIT - N_MSW_NBIT) & 7)) + 1Note
If P_RandomLen is not enough, an error is returned and P_pPrivKeyLen contains the minimum number of bytes of random to provide (and is also the minimum length of P_pPrivKey), while P_pPubKeyLen contains the minimum length of P_pPubKey.
- Parameters :
-
P_pEccCtx – [in] Context for ECC operations
P_CurveParams – [in] Curve Parameters and point functions This parameter can be one of the following:
CMOX_ECC_SECP224R1_LOWMEM
CMOX_ECC_SECP224R1_HIGHMEM
CMOX_ECC_SECP256R1_LOWMEM
CMOX_ECC_SECP256R1_HIGHMEM
CMOX_ECC_SECP384R1_LOWMEM
CMOX_ECC_SECP384R1_HIGHMEM
CMOX_ECC_SECP521R1_LOWMEM
CMOX_ECC_SECP521R1_HIGHMEM
CMOX_ECC_SECP256K1_LOWMEM
CMOX_ECC_SECP256K1_HIGHMEM
CMOX_ECC_BPP160R1_LOWMEM
CMOX_ECC_BPP160R1_HIGHMEM
CMOX_ECC_BPP192R1_LOWMEM
CMOX_ECC_BPP192R1_HIGHMEM
CMOX_ECC_BPP224R1_LOWMEM
CMOX_ECC_BPP224R1_HIGHMEM
CMOX_ECC_BPP256R1_LOWMEM
CMOX_ECC_BPP256R1_HIGHMEM
CMOX_ECC_BPP320R1_LOWMEM
CMOX_ECC_BPP320R1_HIGHMEM
CMOX_ECC_BPP384R1_LOWMEM
CMOX_ECC_BPP384R1_HIGHMEM
CMOX_ECC_BPP512R1_LOWMEM
CMOX_ECC_BPP512R1_HIGHMEM
CMOX_ECC_BPP160T1_LOWMEM
CMOX_ECC_BPP160T1_HIGHMEM
CMOX_ECC_BPP192T1_LOWMEM
CMOX_ECC_BPP192T1_HIGHMEM
CMOX_ECC_BPP224T1_LOWMEM
CMOX_ECC_BPP224T1_HIGHMEM
CMOX_ECC_BPP256T1_LOWMEM
CMOX_ECC_BPP256T1_HIGHMEM
CMOX_ECC_BPP320T1_LOWMEM
CMOX_ECC_BPP320T1_HIGHMEM
CMOX_ECC_BPP384T1_LOWMEM
CMOX_ECC_BPP384T1_HIGHMEM
CMOX_ECC_BPP512T1_LOWMEM
CMOX_ECC_BPP512T1_HIGHMEM
CMOX_ECC_FRP256V1_LOWMEM
CMOX_ECC_FRP256V1_HIGHMEM
P_pRandom – [in] Buffer of random bytes
P_RandomLen – [in] Byte length of the random buffer
P_pPrivKey – [out] Buffer with the private key (in range [1; N - 1])
P_pPrivKeyLen – [out] Byte length of the private key
P_pPubKey – [out] Buffer with the public key
P_pPubKeyLen – [out] Byte length of the public key
- Return values :
-
CMOX_ECC_SUCCESS – Everything OK
CMOX_ECC_ERR_MATHCURVE_MISMATCH – Mathematical function set is not compatible with current ECC curve
CMOX_ECC_ERR_ALGOCURVE_MISMATCH – Curve is not compatible with current functionality
CMOX_ECC_ERR_BAD_PARAMETERS – Some NULL/wrong/empty parameter or Construct API not called
CMOX_ECC_ERR_WRONG_RANDOM – Random material too short or not valid for the functionality
CMOX_ECC_ERR_MEMORY_FAIL – Not enough memory
-
cmox_ecc_retval_t
cmox_ecdsa_sign
(
cmox_ecc_handle_t
*
P_pEccCtx
,
const
cmox_ecc_impl_t
P_CurveParams
,
const
uint8_t
*
P_pRandom
,
size_t
P_RandomLen
,
const
uint8_t
*
P_pPrivKey
,
size_t
P_PrivKeyLen
,
const
uint8_t
*
P_pDigest
,
size_t
P_DigestLen
,
uint8_t
*
P_pSignature
,
size_t
*
P_pSignatureLen
)
-
Generate a signature, using ECDSA.
Note
the internal value k, used as scalar and multiplied by the base point, is derived from the random in the following way:
, where: random is the input random buffer (interpreted as a big-endian integer), WORD_NBIT is the bitsize of a cpu word, N_MSW_NBIT is the bitlength of the most significant word of the parameter N of the curve.k = (random >> ((WORD_NBIT - N_MSW_NBIT) & 7)) + 1Note
If P_RandomLen is not enough, an error is returned and P_pSignatureLen contains the minimum number of bytes of random to provide (and is also the minimum length of P_pPrivKey, and half the length of P_pSignature).
- Parameters :
-
P_pEccCtx – [in] Context for ECC operations
P_CurveParams – [in] Curve Parameters and point functions This parameter can be one of the following:
CMOX_ECC_SECP224R1_LOWMEM
CMOX_ECC_SECP224R1_HIGHMEM
CMOX_ECC_SECP256R1_LOWMEM
CMOX_ECC_SECP256R1_HIGHMEM
CMOX_ECC_SECP384R1_LOWMEM
CMOX_ECC_SECP384R1_HIGHMEM
CMOX_ECC_SECP521R1_LOWMEM
CMOX_ECC_SECP521R1_HIGHMEM
CMOX_ECC_SECP256K1_LOWMEM
CMOX_ECC_SECP256K1_HIGHMEM
CMOX_ECC_BPP160R1_LOWMEM
CMOX_ECC_BPP160R1_HIGHMEM
CMOX_ECC_BPP192R1_LOWMEM
CMOX_ECC_BPP192R1_HIGHMEM
CMOX_ECC_BPP224R1_LOWMEM
CMOX_ECC_BPP224R1_HIGHMEM
CMOX_ECC_BPP256R1_LOWMEM
CMOX_ECC_BPP256R1_HIGHMEM
CMOX_ECC_BPP320R1_LOWMEM
CMOX_ECC_BPP320R1_HIGHMEM
CMOX_ECC_BPP384R1_LOWMEM
CMOX_ECC_BPP384R1_HIGHMEM
CMOX_ECC_BPP512R1_LOWMEM
CMOX_ECC_BPP512R1_HIGHMEM
CMOX_ECC_BPP160T1_LOWMEM
CMOX_ECC_BPP160T1_HIGHMEM
CMOX_ECC_BPP192T1_LOWMEM
CMOX_ECC_BPP192T1_HIGHMEM
CMOX_ECC_BPP224T1_LOWMEM
CMOX_ECC_BPP224T1_HIGHMEM
CMOX_ECC_BPP256T1_LOWMEM
CMOX_ECC_BPP256T1_HIGHMEM
CMOX_ECC_BPP320T1_LOWMEM
CMOX_ECC_BPP320T1_HIGHMEM
CMOX_ECC_BPP384T1_LOWMEM
CMOX_ECC_BPP384T1_HIGHMEM
CMOX_ECC_BPP512T1_LOWMEM
CMOX_ECC_BPP512T1_HIGHMEM
CMOX_ECC_FRP256V1_LOWMEM
CMOX_ECC_FRP256V1_HIGHMEM
P_pRandom – [in] Buffer of random bytes
P_RandomLen – [in] Byte length of the random buffer
P_pPrivKey – [in] Buffer with the private key
P_PrivKeyLen – [in] Byte length of the private key
P_pDigest – [in] Buffer with the digest to sign
P_DigestLen – [in] Byte length of the digest
P_pSignature – [out] Buffer with the signature (concatenation of R and S)
P_pSignatureLen – [out] Byte length of the signature
- Return values :
-
CMOX_ECC_SUCCESS – Everything OK
CMOX_ECC_ERR_MATHCURVE_MISMATCH – Mathematical function set is not compatible with current ECC curve
CMOX_ECC_ERR_ALGOCURVE_MISMATCH – Curve is not compatible with current functionality
CMOX_ECC_ERR_BAD_PARAMETERS – Some NULL/wrong/empty parameter or Construct API not called
CMOX_ECC_ERR_WRONG_RANDOM – Random material too short or not valid for the functionality
CMOX_ECC_ERR_MEMORY_FAIL – Not enough memory
-
cmox_ecc_retval_t
cmox_ecdsa_verify
(
cmox_ecc_handle_t
*
P_pEccCtx
,
const
cmox_ecc_impl_t
P_CurveParams
,
const
uint8_t
*
P_pPubKey
,
size_t
P_PubKeyLen
,
const
uint8_t
*
P_pDigest
,
size_t
P_DigestLen
,
const
uint8_t
*
P_pSignature
,
size_t
P_SignatureLen
,
uint32_t
*
P_pFaultCheck
)
-
Verify a signature, using ECDSA.
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_pEccCtx – [in] Context for ECC operations
P_CurveParams – [in] Curve Parameters and point functions This parameter can be one of the following:
CMOX_ECC_SECP224R1_LOWMEM
CMOX_ECC_SECP224R1_HIGHMEM
CMOX_ECC_SECP256R1_LOWMEM
CMOX_ECC_SECP256R1_HIGHMEM
CMOX_ECC_SECP384R1_LOWMEM
CMOX_ECC_SECP384R1_HIGHMEM
CMOX_ECC_SECP521R1_LOWMEM
CMOX_ECC_SECP521R1_HIGHMEM
CMOX_ECC_SECP256K1_LOWMEM
CMOX_ECC_SECP256K1_HIGHMEM
CMOX_ECC_BPP160R1_LOWMEM
CMOX_ECC_BPP160R1_HIGHMEM
CMOX_ECC_BPP192R1_LOWMEM
CMOX_ECC_BPP192R1_HIGHMEM
CMOX_ECC_BPP224R1_LOWMEM
CMOX_ECC_BPP224R1_HIGHMEM
CMOX_ECC_BPP256R1_LOWMEM
CMOX_ECC_BPP256R1_HIGHMEM
CMOX_ECC_BPP320R1_LOWMEM
CMOX_ECC_BPP320R1_HIGHMEM
CMOX_ECC_BPP384R1_LOWMEM
CMOX_ECC_BPP384R1_HIGHMEM
CMOX_ECC_BPP512R1_LOWMEM
CMOX_ECC_BPP512R1_HIGHMEM
CMOX_ECC_BPP160T1_LOWMEM
CMOX_ECC_BPP160T1_HIGHMEM
CMOX_ECC_BPP192T1_LOWMEM
CMOX_ECC_BPP192T1_HIGHMEM
CMOX_ECC_BPP224T1_LOWMEM
CMOX_ECC_BPP224T1_HIGHMEM
CMOX_ECC_BPP256T1_LOWMEM
CMOX_ECC_BPP256T1_HIGHMEM
CMOX_ECC_BPP320T1_LOWMEM
CMOX_ECC_BPP320T1_HIGHMEM
CMOX_ECC_BPP384T1_LOWMEM
CMOX_ECC_BPP384T1_HIGHMEM
CMOX_ECC_BPP512T1_LOWMEM
CMOX_ECC_BPP512T1_HIGHMEM
CMOX_ECC_FRP256V1_LOWMEM
CMOX_ECC_FRP256V1_HIGHMEM
P_pPubKey – [in] Buffer with the public key
P_PubKeyLen – [in] Byte length of the public key
P_pDigest – [in] Buffer with the digest to sign
P_DigestLen – [in] Byte length of the digest
P_pSignature – [in] Buffer with the signature (concatenation of R and S)
P_SignatureLen – [in] Byte length of the signature
P_pFaultCheck – [out] Optional value to check, together with the retval, to verify if some fault happened
- Return values :
-
CMOX_ECC_AUTH_SUCCESS – Signature verified
CMOX_ECC_AUTH_FAIL – Signature NOT verified
CMOX_ECC_ERR_MATHCURVE_MISMATCH – Mathematical function set is not compatible with current ECC curve
CMOX_ECC_ERR_ALGOCURVE_MISMATCH – Curve is not compatible with current functionality
CMOX_ECC_ERR_BAD_PARAMETERS – Some NULL/wrong/empty parameter or Construct API not called
CMOX_ECC_ERR_MEMORY_FAIL – Not enough memory
CMOX_ECC_ERR_INVALID_SIGNATURE – Input signature corrupted or not in the expected format
CMOX_ECC_ERR_INVALID_PUBKEY – Public key not in a valid format
-
cmox_ecc_retval_t
cmox_ecdsa_keyGen
(
cmox_ecc_handle_t
*
P_pEccCtx
,
const
cmox_ecc_impl_t
P_CurveParams
,
const
uint8_t
*
P_pRandom
,
size_t
P_RandomLen
,
uint8_t
*
P_pPrivKey
,
size_t
*
P_pPrivKeyLen
,
uint8_t
*
P_pPubKey
,
size_t
*
P_pPubKeyLen
)