Use OPENSSL_64_BIT in rc4.c.

This avoids unnecessary differences between LP64 and LLP64. Also
MSVC throws overflow warnings in the big-endian 64-bit codepath,
so use the preprocessor.

Change-Id: I74cef2d631d39f282177e043ed24bc6ecbbcb8fd
Reviewed-on: https://boringssl-review.googlesource.com/1860
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2014-09-30 19:47:35 -04:00 committed by Adam Langley
parent 04284b8952
commit 5e77bd449e

View File

@ -56,11 +56,17 @@
#include <openssl/rc4.h>
#if defined(OPENSSL_NO_ASM) || \
(!defined(OPENSSL_X86_64) && !defined(OPENSSL_X86))
#define RC4_CHUNK unsigned long
#if defined(OPENSSL_64_BIT)
#define RC4_CHUNK uint64_t
#elif defined(OPENSSL_32_BIT)
#define RC4_CHUNK uint32_t
#else
#error "Unknown word size"
#endif
#define RC4_INT uint32_t
@ -157,12 +163,12 @@ void RC4(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out) {
otp |= RC4_STEP << BESHFT(1);
otp |= RC4_STEP << BESHFT(2);
otp |= RC4_STEP << BESHFT(3);
if (sizeof(RC4_CHUNK) == 8) {
otp |= RC4_STEP << BESHFT(4);
otp |= RC4_STEP << BESHFT(5);
otp |= RC4_STEP << BESHFT(6);
otp |= RC4_STEP << BESHFT(7);
}
#if defined(OPENSSL_64_BIT)
otp |= RC4_STEP << BESHFT(4);
otp |= RC4_STEP << BESHFT(5);
otp |= RC4_STEP << BESHFT(6);
otp |= RC4_STEP << BESHFT(7);
#endif
*(RC4_CHUNK *)out = otp ^ ichunk;
in += sizeof(RC4_CHUNK);
out += sizeof(RC4_CHUNK);
@ -206,12 +212,12 @@ void RC4(RC4_KEY *key, size_t len, const uint8_t *in, uint8_t *out) {
otp |= RC4_STEP << 8;
otp |= RC4_STEP << 16;
otp |= RC4_STEP << 24;
if (sizeof(RC4_CHUNK) == 8) {
otp |= RC4_STEP << LESHFT(4);
otp |= RC4_STEP << LESHFT(5);
otp |= RC4_STEP << LESHFT(6);
otp |= RC4_STEP << LESHFT(7);
}
#if defined(OPENSSL_64_BIT)
otp |= RC4_STEP << LESHFT(4);
otp |= RC4_STEP << LESHFT(5);
otp |= RC4_STEP << LESHFT(6);
otp |= RC4_STEP << LESHFT(7);
#endif
*(RC4_CHUNK *)out = otp ^ ichunk;
in += sizeof(RC4_CHUNK);
out += sizeof(RC4_CHUNK);