-
/*
* rc4.c
*
* Copyright (c) 1996-2000 Whistle Communications, Inc.
* All rights reserved.
- *
+ *
* Subject to the following obligations and disclaimer of warranty, use and
* redistribution of this software, in source or object code forms, with or
* without modifications are expressly permitted by Whistle Communications;
* Communications, Inc. trademarks, including the mark "WHISTLE
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
* such appears in the above copyright notice or in the software.
- *
+ *
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
int i;
/* Initialize state with identity permutation */
- for (i = 0; i < 256; i++)
- state->perm[i] = (u_char)i;
+ for (i = 0; i < 256; i++) {
+ state->perm[i] = (u_char)i;
+ }
state->index1 = 0;
state->index2 = 0;
-
+
/* Randomize the permutation using key data */
for (j = i = 0; i < 256; i++) {
- j += state->perm[i] + key[i % keylen];
+ j += state->perm[i] + key[i % keylen];
swap_bytes(&state->perm[i], &state->perm[j]);
}
}
*/
void
rc4_crypt(struct rc4_state *const state,
- const u_char *inbuf, u_char *outbuf, int buflen)
+ const u_char *inbuf, u_char *outbuf, int buflen)
{
int i;
u_char j;
for (i = 0; i < buflen; i++) {
-
/* Update modification indicies */
state->index1++;
state->index2 += state->perm[state->index1];
outbuf[i] = inbuf[i] ^ state->perm[j];
}
}
-