Crypto APIs#

This section describes the Crypto APIs

Functions#

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.

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.

int32_t
rsi_hmac_sha_pen(uint8_t hmac_sha_mode, uint8_t *data, uint16_t total_length, uint16_t chunk_length, key_descriptor_t *key_info, uint8_t pending_flag, uint8_t *digest)

Hold computed digest from HMAC-SHA. This is a blocking API.

int32_t
rsi_hmac_sha(uint8_t hmac_sha_mode, uint8_t *msg, uint32_t msg_length, uint8_t *key, key_descriptor_t *key_info, 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.

int32_t
rsi_aes(uint16_t aes_mode, uint16_t enc_dec, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, 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.

int32_t
rsi_aes_pen(uint16_t aes_mode, uint16_t enc_dec, uint8_t *msg, uint16_t msg_length, uint16_t chunk_length, key_descriptor_t *key_info, uint8_t *iv, uint8_t aes_flags, uint8_t *output)

Encrypt/decrypt the data using AES.

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.

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.

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.

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.

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.

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.

int32_t
rsi_ccm(uint8_t enc_dec, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, 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.

int32_t
rsi_ccm_pen(uint8_t enc_dec, uint8_t *msg, uint16_t msg_length, uint16_t chunk_length, key_descriptor_t *key_info, 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.

int32_t
trng_init(uint32_t *trng_key, uint32_t *trng_test_data, uint16_t input_length, uint32_t *output)

This API Initializes the TRNG hardware engine and Evaluate AES-CBC.

int32_t

This API check the health of Trng.

int32_t
trng_program_key(uint32_t *trng_key, uint16_t key_length)

This API Initializes key which needs to be programmed to TRNG hardware engine.

int32_t
trng_get_random_num(uint32_t *random_number, uint16_t length)

This API generated random number of desired length.

int32_t
sl_attestation_get_token(uint8_t *token, uint16_t length, uint32_t *nonce)

This API gets token.

int32_t
rsi_sha3_shake_pen(uint8_t pad_char, uint8_t mode, uint8_t *msg, uint16_t msg_length, uint16_t chunk_len, uint8_t pending_flag, uint8_t *digest)

Computes the sha3/shake digest.

int32_t
rsi_shake(uint8_t mode, uint8_t *msg, uint16_t msg_length, uint8_t *digest)

Decides whether the sha message can be sent once or requires multiple calls to send.

int32_t
rsi_sha3(uint8_t mode, uint8_t *msg, uint16_t msg_length, uint8_t *digest)

Decides whether the sha message can be sent once or requires multiple calls to send.

int32_t
rsi_chachapoly(uint16_t chachapoly_mode, uint16_t enc_dec, uint16_t dma_use, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, uint8_t *nonce, uint8_t *header_input, uint16_t header_length, uint8_t *output)

Decides whether the CHACHAPOLY message can be sent once or requires multiple calls to send.

int32_t
rsi_chachapoly_pen(uint16_t chachapoly_mode, uint16_t enc_dec, uint16_t dma_use, uint8_t *msg, uint16_t msg_length, uint16_t chunk_len, key_descriptor_t *key_info, uint8_t *nonce, uint8_t *header_input, uint16_t header_length, uint8_t chachapoly_flags, uint8_t *output)

Encrypt/Decrypt the data using CHACHA_POLY.

int32_t
rsi_gcm(uint32_t gcm_mode, uint8_t enc_dec, uint16_t dma_use, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, uint8_t *iv, uint16_t iv_sz, uint8_t *header, uint16_t header_length, uint8_t *output)

Decides whether the GCM/CMAC message can be sent once or requires multiple calls to send.

int32_t
rsi_wrap(key_descriptor_wrap_t *key_info, uint8_t *output)

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.

Parameters
[in]sha_mode

1 – For SHA1 2 – For SHA256 3 – For SHA384 4 – For SHA512 5 – For SHA224

[in]msg

- Pointer to message

[in]msg_length

- Total message length

[in]chunk_len

- Current chunk length

[in]pending_flag

- BIT(0) - 1st chunk BIT(1) - Middle chunk BIT(2) - Last chunk

[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.


Definition at line 39 of file crypto/rsi_crypto.c

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.

Parameters
[in]sha_mode

1 – For SHA1 2 – For SHA256 3 – For SHA384 4 – For SHA512 5– For SHA224

[in]msg

- Pointer to message

[in]msg_length

- Total message length

[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.


Definition at line 197 of file crypto/rsi_crypto.c

References RSI_SUCCESS , SL_PRINTF , and rsi_sha_pen

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, key_descriptor_t *key_info, uint8_t pending_flag, uint8_t *digest)

Hold computed digest from HMAC-SHA. This is a blocking API.

Parameters
[in]hmac_sha_mode

- 1 – For HMAC-SHA1 2 – For HMAC-SHA256 3 – For HMAC-SHA384 4 – For HMAC-SHA512

[in]data

- Pointer to key along with message

[in]total_length

- Total message length

[in]chunk_length

- Current chunk length

[in]key_info

- Structure pointer for key_info

[in]pending_flag

- BIT(0) - 1st chunk BIT(1) - Middle chunk BIT(2) - Last chunk

[out]digest

- Output parameter to hold computed digest from HMAC-SHA

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer to Error Codes for the description of above error codes.


Definition at line 271 of file crypto/rsi_crypto.c

rsi_hmac_sha#

int32_t rsi_hmac_sha (uint8_t hmac_sha_mode, uint8_t *msg, uint32_t msg_length, uint8_t *key, key_descriptor_t *key_info, 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.

Parameters
[in]hmac_sha_mode

- 1 – For HMAC-SHA1 2 – For HMAC-SHA256 3 – For HMAC-SHA384 4 – For HMAC-SHA512

[in]msg

- Pointer to message

[in]msg_length

- Total message length

[in]key

- Pointer to HMAC key

[in]key_info

- Structure Pointer to key_info

[in]digest

- HMAC key length in bytes

[out]hmac_buffer

- Output parameter to hold computed digest from HMAC-SHA

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.


Definition at line 520 of file crypto/rsi_crypto.c

rsi_aes#

int32_t rsi_aes (uint16_t aes_mode, uint16_t enc_dec, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, 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.

Parameters
[in]aes_mode

- 1 – For AES CBC mode 2 – For AES ECB mode 3 – For AES CTR mode

[in]enc_dec

- 1 – For AES Encryption 2 – For AES Decryption

[in]msg

- Pointer to message

[in]msg_length

- Total message length (must be divisible by 16)

[in]key_info

- Structure pointer for key_info

[in]iv

- Pointer to AES iv

[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.


Definition at line 645 of file crypto/rsi_crypto.c

References SL_PRINTF , RSI_SUCCESS , and rsi_aes_pen

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, key_descriptor_t *key_info, uint8_t *iv, uint8_t aes_flags, uint8_t *output)

Encrypt/decrypt the data using AES.

Parameters
[in]aes_mode

- 1 – For AES CBC mode 2 – For AES ECB mode 3 – For AES CTR mode

[in]enc_dec

- 1 – For AES Encryption 2 – For AES Decryption

[in]msg

- Pointer to message

[in]msg_length

- Total message length (must be divisible by 16)

[in]chunk_length

- Current chunk length

[in]key_info

- Structure pointer for key_info

[in]iv

- Pointer to AES iv

[in]aes_flags

- BIT(0) - 1st chunk BIT(1) - Middle chunk BIT(2) - Last chunk

[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.


Definition at line 758 of file crypto/rsi_crypto.c

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.

Parameters
[in]prime

- Pointer to the prime

[in]prime_length

- Length of the prime

[in]base

- Pointer to base

[in]base_length

- Length of the base

[in]exponent

- Pointer to exponent

[in]exponent_length

- Length of the exponent

[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.


Definition at line 1031 of file crypto/rsi_crypto.c

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.

Parameters
[in]ecdh_mode

- 1 – For ECDH 192 2 – For ECDH 224 3 – For ECDH 256

[in]d

- Pointer to scalar value that needs to be multiplied

[in]sx

Pointer to x coordinate of the point to be multiplied with scalar ‘d’

[in]sy

Pointer to y coordinate of the point to be multiplied with scalar ‘d’

[in]sz

Pointer to z coordinate of the point to be multiplied with scalar ‘d’

[in]affinity

- 0 – no affinity 1 – affinity on input 2 – affinity on output 3 – affinity on both input and output

[out]rx

Pointer to x coordinate of the result point

[out]ry

Pointer to y coordinate of the result point

[out]rz

Pointer to z coordinate of the result point

[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.


Definition at line 1191 of file crypto/rsi_crypto.c

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.

Parameters
[in]ecdh_mode

- 1 – For ECDH 192 2 – For ECDH 224 3 – For ECDH 256

[in]sx

- Pointer to x coordinate of the point1 that needs to be added

[in]sy

- Pointer to y coordinate of the point1 that needs to be added

[in]sz

- Pointer to z coordinate of the point1 that needs to be added

[in]tx

- Pointer to x coordinate of the point2 that needs to be added

[in]ty

- Pointer to y coordinate of the point2 that needs to be added

[in]tz

- Pointer to z coordinate of the point2 that needs to be added

[out]rx

- Pointer to x coordinate of the result point

[out]ry

- Pointer to y coordinate of the result point

[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.


Definition at line 1390 of file crypto/rsi_crypto.c

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.

Parameters
[in]ecdh_mode

- 1 – For ECDH 192 2 – For ECDH 224 3 – For ECDH 256

[in]sx

- Pointers to x, y, z coordinates of the point1 that needs to be subtracted

[in]sy

- Pointers to x, y, z coordinates of the point2 that needs to be subtracted

[out]sz

- Pointers to x, y, z coordinates of the result point

N/Atx
N/Aty
N/Atz
N/Arx
N/Ary
N/Arz

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.


Definition at line 1575 of file crypto/rsi_crypto.c

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.

Parameters
[in]ecdh_mode

- 1 – For ECDH 192 2 – For ECDH 224 3 – For ECDH 256

[in]sx

- Pointers to x, y, z coordinates of the point1 that needs to be doubled

[out]sy

- Pointers to x, y, z coordinates of the result point

N/Asz
N/Arx
N/Ary
N/Arz

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.


Definition at line 1763 of file crypto/rsi_crypto.c

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.

Parameters
[in]ecdh_mode

- 1 – For ECDH 192 2 – For ECDH 224 3 – For ECDH 256

[in]sx

- Pointers to x, y, z coordinates of the point1 that needs to be affinified

[out]sy

- Pointers to x, y, z coordinates of the result point

N/Asz
N/Arx
N/Ary
N/Arz

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.


Definition at line 1928 of file crypto/rsi_crypto.c

rsi_ccm#

int32_t rsi_ccm (uint8_t enc_dec, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, 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.

Parameters
[in]enc_dec

0 – For CCM Encryption 1 – For CCM Decryption

[in]msg

Pointer to message

[in]msg_length

Total message length

[in]key_info

- Structure pointer for key_info

[in]iv

Pointer to CCM iv

[in]iv_sz

of IV

[in]tag

Pointer to CCM tag

[in]tag_len

size of tag

[in]ad

to AD

[in]ad_len

Total length of AD

[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


Definition at line 2118 of file crypto/rsi_crypto.c

rsi_ccm_pen#

int32_t rsi_ccm_pen (uint8_t enc_dec, uint8_t *msg, uint16_t msg_length, uint16_t chunk_length, key_descriptor_t *key_info, 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.

Parameters
[in]enc_dec

0 – For CCM Encryption 1 – For CCM Decryption

[in]msg

Pointer to message

[in]msg_length

Total message length

[in]chunk_length

current chunk length

[in]key_info

- Structure pointer for key_info

[in]iv

Pointer to CCM iv

[in]iv_sz

size of IV

[in]tag

Pointer to CCM tag

[in]tag_len

size of tag

[in]ad

to AD

[in]ad_len

Total length of AD

[in]ccm_flags

BIT(0) - 1st chunk BIT(1) - Middle chunk BIT(2) - Last chunk

[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


Definition at line 2325 of file crypto/rsi_crypto.c

trng_init#

int32_t trng_init (uint32_t *trng_key, uint32_t *trng_test_data, uint16_t input_length, uint32_t *output)

This API Initializes the TRNG hardware engine and Evaluate AES-CBC.

Parameters
[in]trng_key

- Pointer to trng_key

[in]trng_test_data

- Pointer to test data for trng

[in]input_length

- Length of test data in dwords

[out]output

- Pointer to output

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This API Initializes the TRNG hardware engine


Definition at line 2596 of file crypto/rsi_crypto.c

trng_entropy#

int32_t trng_entropy (void)

This API check the health of Trng.

Parameters
N/A

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This API checks the Entropy of TRNG


Definition at line 2705 of file crypto/rsi_crypto.c

trng_program_key#

int32_t trng_program_key (uint32_t *trng_key, uint16_t key_length)

This API Initializes key which needs to be programmed to TRNG hardware engine.

Parameters
[in]trng_key

- Pointer to trng_key

[in]key_length

- key_length - key length in Dwords

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This API Initializes key which needs to be programmed to TRNG hardware engine


Definition at line 2794 of file crypto/rsi_crypto.c

trng_get_random_num#

int32_t trng_get_random_num (uint32_t *random_number, uint16_t length)

This API generated random number of desired length.

Parameters
[in]random_number

- Address for Random number

[in]length

- Random number which needs to be generated in Dwords

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This API generated random number of desired length


Definition at line 2891 of file crypto/rsi_crypto.c

sl_attestation_get_token#

int32_t sl_attestation_get_token (uint8_t *token, uint16_t length, uint32_t *nonce)

This API gets token.

Parameters
[in]token

- Address for token

[in]length

-Length of token request

[in]nonce

- 32 byte nonce

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This API gets token


Definition at line 2997 of file crypto/rsi_crypto.c

rsi_sha3_shake_pen#

int32_t rsi_sha3_shake_pen (uint8_t pad_char, uint8_t mode, uint8_t *msg, uint16_t msg_length, uint16_t chunk_len, uint8_t pending_flag, uint8_t *digest)

Computes the sha3/shake digest.

Parameters
[in]pad_char

0x1F SHAKE, 0x06 SHA3

[in]mode

21 - SHAKE_128 17 - SHAKE_256, SHA3_256 18 - SHA3_224 13 - SHA3_384 9 - SHA3_512

[in]msg

Pointer to message

[in]msg_length

Total message length

[in]chunk_len

current chunk length

[in]pending_flag

BIT(0) - 1st chunk BIT(1) - Middle chunk BIT(2) - Last chunk

[out]digest

Output parameter to hold computed digest from SHA3/SHAKE

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This function computes the sha3/shake digest for the given input message


Definition at line 3117 of file crypto/rsi_crypto.c

Referenced by rsi_shake , and rsi_sha3

rsi_shake#

int32_t rsi_shake (uint8_t mode, uint8_t *msg, uint16_t msg_length, uint8_t *digest)

Decides whether the sha message can be sent once or requires multiple calls to send.

Parameters
[in]mode

21 - SHAKE_128 17 - SHAKE_256

[in]msg

Pointer to message

[in]msg_length

Total message length

[out]digest

Output parameter to hold computed digest from SHAKE

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This function decides whether the shakeamessage can be sent once or requires multiple calls to send the message


Definition at line 3276 of file crypto/rsi_crypto.c

rsi_sha3#

int32_t rsi_sha3 (uint8_t mode, uint8_t *msg, uint16_t msg_length, uint8_t *digest)

Decides whether the sha message can be sent once or requires multiple calls to send.

Parameters
[in]mode

17 - SHA3_256 18 - SHA3_224 13 - SHA3_384 9 - SHA3_512

[in]msg

Pointer to message

[in]msg_length

Total message length

[out]digest

Output parameter to hold computed digest from SHA3

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This function decides whether the sha message can be sent once or requires multiple calls to send the message


Definition at line 3351 of file crypto/rsi_crypto.c

rsi_chachapoly#

int32_t rsi_chachapoly (uint16_t chachapoly_mode, uint16_t enc_dec, uint16_t dma_use, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, uint8_t *nonce, uint8_t *header_input, uint16_t header_length, uint8_t *output)

Decides whether the CHACHAPOLY message can be sent once or requires multiple calls to send.

Parameters
[in]chachapoly_mode

- 0 – For CHACHA20POLY1305 mode 1 – For CHACHA20 mode 3 – For POLY1305 mode

[in]enc_dec

- 0 – For CHACHAPOLY Encryption 1 – For CHACHAPOLY Decryption

[in]dma_use

- 1 - DMA enable 0- disable DMA

[in]msg

- Pointer to message

[in]msg_length

- Total message length

[in]key_info

- Structure pointer for key_info

[in]nonce

- pointer to nonce (1st index is IV)

[in]header_input

Pointer to header

[in]header_length

- header length in bytes

[out]output

Output parameter to hold encrypted/decrypted from chachapoly

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.


Definition at line 3426 of file crypto/rsi_crypto.c

rsi_chachapoly_pen#

int32_t rsi_chachapoly_pen (uint16_t chachapoly_mode, uint16_t enc_dec, uint16_t dma_use, uint8_t *msg, uint16_t msg_length, uint16_t chunk_len, key_descriptor_t *key_info, uint8_t *nonce, uint8_t *header_input, uint16_t header_length, uint8_t chachapoly_flags, uint8_t *output)

Encrypt/Decrypt the data using CHACHA_POLY.

Parameters
[in]chachapoly_mode

: 0 – For CHACHA20POLY1305 mode 1 – For CHACHA20 mode 3 – For POLY1305 mode

[in]enc_dec

0 – For CHACHAPOLY Encryption 1 – For CHACHAPOLY Decryption

[in]dma_use

0 - DMA disable 1- DMA enable

[in]msg

Pointer to message

[in]msg_length

Total message length

[in]chunk_len

current chunk length

[in]key_info

Pointer to chacha key

[in]nonce

pointer to keyr_in

[in]header_input

pointer to keys_in

[in]header_length

pointer to nonce (1st index is IV)

[in]chachapoly_flags

Pointer to header

[in]output

header length in bytes

[in]chachapoly_flags

BIT(0) - 1st chunk BIT(1) - Middle chunk BIT(2) - Last chunk

[out]output

Output parameter to hold encrypted/decrypted from chachapoly

Returns

  • 0 - Success

  • Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.


Definition at line 3580 of file crypto/rsi_crypto.c

rsi_gcm#

int32_t rsi_gcm (uint32_t gcm_mode, uint8_t enc_dec, uint16_t dma_use, uint8_t *msg, uint16_t msg_length, key_descriptor_t *key_info, uint8_t *iv, uint16_t iv_sz, uint8_t *header, uint16_t header_length, uint8_t *output)

Decides whether the GCM/CMAC message can be sent once or requires multiple calls to send.

Parameters
[in]gcm_mode

- 0 – For GCM, 1 – For CMAC. CMAC doesn't support decryption

[in]enc_dec

- 0 – For GCM/CMAC Encryption 1 – For GCM Decryption

[in]dma_use

- 0 - DMA disable 1: DMA Enable

[in]msg

- Pointer to message

[in]msg_length

- Total message length

[in]key_info

- Structure pointer for key_info

[in]iv

- Pointer to GCM iv

[in]iv_sz

- size of IV

[in]header

- pointer to header

[in]header_length

- Total length of header

[out]output

- Output parameter to hold encrypted/decrypted from GCM

Returns

  • 0 - Success Non-Zero Value - Failure

Note

  • Refer Error Codes section for above error codes Error Codes.

description#

This function decides whether the GCM/CMAC message can be sent once or requires multiple calls to send the message


Definition at line 3894 of file crypto/rsi_crypto.c

rsi_wrap#

int32_t rsi_wrap (key_descriptor_wrap_t *key_info, uint8_t *output)
Parameters
[in]key_info

- size of keys in bytes, 32- M4_OTA_KEY, 96- M4_PUBLIC_KEY

[in]output

- 1- M4_OTA_KEY, 2- M4_PUBLIC_KEY

[out]output

- Output parameter to hold built-in-key


Definition at line 707 of file include/rsi_crypto.h