summaryrefslogtreecommitdiff
path: root/target-i386
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2014-06-21 00:48:09 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2014-12-15 12:21:01 +0100
commit9551ea6991cfb7c777f7943ad69b30d0a4fadac3 (patch)
tree5e606a993d47f2f5444868c70806c721940a6689 /target-i386
parent5eba5a6632ff4b0aaa8cb6c806fa95758518a28d (diff)
downloadqemu-9551ea6991cfb7c777f7943ad69b30d0a4fadac3.tar.gz
qemu-9551ea6991cfb7c777f7943ad69b30d0a4fadac3.tar.bz2
qemu-9551ea6991cfb7c777f7943ad69b30d0a4fadac3.zip
target-i386: simplify AES emulation
This patch simplifies the AES code, by directly accessing the newly added S-Box, InvS-Box and InvMixColumns tables instead of recreating them by using the AES_Te and AES_Td tables. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target-i386')
-rw-r--r--target-i386/ops_sse.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/target-i386/ops_sse.h b/target-i386/ops_sse.h
index 886e0a8243..0765073792 100644
--- a/target-i386/ops_sse.h
+++ b/target-i386/ops_sse.h
@@ -2228,7 +2228,7 @@ void glue(helper_aesdeclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
Reg rk = *s;
for (i = 0; i < 16; i++) {
- d->B(i) = rk.B(i) ^ (AES_Td4[st.B(AES_ishifts[i])] & 0xff);
+ d->B(i) = rk.B(i) ^ (AES_isbox[st.B(AES_ishifts[i])]);
}
}
@@ -2253,7 +2253,7 @@ void glue(helper_aesenclast, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
Reg rk = *s;
for (i = 0; i < 16; i++) {
- d->B(i) = rk.B(i) ^ (AES_Te4[st.B(AES_shifts[i])] & 0xff);
+ d->B(i) = rk.B(i) ^ (AES_sbox[st.B(AES_shifts[i])]);
}
}
@@ -2264,10 +2264,10 @@ void glue(helper_aesimc, SUFFIX)(CPUX86State *env, Reg *d, Reg *s)
Reg tmp = *s;
for (i = 0 ; i < 4 ; i++) {
- d->L(i) = bswap32(AES_Td0[AES_Te4[tmp.B(4*i+0)] & 0xff] ^
- AES_Td1[AES_Te4[tmp.B(4*i+1)] & 0xff] ^
- AES_Td2[AES_Te4[tmp.B(4*i+2)] & 0xff] ^
- AES_Td3[AES_Te4[tmp.B(4*i+3)] & 0xff]);
+ d->L(i) = bswap32(AES_imc[tmp.B(4*i+0)][0] ^
+ AES_imc[tmp.B(4*i+1)][1] ^
+ AES_imc[tmp.B(4*i+2)][2] ^
+ AES_imc[tmp.B(4*i+3)][3]);
}
}
@@ -2278,8 +2278,8 @@ void glue(helper_aeskeygenassist, SUFFIX)(CPUX86State *env, Reg *d, Reg *s,
Reg tmp = *s;
for (i = 0 ; i < 4 ; i++) {
- d->B(i) = AES_Te4[tmp.B(i + 4)] & 0xff;
- d->B(i + 8) = AES_Te4[tmp.B(i + 12)] & 0xff;
+ d->B(i) = AES_sbox[tmp.B(i + 4)];
+ d->B(i + 8) = AES_sbox[tmp.B(i + 12)];
}
d->L(1) = (d->L(0) << 24 | d->L(0) >> 8) ^ ctrl;
d->L(3) = (d->L(2) << 24 | d->L(2) >> 8) ^ ctrl;