ciphersaber2 0.1.1.0 → 0.1.1.1
raw patch · 2 files changed
+45/−15 lines, 2 filesdep ~arraydep ~base
Dependency ranges changed: array, base
Files
- README.md +39/−9
- ciphersaber2.cabal +6/−6
README.md view
@@ -61,29 +61,35 @@ > **repeat** *r* **times** > **for** *i* **in** 0..255 > *j* ← (*j* + *S*[*i*] + *k*[*i* **mod** *l*]) **mod** 256 -> *S*[*i*] <-> *S*[*j*] +> *S*[*i*] ↔ *S*[*j*] > -- Finally, produce the stream. > *keystream* ← zero-based array of *n* bytes > *j* ← 0 > **for** *i* **in** 0..n-1 -> i' ← *(i + 1)* **mod** 256 +> i' ← (*i* + 1) **mod** 256 > *j* ← (*j* + *S*[i']) **mod** 256 -> *S*[i'] <-> *S*[*j*] +> *S*[i'] ↔ *S*[*j*] > *keystream*[*i*] ← *S*[(*S*[i'] + *S*[*j*]) **mod** 256] > **return** *keystream* <!-- End of pseuf translation of rc4.pseu --> + CS2 encryption requires a plaintext message (treated as a-bytestream), a key with a recommended maximum size of 53-bytes and a required maximum size of 256 bytes, and an-"initial value"+bytestream), a key, and an "initial value" ([IV](http://en.wikipedia.org/wiki/Initialization_vector))-of 10 bytes. The IV is a+of 10 bytes. The key *should* be no more than 53 bytes, to+ensure good mixing during key scheduling.++The IV is a [nonce](http://en.wikipedia.org/wiki/Cryptographic_nonce) that must be different for each message sent: it should be chosen randomly if possible, but may be chosen pseudo-randomly or even just counted if necessary.+CS2 appends the IV to the CS2 key to produce an RC4 key.+RC4 uses only the first 256 RC4 key bytes. Thus, the CS2 key+*must* be no more than 246 bytes: a longer CS2 key would+cause some or all of the IV to not be used by RC4. <!-- This pseudocode translated from encrypt.pseu by pseuf --> @@ -134,8 +140,32 @@ ## Driver The program `cs2` uses the `CipherSaber2` library to encrypt-or decrypt `stdin` to `stdout`. Say "`cs2 --help`" for usage-information.+or decrypt `stdin` to `stdout`.++`cs2` is written in Haskell, so you will need a Haskell+installation to run it. It depends on the package+`[parseargs](http://hackage.haskell.org/package/parseargs)`+from [Hackage](http://hackage.haskell.org), as well as the+`bytestring` package that should probably have come with+your distribution but may need to be installed. Say "`cabal+install parseargs`" and "`cabal install bytestring`" to get+things set up. (This in turn may require a `cabal-install`+package from your Linux distribution or thereabouts.)++Say "`runghc cs2.hs --help`" for usage information.++Say "`runghc cs2.hs -e whee <f.txt >g.cs2`" to encrypt the+file `f.txt` with key `whee`. An IV will be automatically+chosen.++Say "`runghc cs2.hs -d whee <g.cs2 >ff.txt`" to decrypt the+file `g.cs2` with key `whee`.++## Test Instances++The `test` directory include a bunch of plaintext/ciphertext+pairs taken from the original CS2 materials. Please see+`README.md` in that directory for more information. ## License
ciphersaber2.cabal view
@@ -14,7 +14,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 0.1.1.0+version: 0.1.1.1 -- A short (one-line) description of the package. synopsis: Implementation of CipherSaber2 RC4 cryptography.@@ -61,7 +61,7 @@ source-repository this type: git location: http://github.com/BartMassey/ciphersaber2- tag: v0.1.1.0+ tag: v0.1.1.1 library -- Modules exported by the library.@@ -74,8 +74,8 @@ -- other-extensions: -- Other library packages from which modules are imported.- build-depends: base >=4.7 && <5,- array >=0.5 && <1,+ build-depends: base >=4 && <5,+ array >=0.4 && <1, bytestring >= 0.10 && < 1 -- Directories containing source files.@@ -91,8 +91,8 @@ other-modules: Data.CipherSaber2 -- Other library packages from which modules are imported.- build-depends: base >=4.7 && <5,- array >=0.5 && <1,+ build-depends: base >=4 && <5,+ array >=0.4 && <1, parseargs >= 0.1 && < 1, bytestring >= 0.10 && < 1