253 state[0] += a;
254 state[1] += b;
255 state[2] += c;
256 state[3] += d;
257
258 /* zeroize sensitive information */
259 bzero(x, sizeof (*x));
260 }
261
262 /*
263 * Encodes input (uint32_t) into output (unsigned char). Assumes len is
264 * a multiple of 4.
265 */
266 static void
267 Encode(unsigned char *output, uint32_t *input, unsigned int len)
268 {
269 unsigned int i, j;
270
271 for (i = 0, j = 0; j < len; i++, j += 4) {
272 #if defined(_LITTLE_ENDIAN) && defined(UNALIGNED_POINTERS_PERMITTED)
273 *(uint32_t *)&output[j] = input[i];
274 #else
275 /* endian-independent code */
276 output[j] = (unsigned char)(input[i] & 0xff);
277 output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
278 output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
279 output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
280 #endif /* _LITTLE_ENDIAN && UNALIGNED_POINTERS_PERMITTED */
281 }
282 }
283
284 /*
285 * Decodes input (unsigned char) into output (uint32_t). Assumes len is
286 * a multiple of 4.
287 */
288 static void
289 Decode(uint32_t *output, unsigned char *input, unsigned int len)
290 {
291 unsigned int i, j;
292
293 for (i = 0, j = 0; j < len; i++, j += 4) {
294 #if defined(_LITTLE_ENDIAN) && defined(UNALIGNED_POINTERS_PERMITTED)
295 output[i] = *(uint32_t *)&input[j];
296 #else
297 /* endian-independent code */
298 output[i] = ((uint32_t)input[j]) |
299 (((uint32_t)input[j+1]) << 8) |
300 (((uint32_t)input[j+2]) << 16) |
301 (((uint32_t)input[j+3]) << 24);
302 #endif /* _LITTLE_ENDIAN && UNALIGNED_POINTERS_PERMITTED */
303 }
304
305 }
|
253 state[0] += a;
254 state[1] += b;
255 state[2] += c;
256 state[3] += d;
257
258 /* zeroize sensitive information */
259 bzero(x, sizeof (*x));
260 }
261
262 /*
263 * Encodes input (uint32_t) into output (unsigned char). Assumes len is
264 * a multiple of 4.
265 */
266 static void
267 Encode(unsigned char *output, uint32_t *input, unsigned int len)
268 {
269 unsigned int i, j;
270
271 for (i = 0, j = 0; j < len; i++, j += 4) {
272 #if defined(_LITTLE_ENDIAN) && defined(UNALIGNED_POINTERS_PERMITTED)
273 *(uint32_t *)(void *)&output[j] = input[i];
274 #else
275 /* endian-independent code */
276 output[j] = (unsigned char)(input[i] & 0xff);
277 output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
278 output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
279 output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
280 #endif /* _LITTLE_ENDIAN && UNALIGNED_POINTERS_PERMITTED */
281 }
282 }
283
284 /*
285 * Decodes input (unsigned char) into output (uint32_t). Assumes len is
286 * a multiple of 4.
287 */
288 static void
289 Decode(uint32_t *output, unsigned char *input, unsigned int len)
290 {
291 unsigned int i, j;
292
293 for (i = 0, j = 0; j < len; i++, j += 4) {
294 #if defined(_LITTLE_ENDIAN) && defined(UNALIGNED_POINTERS_PERMITTED)
295 output[i] = *(uint32_t *)(void *)&input[j];
296 #else
297 /* endian-independent code */
298 output[i] = ((uint32_t)input[j]) |
299 (((uint32_t)input[j+1]) << 8) |
300 (((uint32_t)input[j+2]) << 16) |
301 (((uint32_t)input[j+3]) << 24);
302 #endif /* _LITTLE_ENDIAN && UNALIGNED_POINTERS_PERMITTED */
303 }
304
305 }
|