HPM SDK
HPMicro Software Development Kit
hpm_sdp_drv.h File Reference
#include "hpm_common.h"
#include "hpm_sdp_regs.h"
#include "hpm_soc_feature.h"

Go to the source code of this file.

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

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 packet data 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 }
 SDP Crypto algorithms. 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...
 

Functions

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