1 #include <u.h> 2 #include <libc.h> 3 #include <mp.h> 4 #include <fcall.h> 5 #include <thread.h> 6 #include <9p.h> 7 #include <libsec.h> 8 #include "netssh.h" 9 10 struct CipherState { 11 RC4state state; 12 }; 13 14 static CipherState* 15 initrc4(Conn *c, int dir) 16 { 17 CipherState *cs; 18 19 cs = emalloc9p(sizeof(CipherState)); 20 if(dir) 21 setupRC4state(&cs->state, c->s2cek, 16); 22 else 23 setupRC4state(&cs->state, c->c2sek, 16); 24 return cs; 25 } 26 27 static void 28 encryptrc4(CipherState *cs, uchar *buf, int nbuf) 29 { 30 rc4(&cs->state, buf, nbuf); 31 } 32 33 static void 34 decryptrc4(CipherState *cs, uchar *buf, int nbuf) 35 { 36 rc4(&cs->state, buf, nbuf); 37 } 38 39 Cipher cipherrc4 = { 40 "arcfour", 41 8, 42 initrc4, 43 encryptrc4, 44 decryptrc4, 45 }; 46 47