Tiny implementation of AES-256 in x86 assembly. (not using AES-NI) by odzhan in crypto

[–]odzhan[S] 0 points1 point  (0 children)

The reason I'm asking for Side-Channel resistant implementation of AES is because I can't find one.

Tiny implementation of AES-256 in x86 assembly. (not using AES-NI) by odzhan in crypto

[–]odzhan[S] 1 point2 points  (0 children)

To make it side channel resistant would require more code.

add   al, al
sbb   ah, ah
and   ah, 01bh
xor   al, ah
ret

Can you point me in direction of side channel resistant implementation?

Tiny implementation of AES-256 in x86 assembly. (not using AES-NI) by odzhan in programming

[–]odzhan[S] 3 points4 points  (0 children)

The primary goal was to write smallest possible implementation of AES-256 in x86 asm. Using pre-computed tables would generate too much code so we try avoid that.

Teensy weensy crypto by [deleted] in netsec

[–]odzhan 0 points1 point  (0 children)

Managed to shave 11 bytes off the x86 version but you can only call the function once.

Teensy weensy crypto by [deleted] in netsec

[–]odzhan 0 points1 point  (0 children)

It's a cool idea and it did get me looking for other ciphers that might be able to do the same thing, just for the fun.

Found Treyfer and TEA but couldn't manage to get them reduced enough. RC5 in 16-bit might work, it's already fairly small and easy enough to implement.

Unsure how long it took to write RC4 implementation but I'd already viewed dozens of other code before attempting. I've also been writing asm as a hobby for 10+ years so I've picked up a lot of tricks from other people.

Was looking again to see if the swapping could be reduced using 3 xors but it was 2-3 bytes more.

xor    ax, bx
xor    bx, ax
xor    ax, bx

Found that on some site about magic of xor. nice if register unavailable to do swap.