MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rc4_crypt

Function rc4_crypt

freebsd/crypto/rc4/rc4.c:87–108  ·  view source on GitHub ↗

* Encrypt some data using the supplied RC4 state buffer. * The input and output buffers may be the same buffer. * Since RC4 is a stream cypher, this function is used * for both encryption and decryption. */

Source from the content-addressed store, hash-verified

85 * for both encryption and decryption.
86 */
87void
88rc4_crypt(struct rc4_state *const state,
89 const u_char *inbuf, u_char *outbuf, int buflen)
90{
91 int i;
92 u_char j;
93
94 for (i = 0; i < buflen; i++) {
95
96 /* Update modification indicies */
97 state->index1++;
98 state->index2 += state->perm[state->index1];
99
100 /* Modify permutation */
101 swap_bytes(&state->perm[state->index1],
102 &state->perm[state->index2]);
103
104 /* Encrypt/decrypt next byte */
105 j = state->perm[state->index1] + state->perm[state->index2];
106 outbuf[i] = inbuf[i] ^ state->perm[j];
107 }
108}
109
110static int
111rc4_modevent(module_t mod, int type, void *unused)

Callers 3

ng_mppc_compressFunction · 0.85
ng_mppc_decompressFunction · 0.85
ng_mppc_updatekeyFunction · 0.85

Calls 1

swap_bytesFunction · 0.85

Tested by

no test coverage detected