bf0_hal_aes.h
AES encrypt/decrypt enginer hardware interface.
- Author
Sifli software development team
Unnamed Group
-
AES_DEC
-
AES_ENC
-
AES_MODE_ECB
AES mode ECB
-
AES_MODE_CTR
AES mode CTR
-
AES_MODE_CBC
AES mode CBC
-
AES_KEY_LEN_128
-
AES_KEY_LEN_192
-
AES_KEY_LEN_256
Defines
-
HAL_AES_busy()
Test whether AES hardware block is busy.
-
HASH_SHA1_SIZE
HASH_ALGO_XXX SHA1 size
-
HASH_SHA224_SIZE
HASH algorithm SHA224, only 28 bytes in valid in final result. 32 bytes need for internal usage
-
HASH_SHA256_SIZE
HASH algorithm SHA256
-
HASH_SM3_SIZE
HASH algorithm SM3
-
HAL_HASH_busy
Test whether AES hardware block is busy.
-
HASH_IRQHandler
HASH_exported_functions
-
HAL_HASH_Regist_IT_cb
-
HAL_HASH_Regist_IT_cb_ns
Typedefs
-
typedef void (*pAESCallback)(void)
Enums
Functions
-
int HAL_AES_init(uint32_t *key, int key_size, uint32_t *iv, uint32_t mode)
Initialize AES hardware block.
- 参数:
key – aes key, must be 32bit aligned
key_size – aes key size in bytes
iv – initial vector, must be 32bit aligned
mode – aes mode
- 返回值:
0 – if successful, otherwise -1
-
int HAL_AES_init_ns(uint32_t *key, int key_size, uint32_t *iv, uint32_t mode)
-
HAL_StatusTypeDef HAL_AES_run(uint8_t enc, uint8_t *in_data, uint8_t *out_data, int size)
run AES hardware enc/dec
- 参数:
enc – 1:encoding, 0:decoding
in_data – input data, input data could not in ITCM or Retention memory
out_data – output data, output data could not in ITCM or Retention memory
size – length of input/output data in bytes, must be multiple of 16 bytes.
- 返回值:
HAL_OK – if successful, otherwise HAL_ERROR
-
HAL_StatusTypeDef HAL_AES_run_ns(uint8_t enc, uint8_t *in_data, uint8_t *out_data, int size)
-
HAL_StatusTypeDef HAL_AES_run_IT(uint8_t enc, uint8_t *in_data, uint8_t *out_data, int size)
run AES hardware enc/dec, generate interrupt when done.
- 参数:
enc – 1:encoding, 0:decoding
in_data – input data, input data could not in ITCM or Retention memory
out_data – output data, output data could not in ITCM or Retention memory
size – length of input/output data in bytes, must be multiple of 16 bytes.
- 返回值:
HAL_OK – if successful, otherwise HAL_ERROR
-
HAL_StatusTypeDef HAL_AES_run_IT_ns(uint8_t enc, uint8_t *in_data, uint8_t *out_data, int size)
-
HAL_StatusTypeDef HAL_AES_copy_IT_ns(uint8_t *src, uint8_t *dst, int size)
Copy ‘src’ to ‘dst’ like DMA, with no encoding either decoding.
- 参数:
src – source data, source data could not in ITCM or Retention memory
dst – destination data, destination data could not in ITCM or Retention memory
size – length of src/dst data in bytes, must be multiple of 16 bytes.
- 返回值:
HAL_OK – if successful, otherwise HAL_ERROR
-
int HAL_AES_reset(void)
Reset AES hardware block.
- 返回值:
0 – if successful, otherwise -1
-
int HAL_AES_reset_ns(void)
-
void HAL_AES_IRQHandler(void)
AES IRQ handler.
-
void HAL_AES_IRQHandler_ns(void)
-
int HAL_HASH_init(uint32_t *iv, uint8_t algo, uint32_t length)
Initialize AES Hash hardware block.
- 参数:
iv – initial vector, must be 32bit aligned, if NULL, use algorithm default initial vector. Initial vector is previous finished hash result, reload this to resume hash calculation. Previous finished hash block length, must be 64 bytes aligned.
algo – hash algorithm, see Hash algorithm
length – previous finished length, must be 64bytes aligned.
- 返回值:
0 – if successful, otherwise -1
-
int HAL_HASH_init_ns(uint32_t *iv, uint8_t algo, uint32_t length)
-
HAL_StatusTypeDef HAL_HASH_run(uint8_t *in_data, int size, int final)
run Hash hardware
- 参数:
in_data – input data, input data could not in ITCM or Retention memory
size – length of input data in bytes. if not last block, size must be 64 bytes aligned.
final – Last block
- 返回值:
HAL_OK – if successful, otherwise HAL_ERROR
-
HAL_StatusTypeDef HAL_HASH_run_ns(uint8_t *in_data, int size, int final)
-
HAL_StatusTypeDef HAL_HASH_run_IT(uint8_t *in_data, int size, int final)
run Hash hardware, return immediately, generate AES HASH interrupt when done.
- 参数:
in_data – input data, input data could not in ITCM or Retention memory
size – length of input data in bytes. if not last block, size must be 64 bytes aligned
final – Last block
- 返回值:
HAL_OK – if successful, otherwise HAL_ERROR
-
HAL_StatusTypeDef HAL_HASH_run_IT_ns(uint8_t *in_data, int size, int final)
-
void HAL_HASH_result(uint8_t *out_data)
Get hash result.
备注
SHA224 result is 28 bytes, but internal need 32 byte, please allocate 32 bytes for usage.
- 参数:
out_data – output data, Size of out_data depends on hash algorithm
-
void HAL_HASH_result_ns(uint8_t *out_data)
-
int HAL_HASH_reset(void)
Reset AES HASH hardware block.
- 返回值:
0 – if successful, otherwise -1
-
int HAL_HASH_reset_ns(void)
-
void HAL_HASH_IRQHandler(void)
AES HASH IRQ handler.
-
void HAL_HASH_IRQHandler_ns(void)
-
HAL_StatusTypeDef HAL_AES_Regist_IT_cb(pAESCallback cb)
-
HAL_StatusTypeDef HAL_AES_Regist_IT_cb_ns(pAESCallback cb)