removed selfmods in rc4

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@312 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2020-12-26 23:32:03 +00:00
parent 65e258488a
commit 98e8ae453a

View File

@ -85,39 +85,32 @@ rc4_key_X
; de/encrypt first X bytes of input buffer to output buffer ; de/encrypt first X bytes of input buffer to output buffer
; X==0 means 256! ; X==0 means 256!
rc4_process_X rc4_process_X
stx .limit stx .length
ldx #0 ldx #0
stx .offset --- stx .count
- ; ++ii inc .ii ; jj += state[++ii]
inc .ii
; jj += state[ii]
ldx .ii
lda .jj lda .jj
ldx .ii
clc clc
adc .state, x adc .state, x
sta .jj sta .jj
tay tay ; now Y holds .jj
; tmp = state[ii]; lda .state, x ; tmp = state[ii];
; state[ii] = state[jj];
; state[jj] = tmp;
lda .state, x
pha pha
lda .state, y lda .state, y ; state[ii] = state[jj];
sta .state, x sta .state, x
pla pla ; state[jj] = tmp;
sta .state, y sta .state, y
; nn = state[ii] + state[jj]; clc ; nn = state[ii] + state[jj];
clc
adc .state, x adc .state, x
; buf[aktueller_offset] ^= state[nn] tax ; buf[aktueller_offset] ^= state[nn]
tax
lda .state, x lda .state, x
ldx #MODIFIED8 : .offset = * - 1 ldx .count
eor .inbuf, x eor .inbuf, x
sta .outbuf, x sta .outbuf, x
; all done? ; all done?
inx inx
cpx #MODIFIED8 : .limit = * - 1 cpx .length
bne - bne ---
rts rts
} }