Created
April 30, 2014 16:57
-
-
Save sellout/c637e16ab003b17dfda3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KSA : ARC4Key n -> Vect 256 (Mod 256) | |
KSA {n=(n ** p)} key = | |
fst (runIdentity (runStateT (nextJ (map Prelude.Classes.fromInteger (fromList [0..255]))) | |
(0, 0))) | |
where | |
nextJ : Vect 256 (Mod 256) -> State (Mod 256, Mod 256) (Vect 256 (Mod 256)) | |
nextJ S = do | |
(i, j) <- get | |
let ind = tightmod (cast i) (cast n) (stillNotZero n p) | |
let pos = index ind key | |
let newJ = the (Mod 256) (j + index (cast i) S + pos) | |
let newS = (swap (cast i) (cast newJ) S) | |
if i == maxBound | |
then | |
return newS | |
else do | |
put (i + 1, newJ) | |
nextJ newS | |
-- Data.Crypto.Encryption.ARC4.KSA, nextJ is possibly not total due to: Data.Crypto.Encryption.ARC4.case block in Data.Crypto.Encryption.ARC4.KSA, nextJ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment