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:
authorSODA Noriyuki <soda@NetBSD.org>2017-06-29 19:08:01 +0300
committerÆvar Arnfjörð Bjarmason <avarab@gmail.com>2017-07-01 09:44:36 +0300
commit0677ba3c1ec30dd3a8aad8047e85081f4c09a6ff (patch)
tree5317ec4bd013f9c34615131fbee9d4a5b99ffa60
parent0e8a1ef784c023e9a9e26132736b5b5b4e450a60 (diff)
Big Endian Detection: fix breakage on *BSD & newlib
In 33a694a ("Fix issues with a big endian platform", 2017-05-15) *BSD and newlib was broken because _BIG_ENDIAN is always defined, even on little-endian platforms. To fix this we need to also check the single-underscore version of BIG_ENDIAN & LITTLE_ENDIAN, but only do this if _LITTLE_ENDIAN is also defined. This makes sure that on Solaris we don't break where _BIG_ENDIAN is simply defined, not to any value (but _LITTLE_ENDIAN won't be). See http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/sys/isa_defs.h#397 The https://github.com/cr-marcstevens/sha1collisiondetection/pull/34 pull request has a lot more details on the various issues involved, things that were tried (and not tried) etc. [Commit message & rebase by Ævar]
-rw-r--r--lib/sha1.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/sha1.c b/lib/sha1.c
index 260a3f1..a116893 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -67,6 +67,18 @@
#endif
/* Not under GCC-alike or glibc */
+#elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN)
+/*
+ * *BSD and newlib (embeded linux, cygwin, etc).
+ * the defined(_BIG_ENDIAN) && defined(_LITTLE_ENDIAN) part prevents
+ * this condition from matching with Solaris/sparc.
+ * (Solaris defines only one endian macro)
+ */
+#if _BYTE_ORDER == _BIG_ENDIAN
+#define SHA1DC_BIGENDIAN
+#endif
+
+/* Not under GCC-alike or glibc or *BSD or newlib */
#elif (defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || \
defined(__sparc))
@@ -77,14 +89,14 @@
*/
#define SHA1DC_BIGENDIAN
-/* Not under GCC-alike or glibc or <processor whitelist> */
+/* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> */
#elif defined(SHA1DC_ON_INTEL_LIKE_PROCESSOR)
/*
* As a last resort before we do anything else we're not 100% sure
* about below, we blacklist specific processors here. We could add
* more, see e.g. https://wiki.debian.org/ArchitectureSpecificsMemo
*/
-#else /* Not under GCC-alike or glibc or <processor whitelist> or <processor blacklist> */
+#else /* Not under GCC-alike or glibc or *BSD or newlib or <processor whitelist> or <processor blacklist> */
/* We do nothing more here for now */
/*#error "Uncomment this to see if you fall through all the detection"*/