A whole lot of changes to make the code more device-oriented
This commit is contained in:
@@ -7,8 +7,9 @@ set(CMAKE_ASM_COMPILER /usr/bin/aarch64-linux-gnu-as)
|
||||
set(CMAKE_OBJCOPY /usr/bin/aarch64-linux-gnu-objcopy)
|
||||
set(CMAKE_C_FLAGS "-nostdlib -O")
|
||||
|
||||
set(PAYLOADS payload_aes)
|
||||
add_executable(payload_aes aes.c)
|
||||
set(PAYLOADS payload_aes payload_sysreg)
|
||||
add_executable(payload_aes src/aes.c)
|
||||
add_executable(payload_sysreg src/sysreg.c)
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
|
||||
foreach(BINARY ${PAYLOADS})
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#include "brfunc_aes.h"
|
||||
#include "brfunc_timing.h"
|
||||
#include "brfunc_sep.h"
|
||||
|
||||
__attribute__ ((section (".payload_text")))
|
||||
int aes_hw_crypto_command(unsigned int cmd,
|
||||
void *src,
|
||||
void *dst,
|
||||
int len,
|
||||
unsigned int opts,
|
||||
void *key,
|
||||
void *iv)
|
||||
{
|
||||
int seeded;
|
||||
long start = 0, timeout = 0;
|
||||
CLOCK_GATE(0x3C, 1);
|
||||
|
||||
seeded = DPA_SEEDED();
|
||||
if(!seeded)
|
||||
{
|
||||
SEP_CREATE_SEND_DPA_MESSAGE();
|
||||
start = SYSTEM_TIME();
|
||||
|
||||
while(!seeded && !timeout)
|
||||
{
|
||||
seeded = DPA_SEEDED();
|
||||
timeout = TIME_HAS_ELAPSED(start, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
if(timeout) return -1;
|
||||
|
||||
unsigned int key_command = CREATE_KEY_COMMAND(0, 0, 0, 0, 1, 0, 0, 0);
|
||||
*rAES_INT_STATUS = 0x20;
|
||||
*rAES_CONTROL = 1;
|
||||
|
||||
PUSH_COMMAND_KEY(key_command, key);
|
||||
PUSH_COMMAND_IV(0, 0, 0, iv);
|
||||
PUSH_COMMAND_DATA(0, 0, src, dst, len);
|
||||
PUSH_COMMAND_FLAG(0, 1, 1);
|
||||
WAIT_FOR_COMMAND_FLAG();
|
||||
|
||||
*rAES_CONTROL = 2;
|
||||
CLOCK_GATE(0x3C, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _start(unsigned int cmd,
|
||||
void *src,
|
||||
void *dst,
|
||||
int len,
|
||||
unsigned int opts,
|
||||
void *key,
|
||||
void *iv)
|
||||
{
|
||||
return aes_hw_crypto_command(cmd, src, dst, len, opts, key, iv);
|
||||
}
|
||||
Reference in New Issue
Block a user