Crypto APIs#
This section describes the Crypto APIs
Functions#
Compute the SHA digest. This is a blocking API.
Decide whether the SHA message can be sent once or requires multiple calls to send. This is a blocking API.
Hold computed digest from HMAC-SHA. This is a blocking API.
Decide whether the HMAC-SHA message can be sent once or requires multiple calls to send the message. This is a blocking API.
Decide whether the AES message can be sent once or requires multiple calls to send the message. This is a blocking API.
Encrypt/decrypt the data using AES.
Calculate the DH key. This is a blocking API.
Compute the ECDH point multiplication vector. This is a blocking API.
Compute the ECDH point addition vector. This is a blocking API.
Compute the ECDH point subtraction vector. This is a blocking API.
Compute the ECDH point double vector. This is a blocking API.
Compute the ECDH point affinity vector. This is a blocking API.
Decides whether the CCM message can be sent once or requires multiple calls to send.
Encrypt/Decrypt the data using CCM.
Function Documentation#
rsi_sha_pen#
int32_t rsi_sha_pen (uint8_t sha_mode, uint8_t * msg, uint16_t msg_length, uint16_t chunk_len, uint8_t pending_flag, uint8_t * digest)
Compute the SHA digest. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | sha_mode | 1 – For SHA1 |
| uint8_t * | [in] | msg | - Pointer to message |
| uint16_t | [in] | msg_length | - Total message length |
| uint16_t | [in] | chunk_len | - Current chunk length |
| uint8_t | [in] | pending_flag | - BIT(0) - 1st chunk |
| uint8_t * | [out] | digest | - Output parameter to hold computed digest from SHA |
Returns
0 - Success
Non-Zero Value - Failure
Note
Refer to Error Codes for the description of above error codes.
rsi_sha#
int32_t rsi_sha (uint8_t sha_mode, uint8_t * msg, uint16_t msg_length, uint8_t * digest)
Decide whether the SHA message can be sent once or requires multiple calls to send. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | sha_mode | 1 – For SHA1 |
| uint8_t * | [in] | msg | - Pointer to message |
| uint16_t | [in] | msg_length | - Total message length |
| uint8_t * | [out] | digest | - Output parameter to hold computed digest from SHA |
Returns
0 - Success
Non-Zero Value - Failure
Note
Refer to Error Codes for the description of above error codes.
rsi_hmac_sha_pen#
int32_t rsi_hmac_sha_pen (uint8_t hmac_sha_mode, uint8_t * data, uint16_t total_length, uint16_t chunk_length, uint32_t key_length, uint8_t pending_flag, uint8_t * digest)
Hold computed digest from HMAC-SHA. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | hmac_sha_mode | - 1 – For HMAC-SHA1 |
| uint8_t * | [in] | data | - Pointer to key along with message |
| uint16_t | [in] | total_length | - Total message length |
| uint16_t | [in] | chunk_length | - Current chunk length |
| uint32_t | [in] | key_length | - BIT(0) - 1st chunk |
| uint8_t | [out] | pending_flag | - Output parameter to hold computed digest from HMAC-SHA |
| uint8_t * | N/A | digest |
Returns
0 - Success
Non-Zero Value - Failure
Note
Refer to Error Codes for the description of above error codes.
rsi_hmac_sha#
int32_t rsi_hmac_sha (uint8_t hmac_sha_mode, uint8_t * msg, uint32_t msg_length, uint8_t * key, uint32_t key_length, uint8_t * digest, uint8_t * hmac_buffer)
Decide whether the HMAC-SHA message can be sent once or requires multiple calls to send the message. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | hmac_sha_mode | - 1 – For HMAC-SHA1 |
| uint8_t * | [in] | msg | - Pointer to message |
| uint32_t | [in] | msg_length | - Total message length |
| uint8_t * | [in] | key | - Pointer to HMAC key |
| uint32_t | [in] | key_length | - HMAC key length in bytes |
| uint8_t * | [out] | digest | - Output parameter to hold computed digest from HMAC-SHA |
| uint8_t * | N/A | hmac_buffer |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_aes#
int32_t rsi_aes (uint16_t aes_mode, uint16_t enc_dec, uint8_t * msg, uint16_t msg_length, uint8_t * key, uint16_t key_length, uint8_t * iv, uint8_t * output)
Decide whether the AES message can be sent once or requires multiple calls to send the message. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint16_t | [in] | aes_mode | - 1 – For AES CBC mode |
| uint16_t | [in] | enc_dec | - 1 – For AES Encryption |
| uint8_t * | [in] | msg | - Pointer to message |
| uint16_t | [in] | msg_length | - Total message length (must be divisible by 16) |
| uint8_t * | [in] | key | - Pointer to AES key |
| uint16_t | [in] | key_length | - AES key length in bytes |
| uint8_t * | [in] | iv | - Pointer to AES iv |
| uint8_t * | [out] | output | - Output parameter to hold encrypted/decrypted from AES |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_aes_pen#
int32_t rsi_aes_pen (uint16_t aes_mode, uint16_t enc_dec, uint8_t * msg, uint16_t msg_length, uint16_t chunk_length, uint8_t * key, uint16_t key_length, uint8_t * iv, uint8_t aes_flags, uint8_t * output)
Encrypt/decrypt the data using AES.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint16_t | [in] | aes_mode | - 1 – For AES CBC mode |
| uint16_t | [in] | enc_dec | - 1 – For AES Encryption |
| uint8_t * | [in] | msg | - Pointer to message |
| uint16_t | [in] | msg_length | - Total message length (must be divisible by 16) |
| uint16_t | [in] | chunk_length | - Current chunk length |
| uint8_t * | [in] | key | - Pointer to AES key |
| uint16_t | [in] | key_length | - AES key length in bytes |
| uint8_t * | [in] | iv | - Pointer to AES iv |
| uint8_t | [in] | aes_flags | - BIT(0) - 1st chunk |
| uint8_t * | [out] | output | - Output parameter to hold encrypted/decrypted from AES |
Returns
0 - Success
Non-Zero Value - Failure
Note
Refer to Error Codes for the description of above error codes.
rsi_exponentiation#
int32_t rsi_exponentiation (uint8_t * prime, uint32_t prime_length, uint8_t * base, uint32_t base_length, uint8_t * exponent, uint32_t exponent_length, uint8_t * exp_result)
Calculate the DH key. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t * | [in] | prime | - Pointer to the prime |
| uint32_t | [in] | prime_length | - Length of the prime |
| uint8_t * | [in] | base | - Pointer to base |
| uint32_t | [in] | base_length | - Length of the base |
| uint8_t * | [in] | exponent | - Pointer to exponent |
| uint32_t | [in] | exponent_length | - Length of the exponent |
| uint8_t * | [out] | exp_result | - Output exponentiation result |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_ecdh_point_multiplication#
int32_t rsi_ecdh_point_multiplication (uint8_t ecdh_mode, uint8_t * d, uint8_t * sx, uint8_t * sy, uint8_t * sz, uint32_t affinity, uint8_t * rx, uint8_t * ry, uint8_t * rz, uint8_t reverse)
Compute the ECDH point multiplication vector. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | ecdh_mode | - 1 – For ECDH 192 |
| uint8_t * | [in] | d | - Pointer to scalar value that needs to be multiplied |
| uint8_t * | [in] | sx | Pointer to x coordinate of the point to be multiplied with scalar ‘d’ |
| uint8_t * | [in] | sy | Pointer to y coordinate of the point to be multiplied with scalar ‘d’ |
| uint8_t * | [in] | sz | Pointer to z coordinate of the point to be multiplied with scalar ‘d’ |
| uint32_t | [in] | affinity | - 0 – no affinity |
| uint8_t * | [out] | rx | Pointer to x coordinate of the result point |
| uint8_t * | [out] | ry | Pointer to y coordinate of the result point |
| uint8_t * | [out] | rz | Pointer to z coordinate of the result point |
| uint8_t | [in] | reverse | - setting this will perform reverse_8 on the inputs and outputs. |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_ecdh_point_addition#
int32_t rsi_ecdh_point_addition (uint8_t ecdh_mode, uint8_t * sx, uint8_t * sy, uint8_t * sz, uint8_t * tx, uint8_t * ty, uint8_t * tz, uint8_t * rx, uint8_t * ry, uint8_t * rz)
Compute the ECDH point addition vector. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | ecdh_mode | - 1 – For ECDH 192 |
| uint8_t * | [in] | sx | - Pointer to x coordinate of the point1 that needs to be added |
| uint8_t * | [in] | sy | - Pointer to y coordinate of the point1 that needs to be added |
| uint8_t * | [in] | sz | - Pointer to z coordinate of the point1 that needs to be added |
| uint8_t * | [in] | tx | - Pointer to x coordinate of the point2 that needs to be added |
| uint8_t * | [in] | ty | - Pointer to y coordinate of the point2 that needs to be added |
| uint8_t * | [in] | tz | - Pointer to z coordinate of the point2 that needs to be added |
| uint8_t * | [out] | rx | - Pointer to x coordinate of the result point |
| uint8_t * | [out] | ry | - Pointer to y coordinate of the result point |
| uint8_t * | [out] | rz | - Pointer to z coordinate of the result point |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_ecdh_point_subtraction#
int32_t rsi_ecdh_point_subtraction (uint8_t ecdh_mode, uint8_t * sx, uint8_t * sy, uint8_t * sz, uint8_t * tx, uint8_t * ty, uint8_t * tz, uint8_t * rx, uint8_t * ry, uint8_t * rz)
Compute the ECDH point subtraction vector. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | ecdh_mode | - 1 – For ECDH 192 |
| uint8_t * | [in] | sx | - Pointers to x, y, z coordinates of the point1 that needs to be subtracted |
| uint8_t * | [in] | sy | - Pointers to x, y, z coordinates of the point2 that needs to be subtracted |
| uint8_t * | [out] | sz | - Pointers to x, y, z coordinates of the result point |
| uint8_t * | N/A | tx | |
| uint8_t * | N/A | ty | |
| uint8_t * | N/A | tz | |
| uint8_t * | N/A | rx | |
| uint8_t * | N/A | ry | |
| uint8_t * | N/A | rz |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_ecdh_point_double#
int32_t rsi_ecdh_point_double (uint8_t ecdh_mode, uint8_t * sx, uint8_t * sy, uint8_t * sz, uint8_t * rx, uint8_t * ry, uint8_t * rz)
Compute the ECDH point double vector. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | ecdh_mode | - 1 – For ECDH 192 |
| uint8_t * | [in] | sx | - Pointers to x, y, z coordinates of the point1 that needs to be doubled |
| uint8_t * | [out] | sy | - Pointers to x, y, z coordinates of the result point |
| uint8_t * | N/A | sz | |
| uint8_t * | N/A | rx | |
| uint8_t * | N/A | ry | |
| uint8_t * | N/A | rz |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_ecdh_point_affine#
int32_t rsi_ecdh_point_affine (uint8_t ecdh_mode, uint8_t * sx, uint8_t * sy, uint8_t * sz, uint8_t * rx, uint8_t * ry, uint8_t * rz)
Compute the ECDH point affinity vector. This is a blocking API.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | ecdh_mode | - 1 – For ECDH 192 |
| uint8_t * | [in] | sx | - Pointers to x, y, z coordinates of the point1 that needs to be affinified |
| uint8_t * | [out] | sy | - Pointers to x, y, z coordinates of the result point |
| uint8_t * | N/A | sz | |
| uint8_t * | N/A | rx | |
| uint8_t * | N/A | ry | |
| uint8_t * | N/A | rz |
Returns
0 - Success
Non-Zero Value - Failure (Possible Error Codes - 0xfffffffe, 0xfffffffd, 0xfffffffc, 0xFF15, 0xCC9C, 0xCC9B)
Note
Refer to Error Codes for the description of above error codes.
rsi_ccm#
rsi_ccm (uint8_t enc_dec, uint8_t * msg, uint16_t msg_length, uint8_t * key, uint16_t key_length, uint8_t * iv, uint16_t iv_sz, uint8_t * tag, uint16_t tag_len, uint8_t * ad, uint16_t ad_len, uint8_t * output)
Decides whether the CCM message can be sent once or requires multiple calls to send.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | enc_dec | 0 – For CCM Encryption 1 – For CCM Decryption |
| uint8_t * | [in] | msg | Pointer to message |
| uint16_t | [in] | msg_length | Total message length |
| uint8_t * | [in] | key | Pointer to CCM key |
| uint16_t | [in] | key_length | CCM key length in bytes |
| uint8_t * | [in] | iv | Pointer to CCM iv |
| uint16_t | [in] | iv_sz | of IV |
| uint8_t * | [in] | tag | Pointer to CCM tag |
| uint16_t | [in] | tag_len | size of tag |
| uint8_t * | [in] | ad | to AD |
| uint16_t | [in] | ad_len | Total length of AD |
| uint8_t * | [out] | output | Output parameter to hold encrypted/decrypted from CCM |
Returns
Non zero - If fails 0 - If success
description#
This function decides whether the CCM message can be sent once or requires multiple calls to send the message
rsi_ccm_pen#
rsi_ccm_pen (uint8_t enc_dec, uint8_t * msg, uint16_t msg_length, uint16_t chunk_length, uint8_t * key, uint16_t key_length, uint8_t * iv, uint16_t iv_sz, uint8_t * tag, uint16_t tag_len, uint8_t * ad, uint16_t ad_len, uint8_t ccm_flags, uint8_t * output)
Encrypt/Decrypt the data using CCM.
| Type | Direction | Argument Name | Description |
|---|---|---|---|
| uint8_t | [in] | enc_dec | 0 – For CCM Encryption 1 – For CCM Decryption |
| uint8_t * | [in] | msg | Pointer to message |
| uint16_t | [in] | msg_length | Total message length |
| uint16_t | [in] | chunk_length | current chunk length |
| uint8_t * | [in] | key | Pointer to CCM key |
| uint16_t | [in] | key_length | CCM key length in bytes |
| uint8_t * | [in] | iv | Pointer to CCM iv |
| uint16_t | [in] | iv_sz | size of IV |
| uint8_t * | [in] | tag | Pointer to CCM tag |
| uint16_t | [in] | tag_len | size of tag |
| uint8_t * | [in] | ad | to AD |
| uint16_t | [in] | ad_len | Total length of AD |
| uint8_t | [in] | ccm_flags | BIT(0) - 1st chunk BIT(1) - Middle chunk BIT(2) - Last chunk |
| uint8_t * | [out] | output | Output parameter to hold encrypted/decrypted from CCM |
Returns
Non zero - If fails 0 - If success
description#
This function encrypt/decrypt the data using CCM