summaryrefslogtreecommitdiff
path: root/appl/cmd/ssh/cipherblowfish.b
blob: 7e6210ab410e94980e7322cccb068e2d39394df2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);
}