aboutsummaryrefslogtreecommitdiff
path: root/src/lib/crypto/aes/aesopt.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/crypto/aes/aesopt.h')
-rw-r--r--src/lib/crypto/aes/aesopt.h37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/lib/crypto/aes/aesopt.h b/src/lib/crypto/aes/aesopt.h
index 53fa4d5..0eebd46 100644
--- a/src/lib/crypto/aes/aesopt.h
+++ b/src/lib/crypto/aes/aesopt.h
@@ -176,13 +176,20 @@
# endif
#elif defined(_MSC_VER)
# include <stdlib.h>
-#elif !defined(WIN32)
+#elif defined(_MIPSEB)
+# define PLATFORM_BYTE_ORDER AES_BIG_ENDIAN
+#elif defined(_MIPSEL)
+# define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
+#elif defined(_WIN32)
+# define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
+#elif !defined(_WIN32)
# include <stdlib.h>
-#undef _ENDIAN_H /* XXX */
-# if !defined (_ENDIAN_H)
-# include <sys/param.h>
+# if defined(HAVE_ENDIAN_H)
+# include <endian.h>
+# elif defined(HAVE_MACHINE_ENDIAN_H)
+# include <machine/endian.h>
# else
-# include _ENDIAN_H
+# include <sys/param.h>
# endif
#endif
@@ -231,15 +238,10 @@
#define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
#elif 0 /* **** EDIT HERE IF NECESSARY **** */
#define PLATFORM_BYTE_ORDER AES_BIG_ENDIAN
-#elif (('1234' >> 24) == '1')
-# define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
-#elif (('4321' >> 24) == '1')
-# define PLATFORM_BYTE_ORDER AES_BIG_ENDIAN
-#endif
+#elif 1
+#define PLATFORM_BYTE_ORDER AES_LITTLE_ENDIAN
+#define UNKNOWN_BYTE_ORDER /* we're guessing */
#endif
-
-#if !defined(PLATFORM_BYTE_ORDER)
-# error Please set undetermined byte order (lines 229 or 231 of aesopt.h).
#endif
/* 3. ASSEMBLER SUPPORT
@@ -345,6 +347,15 @@
#define SAFE_IO
#endif
+/*
+ * If PLATFORM_BYTE_ORDER does not match the actual machine byte
+ * order, the fast word-access code will cause incorrect results.
+ * Therefore, SAFE_IO is required when the byte order is unknown.
+ */
+#if !defined(SAFE_IO) && defined(UNKNOWN_BYTE_ORDER)
+# error "SAFE_IO must be defined if machine byte order is unknown."
+#endif
+
/* 7. LOOP UNROLLING
The code for encryption and decrytpion cycles through a number of rounds