summaryrefslogtreecommitdiff
path: root/appl/cmd/ssh/cipherblowfish.b
diff options
context:
space:
mode:
Diffstat (limited to 'appl/cmd/ssh/cipherblowfish.b')
-rw-r--r--appl/cmd/ssh/cipherblowfish.b38
1 files changed, 38 insertions, 0 deletions
diff --git a/appl/cmd/ssh/cipherblowfish.b b/appl/cmd/ssh/cipherblowfish.b
new file mode 100644
index 00000000..7e6210ab
--- /dev/null
+++ b/appl/cmd/ssh/cipherblowfish.b
@@ -0,0 +1,38 @@
+implement Cipher;
+
+include "sys.m";
+
+include "keyring.m";
+ kr: Keyring;
+ BFstate: import kr;
+
+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)
+{
+ kr = load Keyring Keyring->PATH;
+ cs = ref Cipherstate(kr->blowfishsetup(key, nil), kr->blowfishsetup(key, nil));
+}
+
+encrypt(buf: array of byte, nbuf: int)
+{
+ kr->blowfishcbc(cs.enc, buf, nbuf, Keyring->Encrypt);
+}
+
+decrypt(buf: array of byte, nbuf: int)
+{
+ kr->blowfishcbc(cs.dec, buf, nbuf, Keyring->Decrypt);
+}