PSoC 6 Peripheral Driver Library

General Description

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_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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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). More...
 
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. More...
 
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. More...
 
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. More...
 

Function Documentation

◆ Cy_Crypto_Core_ECC_MakeKeyPair()

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
baseThe pointer to a Crypto instance.
curveIDSee cy_en_crypto_ecc_curve_id_t.
key[out] Destination of the newly created key. See cy_stc_crypto_ecc_key.
GetRandomDataFuncSee cy_func_get_random_data_t.
randomDataInfo
Returns
status code. See cy_en_crypto_status_t.

◆ Cy_Crypto_Core_ECC_SignHash()

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
baseThe pointer to a Crypto instance.
hashThe message digest to sign. Provided as is in data buffer.
hashlenThe length of the digest in bytes.
sig[out] The destination for the signature, 'r' followed by 's'.
keyKey used for signature generation. See cy_stc_crypto_ecc_key.
messageKeyMessage key.
Returns
status code. See cy_en_crypto_status_t.

◆ Cy_Crypto_Core_ECC_VerifyHash()

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
baseThe pointer to a Crypto instance.
sigThe signature to verify, 'R' followed by 'S'.
hashThe hash (message digest) that was signed.
hashlenThe length of the hash (octets).
statResult of signature, 1==valid, 0==invalid.
keyThe corresponding public ECC key. See cy_stc_crypto_ecc_key.
Returns
status code. See cy_en_crypto_status_t.

◆ Cy_Crypto_Core_ECC_MakePrivateKey()

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
baseThe pointer to a Crypto instance.
curveIDSee cy_en_crypto_ecc_curve_id_t.
key[out] Destination of the newly created key.
GetRandomDataFuncSee cy_func_get_random_data_t.
randomDataInfo
Returns
status code. See cy_en_crypto_status_t.

◆ Cy_Crypto_Core_ECC_MakePublicKey()

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
baseThe pointer to a Crypto instance.
curveIDSee cy_en_crypto_ecc_curve_id_t.
privateKey[out] Destination of the newly created key.
publicKeySee cy_stc_crypto_ecc_key.
Returns
status code. See cy_en_crypto_status_t.

◆ Cy_Crypto_Core_EC_NistP_PointMultiplication()

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
baseThe pointer to a Crypto instance.
curveIDSee cy_en_crypto_ecc_curve_id_t.
ecpGXRegister index for affine X coordinate of base point.
ecpGYRegister index for affine Y coordinate of base point.
ecpDRegister index for multiplication value.
ecpQXRegister index for affine X coordinate of result point.
ecpQYRegister index for affine Y coordinate of result point.
Returns
status code. See cy_en_crypto_status_t.

◆ Cy_Crypto_Core_Rsa_Verify()

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
baseThe pointer to the CRYPTO instance.
verResultThe pointer to the verification result cy_en_crypto_rsa_ver_result_t.
digestTypeSHA mode used for hash calculation cy_en_crypto_sha_mode_t.
digestThe pointer to the hash of the message whose signature is to be verified.
decryptedSignatureThe pointer to the decrypted signature to be verified.
decryptedSignatureLengthThe length of the decrypted signature to be verified (in bytes)
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Rsa_Proc()

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
baseThe pointer to the CRYPTO instance.
keyThe pointer to the cy_stc_crypto_rsa_pub_key_t structure that stores public key.
messageThe pointer to the message to be processed.
messageSizeThe length of the message to be processed.
processedMessageThe pointer to processed message.
Returns
cy_en_crypto_status_t

◆ Cy_Crypto_Core_Rsa_Coef()

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
baseThe pointer to the CRYPTO instance.
keyThe pointer to the cy_stc_crypto_rsa_pub_key_t structure that stores a public key.
Returns
cy_en_crypto_status_t