Skip to contentSkip to conversation

target-ppc: simplify AES emulation

PATCH Alexander Graf 1 participant 1 message Nov 3, 2014 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Alexander Graf

author Applied
#1 lore raw
Quoted 7 lines · Aurelien Jarno

This patch simplifies the AES code, by directly accessing the newly added S-Box, InvS-Box tables instead of recreating them by using the AES_Te and AES_Td tables.

Cc Alexander Graf <[email protected]>
Cc Paolo Bonzini <[email protected]>

Thanks, applied to ppc-next. It's great to see you back Aurelien!

Alex

PS: Please CC qemu-devel on patches, so that non-ppc interested people have the chance to review as well ;).

Quoted 30 lines
---
 target-ppc/int_helper.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Note: This has been requested by Paolo Bonzini, but I have no way to test it, so it is only compile tested.

target-ppc/int_helper.c +2 -2
index 713d777..e67a5ee 100644
@@ -2352,7 +2352,7 @@ void helper_vcipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
     int i;
 
     VECTOR_FOR_INORDER_I(i, u8) {
-        r->AVRB(i) = b->AVRB(i) ^ (AES_Te4[a->AVRB(AES_shifts[i])] & 0xFF);
+        r->AVRB(i) = b->AVRB(i) ^ (AES_sbox[a->AVRB(AES_shifts[i])]);
     }
 }
 
@@ -2381,7 +2381,7 @@ void helper_vncipherlast(ppc_avr_t *r, ppc_avr_t *a, ppc_avr_t *b)
     int i;
 
     VECTOR_FOR_INORDER_I(i, u8) {
-        r->AVRB(i) = b->AVRB(i) ^ (AES_Td4[a->AVRB(AES_ishifts[i])] & 0xFF);
+        r->AVRB(i) = b->AVRB(i) ^ (AES_isbox[a->AVRB(AES_ishifts[i])]);
     }
 }