ARMv8 AES: remove extra memcpy during encrypt/decrypt

This commit is contained in:
Jacob Barthelmeh
2016-09-03 03:49:20 +00:00
parent 8e4ccd355c
commit 09b29cb1d4

View File

@@ -349,10 +349,6 @@ void wc_AesAsyncFree(Aes* aes)
{
byte* keyPt = (byte*)aes->key;
word32 rounds = aes->rounds;
byte out[AES_BLOCK_SIZE];
byte* output = out;
byte* input = (byte*)inBlock;
/*
AESE exor's input with round key
@@ -361,7 +357,7 @@ void wc_AesAsyncFree(Aes* aes)
*/
__asm__ __volatile__ (
"LD1 {v0.16b}, [%[CtrIn]], #16 \n"
"LD1 {v0.16b}, [%[CtrIn]] \n"
"LD1 {v1.16b-v4.16b}, [%[Key]], #64 \n"
"AESE v0.16b, v1.16b \n"
@@ -412,13 +408,13 @@ void wc_AesAsyncFree(Aes* aes)
"EOR v0.16b, v0.16b, v1.16b \n"
"ST1 {v0.16b}, [%[CtrOut]] \n"
:[CtrOut] "=r" (output), "=r" (keyPt), "=r" (rounds)
:[Key] "1" (keyPt), [R] "2" (rounds), [CtrIn] "r" (input), "0" (output)
:[CtrOut] "=r" (outBlock), "=r" (keyPt), "=r" (rounds),
"=r" (inBlock)
:"0" (outBlock), [Key] "1" (keyPt), [R] "2" (rounds),
[CtrIn] "3" (inBlock)
: "cc", "memory", "w12"
);
XMEMCPY(outBlock, out, AES_BLOCK_SIZE);
return 0;
}
#ifdef HAVE_AES_DECRYPT
@@ -426,9 +422,6 @@ void wc_AesAsyncFree(Aes* aes)
{
byte* keyPt = (byte*)aes->key;
word32 rounds = aes->rounds;
byte out[AES_BLOCK_SIZE];
byte* output = out;
byte* input = (byte*)inBlock;
/*
AESE exor's input with round key
@@ -437,7 +430,7 @@ void wc_AesAsyncFree(Aes* aes)
*/
__asm__ __volatile__ (
"LD1 {v0.16b}, [%[CtrIn]], #16 \n"
"LD1 {v0.16b}, [%[CtrIn]] \n"
"LD1 {v1.16b-v4.16b}, [%[Key]], #64 \n"
"AESD v0.16b, v1.16b \n"
@@ -488,13 +481,13 @@ void wc_AesAsyncFree(Aes* aes)
"EOR v0.16b, v0.16b, v1.16b \n"
"ST1 {v0.4s}, [%[CtrOut]] \n"
:[CtrOut] "=r" (output), "=r" (keyPt), "=r" (rounds), "=r" (input)
:[Key] "1" (keyPt), [R] "2" (rounds), [CtrIn] "3" (input), "0" (output)
:[CtrOut] "=r" (outBlock), "=r" (keyPt), "=r" (rounds),
"=r" (inBlock)
:"0" (outBlock), [Key] "1" (keyPt), [R] "2" (rounds),
[CtrIn] "3" (inBlock)
: "cc", "memory", "w12"
);
XMEMCPY(outBlock, out, AES_BLOCK_SIZE);
return 0;
}
#endif /* HAVE_AES_DECRYPT */