summaryrefslogtreecommitdiff
path: root/appl/cmd/ssh/cipherblowfish.b
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2011-01-17 10:45:22 +0000
committerforsyth <forsyth@vitanuova.com>2011-01-17 10:45:22 +0000
commit9e6910dc0c747c8f30b87f6482f4eadb48ad6654 (patch)
tree4f835b35913acfb115b15ea4f1c6af40fd77ab54 /appl/cmd/ssh/cipherblowfish.b
parent16501eaf1cb642b80d7fa0236407a27aecb35b02 (diff)
emu/Nt/ipif.c
Diffstat (limited to 'appl/cmd/ssh/cipherblowfish.b')
-rw-r--r--appl/cmd/ssh/cipherblowfish.b43
1 files changed, 43 insertions, 0 deletions
diff --git a/appl/cmd/ssh/cipherblowfish.b b/appl/cmd/ssh/cipherblowfish.b
new file mode 100644
index 00000000..8d3b0c31
--- /dev/null
+++ b/appl/cmd/ssh/cipherblowfish.b
@@ -0,0 +1,43 @@
+implement Cipher;
+
+include "sys.m";
+
+include "ipints.m";
+ ipints: IPints;
+ IPint: import ipints;
+
+include "crypt.m";
+ crypt: Crypt;
+ BFstate: import crypt;
+
+include "sshio.m";
+
+Cipherstate: adt
+{
+ enc: ref BFstate;
+ dec: ref BFstate;
+};
+
+cs: ref Cipherstate;
+
+id(): int
+{
+ return SSH_CIPHER_BLOWFISH;
+}
+
+init(key: array of byte, nil: int)
+{
+ ipints = load IPints IPints->PATH;
+ crypt = load Crypt Crypt->PATH;
+ cs = ref Cipherstate(crypt->blowfishsetup(key, nil), crypt->blowfishsetup(key, nil));
+}
+
+encrypt(buf: array of byte, nbuf: int)
+{
+ crypt->blowfishcbc(cs.enc, buf, nbuf, Crypt->Encrypt);
+}
+
+decrypt(buf: array of byte, nbuf: int)
+{
+ crypt->blowfishcbc(cs.dec, buf, nbuf, Crypt->Decrypt);
+}