From 98e8ae453a5453387b7dec4ce56d6766bfd432a8 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Sat, 26 Dec 2020 23:32:03 +0000 Subject: [PATCH] removed selfmods in rc4 git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@312 4df02467-bbd4-4a76-a152-e7ce94205b78 --- ACME_Lib/6502/rc4.a | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/ACME_Lib/6502/rc4.a b/ACME_Lib/6502/rc4.a index ed20f3d..1a73150 100644 --- a/ACME_Lib/6502/rc4.a +++ b/ACME_Lib/6502/rc4.a @@ -85,39 +85,32 @@ rc4_key_X ; de/encrypt first X bytes of input buffer to output buffer ; X==0 means 256! rc4_process_X - stx .limit + stx .length ldx #0 - stx .offset -- ; ++ii - inc .ii - ; jj += state[ii] - ldx .ii +--- stx .count + inc .ii ; jj += state[++ii] lda .jj + ldx .ii clc adc .state, x sta .jj - tay - ; tmp = state[ii]; - ; state[ii] = state[jj]; - ; state[jj] = tmp; - lda .state, x + tay ; now Y holds .jj + lda .state, x ; tmp = state[ii]; pha - lda .state, y + lda .state, y ; state[ii] = state[jj]; sta .state, x - pla + pla ; state[jj] = tmp; sta .state, y - ; nn = state[ii] + state[jj]; - clc + clc ; nn = state[ii] + state[jj]; adc .state, x - ; buf[aktueller_offset] ^= state[nn] - tax + tax ; buf[aktueller_offset] ^= state[nn] lda .state, x - ldx #MODIFIED8 : .offset = * - 1 + ldx .count eor .inbuf, x sta .outbuf, x ; all done? inx - cpx #MODIFIED8 : .limit = * - 1 - bne - + cpx .length + bne --- rts }