diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-10 20:48:53 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-06-10 20:48:53 +0300 |
commit | ab42aa88992409eb5db5714df18390387c6e041c (patch) | |
tree | 8f5d8adf9e644f192d6d43d79c8db9656e57c90e /src | |
parent | bugfix (diff) | |
download | aes-tools-ab42aa88992409eb5db5714df18390387c6e041c.tar.gz aes-tools-ab42aa88992409eb5db5714df18390387c6e041c.zip |
fix register usage in the asm implementation
Apparently, the previously used xmm6/xmm7 registers are exactly the
wrong ones to use for storing temp values.
The xmm4/xmm5, on the other hand hand, don't need to be preserved,
so I switched to those.
Diffstat (limited to 'src')
-rw-r--r-- | src/asm/aes128.asm | 96 | ||||
-rw-r--r-- | src/asm/aes192.asm | 112 | ||||
-rw-r--r-- | src/asm/aes256.asm | 146 |
3 files changed, 177 insertions, 177 deletions
diff --git a/src/asm/aes128.asm b/src/asm/aes128.asm index b49de0e..874f876 100644 --- a/src/asm/aes128.asm +++ b/src/asm/aes128.asm @@ -88,25 +88,25 @@ movdqa [ecx], xmm0 ; sets w[0], w[1], w[2], w[3] add ecx, 10h ; ecx = &w[4] - aeskeygenassist xmm7, xmm0, 01h ; xmm7[127:96] = RotWord(SubWord(w[3]))^Rcon + aeskeygenassist xmm5, xmm0, 01h ; xmm5[127:96] = RotWord(SubWord(w[3]))^Rcon call aes128_keygen_assist ; sets w[4], w[5], w[6], w[7] - aeskeygenassist xmm7, xmm0, 02h ; xmm7[127:96] = RotWord(SubWord(w[7]))^Rcon + aeskeygenassist xmm5, xmm0, 02h ; xmm5[127:96] = RotWord(SubWord(w[7]))^Rcon call aes128_keygen_assist ; sets w[8], w[9], w[10], w[11] - aeskeygenassist xmm7, xmm0, 04h ; xmm7[127:96] = RotWord(SubWord(w[11]))^Rcon + aeskeygenassist xmm5, xmm0, 04h ; xmm5[127:96] = RotWord(SubWord(w[11]))^Rcon call aes128_keygen_assist ; sets w[12], w[13], w[14], w[15] - aeskeygenassist xmm7, xmm0, 08h ; xmm7[127:96] = RotWord(SubWord(w[15]))^Rcon + aeskeygenassist xmm5, xmm0, 08h ; xmm5[127:96] = RotWord(SubWord(w[15]))^Rcon call aes128_keygen_assist ; sets w[16], w[17], w[18], w[19] - aeskeygenassist xmm7, xmm0, 10h ; xmm7[127:96] = RotWord(SubWord(w[19]))^Rcon + aeskeygenassist xmm5, xmm0, 10h ; xmm5[127:96] = RotWord(SubWord(w[19]))^Rcon call aes128_keygen_assist ; sets w[20], w[21], w[22], w[23] - aeskeygenassist xmm7, xmm0, 20h ; xmm7[127:96] = RotWord(SubWord(w[23]))^Rcon + aeskeygenassist xmm5, xmm0, 20h ; xmm5[127:96] = RotWord(SubWord(w[23]))^Rcon call aes128_keygen_assist ; sets w[24], w[25], w[26], w[27] - aeskeygenassist xmm7, xmm0, 40h ; xmm7[127:96] = RotWord(SubWord(w[27]))^Rcon + aeskeygenassist xmm5, xmm0, 40h ; xmm5[127:96] = RotWord(SubWord(w[27]))^Rcon call aes128_keygen_assist ; sets w[28], w[29], w[30], w[31] - aeskeygenassist xmm7, xmm0, 80h ; xmm7[127:96] = RotWord(SubWord(w[31]))^Rcon + aeskeygenassist xmm5, xmm0, 80h ; xmm5[127:96] = RotWord(SubWord(w[31]))^Rcon call aes128_keygen_assist ; sets w[32], w[33], w[34], w[35] - aeskeygenassist xmm7, xmm0, 1Bh ; xmm7[127:96] = RotWord(SubWord(w[35]))^Rcon + aeskeygenassist xmm5, xmm0, 1Bh ; xmm5[127:96] = RotWord(SubWord(w[35]))^Rcon call aes128_keygen_assist ; sets w[36], w[37], w[38], w[39] - aeskeygenassist xmm7, xmm0, 36h ; xmm7[127:96] = RotWord(SubWord(w[39]))^Rcon + aeskeygenassist xmm5, xmm0, 36h ; xmm5[127:96] = RotWord(SubWord(w[39]))^Rcon call aes128_keygen_assist ; sets w[40], w[41], w[42], w[43] ret @@ -117,7 +117,7 @@ aes128_keygen_assist: ; * xmm0[95:64] == w[i+2], ; * xmm0[63:32] == w[i+1], ; * xmm0[31:0] == w[i], - ; * xmm7[127:96] == RotWord(SubWord(w[i+3]))^Rcon, + ; * xmm5[127:96] == RotWord(SubWord(w[i+3]))^Rcon, ; * ecx == &w[i+4]. ; ; Postconditions: @@ -126,20 +126,20 @@ aes128_keygen_assist: ; * xmm0[63:32] == w[i+5] == RotWord(SubWord(w[i+3]))^Rcon^w[i+1]^w[i], ; * xmm0[31:0] == w[i+4] == RotWord(SubWord(w[i+3]))^Rcon^w[i], ; * ecx == &w[i+8], - ; * the value in xmm6 is also modified. + ; * the value in xmm4 is also modified. ; Calculate ; w[i+3]^w[i+2]^w[i+1]^w[i], ; w[i+2]^w[i+1]^w[i], ; w[i+1]^w[i] and ; w[i]. - movdqa xmm6, xmm0 ; xmm6 = xmm0 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 + movdqa xmm4, xmm0 ; xmm4 = xmm0 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 ; xmm0[127:96] == w[i+3]^w[i+2]^w[i+1]^w[i] ; xmm0[95:64] == w[i+2]^w[i+1]^w[i] ; xmm0[63:32] == w[i+1]^w[i] @@ -150,8 +150,8 @@ aes128_keygen_assist: ; w[i+6] == RotWord(SubWord(w[i+3]))^Rcon^w[i+2]^w[i+1]^w[i], ; w[i+5] == RotWord(SubWord(w[i+3]))^Rcon^w[i+1]^w[i] and ; w[i+4] == RotWord(SubWord(w[i+3]))^Rcon^w[i]. - pshufd xmm6, xmm7, 0FFh ; xmm6[127:96] = xmm6[95:64] = xmm6[63:32] = xmm6[31:0] = xmm7[127:96] - pxor xmm0, xmm6 ; xmm0 ^= xmm6 + pshufd xmm4, xmm5, 0FFh ; xmm4[127:96] = xmm4[95:64] = xmm4[63:32] = xmm4[31:0] = xmm5[127:96] + pxor xmm0, xmm4 ; xmm0 ^= xmm4 ; xmm0[127:96] == w[i+7] == RotWord(SubWord(w[i+3]))^Rcon^w[i+3]^w[i+2]^w[i+1]^w[i] ; xmm0[95:64] == w[i+6] == RotWord(SubWord(w[i+3]))^Rcon^w[i+2]^w[i+1]^w[i] ; xmm0[63:32] == w[i+5] == RotWord(SubWord(w[i+3]))^Rcon^w[i+1]^w[i] @@ -168,33 +168,33 @@ aes128_keygen_assist: @raw_aes128_expand_key_schedule@20 endp @raw_aes128_invert_key_schedule@8 proc - movdqa xmm7, [ecx] - movdqa xmm6, [ecx + 0A0h] - movdqa [edx], xmm6 - movdqa [edx + 0A0h], xmm7 - - aesimc xmm7, [ecx + 10h] - aesimc xmm6, [ecx + 90h] - movdqa [edx + 10h], xmm6 - movdqa [edx + 90h], xmm7 - - aesimc xmm7, [ecx + 20h] - aesimc xmm6, [ecx + 80h] - movdqa [edx + 20h], xmm6 - movdqa [edx + 80h], xmm7 - - aesimc xmm7, [ecx + 30h] - aesimc xmm6, [ecx + 70h] - movdqa [edx + 30h], xmm6 - movdqa [edx + 70h], xmm7 - - aesimc xmm7, [ecx + 40h] - aesimc xmm6, [ecx + 60h] - movdqa [edx + 40h], xmm6 - movdqa [edx + 60h], xmm7 - - aesimc xmm7, [ecx + 50h] - movdqa [edx + 50h], xmm7 + movdqa xmm5, [ecx] + movdqa xmm4, [ecx + 0A0h] + movdqa [edx], xmm4 + movdqa [edx + 0A0h], xmm5 + + aesimc xmm5, [ecx + 10h] + aesimc xmm4, [ecx + 90h] + movdqa [edx + 10h], xmm4 + movdqa [edx + 90h], xmm5 + + aesimc xmm5, [ecx + 20h] + aesimc xmm4, [ecx + 80h] + movdqa [edx + 20h], xmm4 + movdqa [edx + 80h], xmm5 + + aesimc xmm5, [ecx + 30h] + aesimc xmm4, [ecx + 70h] + movdqa [edx + 30h], xmm4 + movdqa [edx + 70h], xmm5 + + aesimc xmm5, [ecx + 40h] + aesimc xmm4, [ecx + 60h] + movdqa [edx + 40h], xmm4 + movdqa [edx + 60h], xmm5 + + aesimc xmm5, [ecx + 50h] + movdqa [edx + 50h], xmm5 ret @raw_aes128_invert_key_schedule@8 endp diff --git a/src/asm/aes192.asm b/src/asm/aes192.asm index 5cc8ded..adbc690 100644 --- a/src/asm/aes192.asm +++ b/src/asm/aes192.asm @@ -102,35 +102,35 @@ movdqa [ecx], xmm0 ; sets w[0], w[1], w[2], w[3] movq qword ptr [ecx + 10h], xmm1 ; sets w[4], w[5] - aeskeygenassist xmm7, xmm1, 1 ; xmm7[63:32] = RotWord(SubWord(w[5]))^Rcon, + aeskeygenassist xmm5, xmm1, 1 ; xmm5[63:32] = RotWord(SubWord(w[5]))^Rcon, call aes192_keygen_assist movdqu [ecx + 18h], xmm0 movq qword ptr [ecx + 28h], xmm1 - aeskeygenassist xmm7, xmm1, 2 ; xmm7[63:32] = RotWord(SubWord(w[11]))^Rcon + aeskeygenassist xmm5, xmm1, 2 ; xmm5[63:32] = RotWord(SubWord(w[11]))^Rcon call aes192_keygen_assist movdqa [ecx + 30h], xmm0 movq qword ptr [ecx + 40h], xmm1 - aeskeygenassist xmm7, xmm1, 4 ; xmm7[63:32] = RotWord(SubWord(w[17]))^Rcon + aeskeygenassist xmm5, xmm1, 4 ; xmm5[63:32] = RotWord(SubWord(w[17]))^Rcon call aes192_keygen_assist movdqu [ecx + 48h], xmm0 movq qword ptr [ecx + 58h], xmm1 - aeskeygenassist xmm7, xmm1, 8 ; xmm7[63:32] = RotWord(SubWord(w[23]))^Rcon + aeskeygenassist xmm5, xmm1, 8 ; xmm5[63:32] = RotWord(SubWord(w[23]))^Rcon call aes192_keygen_assist movdqa [ecx + 60h], xmm0 movq qword ptr [ecx + 70h], xmm1 - aeskeygenassist xmm7, xmm1, 10h ; xmm7[63:32] = RotWord(SubWord(w[29]))^Rcon + aeskeygenassist xmm5, xmm1, 10h ; xmm5[63:32] = RotWord(SubWord(w[29]))^Rcon call aes192_keygen_assist movdqu [ecx + 78h], xmm0 movq qword ptr [ecx + 88h], xmm1 - aeskeygenassist xmm7, xmm1, 20h ; xmm7[63:32] = RotWord(SubWord(w[35]))^Rcon + aeskeygenassist xmm5, xmm1, 20h ; xmm5[63:32] = RotWord(SubWord(w[35]))^Rcon call aes192_keygen_assist movdqa [ecx + 90h], xmm0 movq qword ptr [ecx + 0a0h], xmm1 - aeskeygenassist xmm7, xmm1, 40h ; xmm7[63:32] = RotWord(SubWord(w[41]))^Rcon + aeskeygenassist xmm5, xmm1, 40h ; xmm5[63:32] = RotWord(SubWord(w[41]))^Rcon call aes192_keygen_assist movdqu [ecx + 0a8h], xmm0 movq qword ptr [ecx + 0b8h], xmm1 - aeskeygenassist xmm7, xmm1, 80h ; xmm7[63:32] = RotWord(SubWord(w[49]))^Rcon + aeskeygenassist xmm5, xmm1, 80h ; xmm5[63:32] = RotWord(SubWord(w[49]))^Rcon call aes192_keygen_assist movdqa [ecx + 0c0h], xmm0 @@ -146,7 +146,7 @@ aes192_keygen_assist: ; * xmm0[95:64] == w[i+2], ; * xmm0[63:32] == w[i+1], ; * xmm0[31:0] == w[i], - ; * xmm7[63:32] == RotWord(SubWord(w[i+5]))^Rcon. + ; * xmm5[63:32] == RotWord(SubWord(w[i+5]))^Rcon. ; ; Postconditions: ; * xmm1[127:96] == 0, @@ -157,20 +157,20 @@ aes192_keygen_assist: ; * xmm0[95:64] == w[i+8] == RotWord(SubWord(w[i+5]))^Rcon^w[i+2]^w[i+1]^w[i], ; * xmm0[63:32] == w[i+7] == RotWord(SubWord(w[i+5]))^Rcon^w[i+1]^w[i], ; * xmm0[31:0] == w[i+6] == RotWord(SubWord(w[i+5]))^Rcon^w[i], - ; * the value in xmm6 is also modified. + ; * the value in xmm4 is also modified. ; Calculate ; w[i+3]^w[i+2]^w[i+1]^w[i], ; w[i+2]^w[i+1]^w[i], ; w[i+1]^w[i] and ; w[i]. - movdqa xmm6, xmm0 ; xmm6 = xmm0 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 + movdqa xmm4, xmm0 ; xmm4 = xmm0 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 ; xmm0[127:96] == w[i+3]^w[i+2]^w[i+1]^w[i] ; xmm0[95:64] == w[i+2]^w[i+1]^w[i] ; xmm0[63:32] == w[i+1]^w[i] @@ -181,8 +181,8 @@ aes192_keygen_assist: ; w[i+8] == RotWord(SubWord(w[i+5]))^Rcon^w[i+2]^w[i+1]^w[i], ; w[i+7] == RotWord(SubWord(w[i+5]))^Rcon^w[i+1]^w[i] and ; w[i+6] == RotWord(SubWord(w[i+5]))^Rcon^w[i]. - pshufd xmm6, xmm7, 55h ; xmm6[127:96] = xmm6[95:64] = xmm6[63:32] = xmm6[31:0] = xmm7[63:32] - pxor xmm0, xmm6 ; xmm0 ^= xmm6 + pshufd xmm4, xmm5, 55h ; xmm4[127:96] = xmm4[95:64] = xmm4[63:32] = xmm4[31:0] = xmm5[63:32] + pxor xmm0, xmm4 ; xmm0 ^= xmm4 ; xmm0[127:96] == w[i+9] == RotWord(SubWord(w[i+5]))^Rcon^w[i+3]^w[i+2]^w[i+1]^w[i] ; xmm0[95:64] == w[i+8] == RotWord(SubWord(w[i+5]))^Rcon^w[i+2]^w[i+1]^w[i] ; xmm0[63:32] == w[i+7] == RotWord(SubWord(w[i+5]))^Rcon^w[i+1]^w[i] @@ -191,17 +191,17 @@ aes192_keygen_assist: ; Calculate ; w[i+5]^w[i+4], ; w[i+4]. - pshufd xmm6, xmm1, 0F3h ; xmm6 = xmm1[31:0] << 32 - pxor xmm1, xmm6 ; xmm1 ^= xmm7 + pshufd xmm4, xmm1, 0F3h ; xmm4 = xmm1[31:0] << 32 + pxor xmm1, xmm4 ; xmm1 ^= xmm5 ; xmm1[63:32] == w[i+5]^w[i+4] ; xmm1[31:0] == w[i+4] ; Calculate ; w[i+10] == RotWord(SubWord(w[i+5]))^Rcon^w[i+5]^w[i+4]^w[i+3]^w[i+2]^w[i+1]^w[i], ; w[i+11] == RotWord(SubWord(w[i+5]))^Rcon^w[i+4]^w[i+3]^w[i+2]^w[i+1]^w[i]. - pshufd xmm6, xmm0, 0FFh ; xmm6[127:96] = xmm6[95:64] = xmm6[63:32] = xmm6[31:0] = xmm0[127:96] - psrldq xmm6, 8 ; xmm6 >>= 64 - pxor xmm1, xmm6 ; xmm1 ^= xmm6 + pshufd xmm4, xmm0, 0FFh ; xmm4[127:96] = xmm4[95:64] = xmm4[63:32] = xmm4[31:0] = xmm0[127:96] + psrldq xmm4, 8 ; xmm4 >>= 64 + pxor xmm1, xmm4 ; xmm1 ^= xmm4 ; xmm1[63:32] == w[i+11] == RotWord(SubWord(w[i+5]))^Rcon^w[i+5]^w[i+4]^w[i+3]^w[i+2]^w[i+1]^w[i] ; xmm1[31:0] == w[i+10] == RotWord(SubWord(w[i+5]))^Rcon^w[i+4]^w[i+3]^w[i+2]^w[i+1]^w[i] @@ -209,38 +209,38 @@ aes192_keygen_assist: @raw_aes192_expand_key_schedule@36 endp @raw_aes192_invert_key_schedule@8 proc - movdqa xmm7, [ecx] - movdqa xmm6, [ecx + 0C0h] - movdqa [edx], xmm6 - movdqa [edx + 0C0h], xmm7 - - aesimc xmm7, [ecx + 10h] - aesimc xmm6, [ecx + 0B0h] - movdqa [edx + 10h], xmm6 - movdqa [edx + 0B0h], xmm7 - - aesimc xmm7, [ecx + 20h] - aesimc xmm6, [ecx + 0A0h] - movdqa [edx + 20h], xmm6 - movdqa [edx + 0A0h], xmm7 - - aesimc xmm7, [ecx + 30h] - aesimc xmm6, [ecx + 90h] - movdqa [edx + 30h], xmm6 - movdqa [edx + 90h], xmm7 - - aesimc xmm7, [ecx + 40h] - aesimc xmm6, [ecx + 80h] - movdqa [edx + 40h], xmm6 - movdqa [edx + 80h], xmm7 - - aesimc xmm7, [ecx + 50h] - aesimc xmm6, [ecx + 70h] - movdqa [edx + 50h], xmm6 - movdqa [edx + 70h], xmm7 - - aesimc xmm7, [ecx + 60h] - movdqa [edx + 60h], xmm7 + movdqa xmm5, [ecx] + movdqa xmm4, [ecx + 0C0h] + movdqa [edx], xmm4 + movdqa [edx + 0C0h], xmm5 + + aesimc xmm5, [ecx + 10h] + aesimc xmm4, [ecx + 0B0h] + movdqa [edx + 10h], xmm4 + movdqa [edx + 0B0h], xmm5 + + aesimc xmm5, [ecx + 20h] + aesimc xmm4, [ecx + 0A0h] + movdqa [edx + 20h], xmm4 + movdqa [edx + 0A0h], xmm5 + + aesimc xmm5, [ecx + 30h] + aesimc xmm4, [ecx + 90h] + movdqa [edx + 30h], xmm4 + movdqa [edx + 90h], xmm5 + + aesimc xmm5, [ecx + 40h] + aesimc xmm4, [ecx + 80h] + movdqa [edx + 40h], xmm4 + movdqa [edx + 80h], xmm5 + + aesimc xmm5, [ecx + 50h] + aesimc xmm4, [ecx + 70h] + movdqa [edx + 50h], xmm4 + movdqa [edx + 70h], xmm5 + + aesimc xmm5, [ecx + 60h] + movdqa [edx + 60h], xmm5 ret @raw_aes192_invert_key_schedule@8 endp diff --git a/src/asm/aes256.asm b/src/asm/aes256.asm index 413e67b..479b0f5 100644 --- a/src/asm/aes256.asm +++ b/src/asm/aes256.asm @@ -117,56 +117,56 @@ movdqa [ecx + 10h], xmm1 ; sets w[4], w[5], w[6], w[7] lea ecx, [ecx + 20h] ; ecx = &w[8] - aeskeygenassist xmm7, xmm1, 1h ; xmm7[127:96] = RotWord(SubWord(w[7]))^Rcon - pshufd xmm7, xmm7, 0FFh ; xmm7[95:64] = xmm7[63:32] = xmm7[31:0] = xmm7[127:96] + aeskeygenassist xmm5, xmm1, 1h ; xmm5[127:96] = RotWord(SubWord(w[7]))^Rcon + pshufd xmm5, xmm5, 0FFh ; xmm5[95:64] = xmm5[63:32] = xmm5[31:0] = xmm5[127:96] call aes256_keygen_assist ; sets w[8], w[9], w[10], w[11] - aeskeygenassist xmm7, xmm1, 0 ; xmm7[95:64] = SubWord(w[11]) - pshufd xmm7, xmm7, 0AAh ; xmm7[127:96] = xmm7[63:32] = xmm7[31:0] = xmm7[95:64] + aeskeygenassist xmm5, xmm1, 0 ; xmm5[95:64] = SubWord(w[11]) + pshufd xmm5, xmm5, 0AAh ; xmm5[127:96] = xmm5[63:32] = xmm5[31:0] = xmm5[95:64] call aes256_keygen_assist ; sets w[12], w[13], w[14], w[15] - aeskeygenassist xmm7, xmm1, 2h ; xmm7[127:96] = RotWord(SubWord(w[15]))^Rcon - pshufd xmm7, xmm7, 0FFh ; xmm7[95:64] = xmm7[63:32] = xmm7[31:0] = xmm7[127:96] + aeskeygenassist xmm5, xmm1, 2h ; xmm5[127:96] = RotWord(SubWord(w[15]))^Rcon + pshufd xmm5, xmm5, 0FFh ; xmm5[95:64] = xmm5[63:32] = xmm5[31:0] = xmm5[127:96] call aes256_keygen_assist ; sets w[16], w[17], w[18], w[19] - aeskeygenassist xmm7, xmm1, 0 ; xmm7[95:64] = SubWord(w[19]) - pshufd xmm7, xmm7, 0AAh ; xmm7[127:96] = xmm7[63:32] = xmm7[31:0] = xmm7[95:64] + aeskeygenassist xmm5, xmm1, 0 ; xmm5[95:64] = SubWord(w[19]) + pshufd xmm5, xmm5, 0AAh ; xmm5[127:96] = xmm5[63:32] = xmm5[31:0] = xmm5[95:64] call aes256_keygen_assist ; sets w[20], w[21], w[22], w[23] - aeskeygenassist xmm7, xmm1, 4h ; xmm7[127:96] = RotWord(SubWord(w[23]))^Rcon - pshufd xmm7, xmm7, 0FFh ; xmm7[95:64] = xmm7[63:32] = xmm7[31:0] = xmm7[127:96] + aeskeygenassist xmm5, xmm1, 4h ; xmm5[127:96] = RotWord(SubWord(w[23]))^Rcon + pshufd xmm5, xmm5, 0FFh ; xmm5[95:64] = xmm5[63:32] = xmm5[31:0] = xmm5[127:96] call aes256_keygen_assist ; sets w[24], w[25], w[26], w[27] - aeskeygenassist xmm7, xmm1, 0 ; xmm7[95:64] = SubWord(w[27]) - pshufd xmm7, xmm7, 0AAh ; xmm7[127:96] = xmm7[63:32] = xmm7[31:0] = xmm7[95:64] + aeskeygenassist xmm5, xmm1, 0 ; xmm5[95:64] = SubWord(w[27]) + pshufd xmm5, xmm5, 0AAh ; xmm5[127:96] = xmm5[63:32] = xmm5[31:0] = xmm5[95:64] call aes256_keygen_assist ; sets w[28], w[29], w[30], w[31] - aeskeygenassist xmm7, xmm1, 8h ; xmm7[127:96] = RotWord(SubWord(w[31]))^Rcon - pshufd xmm7, xmm7, 0FFh ; xmm7[95:64] = xmm7[63:32] = xmm7[31:0] = xmm7[127:96] + aeskeygenassist xmm5, xmm1, 8h ; xmm5[127:96] = RotWord(SubWord(w[31]))^Rcon + pshufd xmm5, xmm5, 0FFh ; xmm5[95:64] = xmm5[63:32] = xmm5[31:0] = xmm5[127:96] call aes256_keygen_assist ; sets w[32], w[33], w[34], w[35] - aeskeygenassist xmm7, xmm1, 0 ; xmm7[95:64] = SubWord(w[35]) - pshufd xmm7, xmm7, 0AAh ; xmm7[127:96] = xmm7[63:32] = xmm7[31:0] = xmm7[95:64] + aeskeygenassist xmm5, xmm1, 0 ; xmm5[95:64] = SubWord(w[35]) + pshufd xmm5, xmm5, 0AAh ; xmm5[127:96] = xmm5[63:32] = xmm5[31:0] = xmm5[95:64] call aes256_keygen_assist ; sets w[36], w[37], w[38], w[39] - aeskeygenassist xmm7, xmm1, 10h ; xmm7[127:96] = RotWord(SubWord(w[39]))^Rcon - pshufd xmm7, xmm7, 0FFh ; xmm7[95:64] = xmm7[63:32] = xmm7[31:0] = xmm7[127:96] + aeskeygenassist xmm5, xmm1, 10h ; xmm5[127:96] = RotWord(SubWord(w[39]))^Rcon + pshufd xmm5, xmm5, 0FFh ; xmm5[95:64] = xmm5[63:32] = xmm5[31:0] = xmm5[127:96] call aes256_keygen_assist ; sets w[40], w[41], w[42], w[43] - aeskeygenassist xmm7, xmm1, 0 ; xmm7[95:64] = SubWord(w[43]) - pshufd xmm7, xmm7, 0AAh ; xmm7[127:96] = xmm7[63:32] = xmm7[31:0] = xmm7[95:64] + aeskeygenassist xmm5, xmm1, 0 ; xmm5[95:64] = SubWord(w[43]) + pshufd xmm5, xmm5, 0AAh ; xmm5[127:96] = xmm5[63:32] = xmm5[31:0] = xmm5[95:64] call aes256_keygen_assist ; sets w[44], w[45], w[46], w[47] - aeskeygenassist xmm7, xmm1, 20h ; xmm7[127:96] = RotWord(SubWord(w[47]))^Rcon - pshufd xmm7, xmm7, 0FFh ; xmm7[95:64] = xmm7[63:32] = xmm7[31:0] = xmm7[127:96] + aeskeygenassist xmm5, xmm1, 20h ; xmm5[127:96] = RotWord(SubWord(w[47]))^Rcon + pshufd xmm5, xmm5, 0FFh ; xmm5[95:64] = xmm5[63:32] = xmm5[31:0] = xmm5[127:96] call aes256_keygen_assist ; sets w[48], w[49], w[50], w[51] - aeskeygenassist xmm7, xmm1, 0 ; xmm7[95:64] = SubWord(w[51]) - pshufd xmm7, xmm7, 0AAh ; xmm7[127:96] = xmm7[63:32] = xmm7[31:0] = xmm7[95:64] + aeskeygenassist xmm5, xmm1, 0 ; xmm5[95:64] = SubWord(w[51]) + pshufd xmm5, xmm5, 0AAh ; xmm5[127:96] = xmm5[63:32] = xmm5[31:0] = xmm5[95:64] call aes256_keygen_assist ; sets w[52], w[53], w[54], w[55] - aeskeygenassist xmm7, xmm1, 40h ; xmm7[127:96] = RotWord(SubWord(w[55]))^Rcon - pshufd xmm7, xmm7, 0FFh ; xmm7[95:64] = xmm7[63:32] = xmm7[31:0] = xmm7[127:96] + aeskeygenassist xmm5, xmm1, 40h ; xmm5[127:96] = RotWord(SubWord(w[55]))^Rcon + pshufd xmm5, xmm5, 0FFh ; xmm5[95:64] = xmm5[63:32] = xmm5[31:0] = xmm5[127:96] call aes256_keygen_assist ; sets w[56], w[57], w[58], w[59] ret @@ -181,7 +181,7 @@ aes256_keygen_assist: ; * xmm0[95:64] == w[i+2], ; * xmm0[63:32] == w[i+1], ; * xmm0[31:0] == w[i], - ; * xmm7[127:96] == xmm7[95:64] == xmm7[63:32] == xmm7[31:0] == HWGEN, + ; * xmm5[127:96] == xmm5[95:64] == xmm5[63:32] == xmm5[31:0] == HWGEN, ; where HWGEN is either RotWord(SubWord(w[i+7]))^Rcon or SubWord(w[i+7]), ; depending on the number of the round being processed, ; * ecx == &w[i+8]. @@ -196,20 +196,20 @@ aes256_keygen_assist: ; * xmm0[63:32] == w[i+5], ; * xmm0[31:0] == w[i+4], ; * ecx == &w[i+12], - ; * the value in xmm6 is also modified. + ; * the value in xmm4 is also modified. ; Calculate ; w[i+3]^w[i+2]^w[i+1]^w[i], ; w[i+2]^w[i+1]^w[i], ; w[i+1]^w[i] and ; w[i]. - movdqa xmm6, xmm0 ; xmm6 = xmm0 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 - pslldq xmm6, 4 ; xmm6 <<= 32 - pxor xmm0, xmm6 ; xmm0 ^= xmm6 + movdqa xmm4, xmm0 ; xmm4 = xmm0 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 + pslldq xmm4, 4 ; xmm4 <<= 32 + pxor xmm0, xmm4 ; xmm0 ^= xmm4 ; xmm0[127:96] == w[i+3]^w[i+2]^w[i+1]^w[i] ; xmm0[95:64] == w[i+2]^w[i+1]^w[i] ; xmm0[63:32] == w[i+1]^w[i] @@ -220,7 +220,7 @@ aes256_keygen_assist: ; HWGEN^w[i+2]^w[i+1]^w[i], ; HWGEN^w[i+1]^w[i] and ; HWGEN^w[i]. - pxor xmm0, xmm7 ; xmm0 ^= xmm7 + pxor xmm0, xmm5 ; xmm0 ^= xmm5 ; xmm0[127:96] == w[i+11] == HWGEN^w[i+3]^w[i+2]^w[i+1]^w[i] ; xmm0[95:64] == w[i+10] == HWGEN^w[i+2]^w[i+1]^w[i] ; xmm0[63:32] == w[i+9] == HWGEN^w[i+1]^w[i] @@ -242,43 +242,43 @@ aes256_keygen_assist: @raw_aes256_expand_key_schedule@36 endp @raw_aes256_invert_key_schedule@8 proc - movdqa xmm7, [ecx] - movdqa xmm6, [ecx + 0E0h] - movdqa [edx], xmm6 - movdqa [edx + 0E0h], xmm7 - - aesimc xmm7, [ecx + 10h] - aesimc xmm6, [ecx + 0D0h] - movdqa [edx + 10h], xmm6 - movdqa [edx + 0D0h], xmm7 - - aesimc xmm7, [ecx + 20h] - aesimc xmm6, [ecx + 0C0h] - movdqa [edx + 20h], xmm6 - movdqa [edx + 0C0h], xmm7 - - aesimc xmm7, [ecx + 30h] - aesimc xmm6, [ecx + 0B0h] - movdqa [edx + 30h], xmm6 - movdqa [edx + 0B0h], xmm7 - - aesimc xmm7, [ecx + 40h] - aesimc xmm6, [ecx + 0A0h] - movdqa [edx + 40h], xmm6 - movdqa [edx + 0A0h], xmm7 - - aesimc xmm7, [ecx + 50h] - aesimc xmm6, [ecx + 90h] - movdqa [edx + 50h], xmm6 - movdqa [edx + 90h], xmm7 - - aesimc xmm7, [ecx + 60h] - aesimc xmm6, [ecx + 80h] - movdqa [edx + 60h], xmm6 - movdqa [edx + 80h], xmm7 - - aesimc xmm7, [ecx + 70h] - movdqa [edx + 70h], xmm7 + movdqa xmm5, [ecx] + movdqa xmm4, [ecx + 0E0h] + movdqa [edx], xmm4 + movdqa [edx + 0E0h], xmm5 + + aesimc xmm5, [ecx + 10h] + aesimc xmm4, [ecx + 0D0h] + movdqa [edx + 10h], xmm4 + movdqa [edx + 0D0h], xmm5 + + aesimc xmm5, [ecx + 20h] + aesimc xmm4, [ecx + 0C0h] + movdqa [edx + 20h], xmm4 + movdqa [edx + 0C0h], xmm5 + + aesimc xmm5, [ecx + 30h] + aesimc xmm4, [ecx + 0B0h] + movdqa [edx + 30h], xmm4 + movdqa [edx + 0B0h], xmm5 + + aesimc xmm5, [ecx + 40h] + aesimc xmm4, [ecx + 0A0h] + movdqa [edx + 40h], xmm4 + movdqa [edx + 0A0h], xmm5 + + aesimc xmm5, [ecx + 50h] + aesimc xmm4, [ecx + 90h] + movdqa [edx + 50h], xmm4 + movdqa [edx + 90h], xmm5 + + aesimc xmm5, [ecx + 60h] + aesimc xmm4, [ecx + 80h] + movdqa [edx + 60h], xmm4 + movdqa [edx + 80h], xmm5 + + aesimc xmm5, [ecx + 70h] + movdqa [edx + 70h], xmm5 ret @raw_aes256_invert_key_schedule@8 endp |