SDP driver APIs. More...
Data Structures | |
| struct | sdp_crypto_ctx_t |
| SDP AES context structure. More... | |
| struct | sdp_dma_ctx_t |
| SDP DMA context. More... | |
| struct | sdp_hash_ctx_t |
| SDP HASH context. More... | |
| struct | sdp_action_t |
| SDP Action Structure. More... | |
Macros | |
| #define | HASH_BLOCK_SIZE (64U) |
| #define | AES_BLOCK_SIZE (16U) |
| #define | AES_128_KEY_SIZE (0x10U) |
| #define | AES_256_KEY_SIZE (0x20U) |
| #define | SM4_BLOCK_SIZE (AES_BLOCK_SIZE) |
| #define | SM4_KEY_SIZE (AES_128_KEY_SIZE) |
| #define | SDP_PKT_CTRL_DERSEMA_MASK (1U << 2) |
| Bitfield definitions for the PKT_CTRL. More... | |
| #define | SDP_PKT_CTRL_CHAIN_MASK (1U << 3) |
| #define | SDP_PKT_CTRL_HASHINIT_MASK (1U << 4) |
| #define | SDP_PKT_CTRL_HASHFINISH_MASK (1U << 5) |
| #define | SDP_PKT_CTRL_CIPHIV_MASK (1U << 6) |
Typedefs | |
| typedef sdp_crypto_key_bits_t | sdp_aes_key_bits_t |
| typedef sdp_crypto_key_bits_t | sdp_sm4_key_bits_t |
| typedef sdp_crypto_op_t | sdp_aes_op_t |
| typedef struct _sdp_packet_struct | sdp_pkt_struct_t |
| SDP Command Packet structure. More... | |
| typedef sdp_crypto_ctx_t | sdp_aes_ctx_t |
Enumerations | |
| enum | sdp_crypto_key_bits_t { sdp_aes_keybits_128 = 0 , sdp_aes_keybits_256 = 1 } |
| SDP AES key bit options. More... | |
| enum | sdp_crypto_op_t { sdp_aes_op_encrypt , sdp_aes_op_decrypt } |
| Crypto operation option. More... | |
| enum | sdp_crypto_alg_t { sdp_crypto_alg_aes = 0 } |
| SDP Crypto algorithms. More... | |
| enum | sdp_crypto_mode_t { sdp_crypto_mode_ecb = 0 , sdp_crypto_mode_cbc = 1 } |
| SDP Crypto modes. More... | |
| enum | sdp_data_swap_mode_t { sdp_swap_mode_none = 0 , sdp_swap_mode_bytes_in_word = 1 , sdp_swap_mode_word_swap = 2 , sdp_swap_mode_switch_endian = 3 } |
| SDP Data Swap modes. More... | |
| enum | sdp_calc_hash_mode_t { sdp_calc_hash_for_input = 0 , sdp_calc_hash_for_output = 1 } |
| SDP HASH calculation mode. More... | |
| enum | sdp_hash_alg_t { sdp_hash_alg_sha1 = 0 , sdp_hash_alg_crc32 = 1 , sdp_hash_alg_sha256 = 2 , sdp_hash_alg_max = sdp_hash_alg_sha256 } |
| SDP HASH algorithm definitions. More... | |
| enum | { status_sdp_no_crypto_support = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 0 )) , status_sdp_no_hash_support = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 1 )) , status_sdp_invalid_key_src = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 2 )) , status_sdp_error_packet = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 3 )) , status_sdp_aes_busy = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 4 )) , status_sdp_hash_busy = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 5 )) , status_sdp_error_setup = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 6 )) , status_sdp_error_src = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 7 )) , status_sdp_error_dst = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 8 )) , status_sdp_error_hash = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 9 )) , status_sdp_error_chain = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 10 )) , status_sdp_error_invalid_mac = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 11 )) , status_sdp_invalid_alg = ((uint32_t)( status_group_sdp )*1000U + (uint32_t)( 12 )) } |
| SDP error status definitions. More... | |
| enum | sdp_operation_t { sdp_op_invalid = 0 , sdp_op_cipher_only = SDP_SDPCR_CIPHEN_MASK , sdp_op_hash_only = SDP_SDPCR_HASHEN_MASK , sdp_op_memcpy_only = SDP_SDPCR_MCPEN_MASK , sdp_op_memfill_only = SDP_SDPCR_CONFEN_MASK , sdp_op_cipher_hash = SDP_SDPCR_CIPHEN_MASK | SDP_SDPCR_HASHEN_MASK , sdp_op_copy_hash = SDP_SDPCR_MCPEN_MASK | SDP_SDPCR_HASHEN_MASK } |
| SDP Operations. More... | |
Functions | |
| static void | sdp_enable_interrupt (SDP_Type *base) |
| Enable SDP interrupt. More... | |
| static void | sdp_disable_interrupt (SDP_Type *base) |
| Disable SDP interrupt. More... | |
| static void | sdp_set_key_index (SDP_Type *base, uint32_t key_index) |
| Set the Crypto Key Index in SDP. More... | |
| static void | sdp_write_key (SDP_Type *base, uint32_t key_index, uint32_t key_bits, const uint32_t *crypto_key) |
| Write SDP key to specified SDP Key RAM. More... | |
| static void | sdp_write_hash_digest (SDP_Type *base, const uint32_t *digest, uint32_t num_words) |
| Write the HASH digest result to SDP. More... | |
| static void | sdp_get_hash_digest (SDP_Type *base, uint32_t *digest, uint32_t num_words) |
| Read the HASH digest result from SDP. More... | |
| static void | sdp_write_cipher_iv (SDP_Type *base, const uint32_t *iv) |
| Write the cipher IV to SDP. More... | |
| static void | sdp_clear_status (SDP_Type *base, uint32_t mask) |
| Clear SDP status. More... | |
| static uint32_t | sdp_get_status (SDP_Type *base) |
| Get SDP status. More... | |
| hpm_stat_t | sdp_init (SDP_Type *base) |
| Initialize the SDP controller. More... | |
| hpm_stat_t | sdp_deinit (SDP_Type *base) |
| De-initialize the SDP controller. More... | |
| hpm_stat_t | sdp_aes_set_key (SDP_Type *base, sdp_aes_ctx_t *aes_ctx, const uint8_t *key, sdp_aes_key_bits_t key_bits, uint32_t key_idx) |
| Set the AES key for the SDP AES operation. More... | |
| hpm_stat_t | sdp_aes_crypt_ecb (SDP_Type *base, sdp_aes_ctx_t *aes_ctx, sdp_aes_op_t op, uint32_t len, const uint8_t *in, uint8_t *out) |
| Perform the basic AES ECB operation. More... | |
| hpm_stat_t | sdp_aes_crypt_cbc (SDP_Type *base, sdp_aes_ctx_t *aes_ctx, sdp_aes_op_t op, uint32_t length, const uint8_t iv[16], const uint8_t *input, uint8_t *output) |
| Perform the AES CBC operation. More... | |
| hpm_stat_t | sdp_aes_crypt_ctr (SDP_Type *base, sdp_aes_ctx_t *aes_ctx, uint8_t *nonce_counter, uint8_t *input, uint8_t *output, uint32_t length) |
| Perform the AES-CTR operation See NIST Special Publication800-38A for more details. More... | |
| hpm_stat_t | sdp_aes_ccm_generate_encrypt (SDP_Type *base, sdp_aes_ctx_t *aes_ctx, uint32_t input_len, const uint8_t *iv, uint32_t iv_len, const uint8_t *aad, uint32_t aad_len, const uint8_t *input, uint8_t *output, uint8_t *tag, uint32_t tag_len) |
| Perform the AES-CCM generate and encrypt See NIST Special Publication 800-38C for more details. More... | |
| hpm_stat_t | sdp_aes_ccm_decrypt_verify (SDP_Type *base, sdp_aes_ctx_t *aes_ctx, uint32_t input_len, const uint8_t *iv, uint32_t iv_len, const uint8_t *aad, uint32_t aad_len, const uint8_t *input, uint8_t *output, const uint8_t *tag, uint32_t tag_len) |
| Perform the AES-CCM decrypt and verify See NIST Special Publication 800-38C for more details. More... | |
| hpm_stat_t | sdp_memcpy (SDP_Type *base, sdp_dma_ctx_t *sdp_ctx, void *dst, const void *src, uint32_t length) |
| Perform the DMA accelerated memcpy. More... | |
| hpm_stat_t | sdp_memset (SDP_Type *base, sdp_dma_ctx_t *sdp_ctx, void *dst, uint8_t pattern, uint32_t length) |
| Perform the DMA accelerated memset. More... | |
| hpm_stat_t | sdp_hash_init (SDP_Type *base, sdp_hash_ctx_t *hash_ctx, sdp_hash_alg_t alg) |
| Initialize the HASH engine. More... | |
| hpm_stat_t | sdp_hash_update (SDP_Type *base, sdp_hash_ctx_t *hash_ctx, const uint8_t *data, uint32_t length) |
| Compute the HASH digest. More... | |
| hpm_stat_t | sdp_hash_finish (SDP_Type *base, sdp_hash_ctx_t *hash_ctx, uint8_t *digest) |
| Finish the HASH calculation and output the digest. More... | |
| hpm_stat_t | sdp_wait_done (SDP_Type *base) |
| Wait until the SDP operation gets done. More... | |
| hpm_stat_t | sdp_trigger_action (SDP_Type *base, const sdp_action_t *action, const sdp_pkt_struct_t *cmd_pkt) |
| Trigger SDP operation via the specified SDP packet description. More... | |
SDP driver APIs.
| #define AES_128_KEY_SIZE (0x10U) |
#include <drivers/inc/hpm_sdp_drv.h>
AES 128-bit key size in bytes
| #define AES_256_KEY_SIZE (0x20U) |
#include <drivers/inc/hpm_sdp_drv.h>
AES 256-bit key size in bytes
| #define AES_BLOCK_SIZE (16U) |
#include <drivers/inc/hpm_sdp_drv.h>
AES block size in bytes
| #define HASH_BLOCK_SIZE (64U) |
#include <drivers/inc/hpm_sdp_drv.h>
Hash block size in bytes
| #define SDP_PKT_CTRL_CHAIN_MASK (1U << 3) |
#include <drivers/inc/hpm_sdp_drv.h>
| #define SDP_PKT_CTRL_CIPHIV_MASK (1U << 6) |
#include <drivers/inc/hpm_sdp_drv.h>
| #define SDP_PKT_CTRL_DERSEMA_MASK (1U << 2) |
#include <drivers/inc/hpm_sdp_drv.h>
Bitfield definitions for the PKT_CTRL.
| #define SDP_PKT_CTRL_HASHFINISH_MASK (1U << 5) |
#include <drivers/inc/hpm_sdp_drv.h>
| #define SDP_PKT_CTRL_HASHINIT_MASK (1U << 4) |
#include <drivers/inc/hpm_sdp_drv.h>
| #define SM4_BLOCK_SIZE (AES_BLOCK_SIZE) |
#include <drivers/inc/hpm_sdp_drv.h>
SM4 block size in bytes
| #define SM4_KEY_SIZE (AES_128_KEY_SIZE) |
#include <drivers/inc/hpm_sdp_drv.h>
SM4 Key size in bytes
| typedef sdp_crypto_ctx_t sdp_aes_ctx_t |
#include <drivers/inc/hpm_sdp_drv.h>
#include <drivers/inc/hpm_sdp_drv.h>
| typedef sdp_crypto_op_t sdp_aes_op_t |
#include <drivers/inc/hpm_sdp_drv.h>
| typedef struct _sdp_packet_struct sdp_pkt_struct_t |
#include <drivers/inc/hpm_sdp_drv.h>
SDP Command Packet structure.
#include <drivers/inc/hpm_sdp_drv.h>
| anonymous enum |
#include <drivers/inc/hpm_sdp_drv.h>
SDP error status definitions.
| enum sdp_calc_hash_mode_t |
#include <drivers/inc/hpm_sdp_drv.h>
SDP HASH calculation mode.
| Enumerator | |
|---|---|
| sdp_calc_hash_for_input | Calculate HASH before doing crypto operation |
| sdp_calc_hash_for_output | Calculate HASH after doing crypto operation |
| enum sdp_crypto_alg_t |
#include <drivers/inc/hpm_sdp_drv.h>
SDP AES key bit options.
| Enumerator | |
|---|---|
| sdp_aes_keybits_128 | 128 bit AES key |
| sdp_aes_keybits_256 | 256 bit AES key |
| enum sdp_crypto_mode_t |
#include <drivers/inc/hpm_sdp_drv.h>
SDP Crypto modes.
| Enumerator | |
|---|---|
| sdp_crypto_mode_ecb | ECB mode |
| sdp_crypto_mode_cbc | CBC mode |
| enum sdp_crypto_op_t |
#include <drivers/inc/hpm_sdp_drv.h>
Crypto operation option.
| Enumerator | |
|---|---|
| sdp_aes_op_encrypt | AES Encrypt operation |
| sdp_aes_op_decrypt | AES Decrypt operation |
| enum sdp_data_swap_mode_t |
#include <drivers/inc/hpm_sdp_drv.h>
SDP Data Swap modes.
| enum sdp_hash_alg_t |
#include <drivers/inc/hpm_sdp_drv.h>
SDP HASH algorithm definitions.
| Enumerator | |
|---|---|
| sdp_hash_alg_sha1 | SDP SHA1 |
| sdp_hash_alg_crc32 | SDP CRC32 |
| sdp_hash_alg_sha256 | SDP SHA256 |
| sdp_hash_alg_max | |
| enum sdp_operation_t |
#include <drivers/inc/hpm_sdp_drv.h>
SDP Operations.
| Enumerator | |
|---|---|
| sdp_op_invalid | |
| sdp_op_cipher_only | |
| sdp_op_hash_only | |
| sdp_op_memcpy_only | |
| sdp_op_memfill_only | |
| sdp_op_cipher_hash | |
| sdp_op_copy_hash | |
| hpm_stat_t sdp_aes_ccm_decrypt_verify | ( | SDP_Type * | base, |
| sdp_aes_ctx_t * | aes_ctx, | ||
| uint32_t | input_len, | ||
| const uint8_t * | iv, | ||
| uint32_t | iv_len, | ||
| const uint8_t * | aad, | ||
| uint32_t | aad_len, | ||
| const uint8_t * | input, | ||
| uint8_t * | output, | ||
| const uint8_t * | tag, | ||
| uint32_t | tag_len | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Perform the AES-CCM decrypt and verify See NIST Special Publication 800-38C for more details.
| [in] | base | SDP base address |
| [in] | aes_ctx | AES operation context |
| [in] | input_len | Input data length in bytes |
| [in] | iv | Initial vector |
| [in] | iv_len | Initial vector length in bytes |
| [in] | aad | Additional Authentication data |
| [in] | aad_len | Additional authentication data size |
| [in] | input | Input data buffer |
| [out] | output | Output buffer |
| [in] | tag | MAC buffer |
| [in] | tag_len | Tag/MAC size in bytes |
| hpm_stat_t sdp_aes_ccm_generate_encrypt | ( | SDP_Type * | base, |
| sdp_aes_ctx_t * | aes_ctx, | ||
| uint32_t | input_len, | ||
| const uint8_t * | iv, | ||
| uint32_t | iv_len, | ||
| const uint8_t * | aad, | ||
| uint32_t | aad_len, | ||
| const uint8_t * | input, | ||
| uint8_t * | output, | ||
| uint8_t * | tag, | ||
| uint32_t | tag_len | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Perform the AES-CCM generate and encrypt See NIST Special Publication 800-38C for more details.
| [in] | base | SDP base address |
| [in] | aes_ctx | AES operation context |
| [in] | input_len | Input data length in bytes |
| [in] | iv | Initial vector |
| [in] | iv_len | Initial vector length in bytes |
| [in] | aad | Additional Authentication data |
| [in] | aad_len | Additional authentication data size |
| [in] | input | Input data buffer |
| [out] | output | Output buffer |
| [out] | tag | MAC buffer |
| [in] | tag_len | Tag/MAC size in bytes |
| hpm_stat_t sdp_aes_crypt_cbc | ( | SDP_Type * | base, |
| sdp_aes_ctx_t * | aes_ctx, | ||
| sdp_aes_op_t | op, | ||
| uint32_t | length, | ||
| const uint8_t | iv[16], | ||
| const uint8_t * | input, | ||
| uint8_t * | output | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Perform the AES CBC operation.
| [in] | base | SDP base address |
| [in] | aes_ctx | AES operation context |
| [in] | op | AES operation option |
| [in] | length | AES data length in bytes |
| [in] | iv | Initial vector/nonce |
| [in] | input | Input buffer |
| [out] | output | Output buffer |
| hpm_stat_t sdp_aes_crypt_ctr | ( | SDP_Type * | base, |
| sdp_aes_ctx_t * | aes_ctx, | ||
| uint8_t * | nonce_counter, | ||
| uint8_t * | input, | ||
| uint8_t * | output, | ||
| uint32_t | length | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Perform the AES-CTR operation See NIST Special Publication800-38A for more details.
| [in] | base | SDP base address |
| [in] | aes_ctx | AES operation context |
| [in] | nonce_counter | AES-CTR nonce/counter |
| [in] | input | Input buffer |
| [out] | output | Output buffer |
| [in] | length | Length of data for AES-CTR operation |
| hpm_stat_t sdp_aes_crypt_ecb | ( | SDP_Type * | base, |
| sdp_aes_ctx_t * | aes_ctx, | ||
| sdp_aes_op_t | op, | ||
| uint32_t | len, | ||
| const uint8_t * | in, | ||
| uint8_t * | out | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Perform the basic AES ECB operation.
| [in] | base | SDP base address |
| [in] | aes_ctx | AES operation context |
| [in] | op | AES operation option |
| [in] | len | AES data length in bytes |
| [in] | in | Input buffer |
| [out] | out | Output buffer |
| hpm_stat_t sdp_aes_set_key | ( | SDP_Type * | base, |
| sdp_aes_ctx_t * | aes_ctx, | ||
| const uint8_t * | key, | ||
| sdp_aes_key_bits_t | key_bits, | ||
| uint32_t | key_idx | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Set the AES key for the SDP AES operation.
| [in] | base | SDP base address |
| [in] | aes_ctx | AES operation context |
| [in] | key | AES key |
| [in] | key_bits | AES key-bit option |
| [in] | key_idx | AES key index |
|
inlinestatic |
#include <drivers/inc/hpm_sdp_drv.h>
Clear SDP status.
| [in] | base | SDP base address |
| [in] | mask | Status Mask |
| hpm_stat_t sdp_deinit | ( | SDP_Type * | base | ) |
#include <drivers/inc/hpm_sdp_drv.h>
De-initialize the SDP controller.
| [in] | base | SDP base address |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
#include <drivers/inc/hpm_sdp_drv.h>
Read the HASH digest result from SDP.
| [in] | base | SDP base address |
| [out] | digest | HASH digest |
| [in] | num_words | Digest size in words |
|
inlinestatic |
#include <drivers/inc/hpm_sdp_drv.h>
Get SDP status.
| [in] | base | SDP base address |
| hpm_stat_t sdp_hash_finish | ( | SDP_Type * | base, |
| sdp_hash_ctx_t * | hash_ctx, | ||
| uint8_t * | digest | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Finish the HASH calculation and output the digest.
| [in] | base | SDP base address |
| [in] | hash_ctx | HASH operation context |
| [out] | digest | Digest buffer |
| hpm_stat_t sdp_hash_init | ( | SDP_Type * | base, |
| sdp_hash_ctx_t * | hash_ctx, | ||
| sdp_hash_alg_t | alg | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Initialize the HASH engine.
| [in] | base | SDP base address |
| [in] | hash_ctx | HASH operation context |
| [in] | alg | Hash algorithm |
| hpm_stat_t sdp_hash_update | ( | SDP_Type * | base, |
| sdp_hash_ctx_t * | hash_ctx, | ||
| const uint8_t * | data, | ||
| uint32_t | length | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Compute the HASH digest.
| [in] | base | SDP base address |
| [in] | hash_ctx | HASH operation context |
| [in] | data | Data for HASH computing |
| [in] | length | Data size for HASH computing |
| hpm_stat_t sdp_init | ( | SDP_Type * | base | ) |
#include <drivers/inc/hpm_sdp_drv.h>
Initialize the SDP controller.
| [in] | base | SDP base address |
| hpm_stat_t sdp_memcpy | ( | SDP_Type * | base, |
| sdp_dma_ctx_t * | sdp_ctx, | ||
| void * | dst, | ||
| const void * | src, | ||
| uint32_t | length | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Perform the DMA accelerated memcpy.
| [in] | base | SDP base address |
| [in] | sdp_ctx | SDP DMA context |
| [out] | dst | Destination address for memcpy operation |
| [in] | src | Source address for memcpy operation |
| [in] | length | Length of the data to be copied |
| hpm_stat_t sdp_memset | ( | SDP_Type * | base, |
| sdp_dma_ctx_t * | sdp_ctx, | ||
| void * | dst, | ||
| uint8_t | pattern, | ||
| uint32_t | length | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Perform the DMA accelerated memset.
| [in] | base | SDP base address |
| [in] | sdp_ctx | SDP DMA context |
| [out] | dst | SDP destination address for memset operation |
| [in] | pattern | pattern for memset operation |
| [in] | length | length of the memory for memset operation |
|
inlinestatic |
#include <drivers/inc/hpm_sdp_drv.h>
Set the Crypto Key Index in SDP.
| [in] | base | SDP base address |
| [in] | key_index | SDP key index |
| hpm_stat_t sdp_trigger_action | ( | SDP_Type * | base, |
| const sdp_action_t * | action, | ||
| const sdp_pkt_struct_t * | cmd_pkt | ||
| ) |
#include <drivers/inc/hpm_sdp_drv.h>
Trigger SDP operation via the specified SDP packet description.
| [in] | base | SDP base address |
| [in] | action | SDP action |
| [in] | cmd_pkt | SDP Command packet description |
| hpm_stat_t sdp_wait_done | ( | SDP_Type * | base | ) |
#include <drivers/inc/hpm_sdp_drv.h>
Wait until the SDP operation gets done.
| [in] | base | SDP base address |
|
inlinestatic |
#include <drivers/inc/hpm_sdp_drv.h>
Write the cipher IV to SDP.
| [in] | base | SDP base address |
| [in] | iv | Initial vector |
|
inlinestatic |
#include <drivers/inc/hpm_sdp_drv.h>
Write the HASH digest result to SDP.
| [in] | base | SDP base address |
| [in] | digest | HASH digest |
| [in] | num_words | Digest size in words |
|
inlinestatic |
#include <drivers/inc/hpm_sdp_drv.h>
Write SDP key to specified SDP Key RAM.
| [in] | base | SDP base address |
| [in] | key_index | Key Index |
| [in] | key_bits | Key bits, valid value: 128, 256 |
| [in] | crypto_key | Crypto Key buffer |