123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- #ifndef NRF_CRYPTO_AES_SHARED_H__
- #define NRF_CRYPTO_AES_SHARED_H__
- #include <stdint.h>
- #include "nrf_crypto_types.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define NRF_CRYPTO_AES_INIT_MAGIC_VALUE (0x53454163)
- #define NRF_CRYPTO_AES_UNINIT_MAGIC_VALUE (0x63414553)
- #define NRF_CRYPTO_MBEDTLS_AES_IV_SIZE (16)
- typedef enum
- {
- NRF_CRYPTO_AES_MODE_CBC,
- NRF_CRYPTO_AES_MODE_CBC_PAD_PCKS7,
- NRF_CRYPTO_AES_MODE_CFB,
- NRF_CRYPTO_AES_MODE_CTR,
- NRF_CRYPTO_AES_MODE_ECB,
- NRF_CRYPTO_AES_MODE_ECB_PAD_PCKS7,
-
- NRF_CRYPTO_AES_MODE_CBC_MAC,
- NRF_CRYPTO_AES_MODE_CBC_MAC_PAD_PCKS7,
- NRF_CRYPTO_AES_MODE_CMAC,
- } nrf_crypto_aes_mode_t;
- typedef ret_code_t (*aes_init_fn_t)(void * const p_context, nrf_crypto_operation_t operation);
- typedef ret_code_t (*aes_uninit_fn_t)(void * const p_context);
- typedef ret_code_t (*aes_key_set_fn_t)(void * const p_context, uint8_t * p_key);
- typedef ret_code_t (*aes_iv_set_fn_t)(void * const p_context, uint8_t * p_iv);
- typedef ret_code_t (*aes_iv_get_fn_t)(void * const p_context, uint8_t * p_iv);
- typedef ret_code_t (*aes_update_fn_t)(void * const p_context,
- uint8_t * p_data_in,
- size_t data_size,
- uint8_t * p_data_out);
- typedef ret_code_t (*aes_finalize_fn_t)(void * const p_context,
- uint8_t * p_data_in,
- size_t data_size,
- uint8_t * p_data_out,
- size_t * p_data_out_size);
- typedef struct
- {
- nrf_crypto_aes_mode_t const mode;
- nrf_crypto_key_size_id_t const key_size;
- size_t const context_size;
- aes_init_fn_t const init_fn;
- aes_uninit_fn_t const uninit_fn;
- aes_key_set_fn_t const key_set_fn;
- aes_iv_set_fn_t const iv_set_fn;
- aes_iv_get_fn_t const iv_get_fn;
- aes_update_fn_t const update_fn;
- aes_finalize_fn_t const finalize_fn;
- } nrf_crypto_aes_info_t;
- typedef struct
- {
- uint32_t init_value;
- nrf_crypto_aes_info_t const * p_info;
- } nrf_crypto_aes_internal_context_t;
- typedef struct
- {
- nrf_crypto_operation_t operation;
- uint8_t iv[NRF_CRYPTO_MBEDTLS_AES_IV_SIZE];
- } nrf_crypto_backend_aes_ctx_t;
- typedef struct
- {
- nrf_crypto_operation_t operation;
- } nrf_crypto_backend_no_iv_aes_ctx_t;
- ret_code_t padding_pkcs7_add(uint8_t * p_padding_buff,
- uint8_t * p_message_buff,
- uint8_t msg_ending_len);
- ret_code_t padding_pkcs7_remove(uint8_t * p_padded_message,
- size_t * p_message_len);
- #ifdef __cplusplus
- }
- #endif
- #endif
|