diff --git a/app/crypto/aes.c b/app/crypto/aes.c index b9e5a81..4bd068d 100644 --- a/app/crypto/aes.c +++ b/app/crypto/aes.c @@ -1,10 +1,7 @@ #include #include "aes.h" #include "hal.h" - -const static uint8_t cmac_iv[AES_IV_SIZE] __attribute__((aligned(4))) = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; +#include "mem.h" #ifdef SOFT_AES #define AES_128_KEYROUND 10 @@ -125,7 +122,7 @@ uint8_t aes_decrypt_cbc(const uint8_t* key, const uint8_t* iv, const uint8_t* da } uint8_t aes_cmac(const uint8_t* key, const uint8_t* data, uint32_t len, uint8_t* out) { - hal_aes256_init(AES_ENCRYPT, AES_CBC, key, cmac_iv); + hal_aes256_init(AES_ENCRYPT, AES_CBC, key, ZERO32); for(uint32_t i = 0; i < len; i += AES_BLOCK_SIZE) { hal_aes256_block_process(&data[i], out); diff --git a/app/mem.c b/app/mem.c index a62ae41..b60e6df 100644 --- a/app/mem.c +++ b/app/mem.c @@ -5,3 +5,8 @@ APP_ALIGNED(uint8_t g_mem_heap[MEM_HEAP_SIZE], 4); APP_ALIGNED(uint8_t g_flash_swap[HAL_FLASH_BLOCK_SIZE], 4); APP_SECTION(uint32_t g_bootcmd, ".bootcmd,\"aw\",%nobits@"); + +const uint8_t ZERO32[32] __attribute__((aligned(4))) = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; diff --git a/app/mem.h b/app/mem.h index 81e0cd0..52180dd 100644 --- a/app/mem.h +++ b/app/mem.h @@ -8,6 +8,8 @@ #define BOOTCMD_SWITCH_FW 0x83578007 +extern const uint8_t ZERO32[32]; + extern uint8_t g_mem_heap[MEM_HEAP_SIZE]; extern uint8_t g_flash_swap[HAL_FLASH_BLOCK_SIZE]; extern uint8_t g_camera_fb[CAMERA_FB_COUNT][CAMERA_FB_SIZE];