10 #define AES_BLOCK_SIZE 0x10 12 #define AES_CCM_DECRYPT_MODE (0u << 27) 13 #define AES_CCM_ENCRYPT_MODE (1u << 27) 14 #define AES_CTR_MODE (2u << 27) 15 #define AES_CBC_DECRYPT_MODE (4u << 27) 16 #define AES_CBC_ENCRYPT_MODE (5u << 27) 17 #define AES_ECB_DECRYPT_MODE (6u << 27) 18 #define AES_ECB_ENCRYPT_MODE (7u << 27) 20 #define REG_AESCNT ((volatile uint32_t*)0x10009000) 21 #define REG_AESBLKCNT ((volatile uint32_t*)0x10009004) 22 #define REG_AESWRFIFO ((volatile uint32_t*)0x10009008) 23 #define REG_AESRDFIFO ((volatile uint32_t*)0x1000900C) 24 #define REG_AESKEYSEL ((volatile uint8_t *)0x10009010) 25 #define REG_AESKEYCNT ((volatile uint8_t *)0x10009011) 26 #define REG_AESCTR ((volatile uint32_t*)0x10009020) 27 #define REG_AESKEYFIFO ((volatile uint32_t*)0x10009100) 28 #define REG_AESKEYXFIFO ((volatile uint32_t*)0x10009104) 29 #define REG_AESKEYYFIFO ((volatile uint32_t*)0x10009108) 30 #define REG_AESMAC ((volatile uint32_t*)0x10009030) 32 #define REG_AESKEY0123 ((volatile uint32_t*)0x10009040) 34 #define AES_CNT_START 0x80000000u 35 #define AES_CNT_INPUT_ORDER 0x02000000u 36 #define AES_CNT_OUTPUT_ORDER 0x01000000u 37 #define AES_CNT_INPUT_ENDIAN 0x00800000u 38 #define AES_CNT_OUTPUT_ENDIAN 0x00400000u 39 #define AES_CNT_FLUSH_READ 0x00000800u 40 #define AES_CNT_FLUSH_WRITE 0x00000400u 42 #define AES_CNT_CTRNAND_MODE (AES_CTR_MODE | AES_CNT_INPUT_ORDER | AES_CNT_OUTPUT_ORDER | AES_CNT_INPUT_ENDIAN | AES_CNT_OUTPUT_ENDIAN) 43 #define AES_CNT_TWLNAND_MODE AES_CTR_MODE 44 #define AES_CNT_TITLEKEY_DECRYPT_MODE (AES_CBC_DECRYPT_MODE | AES_CNT_INPUT_ORDER | AES_CNT_OUTPUT_ORDER | AES_CNT_INPUT_ENDIAN | AES_CNT_OUTPUT_ENDIAN) 45 #define AES_CNT_TITLEKEY_ENCRYPT_MODE (AES_CBC_ENCRYPT_MODE | AES_CNT_INPUT_ORDER | AES_CNT_OUTPUT_ORDER | AES_CNT_INPUT_ENDIAN | AES_CNT_OUTPUT_ENDIAN) 47 void setup_aeskeyX(uint8_t keyslot,
void* keyx);
48 void setup_aeskeyY(uint8_t keyslot,
void* keyy);
49 void setup_aeskey(uint8_t keyslot,
void* keyy);
50 void use_aeskey(uint32_t keyno);
51 void set_ctr(
void* iv);
52 void add_ctr(
void* ctr, uint32_t carry);
53 void aes_decrypt(
void* inbuf,
void* outbuf,
size_t size, uint32_t mode);
54 void aes_fifos(
void* inbuf,
void* outbuf,
size_t blocks);
55 void set_aeswrfifo(uint32_t value);
56 uint32_t read_aesrdfifo(
void);
57 uint32_t aes_getwritecount(
void);
58 uint32_t aes_getreadcount(
void);
59 uint32_t aescnt_checkwrite(
void);
60 uint32_t aescnt_checkread(
void);