Functions¶
-
group
group_crypto_lld_asymmetric_functions
Typedefs
-
typedef int (*
cy_func_get_random_data_t
)(void *rndInfo, uint8_t *rndData, size_t rndSize) Pointer to a random number supplier function.
Functions
-
cy_en_crypto_status_t
Cy_Crypto_Core_Rsa_Verify
(CRYPTO_Type *base, cy_en_crypto_rsa_ver_result_t *verResult, cy_en_crypto_sha_mode_t digestType, uint8_t const *digest, uint8_t const *decryptedSignature, uint32_t decryptedSignatureLength) RSA verification with checks for content, paddings and signature format.
SHA digest of the message and decrypted message should be calculated before. Supports only PKCS1-v1_5 format, inside of this format supported padding using only SHA, cases with MD2 and MD5 are not supported. PKCS1-v1_5 described here, page 31: http://www.emc.com/collateral/white-papers/h11300-pkcs-1v2-2-rsa-cryptography-standard-wp.pdf
Returns the verification result cy_en_crypto_rsa_ver_result_t.
- Parameters
base – The pointer to the CRYPTO instance.
verResult – The pointer to the verification result cy_en_crypto_rsa_ver_result_t.
digestType – SHA mode used for hash calculation cy_en_crypto_sha_mode_t.
digest – The pointer to the hash of the message whose signature is to be verified.
decryptedSignature – The pointer to the decrypted signature to be verified.
decryptedSignatureLength – The length of the decrypted signature to be verified (in bytes)
- Returns
-
cy_en_crypto_status_t
Cy_Crypto_Core_Rsa_Proc
(CRYPTO_Type *base, cy_stc_crypto_rsa_pub_key_t const *key, uint8_t const *message, uint32_t messageSize, uint8_t *processedMessage) RSA process algorithm based on the Montgomery algorithm using Barrett reduction.
https://en.wikipedia.org/wiki/RSA_%28cryptosystem%29
- Parameters
base – The pointer to the CRYPTO instance.
key – The pointer to the cy_stc_crypto_rsa_pub_key_t structure that stores public key.
message – The pointer to the message to be processed.
messageSize – The length of the message to be processed.
processedMessage – The pointer to processed message.
- Returns
-
cy_en_crypto_status_t
Cy_Crypto_Core_Rsa_Coef
(CRYPTO_Type *base, cy_stc_crypto_rsa_pub_key_t const *key) Calculation constant coefficients to to speed-up Montgomery algorithm.
These coefficients are: coefficient for Barrett reduction, binary inverse of the modulo, result of (2^moduloLength mod modulo)
- Parameters
base – The pointer to the CRYPTO instance.
key – The pointer to the cy_stc_crypto_rsa_pub_key_t structure that stores a public key.
- Returns
-
cy_en_crypto_status_t
Cy_Crypto_Core_ECC_MakeKeyPair
(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, cy_stc_crypto_ecc_key *key, cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo) Make a new ECC key pair.
- Parameters
base – The pointer to a Crypto instance.
curveID – See cy_en_crypto_ecc_curve_id_t.
key – [out] Destination of the newly created key. See cy_stc_crypto_ecc_key.
GetRandomDataFunc – See cy_func_get_random_data_t.
randomDataInfo –
- Returns
status code. See cy_en_crypto_status_t.
-
cy_en_crypto_status_t
Cy_Crypto_Core_ECC_SignHash
(CRYPTO_Type *base, const uint8_t *hash, uint32_t hashlen, uint8_t *sig, const cy_stc_crypto_ecc_key *key, const uint8_t *messageKey) Sign a message digest.
- Parameters
base – The pointer to a Crypto instance.
hash – The message digest to sign. Provided as is in data buffer.
hashlen – The length of the digest in bytes.
sig – [out] The destination for the signature, ‘r’ followed by ‘s’.
key – Key used for signature generation. See cy_stc_crypto_ecc_key.
messageKey – Message key.
- Returns
status code. See cy_en_crypto_status_t.
-
cy_en_crypto_status_t
Cy_Crypto_Core_ECC_VerifyHash
(CRYPTO_Type *base, const uint8_t *sig, const uint8_t *hash, uint32_t hashlen, uint8_t *stat, const cy_stc_crypto_ecc_key *key) Verify an ECC signature.
- Parameters
base – The pointer to a Crypto instance.
sig – The signature to verify, ‘R’ followed by ‘S’.
hash – The hash (message digest) that was signed.
hashlen – The length of the hash (octets).
stat – Result of signature, 1==valid, 0==invalid.
key – The corresponding public ECC key. See cy_stc_crypto_ecc_key.
- Returns
status code. See cy_en_crypto_status_t.
-
cy_en_crypto_status_t
Cy_Crypto_Core_ECC_MakePrivateKey
(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, uint8_t *key, cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo) Make a new ECC private key.
- Parameters
base – The pointer to a Crypto instance.
curveID – See cy_en_crypto_ecc_curve_id_t.
key – [out] Destination of the newly created key.
GetRandomDataFunc – See cy_func_get_random_data_t.
randomDataInfo –
- Returns
status code. See cy_en_crypto_status_t.
-
cy_en_crypto_status_t
Cy_Crypto_Core_ECC_MakePublicKey
(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, const uint8_t *privateKey, cy_stc_crypto_ecc_key *publicKey) Make a new ECC public key.
- Parameters
base – The pointer to a Crypto instance.
curveID – See cy_en_crypto_ecc_curve_id_t.
privateKey – [out] Destination of the newly created key.
publicKey – See cy_stc_crypto_ecc_key.
- Returns
status code. See cy_en_crypto_status_t.
-
cy_en_crypto_status_t
Cy_Crypto_Core_EC_NistP_PointMultiplication
(CRYPTO_Type *base, cy_en_crypto_ecc_curve_id_t curveID, const uint8_t *ecpGX, const uint8_t *ecpGY, const uint8_t *ecpD, uint8_t *ecpQX, uint8_t *ecpQY) Elliptic curve point multiplication in GF(p).
- Parameters
base – The pointer to a Crypto instance.
curveID – See cy_en_crypto_ecc_curve_id_t.
ecpGX – Register index for affine X coordinate of base point.
ecpGY – Register index for affine Y coordinate of base point.
ecpD – Register index for multiplication value.
ecpQX – Register index for affine X coordinate of result point.
ecpQY – Register index for affine Y coordinate of result point.
- Returns
status code. See cy_en_crypto_status_t.
-
typedef int (*