1. Fix bad opcode mnemonics in the intel-format source listing.

2. Update the aes.c file to call both format assembly routines the same
way.
This commit is contained in:
John Safranek
2016-04-13 16:42:58 -07:00
parent c34944e389
commit 6f51c2a8f8
2 changed files with 41 additions and 33 deletions

View File

@@ -1095,17 +1095,17 @@ void AES_CBC_encrypt(const unsigned char* in, unsigned char* out,
#ifdef HAVE_AES_DECRYPT #ifdef HAVE_AES_DECRYPT
#if defined(WOLFSSL_AESNI_BY4) #if defined(WOLFSSL_AESNI_BY4)
void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, void AES_CBC_decrypt_by4(const unsigned char* in, unsigned char* out,
unsigned char* ivec, unsigned long length, unsigned char* ivec, unsigned long length,
const unsigned char* KS, int nr) const unsigned char* KS, int nr)
XASM_LINK("AES_CBC_decrypt_by4"); XASM_LINK("AES_CBC_decrypt_by4");
#elif defined(WOLFSSL_AESNI_BY6) #elif defined(WOLFSSL_AESNI_BY6)
void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, void AES_CBC_decrypt_by6(const unsigned char* in, unsigned char* out,
unsigned char* ivec, unsigned long length, unsigned char* ivec, unsigned long length,
const unsigned char* KS, int nr) const unsigned char* KS, int nr)
XASM_LINK("AES_CBC_decrypt_by6"); XASM_LINK("AES_CBC_decrypt_by6");
#else #else /* WOLFSSL_AESNI_BYx */
void AES_CBC_decrypt(const unsigned char* in, unsigned char* out, void AES_CBC_decrypt_by8(const unsigned char* in, unsigned char* out,
unsigned char* ivec, unsigned long length, unsigned char* ivec, unsigned long length,
const unsigned char* KS, int nr) const unsigned char* KS, int nr)
XASM_LINK("AES_CBC_decrypt_by8"); XASM_LINK("AES_CBC_decrypt_by8");
@@ -2561,8 +2561,16 @@ int wc_AesSetIV(Aes* aes, const byte* iv)
/* if input and output same will overwrite input iv */ /* if input and output same will overwrite input iv */
XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE); XMEMCPY(aes->tmp, in + sz - AES_BLOCK_SIZE, AES_BLOCK_SIZE);
AES_CBC_decrypt(in, out, (byte*)aes->reg, sz, (byte*)aes->key, #if defined(WOLFSSL_AESNI_BY4)
AES_CBC_decrypt_by4(in, out, (byte*)aes->reg, sz, (byte*)aes->key,
aes->rounds); aes->rounds);
#elif defined(WOLFSSL_AESNI_BY6)
AES_CBC_decrypt_by6(in, out, (byte*)aes->reg, sz, (byte*)aes->key,
aes->rounds);
#else /* WOLFSSL_AESNI_BYx */
AES_CBC_decrypt_by8(in, out, (byte*)aes->reg, sz, (byte*)aes->key,
aes->rounds);
#endif /* WOLFSSL_AESNI_BYx */
/* store iv for next call */ /* store iv for next call */
XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE); XMEMCPY(aes->reg, aes->tmp, AES_BLOCK_SIZE);
return 0; return 0;

View File

@@ -352,22 +352,22 @@ AES_CBC_decrypt_by6 PROC
je DNO_PARTS_6 je DNO_PARTS_6
add rcx, 1 add rcx, 1
DNO_PARTS_6: DNO_PARTS_6:
movq r12, rax mov r12, rax
movq r13, rdx mov r13, rdx
movq r14, rbx mov r14, rbx
movq rdx, 0 mov rdx, 0
movq rax, %rcx mov rax, rcx
movq rbx, 6 mov rbx, 6
div rbx div rbx
movq rcx, rax mov rcx, rax
movq r10, rdx mov r10, rdx
movq rax, r12 mov rax, r12
movq rdx, r13 mov rdx, r13
movq rbx, r14 mov rbx, r14
cmpq rcx, 0 cmp rcx, 0
movdqu xmm7, [rdx] movdqu xmm7, [rdx]
je DREMAINDER_6 je DREMAINDER_6
subq rsi, 96 sub rsi, 96
DLOOP_6: DLOOP_6:
movdqu xmm1, [rdi] movdqu xmm1, [rdi]
movdqu xmm2, 16[rdi] movdqu xmm2, 16[rdi]
@@ -532,7 +532,7 @@ DLOOP_6_2:
aesdec xmm1, 144[r8] aesdec xmm1, 144[r8]
jb DLAST_6_2 jb DLAST_6_2
movdqu xmm2, 192[r8] movdqu xmm2, 192[r8]
cmp r9d, 14, r9d cmp r9d, 14
aesdec xmm1, 160[r8] aesdec xmm1, 160[r8]
aesdec xmm1, 176[r8] aesdec xmm1, 176[r8]
jb DLAST_6_2 jb DLAST_6_2
@@ -758,7 +758,7 @@ DLOOP_8:
aesdec xmm7, xmm11 aesdec xmm7, xmm11
aesdec xmm8, xmm11 aesdec xmm8, xmm11
DLAST_8: DLAST_8:
add 128, rsi add rsi, 128
aesdeclast xmm1, xmm12 aesdeclast xmm1, xmm12
aesdeclast xmm2, xmm12 aesdeclast xmm2, xmm12
aesdeclast xmm3, xmm12 aesdeclast xmm3, xmm12
@@ -846,7 +846,7 @@ DEND_8:
movdqa xmm13, [rsp+112] movdqa xmm13, [rsp+112]
add rsp, 8+8*16 ; 8 = align stack , 8 xmm6-13 16 bytes each add rsp, 8+8*16 ; 8 = align stack , 8 xmm6-13 16 bytes each
ret ret
AES_CBC_decrypt_by6 ENDP AES_CBC_decrypt_by8 ENDP
; /* ; /*