ECB: Provide cheat interface to adjust the time it takes to complete

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-03-30 13:55:12 +02:00
parent 7078310d52
commit c5daf6abe8
2 changed files with 23 additions and 1 deletions

View File

@ -26,6 +26,9 @@ NRF_ECB_Type NRF_ECB_regs;
static uint32_t ECB_INTEN; /* interrupt enable */
static bool ECB_Running;
#define DEFAULT_t_ECB 7
static uint ECB_t_ECB = DEFAULT_t_ECB;
typedef struct {
uint8_t KEY[16]; /* 16 byte AES key */
uint8_t CLEARTEXT[16]; /* 16 byte AES cleartext input block */
@ -43,6 +46,23 @@ void nrf_aes_ecb_clean_up(){
}
/*
* Cheat interface to adjust the time in microseconds it takes
* for a 16byte AES ECB block to be computed
*/
void nrf_aes_ecb_cheat_set_t_ecb(unsigned int new_t){
ECB_t_ECB = new_t;
}
/*
* Cheat interface to reset the time it takes
* for a 16byte AES ECB block to be computed
* to the value specified in the infocenter spec.
*/
void nrf_aes_ecb_cheat_reset_t_ecb(void){
ECB_t_ECB = DEFAULT_t_ECB;
}
static void signal_ENDECB(){
NRF_ECB_regs.EVENTS_ENDECB = 1;
nrf_ppi_event(ECB_EVENTS_ENDECB);
@ -74,7 +94,7 @@ void nrf_ecb_TASK_STOPECB(){
void nrf_ecb_TASK_STARTECB(){
ECB_Running = true;
Timer_ECB = tm_get_hw_time() + 7 /*ECB delay*/;
Timer_ECB = tm_get_hw_time() + ECB_t_ECB;
nrf_hw_find_next_timer_to_trigger();
}

View File

@ -19,6 +19,8 @@ void nrf_ecb_regw_sideeffects_INTENSET();
void nrf_ecb_regw_sideeffects_INTENCLEAR();
void nrf_ecb_regw_sideeffects_TASKS_STARTECB();
void nrf_ecb_regw_sideeffects_TASKS_STOPECB();
void nrf_aes_ecb_cheat_set_t_ecb(unsigned int new_t);
void nrf_aes_ecb_cheat_reset_t_ecb(void);
#ifdef __cplusplus
}