From 9e85ae9b75acdbe245243784d8d5b1b4de1b24f9 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Mon, 30 Mar 2009 08:58:09 +0000 Subject: x20090330-0957 --- appl/cmd/ssh/cipherrc4.b | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 appl/cmd/ssh/cipherrc4.b (limited to 'appl/cmd/ssh/cipherrc4.b') diff --git a/appl/cmd/ssh/cipherrc4.b b/appl/cmd/ssh/cipherrc4.b new file mode 100644 index 00000000..fc6378ef --- /dev/null +++ b/appl/cmd/ssh/cipherrc4.b @@ -0,0 +1,41 @@ +implement Cipher; + +include "sys.m"; + +include "keyring.m"; + kr: Keyring; + RC4state: import kr; + +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) +{ + kr = load Keyring Keyring->PATH; + if(isserver) + cs = ref Cipherstate(kr->rc4setup(key[0:16]), kr->rc4setup(key[16:32])); + else + cs = ref Cipherstate(kr->rc4setup(key[16:32]), kr->rc4setup(key[0:16])); +} + +encrypt(buf: array of byte, nbuf: int) +{ + kr->rc4(cs.enc, buf, nbuf); +} + +decrypt(buf: array of byte, nbuf: int) +{ + kr->rc4(cs.dec, buf, nbuf); +} -- cgit v1.2.3