forked from wolfSSL/wolfssl
ARMv8 AES: remove extra memcpy during encrypt/decrypt
This commit is contained in:
@@ -349,10 +349,6 @@ void wc_AesAsyncFree(Aes* aes)
|
|||||||
{
|
{
|
||||||
byte* keyPt = (byte*)aes->key;
|
byte* keyPt = (byte*)aes->key;
|
||||||
word32 rounds = aes->rounds;
|
word32 rounds = aes->rounds;
|
||||||
byte out[AES_BLOCK_SIZE];
|
|
||||||
byte* output = out;
|
|
||||||
byte* input = (byte*)inBlock;
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AESE exor's input with round key
|
AESE exor's input with round key
|
||||||
@@ -361,7 +357,7 @@ void wc_AesAsyncFree(Aes* aes)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"LD1 {v0.16b}, [%[CtrIn]], #16 \n"
|
"LD1 {v0.16b}, [%[CtrIn]] \n"
|
||||||
"LD1 {v1.16b-v4.16b}, [%[Key]], #64 \n"
|
"LD1 {v1.16b-v4.16b}, [%[Key]], #64 \n"
|
||||||
|
|
||||||
"AESE v0.16b, v1.16b \n"
|
"AESE v0.16b, v1.16b \n"
|
||||||
@@ -412,13 +408,13 @@ void wc_AesAsyncFree(Aes* aes)
|
|||||||
"EOR v0.16b, v0.16b, v1.16b \n"
|
"EOR v0.16b, v0.16b, v1.16b \n"
|
||||||
"ST1 {v0.16b}, [%[CtrOut]] \n"
|
"ST1 {v0.16b}, [%[CtrOut]] \n"
|
||||||
|
|
||||||
:[CtrOut] "=r" (output), "=r" (keyPt), "=r" (rounds)
|
:[CtrOut] "=r" (outBlock), "=r" (keyPt), "=r" (rounds),
|
||||||
:[Key] "1" (keyPt), [R] "2" (rounds), [CtrIn] "r" (input), "0" (output)
|
"=r" (inBlock)
|
||||||
|
:"0" (outBlock), [Key] "1" (keyPt), [R] "2" (rounds),
|
||||||
|
[CtrIn] "3" (inBlock)
|
||||||
: "cc", "memory", "w12"
|
: "cc", "memory", "w12"
|
||||||
);
|
);
|
||||||
|
|
||||||
XMEMCPY(outBlock, out, AES_BLOCK_SIZE);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_AES_DECRYPT
|
#ifdef HAVE_AES_DECRYPT
|
||||||
@@ -426,9 +422,6 @@ void wc_AesAsyncFree(Aes* aes)
|
|||||||
{
|
{
|
||||||
byte* keyPt = (byte*)aes->key;
|
byte* keyPt = (byte*)aes->key;
|
||||||
word32 rounds = aes->rounds;
|
word32 rounds = aes->rounds;
|
||||||
byte out[AES_BLOCK_SIZE];
|
|
||||||
byte* output = out;
|
|
||||||
byte* input = (byte*)inBlock;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AESE exor's input with round key
|
AESE exor's input with round key
|
||||||
@@ -437,7 +430,7 @@ void wc_AesAsyncFree(Aes* aes)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"LD1 {v0.16b}, [%[CtrIn]], #16 \n"
|
"LD1 {v0.16b}, [%[CtrIn]] \n"
|
||||||
"LD1 {v1.16b-v4.16b}, [%[Key]], #64 \n"
|
"LD1 {v1.16b-v4.16b}, [%[Key]], #64 \n"
|
||||||
|
|
||||||
"AESD v0.16b, v1.16b \n"
|
"AESD v0.16b, v1.16b \n"
|
||||||
@@ -488,13 +481,13 @@ void wc_AesAsyncFree(Aes* aes)
|
|||||||
"EOR v0.16b, v0.16b, v1.16b \n"
|
"EOR v0.16b, v0.16b, v1.16b \n"
|
||||||
"ST1 {v0.4s}, [%[CtrOut]] \n"
|
"ST1 {v0.4s}, [%[CtrOut]] \n"
|
||||||
|
|
||||||
:[CtrOut] "=r" (output), "=r" (keyPt), "=r" (rounds), "=r" (input)
|
:[CtrOut] "=r" (outBlock), "=r" (keyPt), "=r" (rounds),
|
||||||
:[Key] "1" (keyPt), [R] "2" (rounds), [CtrIn] "3" (input), "0" (output)
|
"=r" (inBlock)
|
||||||
|
:"0" (outBlock), [Key] "1" (keyPt), [R] "2" (rounds),
|
||||||
|
[CtrIn] "3" (inBlock)
|
||||||
: "cc", "memory", "w12"
|
: "cc", "memory", "w12"
|
||||||
);
|
);
|
||||||
|
|
||||||
XMEMCPY(outBlock, out, AES_BLOCK_SIZE);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif /* HAVE_AES_DECRYPT */
|
#endif /* HAVE_AES_DECRYPT */
|
||||||
|
Reference in New Issue
Block a user