Typedefs | |
typedef cy_en_cryptolite_status_t(* | cy_cryptolite_ed25519_sha512_init_t) (void *context) |
Pointer to a sha initialization function. | |
typedef cy_en_cryptolite_status_t(* | cy_cryptolite_ed25519_sha512_update_t) (void *context, uint8_t const *input, uint32_t inputSize) |
Pointer to a sha update function. | |
typedef cy_en_cryptolite_status_t(* | cy_cryptolite_ed25519_sha512_start_t) (void *context) |
Pointer to a sha start function. | |
typedef cy_en_cryptolite_status_t(* | cy_cryptolite_ed25519_sha512_finish_t) (void *context, uint8_t *output) |
Pointer to a sha output function. | |
typedef cy_en_cryptolite_status_t(* | cy_cryptolite_ed25519_sha512_free_t) (void *context) |
Pointer to a sha deinitialization function. | |
Functions | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ECC_Init (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, cy_stc_cryptolite_ecc_buffer_t *eccBuffer) |
Init ECC Context. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ECC_Free (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext) |
Clean up ECC Context. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ECC_SignHash (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, const uint8_t *hash, uint32_t hashlen, uint8_t *sig, const cy_stc_cryptolite_ecc_key *key, const uint8_t *messageKey) |
Function to generate an ECC signature. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ECC_VerifyHash (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, const uint8_t *sig, uint32_t siglen, const uint8_t *hash, uint32_t hashlen, cy_en_cryptolite_sig_verify_result_t *stat, const cy_stc_cryptolite_ecc_key *key) |
Verify an ECC signature. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ECC_SharedSecret (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, cy_en_cryptolite_ecc_curve_id_t curveID, const uint8_t *privateKey, const cy_stc_cryptolite_ecc_key *key, uint8_t const *sharedSecret) |
Generate a Shared Secret key from one private key and others public key. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ED25519_Init (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, cy_stc_cryptolite_ecc_buffer_t *eccBuffer, cy_stc_cryptolite_ed25519_sha512_t *shaFunctions) |
Init ED25519 Context. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ED25519_Free (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext) |
Free ED25519 Context. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ED25519_Sign (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, const uint8_t *hash, uint32_t hashlen, uint8_t *sig, const cy_stc_cryptolite_ecc_key *key, cy_en_cryptolite_eddsa_sig_type_t sigType, const uint8_t *sigctx, uint32_t sigctx_len) |
Sign a message. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ED25519_PointMultiplication (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, const uint8_t *ecpGX, const uint8_t *ecpGY, const uint8_t *ecpD, uint8_t *ecpQX, uint8_t *ecpQY) |
Edwards 25519 elliptic curve point multiplication in GF(p). More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ED25519_PointDecode (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, const uint8_t *publicKey, uint8_t *pubKey_x, uint8_t *pubKey_y) |
Decode ED25519 encoded public key in to x and y. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ED25519_Verify (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, uint8_t *sig, const uint8_t *hash, uint32_t hashlen, const cy_stc_cryptolite_ecc_key *key, uint32_t *stat, cy_en_cryptolite_eddsa_sig_type_t sigType, const uint8_t *sigctx, uint32_t sigctx_len) |
Verify ED25519 signed message. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_ED25519_MakePublicKey (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, const uint8_t *privateKey, cy_stc_cryptolite_ecc_key *publicKey) |
Make a new ED25519 public key. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_EC25519_MakePublicKey (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, const uint8_t *privateKey, cy_stc_cryptolite_ecc_key *publicKey) |
Make a new EC25519 public key. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_EC25519_MakePrivateKey (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, uint8_t *privateKey, cy_func_get_random_data_t GetRandomDataFunc, void *randomDataInfo) |
Make a new EC25519 private key. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_EC25519_PointMultiplication (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_ecdsa_t *cfContext, uint8_t *p_r, const uint8_t *p_x, const uint8_t *p_d) |
EC25519 Elliptic curve point multiplication in GF(p). More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_Rsa_Init (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_rsa_t *cfContext, cy_stc_cryptolite_rsa_buffer_t *rsaBuffers) |
Initialize the RSA context. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_Rsa_Proc (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_rsa_t *cfContext, cy_stc_cryptolite_rsa_pub_key_t *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_cryptolite_status_t | Cy_Cryptolite_Rsa_Coef (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_rsa_t *cfContext, cy_stc_cryptolite_rsa_pub_key_t *key) |
Calculation constant coefficients to speed-up Montgomery algorithm. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_Rsa_Free (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_rsa_t *cfContext) |
Cleanup the RSA context. More... | |
cy_en_cryptolite_status_t | Cy_Cryptolite_Rsa_Verify (CRYPTOLITE_Type *base, cy_stc_cryptolite_context_rsa_t *cfContext, cy_en_cryptolite_sig_verify_result_t *verResult, cy_en_cryptolite_sha_mode_t digestType, uint8_t const *digest, uint32_t digestLength, uint8_t const *decryptedSignature, uint32_t decryptedSignatureLength) |
RSA verification with checks for content, paddings and signature format. More... | |
cy_en_cryptolite_status_t Cy_Cryptolite_ECC_Init | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
cy_stc_cryptolite_ecc_buffer_t * | eccBuffer | ||
) |
Init ECC Context.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
eccBuffer | The pointer to the cy_stc_cryptolite_ecc_buffer_t. |
cy_en_cryptolite_status_t Cy_Cryptolite_ECC_Free | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext | ||
) |
Clean up ECC Context.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
cy_en_cryptolite_status_t Cy_Cryptolite_ECC_SignHash | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
const uint8_t * | hash, | ||
uint32_t | hashlen, | ||
uint8_t * | sig, | ||
const cy_stc_cryptolite_ecc_key * | key, | ||
const uint8_t * | messageKey | ||
) |
Function to generate an ECC signature.
key, hash and messageKey must be in little endian. Cy_Cryptolite_InvertEndianness() function is used for converting the endianness.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
hash | The hash (message digest) to be signed. |
hashlen | The length of the hash (octets). |
sig | The pointer to the buffer to store the generated signature 'R' followed by 'S'. |
key | The private ECC key to sign the hash. See cy_stc_cryptolite_ecc_key. |
messageKey | The random number for generating the signature. |
cy_en_cryptolite_status_t Cy_Cryptolite_ECC_VerifyHash | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
const uint8_t * | sig, | ||
uint32_t | siglen, | ||
const uint8_t * | hash, | ||
uint32_t | hashlen, | ||
cy_en_cryptolite_sig_verify_result_t * | stat, | ||
const cy_stc_cryptolite_ecc_key * | key | ||
) |
Verify an ECC signature.
sig, hash and key must be in little endian. Cy_Cryptolite_InvertEndianness() function is used for converting the endianness.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the ecdsa context. |
sig | The signature to verify, 'R' followed by 'S'. |
siglen | The length of signature. |
hash | The hash (message digest) that was signed. |
hashlen | The length of the hash (octets). |
stat | Result of signature, 0xAAAAAAAA = invalid, 0x55555555 = valid. |
key | The corresponding public ECC key. See cy_stc_cryptolite_ecc_key. |
cy_en_cryptolite_status_t Cy_Cryptolite_ECC_SharedSecret | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
cy_en_cryptolite_ecc_curve_id_t | curveID, | ||
const uint8_t * | privateKey, | ||
const cy_stc_cryptolite_ecc_key * | key, | ||
uint8_t const * | sharedSecret | ||
) |
Generate a Shared Secret key from one private key and others public key.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
curveID | The ECC curve id. |
privateKey | The pointer to the ECC private key. |
key | The generated public ECC key. See cy_stc_cryptolite_ecc_key. |
sharedSecret | The pointer to store the generated shared Secret. |
cy_en_cryptolite_status_t Cy_Cryptolite_ED25519_Init | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
cy_stc_cryptolite_ecc_buffer_t * | eccBuffer, | ||
cy_stc_cryptolite_ed25519_sha512_t * | shaFunctions | ||
) |
Init ED25519 Context.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
eccBuffer | The pointer to the cy_stc_cryptolite_ecc_buffer_t. |
shaFunctions | The pointer to the cy_stc_cryptolite_ed25519_sha512_t. |
cy_en_cryptolite_status_t Cy_Cryptolite_ED25519_Free | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext | ||
) |
Free ED25519 Context.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
cy_en_cryptolite_status_t Cy_Cryptolite_ED25519_Sign | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
const uint8_t * | hash, | ||
uint32_t | hashlen, | ||
uint8_t * | sig, | ||
const cy_stc_cryptolite_ecc_key * | key, | ||
cy_en_cryptolite_eddsa_sig_type_t | sigType, | ||
const uint8_t * | sigctx, | ||
uint32_t | sigctx_len | ||
) |
Sign a message.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
hash | The message to sign. Provided as is in data buffer. This is usually the hash of the original data to be signed. |
hashlen | The length of the message in bytes. |
sig | [out] The destination for the signature, 'r' followed by 's'. |
key | Key (Little Endian) used for signature generation. See cy_stc_cryptolite_ecc_key. |
sigType | signature Type. CY_CRYPTOLITE_EDDSA_PURE,CY_CRYPTOLITE_EDDSA_CTX or CY_CRYPTOLITE_EDDSA_PREHASH |
sigctx | signature context. can be NULL if EDDSA_PURE is used or if no context is provided. |
sigctx_len | The length of the signature context |
cy_en_cryptolite_status_t Cy_Cryptolite_ED25519_PointMultiplication | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
const uint8_t * | ecpGX, | ||
const uint8_t * | ecpGY, | ||
const uint8_t * | ecpD, | ||
uint8_t * | ecpQX, | ||
uint8_t * | ecpQY | ||
) |
Edwards 25519 elliptic curve point multiplication in GF(p).
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
ecpGX | X coordinate of base point. |
ecpGY | Y coordinate of base point. |
ecpD | multiplication scalar value. |
ecpQX | X coordinate of result point. |
ecpQY | Y coordinate of result point. |
cy_en_cryptolite_status_t Cy_Cryptolite_ED25519_PointDecode | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
const uint8_t * | publicKey, | ||
uint8_t * | pubKey_x, | ||
uint8_t * | pubKey_y | ||
) |
Decode ED25519 encoded public key in to x and y.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
publicKey | [in] encoded 32 byte Public key. |
pubKey_x | [out] Decoded 32 bytes Public key x in little-endian format. |
pubKey_y | [out] Decoded 32 bytes Public key y in little-endian format. |
cy_en_cryptolite_status_t Cy_Cryptolite_ED25519_Verify | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
uint8_t * | sig, | ||
const uint8_t * | hash, | ||
uint32_t | hashlen, | ||
const cy_stc_cryptolite_ecc_key * | key, | ||
uint32_t * | stat, | ||
cy_en_cryptolite_eddsa_sig_type_t | sigType, | ||
const uint8_t * | sigctx, | ||
uint32_t | sigctx_len | ||
) |
Verify ED25519 signed message.
On successful verification, CY_CRYPTOLITE_SUCCESS is returned and stat is 0xA1A1A1A1.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
sig | The signature to verify, 'R' followed by 'S'. |
hash | The hash or message that was signed. |
hashlen | The length of the hash or message (octets). |
stat | Result of signature verification, 0xA1A1A1A1==valid, 0x00BADBAD==invalid. |
key | The corresponding uncompressed public key to use (little-endian). See cy_stc_cryptolite_ecc_key. |
sigType | signature Type. CY_CRYPTOLITE_EDDSA_PURE,CY_CRYPTOLITE_EDDSA_CTX or CY_CRYPTOLITE_EDDSA_PREHASH |
sigctx | signature context. can be NULL if EDDSA_PURE is used or if no context is provided. |
sigctx_len | The length of the signature context |
cy_en_cryptolite_status_t Cy_Cryptolite_ED25519_MakePublicKey | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
const uint8_t * | privateKey, | ||
cy_stc_cryptolite_ecc_key * | publicKey | ||
) |
Make a new ED25519 public key.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
privateKey | [in] Private key. |
publicKey | [out] Newly created Public key. See cy_stc_cryptolite_ecc_key. |
cy_en_cryptolite_status_t Cy_Cryptolite_EC25519_MakePublicKey | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
const uint8_t * | privateKey, | ||
cy_stc_cryptolite_ecc_key * | publicKey | ||
) |
Make a new EC25519 public key.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
privateKey | [in] Private key. |
publicKey | [out] Newly created Public key. See cy_stc_cryptolite_ecc_key. |
cy_en_cryptolite_status_t Cy_Cryptolite_EC25519_MakePrivateKey | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
uint8_t * | privateKey, | ||
cy_func_get_random_data_t | GetRandomDataFunc, | ||
void * | randomDataInfo | ||
) |
Make a new EC25519 private key.
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
privateKey | [out] Destination of the newly created key. |
GetRandomDataFunc | See cy_func_get_random_data_t. |
randomDataInfo | Argument for GetRandomDataFunc. |
cy_en_cryptolite_status_t Cy_Cryptolite_EC25519_PointMultiplication | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_ecdsa_t * | cfContext, | ||
uint8_t * | p_r, | ||
const uint8_t * | p_x, | ||
const uint8_t * | p_d | ||
) |
EC25519 Elliptic curve point multiplication in GF(p).
base | The pointer to a Cryptolite instance. |
cfContext | The pointer to the cy_stc_cryptolite_context_ecdsa_t. |
p_r | Pointer to result point. |
p_x | Pointer to X coordinate of base point. |
p_d | Pointer to Scalar multiplication value. |
cy_en_cryptolite_status_t Cy_Cryptolite_Rsa_Init | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_rsa_t * | cfContext, | ||
cy_stc_cryptolite_rsa_buffer_t * | rsaBuffers | ||
) |
Initialize the RSA context.
base | The pointer to the CRYPTOLITE instance. |
cfContext | The pointer to the CRYPTOLITE context. |
rsaBuffers | The pointer to the RSA buffers. |
cy_en_cryptolite_status_t Cy_Cryptolite_Rsa_Proc | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_rsa_t * | cfContext, | ||
cy_stc_cryptolite_rsa_pub_key_t * | 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
Key, message, processedMessage buffers must be 4 byte aligned and end with 4 byte boundary.
base | The pointer to the CRYPTOLITE instance. |
cfContext | The pointer to the CRYPTOLITE context. |
key | The pointer to the cy_stc_cryptolite_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. |
cy_en_cryptolite_status_t Cy_Cryptolite_Rsa_Coef | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_rsa_t * | cfContext, | ||
cy_stc_cryptolite_rsa_pub_key_t * | key | ||
) |
Calculation constant coefficients to speed-up Montgomery algorithm.
These coefficients are: coefficient for Barrett reduction, binary inverse of the modulo, result of (2^moduloLength mod modulo)
base | The pointer to the CRYPTOLITE instance. |
cfContext | The pointer to the CRYPTOLITE context. |
key | The pointer to the cy_stc_cryptolite_rsa_pub_key_t structure that stores a public key. |
cy_en_cryptolite_status_t Cy_Cryptolite_Rsa_Free | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_rsa_t * | cfContext | ||
) |
Cleanup the RSA context.
base | The pointer to the CRYPTOLITE instance. |
cfContext | The pointer to the CRYPTOLITE context. |
cy_en_cryptolite_status_t Cy_Cryptolite_Rsa_Verify | ( | CRYPTOLITE_Type * | base, |
cy_stc_cryptolite_context_rsa_t * | cfContext, | ||
cy_en_cryptolite_sig_verify_result_t * | verResult, | ||
cy_en_cryptolite_sha_mode_t | digestType, | ||
uint8_t const * | digest, | ||
uint32_t | digestLength, | ||
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
The digest and decryptedSignature buffers must be 4 byte aligned
Returns the verification result cy_en_cryptolite_sig_verify_result_t.
base | The pointer to the CRYPTOLITE instance. |
cfContext | The pointer to the CRYPTOLITE context. |
verResult | The pointer to the verification result cy_en_cryptolite_sig_verify_result_t. |
digestType | SHA mode used for hash calculation cy_en_cryptolite_sha_mode_t. |
digest | The pointer to the hash of the message or the message whose signature is to be verified. |
digestLength | The length of the message whose signature is to be verified and is applicable for CY_CRYPTOLITE_MODE_SHA_NONE mode. |
decryptedSignature | The pointer to the decrypted signature to be verified. |
decryptedSignatureLength | The length of the decrypted signature to be verified (in bytes) |