Attempted to get AES to work

This commit is contained in:
2019-12-24 12:16:19 -05:00
parent 3972ac655e
commit 1f2a567ab9
15 changed files with 129 additions and 47 deletions

View File

@@ -14,23 +14,26 @@ int aes_hw_crypto_command(unsigned int cmd,
void *iv)
{
int seeded;
long cgvar;
long start = 0, timeout = 0;
CLOCK_GATE(0x3C, 1);
seeded = DPA_SEEDED();
if(!seeded)
{
SEP_CREATE_SEND_DPA_MESSAGE();
start = SYSTEM_TIME();
__asm__("orr %0, xzr, #0x3c" : "=r" (cgvar));
CLOCK_GATE(cgvar, 1);
while(!seeded && !timeout)
{
seeded = DPA_SEEDED();
timeout = TIME_HAS_ELAPSED(start, 1000);
}
}
if(timeout) return -1;
// seeded = DPA_SEEDED();
// if(!(seeded & 1))
// {
// SEP_CREATE_SEND_DPA_MESSAGE();
// start = SYSTEM_TIME();
//
// while(!(seeded & 1) && !(timeout & 1))
// {
// 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;
@@ -43,18 +46,14 @@ int aes_hw_crypto_command(unsigned int cmd,
WAIT_FOR_COMMAND_FLAG();
*rAES_CONTROL = 2;
CLOCK_GATE(0x3C, 0);
CLOCK_GATE(cgvar, 0);
return 0;
}
TEXT_SECTION
int _start(unsigned int cmd,
void *src,
int _start(void *src,
void *dst,
int len,
unsigned int opts,
void *key,
void *iv)
void *key)
{
return aes_hw_crypto_command(cmd, src, dst, len, opts, key, iv);
return aes_hw_crypto_command(0, src, dst, 128, 0, key, 0);
}