summaryrefslogtreecommitdiff
path: root/appl/cmd/ssh/cipherblowfish.b
blob: 8d3b0c3182aa9760f30af331593bf051655d267b (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
39
40
41
42
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);
}