Add support for AES-256 decryption.

This commit is contained in:
Stephen Heumann 2017-06-27 18:35:04 -05:00
parent 0e3e511ba8
commit 46fcb3badc
4 changed files with 31 additions and 4 deletions

18
aes.asm
View File

@ -345,17 +345,27 @@ aes192_decrypt start
CFunction AES192_DECRYPT
end
AES192_DECRYPT start
aes256_decrypt start
CFunction AES256_DECRYPT
end
AES256_DECRYPT start
using tables
InvFinalRound 14
InvNormalRound 13
InvNormalRound 12
jmp cont1
AES192_DECRYPT entry
InvFinalRound 12
cont1 anop
InvNormalRound 11
InvNormalRound 10
jmp cont
jmp cont2
AES128_DECRYPT entry
InvFinalRound 10
cont anop
cont2 anop
InvNormalRound 9
InvNormalRound 8
InvNormalRound 7

1
aes.h
View File

@ -14,3 +14,4 @@ void aes_encrypt(struct aes_state *state);
void aes128_decrypt(struct aes_state *state);
void aes192_decrypt(struct aes_state *state);
void aes256_decrypt(struct aes_state *state);

View File

@ -246,7 +246,13 @@
.loop
lda &state+&i
aif (rk+&round*16+&i)>255,.bigindex
eor rk+&round*16+&i
ago .cont
.bigindex
ldx #&round*16+&i
eor rk,X
.cont
sta &state+&i
&i seta &i+2
aif &i<16,.loop
@ -319,7 +325,13 @@
InvFinalRoundStep &to,&from
lda state1+&from
aif (rk+&round*16+&from)>255,.bigindex
eor rk+&round*16+&from
ago .cont
.bigindex
ldx #&round*16+&from
eor rk,X
.cont
tay
lda InvSbox,Y
sta state2+&to

View File

@ -98,6 +98,10 @@ void aes256_test(void) {
aes_encrypt(&aes_state);
print_hexbytes("Output: ", aes_state.data, 16);
aes256_decrypt(&aes_state);
print_hexbytes("Decrypted: ", aes_state.data, 16);
}
unsigned long aes128_time_test(unsigned int iters) {