diff options
| author | forsyth <forsyth@vitanuova.com> | 2011-01-17 10:45:22 +0000 |
|---|---|---|
| committer | forsyth <forsyth@vitanuova.com> | 2011-01-17 10:45:22 +0000 |
| commit | 9e6910dc0c747c8f30b87f6482f4eadb48ad6654 (patch) | |
| tree | 4f835b35913acfb115b15ea4f1c6af40fd77ab54 /appl/cmd/ssh/cipherrc4.b | |
| parent | 16501eaf1cb642b80d7fa0236407a27aecb35b02 (diff) | |
emu/Nt/ipif.c
Diffstat (limited to 'appl/cmd/ssh/cipherrc4.b')
| -rw-r--r-- | appl/cmd/ssh/cipherrc4.b | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/appl/cmd/ssh/cipherrc4.b b/appl/cmd/ssh/cipherrc4.b new file mode 100644 index 00000000..f43f9c8d --- /dev/null +++ b/appl/cmd/ssh/cipherrc4.b @@ -0,0 +1,46 @@ +implement Cipher; + +include "sys.m"; + +include "ipints.m"; + ipints: IPints; + IPint: import ipints; + +include "crypt.m"; + crypt: Crypt; + RC4state: import crypt; + +include "sshio.m"; + +Cipherstate: adt +{ + enc: ref RC4state; + dec: ref RC4state; +}; + +cs: ref Cipherstate; + +id(): int +{ + return SSH_CIPHER_RC4; +} + +init(key: array of byte, isserver: int) +{ + ipints = load IPints IPints->PATH; + crypt = load Crypt Crypt->PATH; + if(isserver) + cs = ref Cipherstate(crypt->rc4setup(key[0:16]), crypt->rc4setup(key[16:32])); + else + cs = ref Cipherstate(crypt->rc4setup(key[16:32]), crypt->rc4setup(key[0:16])); +} + +encrypt(buf: array of byte, nbuf: int) +{ + crypt->rc4(cs.enc, buf, nbuf); +} + +decrypt(buf: array of byte, nbuf: int) +{ + crypt->rc4(cs.dec, buf, nbuf); +} |
