OLD | NEW |
1 /* arcfour.c - the arc four algorithm. | 1 /* arcfour.c - the arc four algorithm. |
2 * | 2 * |
3 * This Source Code Form is subject to the terms of the Mozilla Public | 3 * This Source Code Form is subject to the terms of the Mozilla Public |
4 * License, v. 2.0. If a copy of the MPL was not distributed with this | 4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | 6 |
7 /* See NOTES ON UMRs, Unititialized Memory Reads, below. */ | 7 /* See NOTES ON UMRs, Unititialized Memory Reads, below. */ |
8 | 8 |
9 #ifdef FREEBL_NO_DEPEND | 9 #ifdef FREEBL_NO_DEPEND |
10 #include "stubs.h" | 10 #include "stubs.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const unsigned char * unused1, int unused2, | 119 const unsigned char * unused1, int unused2, |
120 unsigned int unused3, unsigned int unused4) | 120 unsigned int unused3, unsigned int unused4) |
121 { | 121 { |
122 int i; | 122 int i; |
123 PRUint8 j, tmp; | 123 PRUint8 j, tmp; |
124 PRUint8 K[256]; | 124 PRUint8 K[256]; |
125 PRUint8 *L; | 125 PRUint8 *L; |
126 | 126 |
127 /* verify the key length. */ | 127 /* verify the key length. */ |
128 PORT_Assert(len > 0 && len < ARCFOUR_STATE_SIZE); | 128 PORT_Assert(len > 0 && len < ARCFOUR_STATE_SIZE); |
129 » if (len < 0 || len >= ARCFOUR_STATE_SIZE) { | 129 » if (len == 0 || len >= ARCFOUR_STATE_SIZE) { |
130 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 130 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
131 return SECFailure; | 131 return SECFailure; |
132 } | 132 } |
133 if (cx == NULL) { | 133 if (cx == NULL) { |
134 PORT_SetError(SEC_ERROR_INVALID_ARGS); | 134 PORT_SetError(SEC_ERROR_INVALID_ARGS); |
135 return SECFailure; | 135 return SECFailure; |
136 } | 136 } |
137 /* Initialize the state using array indices. */ | 137 /* Initialize the state using array indices. */ |
138 memcpy(cx->S, Kinit, sizeof cx->S); | 138 memcpy(cx->S, Kinit, sizeof cx->S); |
139 /* Fill in K repeatedly with values from key. */ | 139 /* Fill in K repeatedly with values from key. */ |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 /* Convert the byte-stream to a word-stream */ | 600 /* Convert the byte-stream to a word-stream */ |
601 return rc4_wordconv(cx, output, outputLen, maxOutputLen, input, inputLen
); | 601 return rc4_wordconv(cx, output, outputLen, maxOutputLen, input, inputLen
); |
602 #else | 602 #else |
603 /* Operate on bytes, but unroll the main loop */ | 603 /* Operate on bytes, but unroll the main loop */ |
604 return rc4_unrolled(cx, output, outputLen, maxOutputLen, input, inputLen
); | 604 return rc4_unrolled(cx, output, outputLen, maxOutputLen, input, inputLen
); |
605 #endif | 605 #endif |
606 } | 606 } |
607 | 607 |
608 #undef CONVERT_TO_WORDS | 608 #undef CONVERT_TO_WORDS |
609 #undef USE_WORD | 609 #undef USE_WORD |
OLD | NEW |