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:
authorMarc Stevens <cr-marcstevens@users.noreply.github.com>2017-03-27 19:11:23 +0300
committerGitHub <noreply@github.com>2017-03-27 19:11:23 +0300
commit38096fc021ac5b8f8207c7e926f11feb6b5eb17c (patch)
tree834a2888882854a068837bcc891fd2bf444a3679
parent007905a93c973f55b2daed6585f9f6c23545bf66 (diff)
parent15c90b2811375ea497cbbd18b9da19e8f2b9b6ff (diff)
Merge pull request #23 from cr-marcstevens/bigendianstable-v1.0.3
* Protect against outside definitions of SHA1DC_BIGENDIAN, one can fo…
-rw-r--r--lib/sha1.c16
-rw-r--r--lib/sha1.h5
-rw-r--r--lib/ubc_check.h6
3 files changed, 18 insertions, 9 deletions
diff --git a/lib/sha1.c b/lib/sha1.c
index 8d12b83..939b9b0 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -16,18 +16,22 @@
/*
Because Little-Endian architectures are most common,
- we only set BIGENDIAN if one of these conditions is met.
+ we only set SHA1DC_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)) || \
+#ifdef SHA1DC_BIGENDIAN
+#undef SHA1DC_BIGENDIAN
+#endif
+#if (!defined SHA1DC_FORCE_LITTLEENDIAN) && \
+ ((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__)
+ defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || defined(SHA1DC_FORCE_BIGENDIAN))
-#define BIGENDIAN (1)
+#define SHA1DC_BIGENDIAN
#endif /*ENDIANNESS SELECTION*/
@@ -39,11 +43,11 @@
#define sha1_mix(W, t) (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))
-#if defined(BIGENDIAN)
+#ifdef SHA1DC_BIGENDIAN
#define sha1_load(m, t, temp) { temp = m[t]; }
#else
#define sha1_load(m, t, temp) { temp = m[t]; sha1_bswap32(temp); }
-#endif /*define(BIGENDIAN)*/
+#endif
#define sha1_store(W, t, x) *(volatile uint32_t *)&W[t] = x
diff --git a/lib/sha1.h b/lib/sha1.h
index e867724..07e943f 100644
--- a/lib/sha1.h
+++ b/lib/sha1.h
@@ -5,6 +5,9 @@
* https://opensource.org/licenses/MIT
***/
+#ifndef SHA1DC_SHA1_H
+#define SHA1DC_SHA1_H
+
#if defined(__cplusplus)
extern "C" {
#endif
@@ -103,3 +106,5 @@ int SHA1DCFinal(unsigned char[20], SHA1_CTX*);
#if defined(__cplusplus)
}
#endif
+
+#endif
diff --git a/lib/ubc_check.h b/lib/ubc_check.h
index b349bed..ff567c6 100644
--- a/lib/ubc_check.h
+++ b/lib/ubc_check.h
@@ -20,8 +20,8 @@
// thus one needs to do the recompression check for each DV that has its bit set
*/
-#ifndef UBC_CHECK_H
-#define UBC_CHECK_H
+#ifndef SHA1DC_UBC_CHECK_H
+#define SHA1DC_UBC_CHECK_H
#if defined(__cplusplus)
extern "C" {
@@ -43,4 +43,4 @@ void ubc_check(const uint32_t W[80], uint32_t dvmask[DVMASKSIZE]);
}
#endif
-#endif /* UBC_CHECK_H */
+#endif