diff options
author | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
---|---|---|
committer | Taru Karttunen <taruti@taruti.net> | 2011-03-30 15:46:40 +0300 |
commit | e5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch) | |
tree | d8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/ssh/cipherrc4.c |
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/ssh/cipherrc4.c')
-rwxr-xr-x | sys/src/cmd/ssh/cipherrc4.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/src/cmd/ssh/cipherrc4.c b/sys/src/cmd/ssh/cipherrc4.c new file mode 100755 index 000000000..5b41f0d23 --- /dev/null +++ b/sys/src/cmd/ssh/cipherrc4.c @@ -0,0 +1,45 @@ +#include "ssh.h" + +struct CipherState +{ + RC4state enc; + RC4state dec; +}; + +static CipherState* +initrc4(Conn *c, int isserver) +{ + CipherState *cs; + + cs = emalloc(sizeof(CipherState)); + if(isserver){ + setupRC4state(&cs->enc, c->sesskey, 16); + setupRC4state(&cs->dec, c->sesskey+16, 16); + }else{ + setupRC4state(&cs->dec, c->sesskey, 16); + setupRC4state(&cs->enc, c->sesskey+16, 16); + } + return cs; +} + +static void +encryptrc4(CipherState *cs, uchar *buf, int nbuf) +{ + rc4(&cs->enc, buf, nbuf); +} + +static void +decryptrc4(CipherState *cs, uchar *buf, int nbuf) +{ + rc4(&cs->dec, buf, nbuf); +} + +Cipher cipherrc4 = +{ + SSH_CIPHER_RC4, + "rc4", + initrc4, + encryptrc4, + decryptrc4, +}; + |