mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-22 03:30:46 +00:00
rc4 implementation in ACME_Lib seems to work
git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@313 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
parent
98e8ae453a
commit
b09b484a90
@ -1,22 +1,22 @@
|
|||||||
;ACME 0.97
|
;ACME 0.97
|
||||||
|
|
||||||
; this is an implementation of the stream cipher algorithm known as RC4.
|
; this is an implementation of the stream cipher algorithm known as RC4.
|
||||||
; UNFINISHED - DO NOT USE!
|
|
||||||
|
|
||||||
; you need to define these symbols in your code:
|
; you need to define these symbols in your code:
|
||||||
; rc4_length a single byte to hold key/chunk lengths
|
; rc4_length a single byte to hold key/chunk lengths
|
||||||
; rc4_count a single byte (iteration counter)
|
; rc4_count a single byte (tmp var for iteration counter)
|
||||||
; rc4_ii a single byte to hold state
|
; rc4_ii a single byte to hold state
|
||||||
; rc4_jj a single byte to hold state
|
; rc4_jj a single byte to hold state
|
||||||
; rc4_state a full page of memory (256 bytes)
|
; rc4_state a full page of memory (256 bytes)
|
||||||
|
; rc4_key key buffer
|
||||||
; rc4_in input buffer
|
; rc4_in input buffer
|
||||||
; rc4_out output buffer
|
; rc4_out output buffer
|
||||||
; the size of the buffers limits how much data you can pass to the functions.
|
; the size of the buffers limits how much data you can pass to the functions.
|
||||||
; the two buffer addresses may be identical, in that case the output will
|
; all three buffer addresses may be identical, in that case the output will
|
||||||
; overwrite the input.
|
; overwrite the input (and/or the key).
|
||||||
; functions you can then call:
|
; functions you can then call:
|
||||||
; rc4_init initialise state
|
; rc4_init initialise state
|
||||||
; rc4_key_X use key (in input buffer, length in X) to change state
|
; rc4_usekey_X use key (in key buffer, length in X) to change state
|
||||||
; rc4_reset reset ii and jj (call between keying and processing)
|
; rc4_reset reset ii and jj (call between keying and processing)
|
||||||
; rc4_process_X de/encrypt a chunk of data buffer-to-buffer (length in X)
|
; rc4_process_X de/encrypt a chunk of data buffer-to-buffer (length in X)
|
||||||
|
|
||||||
@ -27,6 +27,7 @@
|
|||||||
.ii = rc4_ii
|
.ii = rc4_ii
|
||||||
.jj = rc4_jj
|
.jj = rc4_jj
|
||||||
.state = rc4_state
|
.state = rc4_state
|
||||||
|
.keybuf = rc4_key
|
||||||
.inbuf = rc4_in
|
.inbuf = rc4_in
|
||||||
.outbuf = rc4_out
|
.outbuf = rc4_out
|
||||||
|
|
||||||
@ -44,8 +45,9 @@ rc4_reset ldx #0
|
|||||||
stx .jj
|
stx .jj
|
||||||
rts
|
rts
|
||||||
|
|
||||||
; use key (in input buffer, length in X) to change permutation in state array
|
; use key (in key buffer, length in X) to change permutation in state array
|
||||||
rc4_key_X
|
; X==0 means 256!
|
||||||
|
rc4_usekey_X
|
||||||
; X holds .ii (but we count from 0 to 255 and so do not use the real .ii at all)
|
; X holds .ii (but we count from 0 to 255 and so do not use the real .ii at all)
|
||||||
; Y holds .jj or .count (.jj is then in A)
|
; Y holds .jj or .count (.jj is then in A)
|
||||||
stx .length
|
stx .length
|
||||||
@ -61,7 +63,7 @@ rc4_key_X
|
|||||||
adc .state, x
|
adc .state, x
|
||||||
ldy .count
|
ldy .count
|
||||||
clc
|
clc
|
||||||
adc .inbuf, y
|
adc .keybuf, y
|
||||||
;sta .jj
|
;sta .jj
|
||||||
;if (++count == length)
|
;if (++count == length)
|
||||||
; count = 0;
|
; count = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user