add zero-ed constant

This commit is contained in:
Michele Balistreri 2024-07-05 13:48:37 +02:00
parent bcc9ce484c
commit 05f4e7438f
No known key found for this signature in database
GPG Key ID: E9567DA33A4F791A
3 changed files with 9 additions and 5 deletions

View File

@ -1,10 +1,7 @@
#include <string.h> #include <string.h>
#include "aes.h" #include "aes.h"
#include "hal.h" #include "hal.h"
#include "mem.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
};
#ifdef SOFT_AES #ifdef SOFT_AES
#define AES_128_KEYROUND 10 #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) { 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) { for(uint32_t i = 0; i < len; i += AES_BLOCK_SIZE) {
hal_aes256_block_process(&data[i], out); hal_aes256_block_process(&data[i], out);

View File

@ -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_ALIGNED(uint8_t g_flash_swap[HAL_FLASH_BLOCK_SIZE], 4);
APP_SECTION(uint32_t g_bootcmd, ".bootcmd,\"aw\",%nobits@"); 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,
};

View File

@ -8,6 +8,8 @@
#define BOOTCMD_SWITCH_FW 0x83578007 #define BOOTCMD_SWITCH_FW 0x83578007
extern const uint8_t ZERO32[32];
extern uint8_t g_mem_heap[MEM_HEAP_SIZE]; extern uint8_t g_mem_heap[MEM_HEAP_SIZE];
extern uint8_t g_flash_swap[HAL_FLASH_BLOCK_SIZE]; extern uint8_t g_flash_swap[HAL_FLASH_BLOCK_SIZE];
extern uint8_t g_camera_fb[CAMERA_FB_COUNT][CAMERA_FB_SIZE]; extern uint8_t g_camera_fb[CAMERA_FB_COUNT][CAMERA_FB_SIZE];