diff options
Diffstat (limited to 'src/lib/libcrypto/rc4/rc4_enc.c')
-rw-r--r-- | src/lib/libcrypto/rc4/rc4_enc.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/lib/libcrypto/rc4/rc4_enc.c b/src/lib/libcrypto/rc4/rc4_enc.c index 8c4fc6c7a3..d8fc939dac 100644 --- a/src/lib/libcrypto/rc4/rc4_enc.c +++ b/src/lib/libcrypto/rc4/rc4_enc.c | |||
@@ -56,6 +56,7 @@ | |||
56 | * [including the GNU Public Licence.] | 56 | * [including the GNU Public Licence.] |
57 | */ | 57 | */ |
58 | 58 | ||
59 | #include <machine/endian.h> | ||
59 | #include <openssl/rc4.h> | 60 | #include <openssl/rc4.h> |
60 | #include "rc4_locl.h" | 61 | #include "rc4_locl.h" |
61 | 62 | ||
@@ -124,7 +125,6 @@ void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, | |||
124 | ((size_t)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 ) | 125 | ((size_t)outdata & (sizeof(RC4_CHUNK)-1)) ) == 0 ) |
125 | { | 126 | { |
126 | RC4_CHUNK ichunk,otp; | 127 | RC4_CHUNK ichunk,otp; |
127 | const union { long one; char little; } is_endian = {1}; | ||
128 | 128 | ||
129 | /* | 129 | /* |
130 | * I reckon we can afford to implement both endian | 130 | * I reckon we can afford to implement both endian |
@@ -132,14 +132,10 @@ void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, | |||
132 | * because the machine code appears to be very compact | 132 | * because the machine code appears to be very compact |
133 | * and redundant 1-2KB is perfectly tolerable (i.e. | 133 | * and redundant 1-2KB is perfectly tolerable (i.e. |
134 | * in case the compiler fails to eliminate it:-). By | 134 | * in case the compiler fails to eliminate it:-). By |
135 | * suggestion from Terrel Larson <terr@terralogic.net> | 135 | * suggestion from Terrel Larson <terr@terralogic.net>. |
136 | * who also stands for the is_endian union:-) | ||
137 | * | 136 | * |
138 | * Special notes. | 137 | * Special notes. |
139 | * | 138 | * |
140 | * - is_endian is declared automatic as doing otherwise | ||
141 | * (declaring static) prevents gcc from eliminating | ||
142 | * the redundant code; | ||
143 | * - compilers (those I've tried) don't seem to have | 139 | * - compilers (those I've tried) don't seem to have |
144 | * problems eliminating either the operators guarded | 140 | * problems eliminating either the operators guarded |
145 | * by "if (sizeof(RC4_CHUNK)==8)" or the condition | 141 | * by "if (sizeof(RC4_CHUNK)==8)" or the condition |
@@ -154,7 +150,7 @@ void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, | |||
154 | * | 150 | * |
155 | * <appro@fy.chalmers.se> | 151 | * <appro@fy.chalmers.se> |
156 | */ | 152 | */ |
157 | if (!is_endian.little) | 153 | if (_BYTE_ORDER != _LITTLE_ENDIAN) |
158 | { /* BIG-ENDIAN CASE */ | 154 | { /* BIG-ENDIAN CASE */ |
159 | # define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1)) | 155 | # define BESHFT(c) (((sizeof(RC4_CHUNK)-(c)-1)*8)&(sizeof(RC4_CHUNK)*8-1)) |
160 | for (;len&(0-sizeof(RC4_CHUNK));len-=sizeof(RC4_CHUNK)) | 156 | for (;len&(0-sizeof(RC4_CHUNK));len-=sizeof(RC4_CHUNK)) |