X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/9bccf70c0258c7cac2dcb80011b2a964d884c552..eb6b6ca394357805f2bdba989abae309f718b4d8:/bsd/crypto/rc4/rc4.c diff --git a/bsd/crypto/rc4/rc4.c b/bsd/crypto/rc4/rc4.c index 2154cc404..da9559fea 100644 --- a/bsd/crypto/rc4/rc4.c +++ b/bsd/crypto/rc4/rc4.c @@ -1,10 +1,9 @@ - /* * 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; @@ -15,7 +14,7 @@ * 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, @@ -61,14 +60,15 @@ rc4_init(struct rc4_state *const state, const u_char *key, int keylen) 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]); } } @@ -81,13 +81,12 @@ rc4_init(struct rc4_state *const state, const u_char *key, int keylen) */ 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]; @@ -101,4 +100,3 @@ rc4_crypt(struct rc4_state *const state, outbuf[i] = inbuf[i] ^ state->perm[j]; } } -