Functions | |
cy_en_crypto_status_t | Cy_Crypto_Init (cy_stc_crypto_config_t const *config, cy_stc_crypto_context_t *context) |
This function initializes the Crypto context buffer and configures the Crypto driver. More... | |
cy_en_crypto_status_t | Cy_Crypto_DeInit (void) |
This function de-initializes the Crypto driver. More... | |
cy_en_crypto_status_t | Cy_Crypto_Enable (void) |
This function enables (turns on) the Crypto hardware. More... | |
cy_en_crypto_status_t | Cy_Crypto_Disable (void) |
This function disables (turns off) the Crypto hardware. More... | |
cy_en_crypto_status_t | Cy_Crypto_Sync (bool isBlocking) |
This function waits or just checks (depending on the parameter) for the Crypto operation to complete. More... | |
cy_en_crypto_status_t | Cy_Crypto_GetErrorStatus (cy_stc_crypto_hw_error_t *hwErrorCause) |
This function returns a cause of a Crypto hardware error. More... | |
cy_en_crypto_status_t | Cy_Crypto_Prng_Init (uint32_t lfsr32InitState, uint32_t lfsr31InitState, uint32_t lfsr29InitState, cy_stc_crypto_context_prng_t *cfContext) |
This function initializes parameters of the PRNG. More... | |
cy_en_crypto_status_t | Cy_Crypto_Prng_Generate (uint32_t max, uint32_t *randomNum, cy_stc_crypto_context_prng_t *cfContext) |
This function generates 32-bit the Pseudo Random Number. More... | |
cy_en_crypto_status_t | Cy_Crypto_Aes_Init (uint32_t *key, cy_en_crypto_aes_key_length_t keyLength, cy_stc_crypto_context_aes_t *cfContext) |
This function initializes the AES operation by setting key and key length. More... | |
cy_en_crypto_status_t | Cy_Crypto_Aes_Ecb_Run (cy_en_crypto_dir_mode_t dirMode, uint32_t *dstBlock, uint32_t *srcBlock, cy_stc_crypto_context_aes_t *cfContext) |
This function performs AES operation on one 16-byte block (see CY_CRYPTO_AES_BLOCK_SIZE). More... | |
cy_en_crypto_status_t | Cy_Crypto_Aes_Cbc_Run (cy_en_crypto_dir_mode_t dirMode, uint32_t srcSize, uint32_t *ivPtr, uint32_t *dst, uint32_t *src, cy_stc_crypto_context_aes_t *cfContext) |
This function performs AES operation on a plain text with Cipher Block Chaining (CBC). More... | |
cy_en_crypto_status_t | Cy_Crypto_Aes_Cfb_Run (cy_en_crypto_dir_mode_t dirMode, uint32_t srcSize, uint32_t *ivPtr, uint32_t *dst, uint32_t *src, cy_stc_crypto_context_aes_t *cfContext) |
This function performs AES operation on a plain text with Cipher Feedback mode (CFB). More... | |
cy_en_crypto_status_t | Cy_Crypto_Aes_Ctr_Run (cy_en_crypto_dir_mode_t dirMode, uint32_t srcSize, uint32_t *srcOffset, uint32_t nonceCounter[CY_CRYPTO_AES_BLOCK_SIZE/8u], uint32_t streamBlock[CY_CRYPTO_AES_BLOCK_SIZE/8u], uint32_t *dst, uint32_t *src, cy_stc_crypto_context_aes_t *cfContext) |
This function performs AES operation on a plain text with Cipher Block Counter mode (CTR). More... | |
cy_en_crypto_status_t | Cy_Crypto_Aes_Cmac_Run (uint32_t *src, uint32_t srcSize, uint32_t *key, cy_en_crypto_aes_key_length_t keyLength, uint32_t *cmacPtr, cy_stc_crypto_context_aes_t *cfContext) |
This function performs the cipher-block chaining-message authentication-code. More... | |
cy_en_crypto_status_t | Cy_Crypto_Sha_Run (uint32_t *message, uint32_t messageSize, uint32_t *digest, cy_en_crypto_sha_mode_t mode, cy_stc_crypto_context_sha_t *cfContext) |
This function performs the SHA Hash function. More... | |
cy_en_crypto_status_t | Cy_Crypto_Hmac_Run (uint32_t *hmac, uint32_t *message, uint32_t messageSize, uint32_t *key, uint32_t keyLength, cy_en_crypto_sha_mode_t mode, cy_stc_crypto_context_sha_t *cfContext) |
This function performs HMAC calculation. More... | |
cy_en_crypto_status_t | Cy_Crypto_Str_MemCpy (void *dst, void const *src, uint16_t size, cy_stc_crypto_context_str_t *cfContext) |
This function copies a memory block. More... | |
cy_en_crypto_status_t | Cy_Crypto_Str_MemSet (void *dst, uint8_t data, uint16_t size, cy_stc_crypto_context_str_t *cfContext) |
This function sets the memory block. More... | |
cy_en_crypto_status_t | Cy_Crypto_Str_MemCmp (void const *src0, void const *src1, uint16_t size, uint32_t *resultPtr, cy_stc_crypto_context_str_t *cfContext) |
This function compares memory blocks. More... | |
cy_en_crypto_status_t | Cy_Crypto_Str_MemXor (void const *src0, void const *src1, void *dst, uint16_t size, cy_stc_crypto_context_str_t *cfContext) |
This function calculates the XOR of two memory blocks. More... | |
cy_en_crypto_status_t | Cy_Crypto_Crc_Init (uint32_t polynomial, uint8_t dataReverse, uint8_t dataXor, uint8_t remReverse, uint32_t remXor, cy_stc_crypto_context_crc_t *cfContext) |
This function performs CRC initialization. More... | |
cy_en_crypto_status_t | Cy_Crypto_Crc_Run (void *data, uint16_t dataSize, uint32_t *crc, uint32_t lfsrInitState, cy_stc_crypto_context_crc_t *cfContext) |
This function performs CRC calculation on a message. More... | |
cy_en_crypto_status_t | Cy_Crypto_Trng_Generate (uint32_t GAROPol, uint32_t FIROPol, uint32_t max, uint32_t *randomNum, cy_stc_crypto_context_trng_t *cfContext) |
This function generates a 32-bit True Random Number. More... | |
cy_en_crypto_status_t | Cy_Crypto_Des_Run (cy_en_crypto_dir_mode_t dirMode, uint32_t *key, uint32_t *dstBlock, uint32_t *srcBlock, cy_stc_crypto_context_des_t *cfContext) |
This function performs DES operation on a Single Block. More... | |
cy_en_crypto_status_t | Cy_Crypto_Tdes_Run (cy_en_crypto_dir_mode_t dirMode, uint32_t *key, uint32_t *dstBlock, uint32_t *srcBlock, cy_stc_crypto_context_des_t *cfContext) |
This function performs the TDES operation on a single block. More... | |
cy_en_crypto_status_t | Cy_Crypto_Rsa_Proc (cy_stc_crypto_rsa_pub_key_t const *pubKey, uint32_t const *message, uint32_t messageSize, uint32_t *processedMessage, cy_stc_crypto_context_rsa_t *cfContext) |
This function calculates (m^e mod modulo) where m is Message (Signature), e - public exponent using a public key in the next representation, it contains: modulo, public exponent, coefficient for Barrett reduction, binary inverse of the modulo, and result of (2^moduloLength mod modulo). More... | |
cy_en_crypto_status_t | Cy_Crypto_Rsa_CalcCoefs (cy_stc_crypto_rsa_pub_key_t const *pubKey, cy_stc_crypto_context_rsa_t *cfContext) |
This function calculates constant coefficients (which is dependent only on modulo and independent on message). More... | |
cy_en_crypto_status_t | Cy_Crypto_Rsa_Verify (cy_en_crypto_rsa_ver_result_t *verResult, cy_en_crypto_sha_mode_t digestType, uint32_t const *digest, uint32_t const *decryptedSignature, uint32_t decryptedSignatureLength, cy_stc_crypto_context_rsa_ver_t *cfContext) |
This function does an RSA verification with checks for content, paddings, and signature format. More... | |
cy_en_crypto_status_t | Cy_Crypto_ECDSA_SignHash (const uint8_t *hash, uint32_t hashlen, uint8_t *sig, const cy_stc_crypto_ecc_key *key, const uint8_t *messageKey, cy_stc_crypto_context_ecc_t *cfContext) |
Sign a message digest. More... | |
cy_en_crypto_status_t | Cy_Crypto_ECDSA_VerifyHash (const uint8_t *sig, const uint8_t *hash, uint32_t hashlen, uint8_t *stat, const cy_stc_crypto_ecc_key *key, cy_stc_crypto_context_ecc_t *cfContext) |
Verify an ECC signature. More... | |
cy_en_crypto_status_t | Cy_Crypto_SetMemBufAddress (uint32_t const *newMembufAddress, uint32_t newMembufSize, cy_stc_crypto_context_str_t *cfContext) |
This function sets a new operation memory buffer. More... | |
cy_en_crypto_status_t | Cy_Crypto_GetMemBufAddress (uint32_t **membufAddress, cy_stc_crypto_context_str_t *cfContext) |
This function gets an operation memory buffer location. More... | |
cy_en_crypto_status_t | Cy_Crypto_GetMemBufSize (uint32_t *membufSize, cy_stc_crypto_context_str_t *cfContext) |
This function gets an operation memory buffer size. More... | |
void | Cy_Crypto_InvertEndianness (void *inArrPtr, uint32_t byteSize) |
This function reverts byte-array memory block, like: inArr[0] <—> inArr[n] inArr[1] <—> inArr[n-1] inArr[2] <—> inArr[n-2] ........................ inArr[n/2] <—> inArr[n/2-1] More... | |
cy_en_crypto_status_t Cy_Crypto_Init | ( | cy_stc_crypto_config_t const * | config, |
cy_stc_crypto_context_t * | context | ||
) |
This function initializes the Crypto context buffer and configures the Crypto driver.
Must be called at first.
To start working with Crypto methods after Crypto_Init(), call Crypto_Enable() to turn-on the Crypto Hardware.
config | The pointer to the Crypto configuration structure. |
context | The pointer to the cy_stc_crypto_context_t instance of structure that stores the Crypto driver common context. |
cy_en_crypto_status_t Cy_Crypto_DeInit | ( | void | ) |
This function de-initializes the Crypto driver.
cy_en_crypto_status_t Cy_Crypto_Enable | ( | void | ) |
This function enables (turns on) the Crypto hardware.
cy_en_crypto_status_t Cy_Crypto_Disable | ( | void | ) |
This function disables (turns off) the Crypto hardware.
cy_en_crypto_status_t Cy_Crypto_Sync | ( | bool | isBlocking | ) |
This function waits or just checks (depending on the parameter) for the Crypto operation to complete.
isBlocking | Set whether Crypto_Sync is blocking: True - is blocking. False - is not blocking. |
cy_en_crypto_status_t Cy_Crypto_GetErrorStatus | ( | cy_stc_crypto_hw_error_t * | hwErrorCause | ) |
This function returns a cause of a Crypto hardware error.
It is independent of the Crypto previous state.
hwErrorCause | cy_stc_crypto_hw_error_t. |
cy_en_crypto_status_t Cy_Crypto_Prng_Init | ( | uint32_t | lfsr32InitState, |
uint32_t | lfsr31InitState, | ||
uint32_t | lfsr29InitState, | ||
cy_stc_crypto_context_prng_t * | cfContext | ||
) |
This function initializes parameters of the PRNG.
Call to initialize this encryption technique before using any associated functions. You must initialize this technique again after using any other encryption technique. Invoking this function resets the pseudo random sequence.
lfsr32InitState | A non-zero seed value for the first LFSR. User selected. |
lfsr31InitState | A non-zero seed value for the second LFSR. User selected. |
lfsr29InitState | A non-zero seed value for the third LFSR. User selected. |
cfContext | The pointer to the cy_stc_crypto_context_prng_t structure that stores the Crypto function context. |
cy_en_crypto_status_t Cy_Crypto_Prng_Generate | ( | uint32_t | max, |
uint32_t * | randomNum, | ||
cy_stc_crypto_context_prng_t * | cfContext | ||
) |
This function generates 32-bit the Pseudo Random Number.
It depends on Cy_Crypto_Prng_Init that should be called before.
max | The maximum value of a generated random number. |
randomNum | The pointer to a variable to store the generated pseudo random number. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_prng_t structure that stores the Crypto function context. |
cy_en_crypto_status_t Cy_Crypto_Aes_Init | ( | uint32_t * | key, |
cy_en_crypto_aes_key_length_t | keyLength, | ||
cy_stc_crypto_context_aes_t * | cfContext | ||
) |
This function initializes the AES operation by setting key and key length.
Call to initialize this encryption technique before using any associated functions. You must initialize this technique again after using any other encryption technique.
key | The pointer to the encryption/decryption key. Must be 4-byte aligned. |
keyLength | cy_en_crypto_aes_key_length_t |
cfContext | The pointer to the cy_stc_crypto_context_aes_t structure that stores all internal variables the Crypto driver requires. |
cy_en_crypto_status_t Cy_Crypto_Aes_Ecb_Run | ( | cy_en_crypto_dir_mode_t | dirMode, |
uint32_t * | dstBlock, | ||
uint32_t * | srcBlock, | ||
cy_stc_crypto_context_aes_t * | cfContext | ||
) |
This function performs AES operation on one 16-byte block (see CY_CRYPTO_AES_BLOCK_SIZE).
The AES key must be set before by invoking Cy_Crypto_Aes_Init().
dirMode | Can be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t). |
srcBlock | The pointer to a 16-byte source block. Must be 4-byte aligned. |
dstBlock | The pointer to a 16-byte destination cipher block. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_aes_t instance of structure that stores all AES internal variables. |
cy_en_crypto_status_t Cy_Crypto_Aes_Cbc_Run | ( | cy_en_crypto_dir_mode_t | dirMode, |
uint32_t | srcSize, | ||
uint32_t * | ivPtr, | ||
uint32_t * | dst, | ||
uint32_t * | src, | ||
cy_stc_crypto_context_aes_t * | cfContext | ||
) |
This function performs AES operation on a plain text with Cipher Block Chaining (CBC).
The key must be set before by invoking Cy_Crypto_Aes_Init().
dirMode | Can be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t) |
srcSize | The size of the source plain text. |
ivPtr | The pointer to the initial vector. Must be 4-byte aligned. |
dst | The pointer to a destination cipher text. Must be 4-byte aligned. |
src | The pointer to a source plain text. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_aes_t structure that stores all internal variables the Crypto driver requires. |
cy_en_crypto_status_t Cy_Crypto_Aes_Cfb_Run | ( | cy_en_crypto_dir_mode_t | dirMode, |
uint32_t | srcSize, | ||
uint32_t * | ivPtr, | ||
uint32_t * | dst, | ||
uint32_t * | src, | ||
cy_stc_crypto_context_aes_t * | cfContext | ||
) |
This function performs AES operation on a plain text with Cipher Feedback mode (CFB).
The key must be set before by invoking Cy_Crypto_Aes_Init().
dirMode | Can be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t) |
srcSize | The size of the source plain text. |
ivPtr | The pointer to the initial vector. Must be 4-byte aligned. |
dst | The pointer to the destination cipher text. Must be 4-byte aligned. |
src | The pointer to the source plain text. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_aes_t structure that stores all internal variables the Crypto driver requires. |
cy_en_crypto_status_t Cy_Crypto_Aes_Ctr_Run | ( | cy_en_crypto_dir_mode_t | dirMode, |
uint32_t | srcSize, | ||
uint32_t * | srcOffset, | ||
uint32_t | nonceCounter[CY_CRYPTO_AES_BLOCK_SIZE/8u], | ||
uint32_t | streamBlock[CY_CRYPTO_AES_BLOCK_SIZE/8u], | ||
uint32_t * | dst, | ||
uint32_t * | src, | ||
cy_stc_crypto_context_aes_t * | cfContext | ||
) |
This function performs AES operation on a plain text with Cipher Block Counter mode (CTR).
NOTE: preparation of the unique nonceCounter for each block is the user's responsibility. This function is dependent on the key being set before invoking Cy_Crypto_Aes_Init().
dirMode | Can be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t) |
srcSize | The size of a source plain text. |
srcOffset | The size of an offset within the current block stream for resuming within the current cipher stream. |
nonceCounter | The 128-bit nonce and counter. Must be 4-byte aligned. |
streamBlock | The saved stream-block for resuming. Is over-written by the function. Must be 4-byte aligned. |
dst | The pointer to the destination cipher text. Must be 4-byte aligned. |
src | The pointer to the source plain text. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_aes_t structure that stores all internal variables the Crypto driver requires. |
cy_en_crypto_status_t Cy_Crypto_Aes_Cmac_Run | ( | uint32_t * | src, |
uint32_t | srcSize, | ||
uint32_t * | key, | ||
cy_en_crypto_aes_key_length_t | keyLength, | ||
uint32_t * | cmacPtr, | ||
cy_stc_crypto_context_aes_t * | cfContext | ||
) |
This function performs the cipher-block chaining-message authentication-code.
There is no Init function. Provide the required parameters and the pointer to the context structure when making this function call.
src | The pointer to the source plain text. Must be 4-byte aligned. |
srcSize | The size of a source plain text. |
key | The pointer to the encryption key. Must be 4-byte aligned. |
keyLength | cy_en_crypto_aes_key_length_t |
cmacPtr | The pointer to the calculated CMAC. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_aes_t structure that stores all internal variables the Crypto driver requires. |
cy_en_crypto_status_t Cy_Crypto_Sha_Run | ( | uint32_t * | message, |
uint32_t | messageSize, | ||
uint32_t * | digest, | ||
cy_en_crypto_sha_mode_t | mode, | ||
cy_stc_crypto_context_sha_t * | cfContext | ||
) |
This function performs the SHA Hash function.
There is no Init function. Provide the required parameters and the pointer to the context structure when making this function call. It is independent of the previous Crypto state because it already contains preparation, calculation, and finalization steps.
mode | cy_en_crypto_sha_mode_t |
message | The pointer to a message whose hash value is being computed. Must be 4-byte aligned. |
messageSize | The size of a message. |
digest | The pointer to the hash digest. The hash size depends on the selected SHA mode (from 20 to 64 bytes, see CY_CRYPTO_SHA_MAX_DIGEST_SIZE). Must be 4-byte aligned. |
cfContext | the pointer to the cy_stc_crypto_context_sha_t structure that stores all internal variables for Crypto driver. |
cy_en_crypto_status_t Cy_Crypto_Hmac_Run | ( | uint32_t * | hmac, |
uint32_t * | message, | ||
uint32_t | messageSize, | ||
uint32_t * | key, | ||
uint32_t | keyLength, | ||
cy_en_crypto_sha_mode_t | mode, | ||
cy_stc_crypto_context_sha_t * | cfContext | ||
) |
This function performs HMAC calculation.
There is no Init function. Provide the required parameters and the pointer to the context structure when making this function call. It is independent of the previous Crypto state because it already contains preparation, calculation, and finalization steps.
hmac | The pointer to the calculated HMAC. Must be 4-byte aligned. |
message | The pointer to a message whose hash value is being computed. Must be 4-byte aligned. |
messageSize | The size of a message. |
key | The pointer to the key. Must be 4-byte aligned. |
keyLength | The length of the key. |
mode | cy_en_crypto_sha_mode_t |
cfContext | the pointer to the cy_stc_crypto_context_sha_t structure that stores all internal variables for the Crypto driver. |
cy_en_crypto_status_t Cy_Crypto_Str_MemCpy | ( | void * | dst, |
void const * | src, | ||
uint16_t | size, | ||
cy_stc_crypto_context_str_t * | cfContext | ||
) |
This function copies a memory block.
It operates on data in the user SRAM and doesn't use Crypto internal SRAM.
There is no alignment restriction. This function is independent of the previous Crypto state.
dst | The pointer to the destination of MemCpy. |
src | The pointer to the source of MemCpy. |
size | The size in bytes of the copy operation. Maximum size is 65535 Bytes. |
cfContext | The pointer to the cy_stc_crypto_context_str_t structure that stores all internal variables for the Crypto driver. |
cy_en_crypto_status_t Cy_Crypto_Str_MemSet | ( | void * | dst, |
uint8_t | data, | ||
uint16_t | size, | ||
cy_stc_crypto_context_str_t * | cfContext | ||
) |
This function sets the memory block.
It operates on data in the user SRAM and doesn't use Crypto internal SRAM.
There is no alignment restriction. This function is independent from the previous Crypto state.
dst | The pointer to the destination of MemSet. |
data | The value to be set. |
size | The size in bytes of the set operation. Maximum size is 65535 Bytes. |
cfContext | the pointer to the cy_stc_crypto_context_str_t structure that stores all internal variables for the Crypto driver. |
cy_en_crypto_status_t Cy_Crypto_Str_MemCmp | ( | void const * | src0, |
void const * | src1, | ||
uint16_t | size, | ||
uint32_t * | resultPtr, | ||
cy_stc_crypto_context_str_t * | cfContext | ||
) |
This function compares memory blocks.
It operates on data in the user SRAM and doesn't use Crypto internal SRAM.
There is no alignment restriction. This function is independent from the previous Crypto state.
src0 | The pointer to the first source of MemCmp. |
src1 | The pointer to the second source of MemCmp. |
size | The size in bytes of the compare operation. Maximum size is 65535 Bytes. |
resultPtr | The pointer to the result of compare (must be 4-byte aligned):
|
cfContext | the pointer to the cy_stc_crypto_context_str_t structure that stores all internal variables for the Crypto driver. |
cy_en_crypto_status_t Cy_Crypto_Str_MemXor | ( | void const * | src0, |
void const * | src1, | ||
void * | dst, | ||
uint16_t | size, | ||
cy_stc_crypto_context_str_t * | cfContext | ||
) |
This function calculates the XOR of two memory blocks.
It operates on data in the user SRAM and doesn't use Crypto internal SRAM.
There is no alignment restriction. This function is independent from the previous Crypto state.
src0 | The pointer to the first source of MemXor. |
src1 | The pointer to the second source of MemXor. |
dst | The pointer to the destination of MemXor. |
size | The size in bytes of the compare operation. Maximum size is 65535 Bytes. |
cfContext | the pointer to the cy_stc_crypto_context_str_t structure that stores all internal variables for the Crypto driver. |
cy_en_crypto_status_t Cy_Crypto_Crc_Init | ( | uint32_t | polynomial, |
uint8_t | dataReverse, | ||
uint8_t | dataXor, | ||
uint8_t | remReverse, | ||
uint32_t | remXor, | ||
cy_stc_crypto_context_crc_t * | cfContext | ||
) |
This function performs CRC initialization.
Call to initialize this encryption technique before using any associated functions. You must initialize this technique again after using any other encryption technique.
Below is the table with known polynomials with different parameters and their calculated CRCs from the string "123456789":
Name | Width | Poly | Init | Data Rev | Data XOR | Rem Rev | Rem XOR | Expected CRC |
---|---|---|---|---|---|---|---|---|
CRC-3 / ROHC | 3 | 0x3 | 0x7 | 1 | 0 | 1 | 0x0 | 0x6 |
CRC-4 / ITU | 4 | 0x3 | 0x0 | 1 | 0 | 1 | 0x0 | 0x7 |
CRC-5 / EPC | 5 | 0x9 | 0x9 | 0 | 0 | 0 | 0x0 | 0x0 |
CRC-5 / ITU | 5 | 0x15 | 0x0 | 1 | 0 | 1 | 0x0 | 0x7 |
CRC-5 / USB | 5 | 0x5 | 0x1F | 1 | 0 | 1 | 0x1F | 0x19 |
CRC-6 / CDMA2000-A | 6 | 0x27 | 0x3F | 0 | 0 | 0 | 0x0 | 0xD |
CRC-6 / CDMA2000-B | 6 | 0x7 | 0x3F | 0 | 0 | 0 | 0x0 | 0x3B |
CRC-6 / DARC | 6 | 0x19 | 0x0 | 1 | 0 | 1 | 0x0 | 0x26 |
CRC-6 / ITU | 6 | 0x3 | 0x0 | 1 | 0 | 1 | 0x0 | 0x6 |
CRC-7 | 7 | 0x9 | 0x0 | 0 | 0 | 0 | 0x0 | 0x75 |
CRC-7 / ROHC | 7 | 0x4F | 0x7F | 1 | 0 | 1 | 0x0 | 0x53 |
CRC-8 | 8 | 0x7 | 0x0 | 0 | 0 | 0 | 0x0 | 0xF4 |
CRC-8 / CDMA2000 | 8 | 0x9B | 0xFF | 0 | 0 | 0 | 0x0 | 0xDA |
CRC-8 / DARC | 8 | 0x39 | 0x0 | 1 | 0 | 1 | 0x0 | 0x15 |
CRC-8 / DVB-S2 | 8 | 0xD5 | 0x0 | 0 | 0 | 0 | 0x0 | 0xBC |
CRC-8 / EBU | 8 | 0x1D | 0xFF | 1 | 0 | 1 | 0x0 | 0x97 |
CRC-8 / I-CODE | 8 | 0x1D | 0xFD | 0 | 0 | 0 | 0x0 | 0x7E |
CRC-8 / ITU | 8 | 0x7 | 0x0 | 0 | 0 | 0 | 0x55 | 0xA1 |
CRC-8 / MAXIM | 8 | 0x31 | 0x0 | 1 | 0 | 1 | 0x0 | 0xA1 |
CRC-8 / ROHC | 8 | 0x7 | 0xFF | 1 | 0 | 1 | 0x0 | 0xD0 |
CRC-8 / WCDMA | 8 | 0x9B | 0x0 | 1 | 0 | 1 | 0x0 | 0x25 |
CRC-10 | 10 | 0x233 | 0x0 | 0 | 0 | 0 | 0x0 | 0x199 |
CRC-10 / CDMA2000 | 10 | 0x3D9 | 0x3FF | 0 | 0 | 0 | 0x0 | 0x233 |
CRC-11 | 11 | 0x385 | 0x1A | 0 | 0 | 0 | 0x0 | 0x5A3 |
CRC-12 / 3GPP | 12 | 0x80F | 0x0 | 0 | 0 | 1 | 0x0 | 0xDAF |
CRC-12 / CDMA2000 | 12 | 0xF13 | 0xFFF | 0 | 0 | 0 | 0x0 | 0xD4D |
CRC-12 / DECT | 12 | 0x80F | 0x0 | 0 | 0 | 0 | 0x0 | 0xF5B |
CRC-13 / BBC | 13 | 0x1CF5 | 0x0 | 0 | 0 | 0 | 0x0 | 0x4FA |
CRC-14 / DARC | 14 | 0x805 | 0x0 | 1 | 0 | 1 | 0x0 | 0x82D |
CRC-15 | 15 | 0x4599 | 0x0 | 0 | 0 | 0 | 0x0 | 0x59E |
CRC-15 / MPT1327 | 15 | 0x6815 | 0x0 | 0 | 0 | 0 | 0x1 | 0x2566 |
CRC-24 | 24 | 0x0864CFB | 0x00B704CE | 0 | 0 | 0 | 0x0 | 0x21CF02 |
CRC-24 / FLEXRAY-A | 24 | 0x05D6DCB | 0x00FEDCBA | 0 | 0 | 0 | 0x0 | 0x7979BD |
CRC-24 / FLEXRAY-B | 24 | 0x05D6DCB | 0x00ABCDEF | 0 | 0 | 0 | 0x0 | 0x1F23B8 |
CRC-31 / PHILIPS | 31 | 0x4C11DB7 | 0x7FFFFFFF | 0 | 0 | 0 | 0x7FFFFFFF | 0xCE9E46C |
CRC-16 / ARC | 16 | 0x8005 | 0x0000 | 1 | 0 | 1 | 0x0000 | 0xBB3D |
CRC-16 / AUG-CCITT | 16 | 0x1021 | 0x1D0F | 0 | 0 | 0 | 0x0000 | 0xE5CC |
CRC-16 / BUYPASS | 16 | 0x8005 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0xFEE8 |
CRC-16 / CCITT-0 | 16 | 0x1021 | 0xFFFF | 0 | 0 | 0 | 0x0000 | 0x29B1 |
CRC-16 / CDMA2000 | 16 | 0xC867 | 0xFFFF | 0 | 0 | 0 | 0x0000 | 0x4C06 |
CRC-16 / DDS-110 | 16 | 0x8005 | 0x800D | 0 | 0 | 0 | 0x0000 | 0x9ECF |
CRC-16 / DECT-R | 16 | 0x0589 | 0x0000 | 0 | 0 | 0 | 0x0001 | 0x007E |
CRC-16 / DECT-X | 16 | 0x0589 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0x007F |
CRC-16 / DNP | 16 | 0x3D65 | 0x0000 | 1 | 0 | 1 | 0xFFFF | 0xEA82 |
CRC-16 / EN-13757 | 16 | 0x3D65 | 0x0000 | 0 | 0 | 0 | 0xFFFF | 0xC2B7 |
CRC-16 / GENIBUS | 16 | 0x1021 | 0xFFFF | 0 | 0 | 0 | 0xFFFF | 0xD64E |
CRC-16 / MAXIM | 16 | 0x8005 | 0x0000 | 1 | 0 | 1 | 0xFFFF | 0x44C2 |
CRC-16 / MCRF4XX | 16 | 0x1021 | 0xFFFF | 1 | 0 | 1 | 0x0000 | 0x6F91 |
CRC-16 / RIELLO | 16 | 0x1021 | 0xB2AA | 1 | 0 | 1 | 0x0000 | 0x63D0 |
CRC-16 / T10-DIF | 16 | 0x8BB7 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0xD0DB |
CRC-16 / TELEDISK | 16 | 0xA097 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0x0FB3 |
CRC-16 / TMS37157 | 16 | 0x1021 | 0x89EC | 1 | 0 | 1 | 0x0000 | 0x26B1 |
CRC-16 / USB | 16 | 0x8005 | 0xFFFF | 1 | 0 | 1 | 0xFFFF | 0xB4C8 |
CRC-A | 16 | 0x1021 | 0xC6C6 | 1 | 0 | 1 | 0x0000 | 0xBF05 |
CRC-16 / KERMIT | 16 | 0x1021 | 0x0000 | 1 | 0 | 1 | 0x0000 | 0x2189 |
CRC-16 / MODBUS | 16 | 0x8005 | 0xFFFF | 1 | 0 | 1 | 0x0000 | 0x4B37 |
CRC-16 / X-25 | 16 | 0x1021 | 0xFFFF | 1 | 0 | 1 | 0xFFFF | 0x906E |
CRC-16 / XMODEM | 16 | 0x1021 | 0x0000 | 0 | 0 | 0 | 0x0000 | 0x31C3 |
CRC-32 | 32 | 0x04C11DB7 | 0xFFFFFFFF | 1 | 0 | 1 | 0xFFFFFFFF | 0xCBF43926 |
CRC-32 / BZIP2 | 32 | 0x04C11DB7 | 0xFFFFFFFF | 0 | 0 | 0 | 0xFFFFFFFF | 0xFC891918 |
CRC-32C | 32 | 0x1EDC6F41 | 0xFFFFFFFF | 1 | 0 | 1 | 0xFFFFFFFF | 0xE3069283 |
CRC-32D | 32 | 0xA833982B | 0xFFFFFFFF | 1 | 0 | 1 | 0xFFFFFFFF | 0x87315576 |
CRC-32 / MPEG-2 | 32 | 0x04C11DB7 | 0xFFFFFFFF | 0 | 0 | 0 | 0x00000000 | 0x0376E6E7 |
CRC-32 / POSIX | 32 | 0x04C11DB7 | 0x00000000 | 0 | 0 | 0 | 0xFFFFFFFF | 0x765E7680 |
CRC-32Q | 32 | 0x814141AB | 0x00000000 | 0 | 0 | 0 | 0x00000000 | 0x3010BF7F |
CRC-32 / JAMCRC | 32 | 0x04C11DB7 | 0xFFFFFFFF | 1 | 0 | 1 | 0x00000000 | 0x340BC6D9 |
CRC-32 / XFER | 32 | 0x000000AF | 0x00000000 | 0 | 0 | 0 | 0x00000000 | 0xBD0BE338 |
polynomial | The polynomial (specified using 32 bits) used in the computing CRC. |
dataReverse | The order in which data bytes are processed. 0 - MSB first; 1- LSB first. |
dataXor | The byte mask for XORing data |
remReverse | A remainder reverse: 0 means the remainder is not reversed. 1 means reversed. |
remXor | Specifies a mask with which the LFSR32 register is XORed to produce a remainder. |
cfContext | The pointer to the cy_stc_crypto_context_crc_t structure that stores the Crypto driver context. |
cy_en_crypto_status_t Cy_Crypto_Crc_Run | ( | void * | data, |
uint16_t | dataSize, | ||
uint32_t * | crc, | ||
uint32_t | lfsrInitState, | ||
cy_stc_crypto_context_crc_t * | cfContext | ||
) |
This function performs CRC calculation on a message.
It depends on Cy_Crypto_Crc_Init(), which should be called before.
data | The pointer to the message whose CRC is being computed. |
dataSize | The size of a message in bytes. |
crc | The pointer to a computed CRC value. Must be 4-byte aligned. |
lfsrInitState | The initial state of the LFSR. |
cfContext | The pointer to the cy_stc_crypto_context_crc_t structure that stores the Crypto driver context. |
cy_en_crypto_status_t Cy_Crypto_Trng_Generate | ( | uint32_t | GAROPol, |
uint32_t | FIROPol, | ||
uint32_t | max, | ||
uint32_t * | randomNum, | ||
cy_stc_crypto_context_trng_t * | cfContext | ||
) |
This function generates a 32-bit True Random Number.
GAROPol | The polynomial for the programmable Galois ring oscillator. |
FIROPol | The polynomial for the programmable Fibonacci ring oscillator. |
max | The maximum length of a random number, in the range [0, 32] bits. |
randomNum | The pointer to a generated true random number. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_trng_t structure that stores the Crypto driver context. |
cy_en_crypto_status_t Cy_Crypto_Des_Run | ( | cy_en_crypto_dir_mode_t | dirMode, |
uint32_t * | key, | ||
uint32_t * | dstBlock, | ||
uint32_t * | srcBlock, | ||
cy_stc_crypto_context_des_t * | cfContext | ||
) |
This function performs DES operation on a Single Block.
All addresses must be 4-Byte aligned. Ciphertext (dstBlock) may overlap with plaintext (srcBlock) There is no Init function. Provide the required parameters and the pointer to the context structure when making this function call.
dirMode | Can be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t) |
key | The pointer to the encryption/decryption key. Must be 4-byte aligned. |
srcBlock | The pointer to a source block. Must be 4-byte aligned. |
dstBlock | The pointer to a destination cipher block. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_des_t structure that stores the Crypto driver context. |
cy_en_crypto_status_t Cy_Crypto_Tdes_Run | ( | cy_en_crypto_dir_mode_t | dirMode, |
uint32_t * | key, | ||
uint32_t * | dstBlock, | ||
uint32_t * | srcBlock, | ||
cy_stc_crypto_context_des_t * | cfContext | ||
) |
This function performs the TDES operation on a single block.
All addresses Must be 4-byte aligned. Ciphertext (dstBlock) may overlap with plaintext (srcBlock). There is no Init function. Provide the required parameters and the pointer to the context structure when making this function call.
dirMode | Can be CY_CRYPTO_ENCRYPT or CY_CRYPTO_DECRYPT (cy_en_crypto_dir_mode_t) |
key | The pointer to the encryption/decryption key. Must be 4-byte aligned. |
srcBlock | The pointer to a source block. Must be 4-byte aligned. |
dstBlock | The pointer to a destination cipher block. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_des_t structure that stores the Crypto driver context. |
cy_en_crypto_status_t Cy_Crypto_Rsa_Proc | ( | cy_stc_crypto_rsa_pub_key_t const * | pubKey, |
uint32_t const * | message, | ||
uint32_t | messageSize, | ||
uint32_t * | processedMessage, | ||
cy_stc_crypto_context_rsa_t * | cfContext | ||
) |
This function calculates (m^e mod modulo) where m is Message (Signature), e - public exponent using a public key in the next representation, it contains: modulo, public exponent, coefficient for Barrett reduction, binary inverse of the modulo, and result of (2^moduloLength mod modulo).
Not all fields in a key must be given. Modulo and public exponents are mandatory; Barrett coefficient, inverse modulo, and r-bar are optional. If they don't exist, their according pointers should be NULL. These coefficients could be calculated by Cy_Crypto_Rsa_CalcCoefs. Their presence accelerates performance by five times. Approximate performance for 1024-bit modulo is 41.6 ms; for 2048-bit modulo is 142 ms when using a 25 MHz clock for Crypto HW. These numbers just for reference. They depend on many factors (compiler, optimization level, etc.).
Returns the processed value and a success value.
pubKey | 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. Must be 4-byte aligned. |
messageSize | The length of the message to be processed. |
processedMessage | The pointer to processed message. Must be 4-byte aligned. |
cfContext | The pointer to the cy_stc_crypto_context_rsa_t structure that stores the RSA context. |
cy_en_crypto_status_t Cy_Crypto_Rsa_CalcCoefs | ( | cy_stc_crypto_rsa_pub_key_t const * | pubKey, |
cy_stc_crypto_context_rsa_t * | cfContext | ||
) |
This function calculates constant coefficients (which is dependent only on modulo and independent on message).
With this pre-calculated coefficients calculations speed-up by five times.
These coefficients are: coefficient for Barrett reduction, binary inverse of the modulo, result of (2^moduloLength mod modulo)
Calculated coefficients will be placed by addresses provided in the pubKey structure for according coefficients. Function overwrites previous values. Approximate performance for 1024-bit modulo is 33.2 ms; for 2048-bit modulo is 113 ms when using a 25 MHz clock for Crypto HW. These numbers are just for reference. They depend on many factors (compiler, optimization level, etc.).
pubKey | The pointer to the cy_stc_crypto_rsa_pub_key_t structure that stores a public key. |
cfContext | The pointer to the cy_stc_crypto_context_rsa_t structure that stores the RSA context. |
cy_en_crypto_status_t Cy_Crypto_Rsa_Verify | ( | cy_en_crypto_rsa_ver_result_t * | verResult, |
cy_en_crypto_sha_mode_t | digestType, | ||
uint32_t const * | digest, | ||
uint32_t const * | decryptedSignature, | ||
uint32_t | decryptedSignatureLength, | ||
cy_stc_crypto_context_rsa_ver_t * | cfContext | ||
) |
This function does an RSA verification with checks for content, paddings, and signature format.
The SHA digest of the message and decrypted message should be calculated first. 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.
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. Must be 4-byte aligned. |
decryptedSignature | The pointer to the decrypted signature to be verified. Must be 4-byte aligned. |
decryptedSignatureLength | The length of the decrypted signature to be verified (in bytes) |
cfContext | The pointer to the cy_stc_crypto_context_rsa_ver_t structure that stores the RSA context. |
cy_en_crypto_status_t Cy_Crypto_ECDSA_SignHash | ( | const uint8_t * | hash, |
uint32_t | hashlen, | ||
uint8_t * | sig, | ||
const cy_stc_crypto_ecc_key * | key, | ||
const uint8_t * | messageKey, | ||
cy_stc_crypto_context_ecc_t * | cfContext | ||
) |
Sign a message digest.
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. |
cfContext | The pointer to the cy_stc_crypto_context_ecc_t structure that stores the ECC operation context. |
cy_en_crypto_status_t Cy_Crypto_ECDSA_VerifyHash | ( | const uint8_t * | sig, |
const uint8_t * | hash, | ||
uint32_t | hashlen, | ||
uint8_t * | stat, | ||
const cy_stc_crypto_ecc_key * | key, | ||
cy_stc_crypto_context_ecc_t * | cfContext | ||
) |
Verify an ECC signature.
sig | The signature to verify, 'R' followed by 'S'. |
hash | The message digest that was signed. Provided as is in data buffer. |
hashlen | The length of the digest in bytes. |
stat | Result of signature, 1==valid, 0==invalid. |
key | The corresponding public ECC key. See cy_stc_crypto_ecc_key. |
cfContext | The pointer to the cy_stc_crypto_context_ecc_t structure that stores the ECC operation context. |
cy_en_crypto_status_t Cy_Crypto_SetMemBufAddress | ( | uint32_t const * | newMembufAddress, |
uint32_t | newMembufSize, | ||
cy_stc_crypto_context_str_t * | cfContext | ||
) |
This function sets a new operation memory buffer.
newMembufAddress | The pointer to the new operation memory buffer. Must be 4-byte aligned. |
newMembufSize | The size of the new memory buffer (in bytes) |
cfContext | The pointer to the cy_stc_crypto_context_str_t structure that stores the data context. |
cy_en_crypto_status_t Cy_Crypto_GetMemBufAddress | ( | uint32_t ** | membufAddress, |
cy_stc_crypto_context_str_t * | cfContext | ||
) |
This function gets an operation memory buffer location.
membufAddress | The pointer of the operation memory buffer. |
cfContext | The pointer to the cy_stc_crypto_context_str_t structure that stores the data context. |
cy_en_crypto_status_t Cy_Crypto_GetMemBufSize | ( | uint32_t * | membufSize, |
cy_stc_crypto_context_str_t * | cfContext | ||
) |
This function gets an operation memory buffer size.
membufSize | The size of the memory buffer (in bytes) |
cfContext | The pointer to the cy_stc_crypto_context_str_t structure that stores the data context. |
void Cy_Crypto_InvertEndianness | ( | void * | inArrPtr, |
uint32_t | byteSize | ||
) |
This function reverts byte-array memory block, like:
inArr[0] <—> inArr[n]
inArr[1] <—> inArr[n-1]
inArr[2] <—> inArr[n-2]
........................
inArr[n/2] <—> inArr[n/2-1]
Odd or even byteSize are acceptable.
inArrPtr | The pointer to the memory whose endianness is to be inverted. |
byteSize | The length of the memory array whose endianness is to be inverted (in bytes) |