xref: /plan9/sys/src/cmd/ssh1/cipherdes.c (revision 63afb9a5d3f910047231762bcce0ee49fed3d07c)
1 #include "ssh.h"
2 
3 struct CipherState
4 {
5 	DESstate enc;
6 	DESstate dec;
7 };
8 
9 static CipherState*
initdes(Conn * c,int)10 initdes(Conn *c, int)
11 {
12 	CipherState *cs;
13 
14 	cs = emalloc(sizeof(CipherState));
15 	setupDESstate(&cs->enc, c->sesskey, nil);
16 	setupDESstate(&cs->dec, c->sesskey, nil);
17 	return cs;
18 }
19 
20 static void
encryptdes(CipherState * cs,uchar * buf,int nbuf)21 encryptdes(CipherState *cs, uchar *buf, int nbuf)
22 {
23 	desCBCencrypt(buf, nbuf, &cs->enc);
24 }
25 
26 static void
decryptdes(CipherState * cs,uchar * buf,int nbuf)27 decryptdes(CipherState *cs, uchar *buf, int nbuf)
28 {
29 	desCBCdecrypt(buf, nbuf, &cs->dec);
30 }
31 
32 Cipher cipherdes =
33 {
34 	SSH_CIPHER_DES,
35 	"des",
36 	initdes,
37 	encryptdes,
38 	decryptdes,
39 };
40 
41