Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/cr-marcstevens/sha1collisiondetection.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Shumow <shumow@gmail.com>2017-03-10 03:34:52 +0300
committerDan Shumow <shumow@gmail.com>2017-03-10 03:34:52 +0300
commite792e8c9f855b72d68f54b88bb484c40591963df (patch)
tree6713ede592e896eae9bab75fc5c911104e0f9da1
parent55d1db0980501e582f6cd103a04f493995b1df78 (diff)
Add BIGENDIAN detection logic.
-rw-r--r--lib/sha1.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/sha1.c b/lib/sha1.c
index 66b03f3..390b638 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -13,6 +13,24 @@
#include "sha1.h"
#include "ubc_check.h"
+
+/*
+ Because Little-Endian architectures are most common,
+ we only set BIGENDIAN if one of these conditions is met.
+ Note that all MSFT platforms are little endian,
+ so none of these will be defined under the MSC compiler.
+ If you are compiling on a big endian platform and your compiler does not define one of these,
+ you will have to add whatever macros your tool chain defines to indicate Big-Endianness.
+ */
+#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \
+ (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) || \
+ defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
+ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
+
+#define BIGENDIAN (1)
+
+#endif /*ENDIANNESS SELECTION*/
+
#define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))
#define rotate_left(x,n) (((x)<<(n))|((x)>>(32-(n))))