1 /* $MirOS: src/sys/crypto/arc4.c,v 1.3 2010/09/21 21:24:22 tg Exp $ */
2
3 /* rewritten; no code left, only the API */
4
5 #include <sys/types.h>
6 #include <crypto/arc4.h>
7
8 void
rc4_keysetup(struct rc4_ctx * ctx,const u_char * key,u_int32_t klen)9 rc4_keysetup(struct rc4_ctx *ctx, const u_char *key, u_int32_t klen)
10 {
11 arcfour_init(ctx);
12 arcfour_ksa(ctx, key, klen);
13 }
14
15 void
rc4_crypt(struct rc4_ctx * ctx,const u_char * src,u_char * dst,u_int32_t len)16 rc4_crypt(struct rc4_ctx *ctx, const u_char *src, u_char *dst, u_int32_t len)
17 {
18 while (len--)
19 *dst++ = *src++ ^ arcfour_byte(ctx);
20 }
21