{"thread":{"id":"45998","subject":"[PATCH 0/3] Update sha1dc from upstream & optionally make it a submodule","startedAt":"2017-05-18T21:29:15Z","lastAt":"2017-05-25T23:31:13Z","messageCount":20,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano","Stefan Beller"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"320213","messageId":"20170518212858.3649-1-avarab@gmail.com","threadId":"45998","inReplyTo":null,"subject":"[PATCH 0/3] Update sha1dc from upstream & optionally make it a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-18T21:28:55Z","receivedAt":"2017-05-18T21:29:15Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This series:\n\nÆvar Arnfjörð Bjarmason (3):\n  sha1dc: update from upstream\n   \n   * Fixes the Big-Endian detection on Solaris SPARC (and probably\n     others) which broke the build as of 2.13.0 due to sha1dc being the\n     dauflt.\n   \n   * Includes a patch from upstream fixing unaligned access, which broke\n     SPARC even more. This replaces Junio's \"[PATCH] sha1dc: fix issues\n     with a big endian platform\"\n     (<xmqq37c4xcr6.fsf_-_@gitster.mtv.corp.google.com>) with something\n     which brings in upstream as-is.\n   \n   * Most importantly: Uses upstream code as-is with no modifications,\n     which is possible due to a pull request I sent them.\n\n   * This patch can be picked stand-alone without [23]/3.\n\n  sha1dc: use sha1collisiondetection as a submodule\n\n   * Since we can now use upstream code as-is let's use it as a\n     submodule.\n   \n     Yes there are still (solvable) UX issues with submodules, but\n     there's no project better equipped to deal with them than\n     git.git.\n\n  sha1dc: remove the unused sha1dc/ directory\n\n   * Sent as a separate patch for readability. Can be squashed into\n     2/3.\n\n .gitmodules            |   4 +\n Makefile               |  13 +-\n hash.h                 |   2 +-\n sha1collisiondetection |   1 +\n sha1dc/LICENSE.txt     |  30 ----\n sha1dc/sha1.c          |  99 +++++++++-----\n sha1dc/sha1.h          | 122 -----------------\n sha1dc/ubc_check.c     | 363 -------------------------------------------------\n sha1dc/ubc_check.h     |  44 ------\n sha1dc_git.c           |  24 ++++\n sha1dc_git.h           |  19 +++\n 11 files changed, 124 insertions(+), 597 deletions(-)\n create mode 100644 .gitmodules\n create mode 160000 sha1collisiondetection\n delete mode 100644 sha1dc/LICENSE.txt\n delete mode 100644 sha1dc/sha1.h\n delete mode 100644 sha1dc/ubc_check.c\n delete mode 100644 sha1dc/ubc_check.h\n create mode 100644 sha1dc_git.c\n create mode 100644 sha1dc_git.h\n\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320214","messageId":"20170518212858.3649-2-avarab@gmail.com","threadId":"45998","inReplyTo":"20170518212858.3649-1-avarab@gmail.com","subject":"[PATCH 1/3] sha1dc: update from upstream","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-18T21:28:56Z","receivedAt":"2017-05-18T21:29:21Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Update sha1dc from the latest version by the upstream\nmaintainer[1].\n\nThis version includes a commit of mine which allows for replacing the\nlocal modifications done to the upstream files in git.git with macro\ndefinitions to monkeypatch it in place.\n\nIt also brings in a change[2] upstream made for the breakage 2.13.0\nintroduced on SPARC and other platforms that forbid unaligned\naccess[3].\n\nThis means that the code customizations done since the initial import\nin commit 28dc98e343 (\"sha1dc: add collision-detecting sha1\nimplementation\", 2017-03-16) can be done purely via Makefile\ndefinitions and by including the content of our own sha1dc_git.[ch] in\nsha1dc/sha1.c via a macro.\n\n1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/b45fcefc71270d9a159028c22e6d36c3817da188\n2. https://github.com/cr-marcstevens/sha1collisiondetection/commit/33a694a9ee1b79c24be45f9eab5ac0e1aeeaf271\n3. \"Git 2.13.0 segfaults on Solaris SPARC due to DC_SHA1=YesPlease\n   being on by default\"\n   (https://public-inbox.org/git/CACBZZX6nmKK8af0-UpjCKWV4R+hV-uk2xWXVA5U+_UQ3VXU03g@mail.gmail.com/)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Makefile           |  9 ++++-\n sha1dc/sha1.c      | 99 +++++++++++++++++++++++++++++++++++-------------------\n sha1dc/sha1.h      | 92 ++++++++++++++++++++++----------------------------\n sha1dc/ubc_check.c | 13 +++++--\n sha1dc/ubc_check.h | 14 ++++++--\n sha1dc_git.c       | 24 +++++++++++++\n sha1dc_git.h       | 19 +++++++++++\n 7 files changed, 178 insertions(+), 92 deletions(-)\n create mode 100644 sha1dc_git.c\n create mode 100644 sha1dc_git.h\n\ndiff --git a/Makefile b/Makefile\nindex e35542e631..ffa6da71b7 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1414,7 +1414,14 @@ else\n \tDC_SHA1 := YesPlease\n \tLIB_OBJS += sha1dc/sha1.o\n \tLIB_OBJS += sha1dc/ubc_check.o\n-\tBASIC_CFLAGS += -DSHA1_DC\n+\tBASIC_CFLAGS += \\\n+\t\t-DSHA1_DC \\\n+\t\t-DSHA1DC_NO_STANDARD_INCLUDES \\\n+\t\t-DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 \\\n+\t\t-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"\\\"cache.h\\\"\" \\\n+\t\t-DSHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C=\"\\\"sha1dc_git.c\\\"\" \\\n+\t\t-DSHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H=\"\\\"sha1dc_git.h\\\"\" \\\n+\t\t-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"\\\"git-compat-util.h\\\"\"\n endif\n endif\n endif\ndiff --git a/sha1dc/sha1.c b/sha1dc/sha1.c\nindex 35e9dd5bf4..26516b102f 100644\n--- a/sha1dc/sha1.c\n+++ b/sha1dc/sha1.c\n@@ -5,12 +5,26 @@\n * https://opensource.org/licenses/MIT\n ***/\n \n-#include \"cache.h\"\n-#include \"sha1dc/sha1.h\"\n-#include \"sha1dc/ubc_check.h\"\n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <string.h>\n+#include <memory.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#endif\n+\n+#ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C\n+#include SHA1DC_CUSTOM_INCLUDE_SHA1_C\n+#endif\n+\n+#ifndef SHA1DC_INIT_SAFE_HASH_DEFAULT\n+#define SHA1DC_INIT_SAFE_HASH_DEFAULT 1\n+#endif\n \n+#include \"sha1.h\"\n+#include \"ubc_check.h\"\n \n-/*\n+\n+/* \n    Because Little-Endian architectures are most common,\n    we only set SHA1DC_BIGENDIAN if one of these conditions is met.\n    Note that all MSFT platforms are little endian,\n@@ -18,16 +32,30 @@\n    If you are compiling on a big endian platform and your compiler does not define one of these,\n    you will have to add whatever macros your tool chain defines to indicate Big-Endianness.\n  */\n-#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \\\n+#ifdef SHA1DC_BIGENDIAN\n+#undef SHA1DC_BIGENDIAN\n+#endif\n+#if (!defined SHA1DC_FORCE_LITTLEENDIAN) && \\\n+    ((defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \\\n     (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) || \\\n-    defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) ||  defined(__AARCH64EB__) || \\\n-    defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)\n+    defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) ||  defined(__AARCH64EB__) || \\\n+    defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || defined(SHA1DC_FORCE_BIGENDIAN))\n+\n+#define SHA1DC_BIGENDIAN\n \n-#define SHA1DC_BIGENDIAN\t1\n-#else\n-#undef SHA1DC_BIGENDIAN\n #endif /*ENDIANNESS SELECTION*/\n \n+#if (defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \\\n+     defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__)  || \\\n+     defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || \\\n+     defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__) || \\\n+     defined(__386) || defined(_M_X64) || defined(_M_AMD64))\n+\n+#define SHA1DC_ALLOW_UNALIGNED_ACCESS\n+\n+#endif /*UNALIGNMENT DETECTION*/\n+\n+\n #define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))\n #define rotate_left(x,n)  (((x)<<(n))|((x)>>(32-(n))))\n \n@@ -36,11 +64,11 @@\n \n #define sha1_mix(W, t)  (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))\n \n-#if defined(SHA1DC_BIGENDIAN)\n+#ifdef SHA1DC_BIGENDIAN\n \t#define sha1_load(m, t, temp)  { temp = m[t]; }\n #else\n \t#define sha1_load(m, t, temp)  { temp = m[t]; sha1_bswap32(temp); }\n-#endif /* !defined(SHA1DC_BIGENDIAN) */\n+#endif\n \n #define sha1_store(W, t, x)\t*(volatile uint32_t *)&W[t] = x\n \n@@ -869,6 +897,11 @@ static void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], co\n \tihvout[0] = ihvin[0] + a; ihvout[1] = ihvin[1] + b; ihvout[2] = ihvin[2] + c; ihvout[3] = ihvin[3] + d; ihvout[4] = ihvin[4] + e; \\\n }\n \n+#ifdef _MSC_VER\n+#pragma warning(push)\n+#pragma warning(disable: 4127)  /* Complier complains about the checks in the above macro being constant. */\n+#endif\n+\n #ifdef DOSTORESTATE0\n SHA1_RECOMPRESS(0)\n #endif\n@@ -1189,6 +1222,10 @@ SHA1_RECOMPRESS(78)\n SHA1_RECOMPRESS(79)\n #endif\n \n+#ifdef _MSC_VER\n+#pragma warning(pop)\n+#endif\n+\n static void sha1_recompression_step(uint32_t step, uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5])\n {\n \tswitch (step)\n@@ -1606,7 +1643,7 @@ static void sha1_process(SHA1_CTX* ctx, const uint32_t block[16])\n \tunsigned i, j;\n \tuint32_t ubc_dv_mask[DVMASKSIZE] = { 0xFFFFFFFF };\n \tuint32_t ihvtmp[5];\n-\n+\t\n \tctx->ihv1[0] = ctx->ihv[0];\n \tctx->ihv1[1] = ctx->ihv[1];\n \tctx->ihv1[2] = ctx->ihv[2];\n@@ -1662,7 +1699,7 @@ void SHA1DCInit(SHA1_CTX* ctx)\n \tctx->ihv[3] = 0x10325476;\n \tctx->ihv[4] = 0xC3D2E1F0;\n \tctx->found_collision = 0;\n-\tctx->safe_hash = 0;\n+\tctx->safe_hash = SHA1DC_INIT_SAFE_HASH_DEFAULT;\n \tctx->ubc_check = 1;\n \tctx->detect_coll = 1;\n \tctx->reduced_round_coll = 0;\n@@ -1710,6 +1747,9 @@ void SHA1DCSetCallback(SHA1_CTX* ctx, collision_block_callback callback)\n void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len)\n {\n \tunsigned left, fill;\n+\n+    const uint32_t* buffer_to_hash = NULL;\n+\n \tif (len == 0)\n \t\treturn;\n \n@@ -1728,7 +1768,14 @@ void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len)\n \twhile (len >= 64)\n \t{\n \t\tctx->total += 64;\n-\t\tsha1_process(ctx, (uint32_t*)(buf));\n+\n+#if defined(SHA1DC_ALLOW_UNALIGNED_ACCESS)\n+        buffer_to_hash = (const uint32_t*)buf;\n+#else\n+        buffer_to_hash = (const uint32_t*)ctx->buffer;\n+        memcpy(ctx->buffer, buf, 64);\n+#endif /* defined(SHA1DC_ALLOW_UNALIGNED_ACCESS) */\n+\t\tsha1_process(ctx, buffer_to_hash);\n \t\tbuf += 64;\n \t\tlen -= 64;\n \t}\n@@ -1788,22 +1835,6 @@ int SHA1DCFinal(unsigned char output[20], SHA1_CTX *ctx)\n \treturn ctx->found_collision;\n }\n \n-void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n-{\n-\tif (!SHA1DCFinal(hash, ctx))\n-\t\treturn;\n-\tdie(\"SHA-1 appears to be part of a collision attack: %s\",\n-\t    sha1_to_hex(hash));\n-}\n-\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n-{\n-\tconst char *data = vdata;\n-\t/* We expect an unsigned long, but sha1dc only takes an int */\n-\twhile (len > INT_MAX) {\n-\t\tSHA1DCUpdate(ctx, data, INT_MAX);\n-\t\tdata += INT_MAX;\n-\t\tlen -= INT_MAX;\n-\t}\n-\tSHA1DCUpdate(ctx, data, len);\n-}\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C\n+#endif\ndiff --git a/sha1dc/sha1.h b/sha1dc/sha1.h\nindex bd8bd928fb..dd41b0a5a6 100644\n--- a/sha1dc/sha1.h\n+++ b/sha1dc/sha1.h\n@@ -4,6 +4,7 @@\n * See accompanying file LICENSE.txt or copy at\n * https://opensource.org/licenses/MIT\n ***/\n+\n #ifndef SHA1DC_SHA1_H\n #define SHA1DC_SHA1_H\n \n@@ -11,36 +12,30 @@\n extern \"C\" {\n #endif\n \n-/* uses SHA-1 message expansion to expand the first 16 words of W[] to 80 words */\n-/* void sha1_message_expansion(uint32_t W[80]); */\n-\n-/* sha-1 compression function; first version takes a message block pre-parsed as 16 32-bit integers, second version takes an already expanded message) */\n-/* void sha1_compression(uint32_t ihv[5], const uint32_t m[16]);\n-void sha1_compression_W(uint32_t ihv[5], const uint32_t W[80]); */\n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <stdint.h>\n+#endif\n \n-/* same as sha1_compression_W, but additionally store intermediate states */\n+/* sha-1 compression function that takes an already expanded message, and additionally store intermediate states */\n /* only stores states ii (the state between step ii-1 and step ii) when DOSTORESTATEii is defined in ubc_check.h */\n void sha1_compression_states(uint32_t[5], const uint32_t[16], uint32_t[80], uint32_t[80][5]);\n \n /*\n-// function type for sha1_recompression_step_T (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5])\n-// where 0 <= T < 80\n-//       me2 is an expanded message (the expansion of an original message block XOR'ed with a disturbance vector's message block difference)\n-//       state is the internal state (a,b,c,d,e) before step T of the SHA-1 compression function while processing the original message block\n-// the function will return:\n-//       ihvin: the reconstructed input chaining value\n-//       ihvout: the reconstructed output chaining value\n+// Function type for sha1_recompression_step_T (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]).\n+// Where 0 <= T < 80\n+//       me2 is an expanded message (the expansion of an original message block XOR'ed with a disturbance vector's message block difference.)\n+//       state is the internal state (a,b,c,d,e) before step T of the SHA-1 compression function while processing the original message block.\n+// The function will return:\n+//       ihvin: The reconstructed input chaining value.\n+//       ihvout: The reconstructed output chaining value.\n */\n typedef void(*sha1_recompression_type)(uint32_t*, uint32_t*, const uint32_t*, const uint32_t*);\n \n-/* table of sha1_recompression_step_0, ... , sha1_recompression_step_79 */\n-/* extern sha1_recompression_type sha1_recompression_step[80];*/\n-\n-/* a callback function type that can be set to be called when a collision block has been found: */\n+/* A callback function type that can be set to be called when a collision block has been found: */\n /* void collision_block_callback(uint64_t byteoffset, const uint32_t ihvin1[5], const uint32_t ihvin2[5], const uint32_t m1[80], const uint32_t m2[80]) */\n typedef void(*collision_block_callback)(uint64_t, const uint32_t*, const uint32_t*, const uint32_t*, const uint32_t*);\n \n-/* the SHA-1 context */\n+/* The SHA-1 context. */\n typedef struct {\n \tuint64_t total;\n \tuint32_t ihv[5];\n@@ -59,30 +54,34 @@ typedef struct {\n \tuint32_t states[80][5];\n } SHA1_CTX;\n \n-/* initialize SHA-1 context */\n+/* Initialize SHA-1 context. */\n void SHA1DCInit(SHA1_CTX*);\n \n /*\n-// function to enable safe SHA-1 hashing:\n-// collision attacks are thwarted by hashing a detected near-collision block 3 times\n-// think of it as extending SHA-1 from 80-steps to 240-steps for such blocks:\n-//   the best collision attacks against SHA-1 have complexity about 2^60,\n-//   thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would 2^180\n-//   an attacker would be better off using a generic birthday search of complexity 2^80\n-//\n-// enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected\n-// but it will result in a different SHA-1 hash for messages where a collision attack was detected\n-// this will automatically invalidate SHA-1 based digital signature forgeries\n-// enabled by default\n+    Function to enable safe SHA-1 hashing:\n+    Collision attacks are thwarted by hashing a detected near-collision block 3 times.\n+    Think of it as extending SHA-1 from 80-steps to 240-steps for such blocks:\n+        The best collision attacks against SHA-1 have complexity about 2^60,\n+        thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would be 2^180.\n+        An attacker would be better off using a generic birthday search of complexity 2^80.\n+  \n+   Enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected,\n+   but it will result in a different SHA-1 hash for messages where a collision attack was detected.\n+   This will automatically invalidate SHA-1 based digital signature forgeries.\n+   Enabled by default.\n */\n void SHA1DCSetSafeHash(SHA1_CTX*, int);\n \n-/* function to disable or enable the use of Unavoidable Bitconditions (provides a significant speed up) */\n-/* enabled by default */\n+/*\n+    Function to disable or enable the use of Unavoidable Bitconditions (provides a significant speed up).\n+    Enabled by default\n+ */\n void SHA1DCSetUseUBC(SHA1_CTX*, int);\n \n-/* function to disable or enable the use of Collision Detection */\n-/* enabled by default */\n+/*\n+    Function to disable or enable the use of Collision Detection.\n+    Enabled by default.\n+ */\n void SHA1DCSetUseDetectColl(SHA1_CTX*, int);\n \n /* function to disable or enable the detection of reduced-round SHA-1 collisions */\n@@ -98,25 +97,14 @@ void SHA1DCUpdate(SHA1_CTX*, const char*, size_t);\n \n /* obtain SHA-1 hash from SHA-1 context */\n /* returns: 0 = no collision detected, otherwise = collision found => warn user for active attack */\n-int  SHA1DCFinal(unsigned char[20], SHA1_CTX*);\n-\n-/*\n- * Same as SHA1DCFinal, but convert collision attack case into a verbose die().\n- */\n-void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n-\n-/*\n- * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n- */\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n-\n-#define platform_SHA_CTX SHA1_CTX\n-#define platform_SHA1_Init SHA1DCInit\n-#define platform_SHA1_Update git_SHA1DCUpdate\n-#define platform_SHA1_Final git_SHA1DCFinal\n+int  SHA1DCFinal(unsigned char[20], SHA1_CTX*); \n \n #if defined(__cplusplus)\n }\n #endif\n \n-#endif /* SHA1DC_SHA1_H */\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H\n+#endif\n+\n+#endif\ndiff --git a/sha1dc/ubc_check.c b/sha1dc/ubc_check.c\nindex 089dd4743d..b3beff2afb 100644\n--- a/sha1dc/ubc_check.c\n+++ b/sha1dc/ubc_check.c\n@@ -24,8 +24,13 @@\n // ubc_check has been verified against ubc_check_verify using the 'ubc_check_test' program in the tools section\n */\n \n-#include \"git-compat-util.h\"\n-#include \"sha1dc/ubc_check.h\"\n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <stdint.h>\n+#endif\n+#ifdef SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C\n+#include SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C\n+#endif\n+#include \"ubc_check.h\"\n \n static const uint32_t DV_I_43_0_bit \t= (uint32_t)(1) << 0;\n static const uint32_t DV_I_44_0_bit \t= (uint32_t)(1) << 1;\n@@ -361,3 +366,7 @@ if (mask) {\n \n \tdvmask[0]=mask;\n }\n+\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C\n+#endif\ndiff --git a/sha1dc/ubc_check.h b/sha1dc/ubc_check.h\nindex b64c306d77..d7e17dc734 100644\n--- a/sha1dc/ubc_check.h\n+++ b/sha1dc/ubc_check.h\n@@ -20,13 +20,17 @@\n // thus one needs to do the recompression check for each DV that has its bit set\n */\n \n-#ifndef UBC_CHECK_H\n-#define UBC_CHECK_H\n+#ifndef SHA1DC_UBC_CHECK_H\n+#define SHA1DC_UBC_CHECK_H\n \n #if defined(__cplusplus)\n extern \"C\" {\n #endif\n \n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <stdint.h>\n+#endif\n+\n #define DVMASKSIZE 1\n typedef struct { int dvType; int dvK; int dvB; int testt; int maski; int maskb; uint32_t dm[80]; } dv_info_t;\n extern dv_info_t sha1_dvs[];\n@@ -41,4 +45,8 @@ void ubc_check(const uint32_t W[80], uint32_t dvmask[DVMASKSIZE]);\n }\n #endif\n \n-#endif /* UBC_CHECK_H */\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H\n+#endif\n+\n+#endif\ndiff --git a/sha1dc_git.c b/sha1dc_git.c\nnew file mode 100644\nindex 0000000000..4d32b4f77e\n--- /dev/null\n+++ b/sha1dc_git.c\n@@ -0,0 +1,24 @@\n+/*\n+ * This code is included at the end of sha1dc/sha1.c with the\n+ * SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C macro.\n+ */\n+\n+void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n+{\n+\tif (!SHA1DCFinal(hash, ctx))\n+\t\treturn;\n+\tdie(\"SHA-1 appears to be part of a collision attack: %s\",\n+\t    sha1_to_hex(hash));\n+}\n+\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n+{\n+\tconst char *data = vdata;\n+\t/* We expect an unsigned long, but sha1dc only takes an int */\n+\twhile (len > INT_MAX) {\n+\t\tSHA1DCUpdate(ctx, data, INT_MAX);\n+\t\tdata += INT_MAX;\n+\t\tlen -= INT_MAX;\n+\t}\n+\tSHA1DCUpdate(ctx, data, len);\n+}\ndiff --git a/sha1dc_git.h b/sha1dc_git.h\nnew file mode 100644\nindex 0000000000..a8a5c1da16\n--- /dev/null\n+++ b/sha1dc_git.h\n@@ -0,0 +1,19 @@\n+/*\n+ * This code is included at the end of sha1dc/sha1.h with the\n+ * SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H macro.\n+ */\n+\n+/*\n+ * Same as SHA1DCFinal, but convert collision attack case into a verbose die().\n+ */\n+void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n+\n+/*\n+ * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n+ */\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n+\n+#define platform_SHA_CTX SHA1_CTX\n+#define platform_SHA1_Init SHA1DCInit\n+#define platform_SHA1_Update git_SHA1DCUpdate\n+#define platform_SHA1_Final git_SHA1DCFinal\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320215","messageId":"20170518212858.3649-3-avarab@gmail.com","threadId":"45998","inReplyTo":"20170518212858.3649-1-avarab@gmail.com","subject":"[PATCH 2/3] sha1dc: use sha1collisiondetection as a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-18T21:28:57Z","receivedAt":"2017-05-18T21:29:29Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Replace the forked sha1dc directory with a copy of the upstream code\nimported as a submodule. This is the exact same code as now exists in\nthe sha1dc/ directory.\n\nThe initial reason for copy/pasting the code into sha1dc and locally\nmodifying it was that it needed to be altered to work with the git\nproject.\n\nThe upstream project has accepted my code changes to allow us to use\ntheir code as-is, see the preceding commit for details. So import the\ncode as a submodule instead, this will make it easier to keep\nup-to-date with any upstream fixes or improvements.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n .gitmodules            | 4 ++++\n Makefile               | 4 ++--\n hash.h                 | 2 +-\n sha1collisiondetection | 1 +\n 4 files changed, 8 insertions(+), 3 deletions(-)\n create mode 100644 .gitmodules\n create mode 160000 sha1collisiondetection\n\ndiff --git a/.gitmodules b/.gitmodules\nnew file mode 100644\nindex 0000000000..cbeebdab7a\n--- /dev/null\n+++ b/.gitmodules\n@@ -0,0 +1,4 @@\n+[submodule \"sha1collisiondetection\"]\n+\tpath = sha1collisiondetection\n+\turl = https://github.com/cr-marcstevens/sha1collisiondetection.git\n+\tbranch = master\ndiff --git a/Makefile b/Makefile\nindex ffa6da71b7..d7f506e790 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1412,8 +1412,8 @@ ifdef APPLE_COMMON_CRYPTO\n \tBASIC_CFLAGS += -DSHA1_APPLE\n else\n \tDC_SHA1 := YesPlease\n-\tLIB_OBJS += sha1dc/sha1.o\n-\tLIB_OBJS += sha1dc/ubc_check.o\n+\tLIB_OBJS += sha1collisiondetection/lib/sha1.o\n+\tLIB_OBJS += sha1collisiondetection/lib/ubc_check.o\n \tBASIC_CFLAGS += \\\n \t\t-DSHA1_DC \\\n \t\t-DSHA1DC_NO_STANDARD_INCLUDES \\\ndiff --git a/hash.h b/hash.h\nindex a11fc9233f..9d9892ac3e 100644\n--- a/hash.h\n+++ b/hash.h\n@@ -8,7 +8,7 @@\n #elif defined(SHA1_OPENSSL)\n #include <openssl/sha.h>\n #elif defined(SHA1_DC)\n-#include \"sha1dc/sha1.h\"\n+#include \"sha1collisiondetection/lib/sha1.h\"\n #else /* SHA1_BLK */\n #include \"block-sha1/sha1.h\"\n #endif\ndiff --git a/sha1collisiondetection b/sha1collisiondetection\nnew file mode 160000\nindex 0000000000..b45fcefc71\n--- /dev/null\n+++ b/sha1collisiondetection\n@@ -0,0 +1 @@\n+Subproject commit b45fcefc71270d9a159028c22e6d36c3817da188\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320216","messageId":"20170518212858.3649-4-avarab@gmail.com","threadId":"45998","inReplyTo":"20170518212858.3649-1-avarab@gmail.com","subject":"[PATCH 3/3] sha1dc: remove the unused sha1dc/ directory","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-18T21:28:58Z","receivedAt":"2017-05-18T21:29:32Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This has been made obsolete by the sha1collisiondetection\nsubmodule. See the preceding change for details.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n sha1dc/LICENSE.txt |  30 -----\n sha1dc/sha1.h      | 110 ----------------\n sha1dc/ubc_check.c | 372 -----------------------------------------------------\n sha1dc/ubc_check.h |  52 --------\n 4 files changed, 564 deletions(-)\n delete mode 100644 sha1dc/LICENSE.txt\n delete mode 100644 sha1dc/sha1.h\n delete mode 100644 sha1dc/ubc_check.c\n delete mode 100644 sha1dc/ubc_check.h\n\ndiff --git a/sha1dc/LICENSE.txt b/sha1dc/LICENSE.txt\ndeleted file mode 100644\nindex 4a3e6a1b15..0000000000\n--- a/sha1dc/LICENSE.txt\n+++ /dev/null\n@@ -1,30 +0,0 @@\n-MIT License\n-\n-Copyright (c) 2017:\n-    Marc Stevens\n-    Cryptology Group\n-    Centrum Wiskunde & Informatica\n-    P.O. Box 94079, 1090 GB Amsterdam, Netherlands\n-    marc@marc-stevens.nl\n-\n-    Dan Shumow\n-    Microsoft Research\n-    danshu@microsoft.com\n-\n-Permission is hereby granted, free of charge, to any person obtaining a copy\n-of this software and associated documentation files (the \"Software\"), to deal\n-in the Software without restriction, including without limitation the rights\n-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n-copies of the Software, and to permit persons to whom the Software is\n-furnished to do so, subject to the following conditions:\n-\n-The above copyright notice and this permission notice shall be included in all\n-copies or substantial portions of the Software.\n-\n-THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n-SOFTWARE.\ndiff --git a/sha1dc/sha1.h b/sha1dc/sha1.h\ndeleted file mode 100644\nindex dd41b0a5a6..0000000000\n--- a/sha1dc/sha1.h\n+++ /dev/null\n@@ -1,110 +0,0 @@\n-/***\n-* Copyright 2017 Marc Stevens <marc@marc-stevens.nl>, Dan Shumow <danshu@microsoft.com>\n-* Distributed under the MIT Software License.\n-* See accompanying file LICENSE.txt or copy at\n-* https://opensource.org/licenses/MIT\n-***/\n-\n-#ifndef SHA1DC_SHA1_H\n-#define SHA1DC_SHA1_H\n-\n-#if defined(__cplusplus)\n-extern \"C\" {\n-#endif\n-\n-#ifndef SHA1DC_NO_STANDARD_INCLUDES\n-#include <stdint.h>\n-#endif\n-\n-/* sha-1 compression function that takes an already expanded message, and additionally store intermediate states */\n-/* only stores states ii (the state between step ii-1 and step ii) when DOSTORESTATEii is defined in ubc_check.h */\n-void sha1_compression_states(uint32_t[5], const uint32_t[16], uint32_t[80], uint32_t[80][5]);\n-\n-/*\n-// Function type for sha1_recompression_step_T (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]).\n-// Where 0 <= T < 80\n-//       me2 is an expanded message (the expansion of an original message block XOR'ed with a disturbance vector's message block difference.)\n-//       state is the internal state (a,b,c,d,e) before step T of the SHA-1 compression function while processing the original message block.\n-// The function will return:\n-//       ihvin: The reconstructed input chaining value.\n-//       ihvout: The reconstructed output chaining value.\n-*/\n-typedef void(*sha1_recompression_type)(uint32_t*, uint32_t*, const uint32_t*, const uint32_t*);\n-\n-/* A callback function type that can be set to be called when a collision block has been found: */\n-/* void collision_block_callback(uint64_t byteoffset, const uint32_t ihvin1[5], const uint32_t ihvin2[5], const uint32_t m1[80], const uint32_t m2[80]) */\n-typedef void(*collision_block_callback)(uint64_t, const uint32_t*, const uint32_t*, const uint32_t*, const uint32_t*);\n-\n-/* The SHA-1 context. */\n-typedef struct {\n-\tuint64_t total;\n-\tuint32_t ihv[5];\n-\tunsigned char buffer[64];\n-\tint found_collision;\n-\tint safe_hash;\n-\tint detect_coll;\n-\tint ubc_check;\n-\tint reduced_round_coll;\n-\tcollision_block_callback callback;\n-\n-\tuint32_t ihv1[5];\n-\tuint32_t ihv2[5];\n-\tuint32_t m1[80];\n-\tuint32_t m2[80];\n-\tuint32_t states[80][5];\n-} SHA1_CTX;\n-\n-/* Initialize SHA-1 context. */\n-void SHA1DCInit(SHA1_CTX*);\n-\n-/*\n-    Function to enable safe SHA-1 hashing:\n-    Collision attacks are thwarted by hashing a detected near-collision block 3 times.\n-    Think of it as extending SHA-1 from 80-steps to 240-steps for such blocks:\n-        The best collision attacks against SHA-1 have complexity about 2^60,\n-        thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would be 2^180.\n-        An attacker would be better off using a generic birthday search of complexity 2^80.\n-  \n-   Enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected,\n-   but it will result in a different SHA-1 hash for messages where a collision attack was detected.\n-   This will automatically invalidate SHA-1 based digital signature forgeries.\n-   Enabled by default.\n-*/\n-void SHA1DCSetSafeHash(SHA1_CTX*, int);\n-\n-/*\n-    Function to disable or enable the use of Unavoidable Bitconditions (provides a significant speed up).\n-    Enabled by default\n- */\n-void SHA1DCSetUseUBC(SHA1_CTX*, int);\n-\n-/*\n-    Function to disable or enable the use of Collision Detection.\n-    Enabled by default.\n- */\n-void SHA1DCSetUseDetectColl(SHA1_CTX*, int);\n-\n-/* function to disable or enable the detection of reduced-round SHA-1 collisions */\n-/* disabled by default */\n-void SHA1DCSetDetectReducedRoundCollision(SHA1_CTX*, int);\n-\n-/* function to set a callback function, pass NULL to disable */\n-/* by default no callback set */\n-void SHA1DCSetCallback(SHA1_CTX*, collision_block_callback);\n-\n-/* update SHA-1 context with buffer contents */\n-void SHA1DCUpdate(SHA1_CTX*, const char*, size_t);\n-\n-/* obtain SHA-1 hash from SHA-1 context */\n-/* returns: 0 = no collision detected, otherwise = collision found => warn user for active attack */\n-int  SHA1DCFinal(unsigned char[20], SHA1_CTX*); \n-\n-#if defined(__cplusplus)\n-}\n-#endif\n-\n-#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H\n-#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H\n-#endif\n-\n-#endif\ndiff --git a/sha1dc/ubc_check.c b/sha1dc/ubc_check.c\ndeleted file mode 100644\nindex b3beff2afb..0000000000\n--- a/sha1dc/ubc_check.c\n+++ /dev/null\n@@ -1,372 +0,0 @@\n-/***\n-* Copyright 2017 Marc Stevens <marc@marc-stevens.nl>, Dan Shumow <danshu@microsoft.com>\n-* Distributed under the MIT Software License.\n-* See accompanying file LICENSE.txt or copy at\n-* https://opensource.org/licenses/MIT\n-***/\n-\n-/*\n-// this file was generated by the 'parse_bitrel' program in the tools section\n-// using the data files from directory 'tools/data/3565'\n-//\n-// sha1_dvs contains a list of SHA-1 Disturbance Vectors (DV) to check\n-// dvType, dvK and dvB define the DV: I(K,B) or II(K,B) (see the paper)\n-// dm[80] is the expanded message block XOR-difference defined by the DV\n-// testt is the step to do the recompression from for collision detection\n-// maski and maskb define the bit to check for each DV in the dvmask returned by ubc_check\n-//\n-// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs\n-// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met\n-// thus one needs to do the recompression check for each DV that has its bit set\n-//\n-// ubc_check is programmatically generated and the unavoidable bitconditions have been hardcoded\n-// a directly verifiable version named ubc_check_verify can be found in ubc_check_verify.c\n-// ubc_check has been verified against ubc_check_verify using the 'ubc_check_test' program in the tools section\n-*/\n-\n-#ifndef SHA1DC_NO_STANDARD_INCLUDES\n-#include <stdint.h>\n-#endif\n-#ifdef SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C\n-#include SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C\n-#endif\n-#include \"ubc_check.h\"\n-\n-static const uint32_t DV_I_43_0_bit \t= (uint32_t)(1) << 0;\n-static const uint32_t DV_I_44_0_bit \t= (uint32_t)(1) << 1;\n-static const uint32_t DV_I_45_0_bit \t= (uint32_t)(1) << 2;\n-static const uint32_t DV_I_46_0_bit \t= (uint32_t)(1) << 3;\n-static const uint32_t DV_I_46_2_bit \t= (uint32_t)(1) << 4;\n-static const uint32_t DV_I_47_0_bit \t= (uint32_t)(1) << 5;\n-static const uint32_t DV_I_47_2_bit \t= (uint32_t)(1) << 6;\n-static const uint32_t DV_I_48_0_bit \t= (uint32_t)(1) << 7;\n-static const uint32_t DV_I_48_2_bit \t= (uint32_t)(1) << 8;\n-static const uint32_t DV_I_49_0_bit \t= (uint32_t)(1) << 9;\n-static const uint32_t DV_I_49_2_bit \t= (uint32_t)(1) << 10;\n-static const uint32_t DV_I_50_0_bit \t= (uint32_t)(1) << 11;\n-static const uint32_t DV_I_50_2_bit \t= (uint32_t)(1) << 12;\n-static const uint32_t DV_I_51_0_bit \t= (uint32_t)(1) << 13;\n-static const uint32_t DV_I_51_2_bit \t= (uint32_t)(1) << 14;\n-static const uint32_t DV_I_52_0_bit \t= (uint32_t)(1) << 15;\n-static const uint32_t DV_II_45_0_bit \t= (uint32_t)(1) << 16;\n-static const uint32_t DV_II_46_0_bit \t= (uint32_t)(1) << 17;\n-static const uint32_t DV_II_46_2_bit \t= (uint32_t)(1) << 18;\n-static const uint32_t DV_II_47_0_bit \t= (uint32_t)(1) << 19;\n-static const uint32_t DV_II_48_0_bit \t= (uint32_t)(1) << 20;\n-static const uint32_t DV_II_49_0_bit \t= (uint32_t)(1) << 21;\n-static const uint32_t DV_II_49_2_bit \t= (uint32_t)(1) << 22;\n-static const uint32_t DV_II_50_0_bit \t= (uint32_t)(1) << 23;\n-static const uint32_t DV_II_50_2_bit \t= (uint32_t)(1) << 24;\n-static const uint32_t DV_II_51_0_bit \t= (uint32_t)(1) << 25;\n-static const uint32_t DV_II_51_2_bit \t= (uint32_t)(1) << 26;\n-static const uint32_t DV_II_52_0_bit \t= (uint32_t)(1) << 27;\n-static const uint32_t DV_II_53_0_bit \t= (uint32_t)(1) << 28;\n-static const uint32_t DV_II_54_0_bit \t= (uint32_t)(1) << 29;\n-static const uint32_t DV_II_55_0_bit \t= (uint32_t)(1) << 30;\n-static const uint32_t DV_II_56_0_bit \t= (uint32_t)(1) << 31;\n-\n-dv_info_t sha1_dvs[] =\n-{\n-  {1,43,0,58,0,0, { 0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803,0x80000161,0x80000599 } }\n-, {1,44,0,58,0,1, { 0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803,0x80000161 } }\n-, {1,45,0,58,0,2, { 0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c,0x00000803 } }\n-, {1,46,0,58,0,3, { 0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6,0x8000004c } }\n-, {1,46,2,58,0,4, { 0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590,0x00001020,0x0000039a,0x00000132 } }\n-, {1,47,0,58,0,5, { 0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408,0x800000e6 } }\n-, {1,47,2,58,0,6, { 0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590,0x00001020,0x0000039a } }\n-, {1,48,0,58,0,7, { 0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164,0x00000408 } }\n-, {1,48,2,58,0,8, { 0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590,0x00001020 } }\n-, {1,49,0,58,0,9, { 0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018,0x00000164 } }\n-, {1,49,2,58,0,10, { 0x60000000,0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060,0x00000590 } }\n-, {1,50,0,65,0,11, { 0x0800000c,0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202,0x00000018 } }\n-, {1,50,2,65,0,12, { 0x20000030,0x60000000,0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a,0x00000060 } }\n-, {1,51,0,65,0,13, { 0xe8000000,0x0800000c,0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012,0x80000202 } }\n-, {1,51,2,65,0,14, { 0xa0000003,0x20000030,0x60000000,0xe000002a,0x20000043,0xb0000040,0xd0000053,0xd0000022,0x20000000,0x60000032,0x60000043,0x20000040,0xe0000042,0x60000002,0x80000001,0x00000020,0x00000003,0x40000052,0x40000040,0xe0000052,0xa0000000,0x80000040,0x20000001,0x20000060,0x80000001,0x40000042,0xc0000043,0x40000022,0x00000003,0x40000042,0xc0000043,0xc0000022,0x00000001,0x40000002,0xc0000043,0x40000062,0x80000001,0x40000042,0x40000042,0x40000002,0x00000002,0x00000040,0x80000002,0x80000000,0x80000002,0x80000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000000,0x00000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000101,0x00000009,0x00000012,0x00000202,0x0000001a,0x00000124,0x0000040c,0x00000026,0x0000004a,0x0000080a } }\n-, {1,52,0,65,0,15, { 0x04000010,0xe8000000,0x0800000c,0x18000000,0xb800000a,0xc8000010,0x2c000010,0xf4000014,0xb4000008,0x08000000,0x9800000c,0xd8000010,0x08000010,0xb8000010,0x98000000,0x60000000,0x00000008,0xc0000000,0x90000014,0x10000010,0xb8000014,0x28000000,0x20000010,0x48000000,0x08000018,0x60000000,0x90000010,0xf0000010,0x90000008,0xc0000000,0x90000010,0xf0000010,0xb0000008,0x40000000,0x90000000,0xf0000010,0x90000018,0x60000000,0x90000010,0x90000010,0x90000000,0x80000000,0x00000010,0xa0000000,0x20000000,0xa0000000,0x20000010,0x00000000,0x20000010,0x20000000,0x00000010,0x20000000,0x00000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000040,0x40000002,0x80000004,0x80000080,0x80000006,0x00000049,0x00000103,0x80000009,0x80000012 } }\n-, {2,45,0,58,0,16, { 0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a,0x000002e4,0x80000054,0x00000967 } }\n-, {2,46,0,58,0,17, { 0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a,0x000002e4,0x80000054 } }\n-, {2,46,2,58,0,18, { 0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e,0x0000046c,0x000005b6,0x0000106a,0x00000b90,0x00000152 } }\n-, {2,47,0,58,0,19, { 0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a,0x000002e4 } }\n-, {2,48,0,58,0,20, { 0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d,0x8000041a } }\n-, {2,49,0,58,0,21, { 0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b,0x8000016d } }\n-, {2,49,2,58,0,22, { 0xf0000010,0xf000006a,0x80000040,0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e,0x0000046c,0x000005b6 } }\n-, {2,50,0,65,0,23, { 0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b,0x0000011b } }\n-, {2,50,2,65,0,24, { 0xd0000072,0xf0000010,0xf000006a,0x80000040,0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e,0x0000046c } }\n-, {2,51,0,65,0,25, { 0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014,0x8000024b } }\n-, {2,51,2,65,0,26, { 0x00000043,0xd0000072,0xf0000010,0xf000006a,0x80000040,0x90000070,0xb0000053,0x30000008,0x00000043,0xd0000072,0xb0000010,0xf0000062,0xc0000042,0x00000030,0xe0000042,0x20000060,0xe0000041,0x20000050,0xc0000041,0xe0000072,0xa0000003,0xc0000012,0x60000041,0xc0000032,0x20000001,0xc0000002,0xe0000042,0x60000042,0x80000002,0x00000000,0x00000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000000,0x00000040,0x80000001,0x00000060,0x80000003,0x40000002,0xc0000040,0xc0000002,0x80000000,0x80000000,0x80000002,0x00000040,0x00000002,0x80000000,0x80000000,0x80000000,0x00000002,0x00000040,0x00000000,0x80000040,0x80000002,0x00000000,0x80000000,0x80000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000004,0x00000080,0x00000004,0x00000009,0x00000105,0x00000089,0x00000016,0x0000020b,0x0000011b,0x0000012d,0x0000041e,0x00000224,0x00000050,0x0000092e } }\n-, {2,52,0,65,0,27, { 0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089,0x00000014 } }\n-, {2,53,0,65,0,28, { 0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107,0x00000089 } }\n-, {2,54,0,65,0,29, { 0x0400001c,0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b,0x80000107 } }\n-, {2,55,0,65,0,30, { 0x00000010,0x0400001c,0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046,0x4000004b } }\n-, {2,56,0,65,0,31, { 0x2600001a,0x00000010,0x0400001c,0xcc000014,0x0c000002,0xc0000010,0xb400001c,0x3c000004,0xbc00001a,0x20000010,0x2400001c,0xec000014,0x0c000002,0xc0000010,0xb400001c,0x2c000004,0xbc000018,0xb0000010,0x0000000c,0xb8000010,0x08000018,0x78000010,0x08000014,0x70000010,0xb800001c,0xe8000000,0xb0000004,0x58000010,0xb000000c,0x48000000,0xb0000000,0xb8000010,0x98000010,0xa0000000,0x00000000,0x00000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0x20000000,0x00000010,0x60000000,0x00000018,0xe0000000,0x90000000,0x30000010,0xb0000000,0x20000000,0x20000000,0xa0000000,0x00000010,0x80000000,0x20000000,0x20000000,0x20000000,0x80000000,0x00000010,0x00000000,0x20000010,0xa0000000,0x00000000,0x20000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000001,0x00000020,0x00000001,0x40000002,0x40000041,0x40000022,0x80000005,0xc0000082,0xc0000046 } }\n-, {0,0,0,0,0,0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}\n-};\n-void ubc_check(const uint32_t W[80], uint32_t dvmask[1])\n-{\n-\tuint32_t mask = ~((uint32_t)(0));\n-\tmask &= (((((W[44]^W[45])>>29)&1)-1) | ~(DV_I_48_0_bit|DV_I_51_0_bit|DV_I_52_0_bit|DV_II_45_0_bit|DV_II_46_0_bit|DV_II_50_0_bit|DV_II_51_0_bit));\n-\tmask &= (((((W[49]^W[50])>>29)&1)-1) | ~(DV_I_46_0_bit|DV_II_45_0_bit|DV_II_50_0_bit|DV_II_51_0_bit|DV_II_55_0_bit|DV_II_56_0_bit));\n-\tmask &= (((((W[48]^W[49])>>29)&1)-1) | ~(DV_I_45_0_bit|DV_I_52_0_bit|DV_II_49_0_bit|DV_II_50_0_bit|DV_II_54_0_bit|DV_II_55_0_bit));\n-\tmask &= ((((W[47]^(W[50]>>25))&(1<<4))-(1<<4)) | ~(DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_51_0_bit|DV_II_56_0_bit));\n-\tmask &= (((((W[47]^W[48])>>29)&1)-1) | ~(DV_I_44_0_bit|DV_I_51_0_bit|DV_II_48_0_bit|DV_II_49_0_bit|DV_II_53_0_bit|DV_II_54_0_bit));\n-\tmask &= (((((W[46]>>4)^(W[49]>>29))&1)-1) | ~(DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit|DV_II_50_0_bit|DV_II_55_0_bit));\n-\tmask &= (((((W[46]^W[47])>>29)&1)-1) | ~(DV_I_43_0_bit|DV_I_50_0_bit|DV_II_47_0_bit|DV_II_48_0_bit|DV_II_52_0_bit|DV_II_53_0_bit));\n-\tmask &= (((((W[45]>>4)^(W[48]>>29))&1)-1) | ~(DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit|DV_II_49_0_bit|DV_II_54_0_bit));\n-\tmask &= (((((W[45]^W[46])>>29)&1)-1) | ~(DV_I_49_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_47_0_bit|DV_II_51_0_bit|DV_II_52_0_bit));\n-\tmask &= (((((W[44]>>4)^(W[47]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit|DV_II_48_0_bit|DV_II_53_0_bit));\n-\tmask &= (((((W[43]>>4)^(W[46]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit|DV_II_47_0_bit|DV_II_52_0_bit));\n-\tmask &= (((((W[43]^W[44])>>29)&1)-1) | ~(DV_I_47_0_bit|DV_I_50_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_49_0_bit|DV_II_50_0_bit));\n-\tmask &= (((((W[42]>>4)^(W[45]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_51_0_bit));\n-\tmask &= (((((W[41]>>4)^(W[44]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_50_0_bit));\n-\tmask &= (((((W[40]^W[41])>>29)&1)-1) | ~(DV_I_44_0_bit|DV_I_47_0_bit|DV_I_48_0_bit|DV_II_46_0_bit|DV_II_47_0_bit|DV_II_56_0_bit));\n-\tmask &= (((((W[54]^W[55])>>29)&1)-1) | ~(DV_I_51_0_bit|DV_II_47_0_bit|DV_II_50_0_bit|DV_II_55_0_bit|DV_II_56_0_bit));\n-\tmask &= (((((W[53]^W[54])>>29)&1)-1) | ~(DV_I_50_0_bit|DV_II_46_0_bit|DV_II_49_0_bit|DV_II_54_0_bit|DV_II_55_0_bit));\n-\tmask &= (((((W[52]^W[53])>>29)&1)-1) | ~(DV_I_49_0_bit|DV_II_45_0_bit|DV_II_48_0_bit|DV_II_53_0_bit|DV_II_54_0_bit));\n-\tmask &= ((((W[50]^(W[53]>>25))&(1<<4))-(1<<4)) | ~(DV_I_50_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_48_0_bit|DV_II_54_0_bit));\n-\tmask &= (((((W[50]^W[51])>>29)&1)-1) | ~(DV_I_47_0_bit|DV_II_46_0_bit|DV_II_51_0_bit|DV_II_52_0_bit|DV_II_56_0_bit));\n-\tmask &= ((((W[49]^(W[52]>>25))&(1<<4))-(1<<4)) | ~(DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit|DV_II_47_0_bit|DV_II_53_0_bit));\n-\tmask &= ((((W[48]^(W[51]>>25))&(1<<4))-(1<<4)) | ~(DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit|DV_II_46_0_bit|DV_II_52_0_bit));\n-\tmask &= (((((W[42]^W[43])>>29)&1)-1) | ~(DV_I_46_0_bit|DV_I_49_0_bit|DV_I_50_0_bit|DV_II_48_0_bit|DV_II_49_0_bit));\n-\tmask &= (((((W[41]^W[42])>>29)&1)-1) | ~(DV_I_45_0_bit|DV_I_48_0_bit|DV_I_49_0_bit|DV_II_47_0_bit|DV_II_48_0_bit));\n-\tmask &= (((((W[40]>>4)^(W[43]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_50_0_bit|DV_II_49_0_bit|DV_II_56_0_bit));\n-\tmask &= (((((W[39]>>4)^(W[42]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_49_0_bit|DV_II_48_0_bit|DV_II_55_0_bit));\n-\tif (mask & (DV_I_44_0_bit|DV_I_48_0_bit|DV_II_47_0_bit|DV_II_54_0_bit|DV_II_56_0_bit))\n-\t\tmask &= (((((W[38]>>4)^(W[41]>>29))&1)-1) | ~(DV_I_44_0_bit|DV_I_48_0_bit|DV_II_47_0_bit|DV_II_54_0_bit|DV_II_56_0_bit));\n-\tmask &= (((((W[37]>>4)^(W[40]>>29))&1)-1) | ~(DV_I_43_0_bit|DV_I_47_0_bit|DV_II_46_0_bit|DV_II_53_0_bit|DV_II_55_0_bit));\n-\tif (mask & (DV_I_52_0_bit|DV_II_48_0_bit|DV_II_51_0_bit|DV_II_56_0_bit))\n-\t\tmask &= (((((W[55]^W[56])>>29)&1)-1) | ~(DV_I_52_0_bit|DV_II_48_0_bit|DV_II_51_0_bit|DV_II_56_0_bit));\n-\tif (mask & (DV_I_52_0_bit|DV_II_48_0_bit|DV_II_50_0_bit|DV_II_56_0_bit))\n-\t\tmask &= ((((W[52]^(W[55]>>25))&(1<<4))-(1<<4)) | ~(DV_I_52_0_bit|DV_II_48_0_bit|DV_II_50_0_bit|DV_II_56_0_bit));\n-\tif (mask & (DV_I_51_0_bit|DV_II_47_0_bit|DV_II_49_0_bit|DV_II_55_0_bit))\n-\t\tmask &= ((((W[51]^(W[54]>>25))&(1<<4))-(1<<4)) | ~(DV_I_51_0_bit|DV_II_47_0_bit|DV_II_49_0_bit|DV_II_55_0_bit));\n-\tif (mask & (DV_I_48_0_bit|DV_II_47_0_bit|DV_II_52_0_bit|DV_II_53_0_bit))\n-\t\tmask &= (((((W[51]^W[52])>>29)&1)-1) | ~(DV_I_48_0_bit|DV_II_47_0_bit|DV_II_52_0_bit|DV_II_53_0_bit));\n-\tif (mask & (DV_I_46_0_bit|DV_I_49_0_bit|DV_II_45_0_bit|DV_II_48_0_bit))\n-\t\tmask &= (((((W[36]>>4)^(W[40]>>29))&1)-1) | ~(DV_I_46_0_bit|DV_I_49_0_bit|DV_II_45_0_bit|DV_II_48_0_bit));\n-\tif (mask & (DV_I_52_0_bit|DV_II_48_0_bit|DV_II_49_0_bit))\n-\t\tmask &= ((0-(((W[53]^W[56])>>29)&1)) | ~(DV_I_52_0_bit|DV_II_48_0_bit|DV_II_49_0_bit));\n-\tif (mask & (DV_I_50_0_bit|DV_II_46_0_bit|DV_II_47_0_bit))\n-\t\tmask &= ((0-(((W[51]^W[54])>>29)&1)) | ~(DV_I_50_0_bit|DV_II_46_0_bit|DV_II_47_0_bit));\n-\tif (mask & (DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit))\n-\t\tmask &= ((0-(((W[50]^W[52])>>29)&1)) | ~(DV_I_49_0_bit|DV_I_51_0_bit|DV_II_45_0_bit));\n-\tif (mask & (DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit))\n-\t\tmask &= ((0-(((W[49]^W[51])>>29)&1)) | ~(DV_I_48_0_bit|DV_I_50_0_bit|DV_I_52_0_bit));\n-\tif (mask & (DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit))\n-\t\tmask &= ((0-(((W[48]^W[50])>>29)&1)) | ~(DV_I_47_0_bit|DV_I_49_0_bit|DV_I_51_0_bit));\n-\tif (mask & (DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit))\n-\t\tmask &= ((0-(((W[47]^W[49])>>29)&1)) | ~(DV_I_46_0_bit|DV_I_48_0_bit|DV_I_50_0_bit));\n-\tif (mask & (DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit))\n-\t\tmask &= ((0-(((W[46]^W[48])>>29)&1)) | ~(DV_I_45_0_bit|DV_I_47_0_bit|DV_I_49_0_bit));\n-\tmask &= ((((W[45]^W[47])&(1<<6))-(1<<6)) | ~(DV_I_47_2_bit|DV_I_49_2_bit|DV_I_51_2_bit));\n-\tif (mask & (DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit))\n-\t\tmask &= ((0-(((W[45]^W[47])>>29)&1)) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_I_48_0_bit));\n-\tmask &= (((((W[44]^W[46])>>6)&1)-1) | ~(DV_I_46_2_bit|DV_I_48_2_bit|DV_I_50_2_bit));\n-\tif (mask & (DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit))\n-\t\tmask &= ((0-(((W[44]^W[46])>>29)&1)) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_I_47_0_bit));\n-\tmask &= ((0-((W[41]^(W[42]>>5))&(1<<1))) | ~(DV_I_48_2_bit|DV_II_46_2_bit|DV_II_51_2_bit));\n-\tmask &= ((0-((W[40]^(W[41]>>5))&(1<<1))) | ~(DV_I_47_2_bit|DV_I_51_2_bit|DV_II_50_2_bit));\n-\tif (mask & (DV_I_44_0_bit|DV_I_46_0_bit|DV_II_56_0_bit))\n-\t\tmask &= ((0-(((W[40]^W[42])>>4)&1)) | ~(DV_I_44_0_bit|DV_I_46_0_bit|DV_II_56_0_bit));\n-\tmask &= ((0-((W[39]^(W[40]>>5))&(1<<1))) | ~(DV_I_46_2_bit|DV_I_50_2_bit|DV_II_49_2_bit));\n-\tif (mask & (DV_I_43_0_bit|DV_I_45_0_bit|DV_II_55_0_bit))\n-\t\tmask &= ((0-(((W[39]^W[41])>>4)&1)) | ~(DV_I_43_0_bit|DV_I_45_0_bit|DV_II_55_0_bit));\n-\tif (mask & (DV_I_44_0_bit|DV_II_54_0_bit|DV_II_56_0_bit))\n-\t\tmask &= ((0-(((W[38]^W[40])>>4)&1)) | ~(DV_I_44_0_bit|DV_II_54_0_bit|DV_II_56_0_bit));\n-\tif (mask & (DV_I_43_0_bit|DV_II_53_0_bit|DV_II_55_0_bit))\n-\t\tmask &= ((0-(((W[37]^W[39])>>4)&1)) | ~(DV_I_43_0_bit|DV_II_53_0_bit|DV_II_55_0_bit));\n-\tmask &= ((0-((W[36]^(W[37]>>5))&(1<<1))) | ~(DV_I_47_2_bit|DV_I_50_2_bit|DV_II_46_2_bit));\n-\tif (mask & (DV_I_45_0_bit|DV_I_48_0_bit|DV_II_47_0_bit))\n-\t\tmask &= (((((W[35]>>4)^(W[39]>>29))&1)-1) | ~(DV_I_45_0_bit|DV_I_48_0_bit|DV_II_47_0_bit));\n-\tif (mask & (DV_I_48_0_bit|DV_II_48_0_bit))\n-\t\tmask &= ((0-((W[63]^(W[64]>>5))&(1<<0))) | ~(DV_I_48_0_bit|DV_II_48_0_bit));\n-\tif (mask & (DV_I_45_0_bit|DV_II_45_0_bit))\n-\t\tmask &= ((0-((W[63]^(W[64]>>5))&(1<<1))) | ~(DV_I_45_0_bit|DV_II_45_0_bit));\n-\tif (mask & (DV_I_47_0_bit|DV_II_47_0_bit))\n-\t\tmask &= ((0-((W[62]^(W[63]>>5))&(1<<0))) | ~(DV_I_47_0_bit|DV_II_47_0_bit));\n-\tif (mask & (DV_I_46_0_bit|DV_II_46_0_bit))\n-\t\tmask &= ((0-((W[61]^(W[62]>>5))&(1<<0))) | ~(DV_I_46_0_bit|DV_II_46_0_bit));\n-\tmask &= ((0-((W[61]^(W[62]>>5))&(1<<2))) | ~(DV_I_46_2_bit|DV_II_46_2_bit));\n-\tif (mask & (DV_I_45_0_bit|DV_II_45_0_bit))\n-\t\tmask &= ((0-((W[60]^(W[61]>>5))&(1<<0))) | ~(DV_I_45_0_bit|DV_II_45_0_bit));\n-\tif (mask & (DV_II_51_0_bit|DV_II_54_0_bit))\n-\t\tmask &= (((((W[58]^W[59])>>29)&1)-1) | ~(DV_II_51_0_bit|DV_II_54_0_bit));\n-\tif (mask & (DV_II_50_0_bit|DV_II_53_0_bit))\n-\t\tmask &= (((((W[57]^W[58])>>29)&1)-1) | ~(DV_II_50_0_bit|DV_II_53_0_bit));\n-\tif (mask & (DV_II_52_0_bit|DV_II_54_0_bit))\n-\t\tmask &= ((((W[56]^(W[59]>>25))&(1<<4))-(1<<4)) | ~(DV_II_52_0_bit|DV_II_54_0_bit));\n-\tif (mask & (DV_II_51_0_bit|DV_II_52_0_bit))\n-\t\tmask &= ((0-(((W[56]^W[59])>>29)&1)) | ~(DV_II_51_0_bit|DV_II_52_0_bit));\n-\tif (mask & (DV_II_49_0_bit|DV_II_52_0_bit))\n-\t\tmask &= (((((W[56]^W[57])>>29)&1)-1) | ~(DV_II_49_0_bit|DV_II_52_0_bit));\n-\tif (mask & (DV_II_51_0_bit|DV_II_53_0_bit))\n-\t\tmask &= ((((W[55]^(W[58]>>25))&(1<<4))-(1<<4)) | ~(DV_II_51_0_bit|DV_II_53_0_bit));\n-\tif (mask & (DV_II_50_0_bit|DV_II_52_0_bit))\n-\t\tmask &= ((((W[54]^(W[57]>>25))&(1<<4))-(1<<4)) | ~(DV_II_50_0_bit|DV_II_52_0_bit));\n-\tif (mask & (DV_II_49_0_bit|DV_II_51_0_bit))\n-\t\tmask &= ((((W[53]^(W[56]>>25))&(1<<4))-(1<<4)) | ~(DV_II_49_0_bit|DV_II_51_0_bit));\n-\tmask &= ((((W[51]^(W[50]>>5))&(1<<1))-(1<<1)) | ~(DV_I_50_2_bit|DV_II_46_2_bit));\n-\tmask &= ((((W[48]^W[50])&(1<<6))-(1<<6)) | ~(DV_I_50_2_bit|DV_II_46_2_bit));\n-\tif (mask & (DV_I_51_0_bit|DV_I_52_0_bit))\n-\t\tmask &= ((0-(((W[48]^W[55])>>29)&1)) | ~(DV_I_51_0_bit|DV_I_52_0_bit));\n-\tmask &= ((((W[47]^W[49])&(1<<6))-(1<<6)) | ~(DV_I_49_2_bit|DV_I_51_2_bit));\n-\tmask &= ((((W[48]^(W[47]>>5))&(1<<1))-(1<<1)) | ~(DV_I_47_2_bit|DV_II_51_2_bit));\n-\tmask &= ((((W[46]^W[48])&(1<<6))-(1<<6)) | ~(DV_I_48_2_bit|DV_I_50_2_bit));\n-\tmask &= ((((W[47]^(W[46]>>5))&(1<<1))-(1<<1)) | ~(DV_I_46_2_bit|DV_II_50_2_bit));\n-\tmask &= ((0-((W[44]^(W[45]>>5))&(1<<1))) | ~(DV_I_51_2_bit|DV_II_49_2_bit));\n-\tmask &= ((((W[43]^W[45])&(1<<6))-(1<<6)) | ~(DV_I_47_2_bit|DV_I_49_2_bit));\n-\tmask &= (((((W[42]^W[44])>>6)&1)-1) | ~(DV_I_46_2_bit|DV_I_48_2_bit));\n-\tmask &= ((((W[43]^(W[42]>>5))&(1<<1))-(1<<1)) | ~(DV_II_46_2_bit|DV_II_51_2_bit));\n-\tmask &= ((((W[42]^(W[41]>>5))&(1<<1))-(1<<1)) | ~(DV_I_51_2_bit|DV_II_50_2_bit));\n-\tmask &= ((((W[41]^(W[40]>>5))&(1<<1))-(1<<1)) | ~(DV_I_50_2_bit|DV_II_49_2_bit));\n-\tif (mask & (DV_I_52_0_bit|DV_II_51_0_bit))\n-\t\tmask &= ((((W[39]^(W[43]>>25))&(1<<4))-(1<<4)) | ~(DV_I_52_0_bit|DV_II_51_0_bit));\n-\tif (mask & (DV_I_51_0_bit|DV_II_50_0_bit))\n-\t\tmask &= ((((W[38]^(W[42]>>25))&(1<<4))-(1<<4)) | ~(DV_I_51_0_bit|DV_II_50_0_bit));\n-\tif (mask & (DV_I_48_2_bit|DV_I_51_2_bit))\n-\t\tmask &= ((0-((W[37]^(W[38]>>5))&(1<<1))) | ~(DV_I_48_2_bit|DV_I_51_2_bit));\n-\tif (mask & (DV_I_50_0_bit|DV_II_49_0_bit))\n-\t\tmask &= ((((W[37]^(W[41]>>25))&(1<<4))-(1<<4)) | ~(DV_I_50_0_bit|DV_II_49_0_bit));\n-\tif (mask & (DV_II_52_0_bit|DV_II_54_0_bit))\n-\t\tmask &= ((0-((W[36]^W[38])&(1<<4))) | ~(DV_II_52_0_bit|DV_II_54_0_bit));\n-\tmask &= ((0-((W[35]^(W[36]>>5))&(1<<1))) | ~(DV_I_46_2_bit|DV_I_49_2_bit));\n-\tif (mask & (DV_I_51_0_bit|DV_II_47_0_bit))\n-\t\tmask &= ((((W[35]^(W[39]>>25))&(1<<3))-(1<<3)) | ~(DV_I_51_0_bit|DV_II_47_0_bit));\n-if (mask) {\n-\n-\tif (mask & DV_I_43_0_bit)\n-\t\t if (\n-\t\t\t    !((W[61]^(W[62]>>5)) & (1<<1))\n-\t\t\t || !(!((W[59]^(W[63]>>25)) & (1<<5)))\n-\t\t\t || !((W[58]^(W[63]>>30)) & (1<<0))\n-\t\t )  mask &= ~DV_I_43_0_bit;\n-\tif (mask & DV_I_44_0_bit)\n-\t\t if (\n-\t\t\t    !((W[62]^(W[63]>>5)) & (1<<1))\n-\t\t\t || !(!((W[60]^(W[64]>>25)) & (1<<5)))\n-\t\t\t || !((W[59]^(W[64]>>30)) & (1<<0))\n-\t\t )  mask &= ~DV_I_44_0_bit;\n-\tif (mask & DV_I_46_2_bit)\n-\t\tmask &= ((~((W[40]^W[42])>>2)) | ~DV_I_46_2_bit);\n-\tif (mask & DV_I_47_2_bit)\n-\t\t if (\n-\t\t\t    !((W[62]^(W[63]>>5)) & (1<<2))\n-\t\t\t || !(!((W[41]^W[43]) & (1<<6)))\n-\t\t )  mask &= ~DV_I_47_2_bit;\n-\tif (mask & DV_I_48_2_bit)\n-\t\t if (\n-\t\t\t    !((W[63]^(W[64]>>5)) & (1<<2))\n-\t\t\t || !(!((W[48]^(W[49]<<5)) & (1<<6)))\n-\t\t )  mask &= ~DV_I_48_2_bit;\n-\tif (mask & DV_I_49_2_bit)\n-\t\t if (\n-\t\t\t    !(!((W[49]^(W[50]<<5)) & (1<<6)))\n-\t\t\t || !((W[42]^W[50]) & (1<<1))\n-\t\t\t || !(!((W[39]^(W[40]<<5)) & (1<<6)))\n-\t\t\t || !((W[38]^W[40]) & (1<<1))\n-\t\t )  mask &= ~DV_I_49_2_bit;\n-\tif (mask & DV_I_50_0_bit)\n-\t\tmask &= ((((W[36]^W[37])<<7)) | ~DV_I_50_0_bit);\n-\tif (mask & DV_I_50_2_bit)\n-\t\tmask &= ((((W[43]^W[51])<<11)) | ~DV_I_50_2_bit);\n-\tif (mask & DV_I_51_0_bit)\n-\t\tmask &= ((((W[37]^W[38])<<9)) | ~DV_I_51_0_bit);\n-\tif (mask & DV_I_51_2_bit)\n-\t\t if (\n-\t\t\t    !(!((W[51]^(W[52]<<5)) & (1<<6)))\n-\t\t\t || !(!((W[49]^W[51]) & (1<<6)))\n-\t\t\t || !(!((W[37]^(W[37]>>5)) & (1<<1)))\n-\t\t\t || !(!((W[35]^(W[39]>>25)) & (1<<5)))\n-\t\t )  mask &= ~DV_I_51_2_bit;\n-\tif (mask & DV_I_52_0_bit)\n-\t\tmask &= ((((W[38]^W[39])<<11)) | ~DV_I_52_0_bit);\n-\tif (mask & DV_II_46_2_bit)\n-\t\tmask &= ((((W[47]^W[51])<<17)) | ~DV_II_46_2_bit);\n-\tif (mask & DV_II_48_0_bit)\n-\t\t if (\n-\t\t\t    !(!((W[36]^(W[40]>>25)) & (1<<3)))\n-\t\t\t || !((W[35]^(W[40]<<2)) & (1<<30))\n-\t\t )  mask &= ~DV_II_48_0_bit;\n-\tif (mask & DV_II_49_0_bit)\n-\t\t if (\n-\t\t\t    !(!((W[37]^(W[41]>>25)) & (1<<3)))\n-\t\t\t || !((W[36]^(W[41]<<2)) & (1<<30))\n-\t\t )  mask &= ~DV_II_49_0_bit;\n-\tif (mask & DV_II_49_2_bit)\n-\t\t if (\n-\t\t\t    !(!((W[53]^(W[54]<<5)) & (1<<6)))\n-\t\t\t || !(!((W[51]^W[53]) & (1<<6)))\n-\t\t\t || !((W[50]^W[54]) & (1<<1))\n-\t\t\t || !(!((W[45]^(W[46]<<5)) & (1<<6)))\n-\t\t\t || !(!((W[37]^(W[41]>>25)) & (1<<5)))\n-\t\t\t || !((W[36]^(W[41]>>30)) & (1<<0))\n-\t\t )  mask &= ~DV_II_49_2_bit;\n-\tif (mask & DV_II_50_0_bit)\n-\t\t if (\n-\t\t\t    !((W[55]^W[58]) & (1<<29))\n-\t\t\t || !(!((W[38]^(W[42]>>25)) & (1<<3)))\n-\t\t\t || !((W[37]^(W[42]<<2)) & (1<<30))\n-\t\t )  mask &= ~DV_II_50_0_bit;\n-\tif (mask & DV_II_50_2_bit)\n-\t\t if (\n-\t\t\t    !(!((W[54]^(W[55]<<5)) & (1<<6)))\n-\t\t\t || !(!((W[52]^W[54]) & (1<<6)))\n-\t\t\t || !((W[51]^W[55]) & (1<<1))\n-\t\t\t || !((W[45]^W[47]) & (1<<1))\n-\t\t\t || !(!((W[38]^(W[42]>>25)) & (1<<5)))\n-\t\t\t || !((W[37]^(W[42]>>30)) & (1<<0))\n-\t\t )  mask &= ~DV_II_50_2_bit;\n-\tif (mask & DV_II_51_0_bit)\n-\t\t if (\n-\t\t\t    !(!((W[39]^(W[43]>>25)) & (1<<3)))\n-\t\t\t || !((W[38]^(W[43]<<2)) & (1<<30))\n-\t\t )  mask &= ~DV_II_51_0_bit;\n-\tif (mask & DV_II_51_2_bit)\n-\t\t if (\n-\t\t\t    !(!((W[55]^(W[56]<<5)) & (1<<6)))\n-\t\t\t || !(!((W[53]^W[55]) & (1<<6)))\n-\t\t\t || !((W[52]^W[56]) & (1<<1))\n-\t\t\t || !((W[46]^W[48]) & (1<<1))\n-\t\t\t || !(!((W[39]^(W[43]>>25)) & (1<<5)))\n-\t\t\t || !((W[38]^(W[43]>>30)) & (1<<0))\n-\t\t )  mask &= ~DV_II_51_2_bit;\n-\tif (mask & DV_II_52_0_bit)\n-\t\t if (\n-\t\t\t    !(!((W[59]^W[60]) & (1<<29)))\n-\t\t\t || !(!((W[40]^(W[44]>>25)) & (1<<3)))\n-\t\t\t || !(!((W[40]^(W[44]>>25)) & (1<<4)))\n-\t\t\t || !((W[39]^(W[44]<<2)) & (1<<30))\n-\t\t )  mask &= ~DV_II_52_0_bit;\n-\tif (mask & DV_II_53_0_bit)\n-\t\t if (\n-\t\t\t    !((W[58]^W[61]) & (1<<29))\n-\t\t\t || !(!((W[57]^(W[61]>>25)) & (1<<4)))\n-\t\t\t || !(!((W[41]^(W[45]>>25)) & (1<<3)))\n-\t\t\t || !(!((W[41]^(W[45]>>25)) & (1<<4)))\n-\t\t )  mask &= ~DV_II_53_0_bit;\n-\tif (mask & DV_II_54_0_bit)\n-\t\t if (\n-\t\t\t    !(!((W[58]^(W[62]>>25)) & (1<<4)))\n-\t\t\t || !(!((W[42]^(W[46]>>25)) & (1<<3)))\n-\t\t\t || !(!((W[42]^(W[46]>>25)) & (1<<4)))\n-\t\t )  mask &= ~DV_II_54_0_bit;\n-\tif (mask & DV_II_55_0_bit)\n-\t\t if (\n-\t\t\t    !(!((W[59]^(W[63]>>25)) & (1<<4)))\n-\t\t\t || !(!((W[57]^(W[59]>>25)) & (1<<4)))\n-\t\t\t || !(!((W[43]^(W[47]>>25)) & (1<<3)))\n-\t\t\t || !(!((W[43]^(W[47]>>25)) & (1<<4)))\n-\t\t )  mask &= ~DV_II_55_0_bit;\n-\tif (mask & DV_II_56_0_bit)\n-\t\t if (\n-\t\t\t    !(!((W[60]^(W[64]>>25)) & (1<<4)))\n-\t\t\t || !(!((W[44]^(W[48]>>25)) & (1<<3)))\n-\t\t\t || !(!((W[44]^(W[48]>>25)) & (1<<4)))\n-\t\t )  mask &= ~DV_II_56_0_bit;\n-}\n-\n-\tdvmask[0]=mask;\n-}\n-\n-#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C\n-#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C\n-#endif\ndiff --git a/sha1dc/ubc_check.h b/sha1dc/ubc_check.h\ndeleted file mode 100644\nindex d7e17dc734..0000000000\n--- a/sha1dc/ubc_check.h\n+++ /dev/null\n@@ -1,52 +0,0 @@\n-/***\n-* Copyright 2017 Marc Stevens <marc@marc-stevens.nl>, Dan Shumow <danshu@microsoft.com>\n-* Distributed under the MIT Software License.\n-* See accompanying file LICENSE.txt or copy at\n-* https://opensource.org/licenses/MIT\n-***/\n-\n-/*\n-// this file was generated by the 'parse_bitrel' program in the tools section\n-// using the data files from directory 'tools/data/3565'\n-//\n-// sha1_dvs contains a list of SHA-1 Disturbance Vectors (DV) to check\n-// dvType, dvK and dvB define the DV: I(K,B) or II(K,B) (see the paper)\n-// dm[80] is the expanded message block XOR-difference defined by the DV\n-// testt is the step to do the recompression from for collision detection\n-// maski and maskb define the bit to check for each DV in the dvmask returned by ubc_check\n-//\n-// ubc_check takes as input an expanded message block and verifies the unavoidable bitconditions for all listed DVs\n-// it returns a dvmask where each bit belonging to a DV is set if all unavoidable bitconditions for that DV have been met\n-// thus one needs to do the recompression check for each DV that has its bit set\n-*/\n-\n-#ifndef SHA1DC_UBC_CHECK_H\n-#define SHA1DC_UBC_CHECK_H\n-\n-#if defined(__cplusplus)\n-extern \"C\" {\n-#endif\n-\n-#ifndef SHA1DC_NO_STANDARD_INCLUDES\n-#include <stdint.h>\n-#endif\n-\n-#define DVMASKSIZE 1\n-typedef struct { int dvType; int dvK; int dvB; int testt; int maski; int maskb; uint32_t dm[80]; } dv_info_t;\n-extern dv_info_t sha1_dvs[];\n-void ubc_check(const uint32_t W[80], uint32_t dvmask[DVMASKSIZE]);\n-\n-#define DOSTORESTATE58\n-#define DOSTORESTATE65\n-\n-#define CHECK_DVMASK(_DVMASK) (0 != _DVMASK[0])\n-\n-#if defined(__cplusplus)\n-}\n-#endif\n-\n-#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H\n-#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H\n-#endif\n-\n-#endif\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320309","messageId":"xmqqpof3srw4.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"20170518212858.3649-3-avarab@gmail.com","subject":"Re: [PATCH 2/3] sha1dc: use sha1collisiondetection as a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-20T11:13:15Z","receivedAt":"2017-05-20T11:13:24Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> Replace the forked sha1dc directory with a copy of the upstream code\n> imported as a submodule. This is the exact same code as now exists in\n> the sha1dc/ directory.\n>\n> The initial reason for copy/pasting the code into sha1dc and locally\n> modifying it was that it needed to be altered to work with the git\n> project.\n>\n> The upstream project has accepted my code changes to allow us to use\n> their code as-is, see the preceding commit for details. So import the\n> code as a submodule instead, this will make it easier to keep\n> up-to-date with any upstream fixes or improvements.\n>\n> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n> ---\n>  .gitmodules            | 4 ++++\n>  Makefile               | 4 ++--\n>  hash.h                 | 2 +-\n>  sha1collisiondetection | 1 +\n>  4 files changed, 8 insertions(+), 3 deletions(-)\n>  create mode 100644 .gitmodules\n>  create mode 160000 sha1collisiondetection\n\nI am not sure how prepared our .travis.yml is to deal with a\nsubmodule, I'd prefer to have this step broken down to two step\nprocess.\n\nThat is, [PATCH 2.1/3] first adds an otherwise unused submodule, so\nthat people can optionally do \"git submodule init && git submodule\nupdate\" so that they can compare the contents of sha1dc/ that has\nbeen updated by [PATCH 1/3] with the up-to-date upstream.  Then\n[PATCH 2.2/3] would update the Makefile and hash.h to use the code\nin the submodule.\n\nI actually would want to see us proceed even more cautiously---if\nthe latter-half, i.e. [PATCH 2.2/3], is arranged so that it uses the\nnew sha1collisiondetection/ only when the submodule is initialized\nand populated, and otherwise it uses sha1dc/ as before, I would feel\na lot safer.  I wouldn't be this paranoid if this \"let's start using\nsubmodule ourselves\" were done to some optional corner (like compat/\nor contrib/ somewhere), but this is the default hash function.  I do\nwant to have something like this to force us (and submodule folks)\nto get any kinks out, but I do not want to see many people not even\nbe able to build while this new arrangement is eased in.  Once\npeople are comfortable with the new arrangement to use code from\nsubmodule, we can then take [PATCH 3/3] to remove the old sha1dc/\ndirectory and the migration will be complete.\n\nI also am not very happy with .gitmodules pointing at a single point\nof failure.  It would be nice if you can arrange a couple of mirrors\nand have a comment in .gitmodules file to tell folks that they can\nuse these alternates by insteadOf or some other mechanism.\n\nThanks.\n"},{"id":"320311","messageId":"20170520115429.12289-1-avarab@gmail.com","threadId":"45998","inReplyTo":"xmqqpof3srw4.fsf@gitster.mtv.corp.google.com","subject":"[PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-20T11:54:27Z","receivedAt":"2017-05-20T11:54:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sat, May 20, 2017 at 1:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> Replace the forked sha1dc directory with a copy of the upstream code\n>> imported as a submodule. This is the exact same code as now exists in\n>> the sha1dc/ directory.\n>>\n>> The initial reason for copy/pasting the code into sha1dc and locally\n>> modifying it was that it needed to be altered to work with the git\n>> project.\n>>\n>> The upstream project has accepted my code changes to allow us to use\n>> their code as-is, see the preceding commit for details. So import the\n>> code as a submodule instead, this will make it easier to keep\n>> up-to-date with any upstream fixes or improvements.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  .gitmodules            | 4 ++++\n>>  Makefile               | 4 ++--\n>>  hash.h                 | 2 +-\n>>  sha1collisiondetection | 1 +\n>>  4 files changed, 8 insertions(+), 3 deletions(-)\n>>  create mode 100644 .gitmodules\n>>  create mode 160000 sha1collisiondetection\n>\n> I am not sure how prepared our .travis.yml is to deal with a\n> submodule, I'd prefer to have this step broken down to two step\n> process.\n>\n> That is, [PATCH 2.1/3] first adds an otherwise unused submodule, so\n> that people can optionally do \"git submodule init && git submodule\n> update\" so that they can compare the contents of sha1dc/ that has\n> been updated by [PATCH 1/3] with the up-to-date upstream.  Then\n> [PATCH 2.2/3] would update the Makefile and hash.h to use the code\n> in the submodule.\n>\n> I actually would want to see us proceed even more cautiously---if\n> the latter-half, i.e. [PATCH 2.2/3], is arranged so that it uses the\n> new sha1collisiondetection/ only when the submodule is initialized\n> and populated, and otherwise it uses sha1dc/ as before, I would feel\n> a lot safer.  I wouldn't be this paranoid if this \"let's start using\n> submodule ourselves\" were done to some optional corner (like compat/\n> or contrib/ somewhere), but this is the default hash function.  I do\n> want to have something like this to force us (and submodule folks)\n> to get any kinks out, but I do not want to see many people not even\n> be able to build while this new arrangement is eased in.  Once\n> people are comfortable with the new arrangement to use code from\n> submodule, we can then take [PATCH 3/3] to remove the old sha1dc/\n> directory and the migration will be complete.\n\nMakes sense to take it slow. Hopefully this addresses your comments. I\ndropped the 3rd patch to remove sha1dc/ and the 2nd patch adds\nsha1collisiondetection/ as submodule, but it's not used unless you\nspecify DC_SHA1_SUBMODULE in addition to DC_SHA1.\n\nBoth patches should be safe to include & not cause any disruption, but\nnow those interested in making the submodule experience in git.git\nbetter can init/update & set DC_SHA1_SUBMODULE=Y to play with it.\n\nNote that both patches update to a newer version of the upstream\ncode. I sent them another pull request with some cleanups, one of\nwhich is to ignore .depends in their .gitignore file.\n\n> I also am not very happy with .gitmodules pointing at a single point\n> of failure.  It would be nice if you can arrange a couple of mirrors\n> and have a comment in .gitmodules file to tell folks that they can\n> use these alternates by insteadOf or some other mechanism.\n\nI liked the suggestion to make the URL a relative path, but this would\nrequire you to maintain a mirror in the same places you push git.git\nto, is that something you'd be willing to do?\n\nFor now having no-mirror isn't a big issue with my new 2/2 since it'se\nsomething you have to opt-in to with a build flag, which I suspect\nonly I/Brandon/Stefan & a few others will use.\n\nÆvar Arnfjörð Bjarmason (2):\n  sha1dc: update from upstream\n  sha1dc: optionally use sha1collisiondetection as a submodule\n\n .gitmodules            |  4 +++\n Makefile               | 21 +++++++++++-\n hash.h                 |  4 +++\n sha1collisiondetection |  1 +\n sha1dc/sha1.c          | 91 +++++++++++++++++++++++++++++++++-----------------\n sha1dc/sha1.h          | 90 ++++++++++++++++++++++---------------------------\n sha1dc/ubc_check.c     | 13 ++++++--\n sha1dc/ubc_check.h     | 14 ++++++--\n sha1dc_git.c           | 24 +++++++++++++\n sha1dc_git.h           | 19 +++++++++++\n 10 files changed, 193 insertions(+), 88 deletions(-)\n create mode 100644 .gitmodules\n create mode 160000 sha1collisiondetection\n create mode 100644 sha1dc_git.c\n create mode 100644 sha1dc_git.h\n\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320312","messageId":"20170520115429.12289-2-avarab@gmail.com","threadId":"45998","inReplyTo":"20170520115429.12289-1-avarab@gmail.com","subject":"[PATCH v2 1/2] sha1dc: update from upstream","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-20T11:54:28Z","receivedAt":"2017-05-20T11:54:56Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Update sha1dc from the latest version by the upstream\nmaintainer[1].\n\nThis version includes a commit of mine which allows for replacing the\nlocal modifications done to the upstream files in git.git with macro\ndefinitions to monkeypatch it in place.\n\nIt also brings in a change[2] upstream made for the breakage 2.13.0\nintroduced on SPARC and other platforms that forbid unaligned\naccess[3].\n\nThis means that the code customizations done since the initial import\nin commit 28dc98e343 (\"sha1dc: add collision-detecting sha1\nimplementation\", 2017-03-16) can be done purely via Makefile\ndefinitions and by including the content of our own sha1dc_git.[ch] in\nsha1dc/sha1.c via a macro.\n\n1. https://github.com/cr-marcstevens/sha1collisiondetection/commit/cc465543b310e5f59a1d534381690052e8509b22\n2. https://github.com/cr-marcstevens/sha1collisiondetection/commit/33a694a9ee1b79c24be45f9eab5ac0e1aeeaf271\n3. \"Git 2.13.0 segfaults on Solaris SPARC due to DC_SHA1=YesPlease\n   being on by default\"\n   (https://public-inbox.org/git/CACBZZX6nmKK8af0-UpjCKWV4R+hV-uk2xWXVA5U+_UQ3VXU03g@mail.gmail.com/)\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n Makefile           |  9 +++++-\n sha1dc/sha1.c      | 91 +++++++++++++++++++++++++++++++++++-------------------\n sha1dc/sha1.h      | 90 +++++++++++++++++++++++------------------------------\n sha1dc/ubc_check.c | 13 ++++++--\n sha1dc/ubc_check.h | 14 +++++++--\n sha1dc_git.c       | 24 ++++++++++++++\n sha1dc_git.h       | 19 ++++++++++++\n 7 files changed, 172 insertions(+), 88 deletions(-)\n create mode 100644 sha1dc_git.c\n create mode 100644 sha1dc_git.h\n\ndiff --git a/Makefile b/Makefile\nindex e35542e631..ffa6da71b7 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1414,7 +1414,14 @@ else\n \tDC_SHA1 := YesPlease\n \tLIB_OBJS += sha1dc/sha1.o\n \tLIB_OBJS += sha1dc/ubc_check.o\n-\tBASIC_CFLAGS += -DSHA1_DC\n+\tBASIC_CFLAGS += \\\n+\t\t-DSHA1_DC \\\n+\t\t-DSHA1DC_NO_STANDARD_INCLUDES \\\n+\t\t-DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 \\\n+\t\t-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"\\\"cache.h\\\"\" \\\n+\t\t-DSHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C=\"\\\"sha1dc_git.c\\\"\" \\\n+\t\t-DSHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H=\"\\\"sha1dc_git.h\\\"\" \\\n+\t\t-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"\\\"git-compat-util.h\\\"\"\n endif\n endif\n endif\ndiff --git a/sha1dc/sha1.c b/sha1dc/sha1.c\nindex 35e9dd5bf4..3dff80ac72 100644\n--- a/sha1dc/sha1.c\n+++ b/sha1dc/sha1.c\n@@ -5,9 +5,23 @@\n * https://opensource.org/licenses/MIT\n ***/\n \n-#include \"cache.h\"\n-#include \"sha1dc/sha1.h\"\n-#include \"sha1dc/ubc_check.h\"\n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <string.h>\n+#include <memory.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#endif\n+\n+#ifdef SHA1DC_CUSTOM_INCLUDE_SHA1_C\n+#include SHA1DC_CUSTOM_INCLUDE_SHA1_C\n+#endif\n+\n+#ifndef SHA1DC_INIT_SAFE_HASH_DEFAULT\n+#define SHA1DC_INIT_SAFE_HASH_DEFAULT 1\n+#endif\n+\n+#include \"sha1.h\"\n+#include \"ubc_check.h\"\n \n \n /*\n@@ -18,16 +32,31 @@\n    If you are compiling on a big endian platform and your compiler does not define one of these,\n    you will have to add whatever macros your tool chain defines to indicate Big-Endianness.\n  */\n-#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \\\n+#ifdef SHA1DC_BIGENDIAN\n+#undef SHA1DC_BIGENDIAN\n+#endif\n+#if (!defined SHA1DC_FORCE_LITTLEENDIAN) && \\\n+    ((defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || \\\n     (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __BIG_ENDIAN__)) || \\\n-    defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) ||  defined(__AARCH64EB__) || \\\n-    defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)\n+    defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__ARMEB__) || defined(__THUMBEB__) ||  defined(__AARCH64EB__) || \\\n+    defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__) || defined(SHA1DC_FORCE_BIGENDIAN))\n+\n+#define SHA1DC_BIGENDIAN\n \n-#define SHA1DC_BIGENDIAN\t1\n-#else\n-#undef SHA1DC_BIGENDIAN\n #endif /*ENDIANNESS SELECTION*/\n \n+#if (defined SHA1DC_FORCE_UNALIGNED_ACCESS || \\\n+     defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || \\\n+     defined(i386) || defined(__i386) || defined(__i386__) || defined(__i486__)  || \\\n+     defined(__i586__) || defined(__i686__) || defined(_M_IX86) || defined(__X86__) || \\\n+     defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__) || defined(__INTEL__) || \\\n+     defined(__386) || defined(_M_X64) || defined(_M_AMD64))\n+\n+#define SHA1DC_ALLOW_UNALIGNED_ACCESS\n+\n+#endif /*UNALIGNMENT DETECTION*/\n+\n+\n #define rotate_right(x,n) (((x)>>(n))|((x)<<(32-(n))))\n #define rotate_left(x,n)  (((x)<<(n))|((x)>>(32-(n))))\n \n@@ -36,11 +65,11 @@\n \n #define sha1_mix(W, t)  (rotate_left(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1))\n \n-#if defined(SHA1DC_BIGENDIAN)\n+#ifdef SHA1DC_BIGENDIAN\n \t#define sha1_load(m, t, temp)  { temp = m[t]; }\n #else\n \t#define sha1_load(m, t, temp)  { temp = m[t]; sha1_bswap32(temp); }\n-#endif /* !defined(SHA1DC_BIGENDIAN) */\n+#endif\n \n #define sha1_store(W, t, x)\t*(volatile uint32_t *)&W[t] = x\n \n@@ -869,6 +898,11 @@ static void sha1recompress_fast_ ## t (uint32_t ihvin[5], uint32_t ihvout[5], co\n \tihvout[0] = ihvin[0] + a; ihvout[1] = ihvin[1] + b; ihvout[2] = ihvin[2] + c; ihvout[3] = ihvin[3] + d; ihvout[4] = ihvin[4] + e; \\\n }\n \n+#ifdef _MSC_VER\n+#pragma warning(push)\n+#pragma warning(disable: 4127)  /* Complier complains about the checks in the above macro being constant. */\n+#endif\n+\n #ifdef DOSTORESTATE0\n SHA1_RECOMPRESS(0)\n #endif\n@@ -1189,6 +1223,10 @@ SHA1_RECOMPRESS(78)\n SHA1_RECOMPRESS(79)\n #endif\n \n+#ifdef _MSC_VER\n+#pragma warning(pop)\n+#endif\n+\n static void sha1_recompression_step(uint32_t step, uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5])\n {\n \tswitch (step)\n@@ -1662,7 +1700,7 @@ void SHA1DCInit(SHA1_CTX* ctx)\n \tctx->ihv[3] = 0x10325476;\n \tctx->ihv[4] = 0xC3D2E1F0;\n \tctx->found_collision = 0;\n-\tctx->safe_hash = 0;\n+\tctx->safe_hash = SHA1DC_INIT_SAFE_HASH_DEFAULT;\n \tctx->ubc_check = 1;\n \tctx->detect_coll = 1;\n \tctx->reduced_round_coll = 0;\n@@ -1710,6 +1748,7 @@ void SHA1DCSetCallback(SHA1_CTX* ctx, collision_block_callback callback)\n void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len)\n {\n \tunsigned left, fill;\n+\n \tif (len == 0)\n \t\treturn;\n \n@@ -1728,7 +1767,13 @@ void SHA1DCUpdate(SHA1_CTX* ctx, const char* buf, size_t len)\n \twhile (len >= 64)\n \t{\n \t\tctx->total += 64;\n+\n+#if defined(SHA1DC_ALLOW_UNALIGNED_ACCESS)\n \t\tsha1_process(ctx, (uint32_t*)(buf));\n+#else\n+\t\tmemcpy(ctx->buffer, buf, 64);\n+\t\tsha1_process(ctx, (uint32_t*)(ctx->buffer));\n+#endif /* defined(SHA1DC_ALLOW_UNALIGNED_ACCESS) */\n \t\tbuf += 64;\n \t\tlen -= 64;\n \t}\n@@ -1788,22 +1833,6 @@ int SHA1DCFinal(unsigned char output[20], SHA1_CTX *ctx)\n \treturn ctx->found_collision;\n }\n \n-void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n-{\n-\tif (!SHA1DCFinal(hash, ctx))\n-\t\treturn;\n-\tdie(\"SHA-1 appears to be part of a collision attack: %s\",\n-\t    sha1_to_hex(hash));\n-}\n-\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n-{\n-\tconst char *data = vdata;\n-\t/* We expect an unsigned long, but sha1dc only takes an int */\n-\twhile (len > INT_MAX) {\n-\t\tSHA1DCUpdate(ctx, data, INT_MAX);\n-\t\tdata += INT_MAX;\n-\t\tlen -= INT_MAX;\n-\t}\n-\tSHA1DCUpdate(ctx, data, len);\n-}\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C\n+#endif\ndiff --git a/sha1dc/sha1.h b/sha1dc/sha1.h\nindex bd8bd928fb..1e4e94be54 100644\n--- a/sha1dc/sha1.h\n+++ b/sha1dc/sha1.h\n@@ -4,6 +4,7 @@\n * See accompanying file LICENSE.txt or copy at\n * https://opensource.org/licenses/MIT\n ***/\n+\n #ifndef SHA1DC_SHA1_H\n #define SHA1DC_SHA1_H\n \n@@ -11,36 +12,30 @@\n extern \"C\" {\n #endif\n \n-/* uses SHA-1 message expansion to expand the first 16 words of W[] to 80 words */\n-/* void sha1_message_expansion(uint32_t W[80]); */\n-\n-/* sha-1 compression function; first version takes a message block pre-parsed as 16 32-bit integers, second version takes an already expanded message) */\n-/* void sha1_compression(uint32_t ihv[5], const uint32_t m[16]);\n-void sha1_compression_W(uint32_t ihv[5], const uint32_t W[80]); */\n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <stdint.h>\n+#endif\n \n-/* same as sha1_compression_W, but additionally store intermediate states */\n+/* sha-1 compression function that takes an already expanded message, and additionally store intermediate states */\n /* only stores states ii (the state between step ii-1 and step ii) when DOSTORESTATEii is defined in ubc_check.h */\n void sha1_compression_states(uint32_t[5], const uint32_t[16], uint32_t[80], uint32_t[80][5]);\n \n /*\n-// function type for sha1_recompression_step_T (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5])\n-// where 0 <= T < 80\n-//       me2 is an expanded message (the expansion of an original message block XOR'ed with a disturbance vector's message block difference)\n-//       state is the internal state (a,b,c,d,e) before step T of the SHA-1 compression function while processing the original message block\n-// the function will return:\n-//       ihvin: the reconstructed input chaining value\n-//       ihvout: the reconstructed output chaining value\n+// Function type for sha1_recompression_step_T (uint32_t ihvin[5], uint32_t ihvout[5], const uint32_t me2[80], const uint32_t state[5]).\n+// Where 0 <= T < 80\n+//       me2 is an expanded message (the expansion of an original message block XOR'ed with a disturbance vector's message block difference.)\n+//       state is the internal state (a,b,c,d,e) before step T of the SHA-1 compression function while processing the original message block.\n+// The function will return:\n+//       ihvin: The reconstructed input chaining value.\n+//       ihvout: The reconstructed output chaining value.\n */\n typedef void(*sha1_recompression_type)(uint32_t*, uint32_t*, const uint32_t*, const uint32_t*);\n \n-/* table of sha1_recompression_step_0, ... , sha1_recompression_step_79 */\n-/* extern sha1_recompression_type sha1_recompression_step[80];*/\n-\n-/* a callback function type that can be set to be called when a collision block has been found: */\n+/* A callback function type that can be set to be called when a collision block has been found: */\n /* void collision_block_callback(uint64_t byteoffset, const uint32_t ihvin1[5], const uint32_t ihvin2[5], const uint32_t m1[80], const uint32_t m2[80]) */\n typedef void(*collision_block_callback)(uint64_t, const uint32_t*, const uint32_t*, const uint32_t*, const uint32_t*);\n \n-/* the SHA-1 context */\n+/* The SHA-1 context. */\n typedef struct {\n \tuint64_t total;\n \tuint32_t ihv[5];\n@@ -59,30 +54,34 @@ typedef struct {\n \tuint32_t states[80][5];\n } SHA1_CTX;\n \n-/* initialize SHA-1 context */\n+/* Initialize SHA-1 context. */\n void SHA1DCInit(SHA1_CTX*);\n \n /*\n-// function to enable safe SHA-1 hashing:\n-// collision attacks are thwarted by hashing a detected near-collision block 3 times\n-// think of it as extending SHA-1 from 80-steps to 240-steps for such blocks:\n-//   the best collision attacks against SHA-1 have complexity about 2^60,\n-//   thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would 2^180\n-//   an attacker would be better off using a generic birthday search of complexity 2^80\n-//\n-// enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected\n-// but it will result in a different SHA-1 hash for messages where a collision attack was detected\n-// this will automatically invalidate SHA-1 based digital signature forgeries\n-// enabled by default\n+    Function to enable safe SHA-1 hashing:\n+    Collision attacks are thwarted by hashing a detected near-collision block 3 times.\n+    Think of it as extending SHA-1 from 80-steps to 240-steps for such blocks:\n+        The best collision attacks against SHA-1 have complexity about 2^60,\n+        thus for 240-steps an immediate lower-bound for the best cryptanalytic attacks would be 2^180.\n+        An attacker would be better off using a generic birthday search of complexity 2^80.\n+\n+   Enabling safe SHA-1 hashing will result in the correct SHA-1 hash for messages where no collision attack was detected,\n+   but it will result in a different SHA-1 hash for messages where a collision attack was detected.\n+   This will automatically invalidate SHA-1 based digital signature forgeries.\n+   Enabled by default.\n */\n void SHA1DCSetSafeHash(SHA1_CTX*, int);\n \n-/* function to disable or enable the use of Unavoidable Bitconditions (provides a significant speed up) */\n-/* enabled by default */\n+/*\n+    Function to disable or enable the use of Unavoidable Bitconditions (provides a significant speed up).\n+    Enabled by default\n+ */\n void SHA1DCSetUseUBC(SHA1_CTX*, int);\n \n-/* function to disable or enable the use of Collision Detection */\n-/* enabled by default */\n+/*\n+    Function to disable or enable the use of Collision Detection.\n+    Enabled by default.\n+ */\n void SHA1DCSetUseDetectColl(SHA1_CTX*, int);\n \n /* function to disable or enable the detection of reduced-round SHA-1 collisions */\n@@ -100,23 +99,12 @@ void SHA1DCUpdate(SHA1_CTX*, const char*, size_t);\n /* returns: 0 = no collision detected, otherwise = collision found => warn user for active attack */\n int  SHA1DCFinal(unsigned char[20], SHA1_CTX*);\n \n-/*\n- * Same as SHA1DCFinal, but convert collision attack case into a verbose die().\n- */\n-void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n-\n-/*\n- * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n- */\n-void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n-\n-#define platform_SHA_CTX SHA1_CTX\n-#define platform_SHA1_Init SHA1DCInit\n-#define platform_SHA1_Update git_SHA1DCUpdate\n-#define platform_SHA1_Final git_SHA1DCFinal\n-\n #if defined(__cplusplus)\n }\n #endif\n \n-#endif /* SHA1DC_SHA1_H */\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H\n+#endif\n+\n+#endif\ndiff --git a/sha1dc/ubc_check.c b/sha1dc/ubc_check.c\nindex 089dd4743d..b3beff2afb 100644\n--- a/sha1dc/ubc_check.c\n+++ b/sha1dc/ubc_check.c\n@@ -24,8 +24,13 @@\n // ubc_check has been verified against ubc_check_verify using the 'ubc_check_test' program in the tools section\n */\n \n-#include \"git-compat-util.h\"\n-#include \"sha1dc/ubc_check.h\"\n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <stdint.h>\n+#endif\n+#ifdef SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C\n+#include SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C\n+#endif\n+#include \"ubc_check.h\"\n \n static const uint32_t DV_I_43_0_bit \t= (uint32_t)(1) << 0;\n static const uint32_t DV_I_44_0_bit \t= (uint32_t)(1) << 1;\n@@ -361,3 +366,7 @@ if (mask) {\n \n \tdvmask[0]=mask;\n }\n+\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C\n+#endif\ndiff --git a/sha1dc/ubc_check.h b/sha1dc/ubc_check.h\nindex b64c306d77..d7e17dc734 100644\n--- a/sha1dc/ubc_check.h\n+++ b/sha1dc/ubc_check.h\n@@ -20,13 +20,17 @@\n // thus one needs to do the recompression check for each DV that has its bit set\n */\n \n-#ifndef UBC_CHECK_H\n-#define UBC_CHECK_H\n+#ifndef SHA1DC_UBC_CHECK_H\n+#define SHA1DC_UBC_CHECK_H\n \n #if defined(__cplusplus)\n extern \"C\" {\n #endif\n \n+#ifndef SHA1DC_NO_STANDARD_INCLUDES\n+#include <stdint.h>\n+#endif\n+\n #define DVMASKSIZE 1\n typedef struct { int dvType; int dvK; int dvB; int testt; int maski; int maskb; uint32_t dm[80]; } dv_info_t;\n extern dv_info_t sha1_dvs[];\n@@ -41,4 +45,8 @@ void ubc_check(const uint32_t W[80], uint32_t dvmask[DVMASKSIZE]);\n }\n #endif\n \n-#endif /* UBC_CHECK_H */\n+#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H\n+#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_H\n+#endif\n+\n+#endif\ndiff --git a/sha1dc_git.c b/sha1dc_git.c\nnew file mode 100644\nindex 0000000000..4d32b4f77e\n--- /dev/null\n+++ b/sha1dc_git.c\n@@ -0,0 +1,24 @@\n+/*\n+ * This code is included at the end of sha1dc/sha1.c with the\n+ * SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_C macro.\n+ */\n+\n+void git_SHA1DCFinal(unsigned char hash[20], SHA1_CTX *ctx)\n+{\n+\tif (!SHA1DCFinal(hash, ctx))\n+\t\treturn;\n+\tdie(\"SHA-1 appears to be part of a collision attack: %s\",\n+\t    sha1_to_hex(hash));\n+}\n+\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *vdata, unsigned long len)\n+{\n+\tconst char *data = vdata;\n+\t/* We expect an unsigned long, but sha1dc only takes an int */\n+\twhile (len > INT_MAX) {\n+\t\tSHA1DCUpdate(ctx, data, INT_MAX);\n+\t\tdata += INT_MAX;\n+\t\tlen -= INT_MAX;\n+\t}\n+\tSHA1DCUpdate(ctx, data, len);\n+}\ndiff --git a/sha1dc_git.h b/sha1dc_git.h\nnew file mode 100644\nindex 0000000000..a8a5c1da16\n--- /dev/null\n+++ b/sha1dc_git.h\n@@ -0,0 +1,19 @@\n+/*\n+ * This code is included at the end of sha1dc/sha1.h with the\n+ * SHA1DC_CUSTOM_TRAILING_INCLUDE_SHA1_H macro.\n+ */\n+\n+/*\n+ * Same as SHA1DCFinal, but convert collision attack case into a verbose die().\n+ */\n+void git_SHA1DCFinal(unsigned char [20], SHA1_CTX *);\n+\n+/*\n+ * Same as SHA1DCUpdate, but adjust types to match git's usual interface.\n+ */\n+void git_SHA1DCUpdate(SHA1_CTX *ctx, const void *data, unsigned long len);\n+\n+#define platform_SHA_CTX SHA1_CTX\n+#define platform_SHA1_Init SHA1DCInit\n+#define platform_SHA1_Update git_SHA1DCUpdate\n+#define platform_SHA1_Final git_SHA1DCFinal\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320313","messageId":"20170520115429.12289-3-avarab@gmail.com","threadId":"45998","inReplyTo":"20170520115429.12289-1-avarab@gmail.com","subject":"[PATCH v2 2/2] sha1dc: optionally use sha1collisiondetection as a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-20T11:54:29Z","receivedAt":"2017-05-20T11:54:58Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Add an option to use the sha1collisiondetection library from the\nsubmodule in sha1collisiondetection/ instead of in the copy in the\nsha1dc/ directory.\n\nThis allows us to try out the submodule in sha1collisiondetection\nwithout breaking the build for anyone who's not expecting them as we\nwork out any kinks.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n .gitmodules            |  4 ++++\n Makefile               | 12 ++++++++++++\n hash.h                 |  4 ++++\n sha1collisiondetection |  1 +\n 4 files changed, 21 insertions(+)\n create mode 100644 .gitmodules\n create mode 160000 sha1collisiondetection\n\ndiff --git a/.gitmodules b/.gitmodules\nnew file mode 100644\nindex 0000000000..cbeebdab7a\n--- /dev/null\n+++ b/.gitmodules\n@@ -0,0 +1,4 @@\n+[submodule \"sha1collisiondetection\"]\n+\tpath = sha1collisiondetection\n+\turl = https://github.com/cr-marcstevens/sha1collisiondetection.git\n+\tbranch = master\ndiff --git a/Makefile b/Makefile\nindex ffa6da71b7..6baad1669e 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -144,6 +144,12 @@ all::\n # algorithm. This is slower, but may detect attempted collision attacks.\n # Takes priority over other *_SHA1 knobs.\n #\n+# Define DC_SHA1_SUBMODULE in addition to DC_SHA1 to use the\n+# sha1collisiondetection shipped as a submodule instead of the\n+# non-submodule copy in sha1dc/. This is an experimental option used\n+# by the git project to migrate to using sha1collisiondetection as a\n+# submodule.\n+#\n # Define OPENSSL_SHA1 environment variable when running make to link\n # with the SHA1 routine from openssl library.\n #\n@@ -1412,8 +1418,14 @@ ifdef APPLE_COMMON_CRYPTO\n \tBASIC_CFLAGS += -DSHA1_APPLE\n else\n \tDC_SHA1 := YesPlease\n+ifdef DC_SHA1_SUBMODULE\n+\tLIB_OBJS += sha1collisiondetection/lib/sha1.o\n+\tLIB_OBJS += sha1collisiondetection/lib/ubc_check.o\n+\tBASIC_CFLAGS += -DDC_SHA1_SUBMODULE\n+else\n \tLIB_OBJS += sha1dc/sha1.o\n \tLIB_OBJS += sha1dc/ubc_check.o\n+endif\n \tBASIC_CFLAGS += \\\n \t\t-DSHA1_DC \\\n \t\t-DSHA1DC_NO_STANDARD_INCLUDES \\\ndiff --git a/hash.h b/hash.h\nindex a11fc9233f..bef3e630a0 100644\n--- a/hash.h\n+++ b/hash.h\n@@ -8,7 +8,11 @@\n #elif defined(SHA1_OPENSSL)\n #include <openssl/sha.h>\n #elif defined(SHA1_DC)\n+#ifdef DC_SHA1_SUBMODULE\n+#include \"sha1collisiondetection/lib/sha1.h\"\n+#else\n #include \"sha1dc/sha1.h\"\n+#endif\n #else /* SHA1_BLK */\n #include \"block-sha1/sha1.h\"\n #endif\ndiff --git a/sha1collisiondetection b/sha1collisiondetection\nnew file mode 160000\nindex 0000000000..cc465543b3\n--- /dev/null\n+++ b/sha1collisiondetection\n@@ -0,0 +1 @@\n+Subproject commit cc465543b310e5f59a1d534381690052e8509b22\n-- \n2.13.0.303.g4ebf302169\n\n"},{"id":"320385","messageId":"xmqqtw4dptek.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"20170520115429.12289-3-avarab@gmail.com","subject":"Re: [PATCH v2 2/2] sha1dc: optionally use sha1collisiondetection as a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-22T01:33:23Z","receivedAt":"2017-05-22T01:33:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> +# Define DC_SHA1_SUBMODULE in addition to DC_SHA1 to use the\n> +# sha1collisiondetection shipped as a submodule instead of the\n> +# non-submodule copy in sha1dc/. This is an experimental option used\n> +# by the git project to migrate to using sha1collisiondetection as a\n> +# submodule.\n> +#\n\nYup, thanks.\n\nI actually was envisioning something like this instead, though.\n\ndiff --git a/Makefile b/Makefile\nindex 6baad1669e..8d33936a12 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -989,6 +989,10 @@ EXTLIBS =\n \n GIT_USER_AGENT = git/$(GIT_VERSION)\n \n+ifeq ($(wildcard sha1collisiondetection/lib/sha1.h),sha1collisiondetection/lib/sha1.h)\n+DC_SHA1_SUBMODULE = auto\n+endif\n+\n include config.mak.uname\n -include config.mak.autogen\n -include config.mak\n\nThat way, a user can say \"git submodule init/update\" it to use it,\nand deinit it to use the frozen version.\n\nBut when somebody (like me?) feels strongly enough, such a change\ncan always come on top of this patch, so let's have this\nmanual-configuration-only version as our first step.\n\nThanks.\n"},{"id":"320391","messageId":"xmqq7f19ppy6.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"xmqqtw4dptek.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 2/2] sha1dc: optionally use sha1collisiondetection as a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-22T02:48:01Z","receivedAt":"2017-05-22T02:48:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> But when somebody (like me?) feels strongly enough, such a change\n> can always come on top of this patch, so let's have this\n> manual-configuration-only version as our first step.\n\nJust so that I have something I can come back to, here it is with a\nlog message.\n\n-- >8 --\nSubject: [PATCH] sha1collisiondetection: automatically enable when submodule is populated\n\nIf a user wants to experiment with the version of collision\ndetecting sha1 from the submodule, the user needed to not just\npopulate the submodule but also needed to turn the knob.\n\nA Makefile trick is easy enough to do so, so let's do this.  When\nsomebody with a copy of the submodule populated wants not to use it,\nthat can be done by overriding it in config.mak or from the command\nline, e.g. \"make DC_SHA1_SUBMODULE= all\".\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n Makefile | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git a/Makefile b/Makefile\nindex 6baad1669e..8d33936a12 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -989,6 +989,10 @@ EXTLIBS =\n \n GIT_USER_AGENT = git/$(GIT_VERSION)\n \n+ifeq ($(wildcard sha1collisiondetection/lib/sha1.h),sha1collisiondetection/lib/sha1.h)\n+DC_SHA1_SUBMODULE = auto\n+endif\n+\n include config.mak.uname\n -include config.mak.autogen\n -include config.mak\n-- \n2.13.0-440-g3ce6d2d5b8\n\n"},{"id":"320398","messageId":"CACBZZX52etn7jjT13tDfiQL2ondBAK8G7MuLvG5bmm8Fmn-FwQ@mail.gmail.com","threadId":"45998","inReplyTo":"xmqq7f19ppy6.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 2/2] sha1dc: optionally use sha1collisiondetection as a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-22T08:27:33Z","receivedAt":"2017-05-22T08:28:01Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, May 22, 2017 at 4:48 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> But when somebody (like me?) feels strongly enough, such a change\n>> can always come on top of this patch, so let's have this\n>> manual-configuration-only version as our first step.\n>\n> Just so that I have something I can come back to, here it is with a\n> log message.\n>\n> -- >8 --\n> Subject: [PATCH] sha1collisiondetection: automatically enable when submodule is populated\n>\n> If a user wants to experiment with the version of collision\n> detecting sha1 from the submodule, the user needed to not just\n> populate the submodule but also needed to turn the knob.\n>\n> A Makefile trick is easy enough to do so, so let's do this.  When\n> somebody with a copy of the submodule populated wants not to use it,\n> that can be done by overriding it in config.mak or from the command\n> line, e.g. \"make DC_SHA1_SUBMODULE= all\".\n>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  Makefile | 4 ++++\n>  1 file changed, 4 insertions(+)\n>\n> diff --git a/Makefile b/Makefile\n> index 6baad1669e..8d33936a12 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -989,6 +989,10 @@ EXTLIBS =\n>\n>  GIT_USER_AGENT = git/$(GIT_VERSION)\n>\n> +ifeq ($(wildcard sha1collisiondetection/lib/sha1.h),sha1collisiondetection/lib/sha1.h)\n> +DC_SHA1_SUBMODULE = auto\n> +endif\n> +\n>  include config.mak.uname\n>  -include config.mak.autogen\n>  -include config.mak\n\n\nI thought this should have something like this:\n\ndiff --git a/Makefile b/Makefile\nindex 8d33936a12..bbcac648a4 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -989,9 +989,11 @@ EXTLIBS =\n\n GIT_USER_AGENT = git/$(GIT_VERSION)\n\n+ifndef DC_SHA1_SUBMODULE\n ifeq ($(wildcard\nsha1collisiondetection/lib/sha1.h),sha1collisiondetection/lib/sha1.h)\n DC_SHA1_SUBMODULE = auto\n endif\n+endif\n\n include config.mak.uname\n -include config.mak.autogen\n\nI.e. so using sha1dc via DC_SHA1_SUBMODULE= even with the submodule\nchecked-out would work, but experimenting with it now that seems to do\nthe right thing, even though this is set unconditionally. There must\nbe some Makefile magic I'm missing here.\n\nBut in any case it would make sense to squash something like this into\nyour patch:\n\ndiff --git a/Makefile b/Makefile\nindex 8d33936a12..4d9c49ae17 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -148,7 +148,8 @@ all::\n # sha1collisiondetection shipped as a submodule instead of the\n # non-submodule copy in sha1dc/. This is an experimental option used\n # by the git project to migrate to using sha1collisiondetection as a\n-# submodule.\n+# submodule. Supplied implicitly if the sha1collisiondetection/\n+# directory is found to be populated.\n #\n # Define OPENSSL_SHA1 environment variable when running make to link\n # with the SHA1 routine from openssl library.\n"},{"id":"320399","messageId":"xmqqfufxnuou.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"CACBZZX52etn7jjT13tDfiQL2ondBAK8G7MuLvG5bmm8Fmn-FwQ@mail.gmail.com","subject":"Re: [PATCH v2 2/2] sha1dc: optionally use sha1collisiondetection as a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-22T08:48:33Z","receivedAt":"2017-05-22T08:48:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> I thought this should have something like this:\n> ...\n> the right thing, even though this is set unconditionally. There must\n> be some Makefile magic I'm missing here.\n\nThe magic you are missing is that to ifdef in $(MAKE), a variable\nthat is not mentioned (undefined) and set to empty string are both\nthe same.  You'll fall into its else clause.\n\n> But in any case it would make sense to squash something like this into\n> your patch:\n>\n> diff --git a/Makefile b/Makefile\n> index 8d33936a12..4d9c49ae17 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -148,7 +148,8 @@ all::\n>  # sha1collisiondetection shipped as a submodule instead of the\n>  # non-submodule copy in sha1dc/. This is an experimental option used\n>  # by the git project to migrate to using sha1collisiondetection as a\n> -# submodule.\n> +# submodule. Supplied implicitly if the sha1collisiondetection/\n> +# directory is found to be populated.\n\nYeah, if it is populated, defaults to true, if it is not, defaults\nto false.  Either case can be overriden from the command line or\nconfig.mak\n"},{"id":"320486","messageId":"xmqqbmqko7c2.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"20170520115429.12289-1-avarab@gmail.com","subject":"Re: [PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-22T22:27:41Z","receivedAt":"2017-05-22T22:27:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> I liked the suggestion to make the URL a relative path, but this would\n> require you to maintain a mirror in the same places you push git.git\n> to, is that something you'd be willing to do?\n\nAfter thinking about this a bit more, I know what I think we want a\nbit better.\n\nRelative URL (e.g. ../sha1collisiondetection that sits next to the\ncopy of git.git) may be a good way to go.  I can arrange to create\nnecessary repository next to git.git on k.org and github.com but I\nneed to double check about other places\n\nWhether the submodule is referenced by a relative URL from the main\nproject, the submodule should not come directly from the upstream,\nand various mirrors that sit next to git.git should not be blind and\nautomated \"mirrors\".  This is because I do not want us to trust the\nsecurity measures of https://github.com/cr-marcstevens/ repository.\nThe consumers already need to trust k.org/pub/scm/git/git.git and by\nensuring k.org/pub/scm/git/sha1dc is managed the same way, they do\nnot have to trust anything extra.\n\nAnother reason is that we want to make sure all commits in the\nsubmodule that we bind to the superproject (i.e. git.git) are always\nin the submodule, regardless of what our upstream does, and one way\nto do so is to have control over _our_ canonical repository for the\nsubmodule.  In normal times, it will faithfully follow the upstream\nwithout doing anything else, but we'd keep the option of anchoring a\nsubmodule commit that is referenced by the superproject history with\nour own tag, if it is ever rewound away in the upstream history for\nwhatever reason.\n\nThanks.\n"},{"id":"320487","messageId":"CAGZ79kb9Ca6QtyRzOW-1Q-E+7Z+PB7+MBtj4KvZx-mV36opWpA@mail.gmail.com","threadId":"45998","inReplyTo":"xmqqbmqko7c2.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2017-05-22T22:48:45Z","receivedAt":"2017-05-22T22:49:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Mon, May 22, 2017 at 3:27 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> I liked the suggestion to make the URL a relative path, but this would\n>> require you to maintain a mirror in the same places you push git.git\n>> to, is that something you'd be willing to do?\n>\n> After thinking about this a bit more, I know what I think we want a\n> bit better.\n>\n> Relative URL (e.g. ../sha1collisiondetection that sits next to the\n> copy of git.git) may be a good way to go.  I can arrange to create\n> necessary repository next to git.git on k.org and github.com but I\n> need to double check about other places\n\nAnd here we see another deficit with a single URL:\nWe have to abide by the same scheme at all hosting endpoints.\n\nFor example consider the host https://kernel.googlesource.com/pub/scm/git/git\nthat mirrors from kernel.org. It would be able to bind the\nsubmodule at  https://kernel.googlesource.com/pub/scm/git/git/sha1dc\ni.e. it would look like a subdirectory of the main git repo.\n\nThis is not an issue for our desired usecase, as all hosts can comply\nwith the scheme that you outlined (url=../sha1...), but worth noting that\nin the long term we may want to have the ability to \"configure\" each\nremote individually by having out-of-history config options. I think we\nwould want to solve that via a \"refs/meta/gitmodules\" branch that can be\nadapted per remote. (original idea from jrnieder@)\n\n> Whether the submodule is referenced by a relative URL from the main\n> project, the submodule should not come directly from the upstream,\n> and various mirrors that sit next to git.git should not be blind and\n> automated \"mirrors\".\n\nThat sounds reasonable for our sanity.\n\n> This is because I do not want us to trust the\n> security measures of https://github.com/cr-marcstevens/ repository.\n> The consumers already need to trust k.org/pub/scm/git/git.git and by\n> ensuring k.org/pub/scm/git/sha1dc is managed the same way, they do\n> not have to trust anything extra.\n\nThe trust would be transitive, as the said submodule is referenced via\nsha1, so all malicious actions upstream could perform are:\n* denial of service: (by remove a commit that we pointed at in our history)\n* denial of service 2: add a huge blob to their repo, such that anyone\n  obtaining the submodule not carefully is annoyed by a super large repo.\n* add additional malicious data (such as illegal numbers and algorithms)\n  to a branch, which would be obtained by users cloning the submodule\n  carelessly.\n\n> Another reason is that we want to make sure all commits in the\n> submodule that we bind to the superproject (i.e. git.git) are always\n> in the submodule, regardless of what our upstream does, and one way\n> to do so is to have control over _our_ canonical repository for the\n> submodule.\n\nBy having all repos under one entity of trust, we would not need to discuss\nall kinds of possible attacks as above.\n\n>  In normal times, it will faithfully follow the upstream\n> without doing anything else, but we'd keep the option of anchoring a\n> submodule commit that is referenced by the superproject history with\n> our own tag, if it is ever rewound away in the upstream history for\n> whatever reason.\n\nThat makes sense.\n\nThanks,\nStefan\n"},{"id":"320514","messageId":"xmqqtw4cmf53.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"CAGZ79kb9Ca6QtyRzOW-1Q-E+7Z+PB7+MBtj4KvZx-mV36opWpA@mail.gmail.com","subject":"Re: [PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-23T03:22:00Z","receivedAt":"2017-05-23T03:22:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> On Mon, May 22, 2017 at 3:27 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>>\n>>> I liked the suggestion to make the URL a relative path, but this would\n>>> require you to maintain a mirror in the same places you push git.git\n>>> to, is that something you'd be willing to do?\n>>\n>> After thinking about this a bit more, I know what I think we want a\n>> bit better.\n>>\n>> Relative URL (e.g. ../sha1collisiondetection that sits next to the\n>> copy of git.git) may be a good way to go.  I can arrange to create\n>> necessary repository next to git.git on k.org and github.com but I\n>> need to double check about other places\n>\n> And here we see another deficit with a single URL:\n> We have to abide by the same scheme at all hosting endpoints.\n\nFWIW, I do not see it a deficit.  It is a price you may or may not\nbe willing to pay for simplicity, and I think it is a reasonable\ntrade-off.\n\nThe .gitmodules format can be enhanced to list multiple URLs quite\neasily.  I think the current users all use the equivalent of \"git\nconfig -f .gitmodules submodule.foo.url\" to grab one value.  Unless\nthe user chooses to do anything special, they will continue to get\nthe same behaviour whensuch an enhancement happens, which is a good\nthing.\n\nBut then, you need to design what users choose to do that is\n\"something special\".  Should \"git clone --recurse-submodules\" have a\nway to control which one of the not-yet-known-before-cloning URLs\nthat may be listed in .gitmodules?  Will we have a way to say \"For\nNorth American users, we recommend this URL, while Asians may want\nto fetch from this other URL\" in .gitmodules and then the recursive\nclone have a way to say \"I want the European option\"?  Would the\nrecursive clone have a way to go interactive?\n\nAnd from that point of view, \"you'll find the submodules relative to\nthe superproject\" convention is one way (not necessarily the only\nway) to allow users not to care too much.  The simplicity comes with\nprice and that is perfectly acceptable.\n\nAlso a single URL scheme may still perfectly fine.  .gitmodules may\nhave new submodule.<name>.alternateURL fields and recursive clone\ncan be told to optionally go interactive when such fields are\npresent.\n\nOr README can list alternate URLs and instruct the users to use the\ninsteadOf if they want to go to mirrors instead.  Those users who do\ncare about picking particular mirror are likely not favor simplicity\nover flexibility, so they would not likely to do a recursive clone\n(after all, clone is a single-time operation) and it may be\nsufficient if they can clone the top-level, read README and then\ndecide how and from where they get their submodules.\n"},{"id":"320549","messageId":"CACBZZX4d4-EGiUtJQT8cvuMzm0c5DUu5sxUb11kUnJu3ocuSHw@mail.gmail.com","threadId":"45998","inReplyTo":"xmqqbmqko7c2.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-23T10:55:15Z","receivedAt":"2017-05-23T10:55:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, May 23, 2017 at 12:27 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> I liked the suggestion to make the URL a relative path, but this would\n>> require you to maintain a mirror in the same places you push git.git\n>> to, is that something you'd be willing to do?\n>\n> After thinking about this a bit more, I know what I think we want a\n> bit better.\n>\n> Relative URL (e.g. ../sha1collisiondetection that sits next to the\n> copy of git.git) may be a good way to go.  I can arrange to create\n> necessary repository next to git.git on k.org and github.com but I\n> need to double check about other places\n\nIf the URL doesn't point to the canonical upstream how do we review a\npatch to update sha1dc here on list? Doesn't change from \"'git am'\nthis and it'll work\" to \"'git am' this and it'll fail, then do this\nsubmodule config modification dance, and run some other command....\".\n\nI haven't tried repointing a submodule temporarily (and locally) to\nanother URL for such a use, how is that even done?\n\n> Whether the submodule is referenced by a relative URL from the main\n> project, the submodule should not come directly from the upstream,\n> and various mirrors that sit next to git.git should not be blind and\n> automated \"mirrors\".  This is because I do not want us to trust the\n> security measures of https://github.com/cr-marcstevens/ repository.\n> The consumers already need to trust k.org/pub/scm/git/git.git and by\n> ensuring k.org/pub/scm/git/sha1dc is managed the same way, they do\n> not have to trust anything extra.\n\nI had the same comments Stefan pointed out below about this. So I\nwon't repeat any of that...\n\n> Another reason is that we want to make sure all commits in the\n> submodule that we bind to the superproject (i.e. git.git) are always\n> in the submodule, regardless of what our upstream does, and one way\n> to do so is to have control over _our_ canonical repository for the\n> submodule.  In normal times, it will faithfully follow the upstream\n> without doing anything else, but we'd keep the option of anchoring a\n> submodule commit that is referenced by the superproject history with\n> our own tag, if it is ever rewound away in the upstream history for\n> whatever reason.\n\nIf we were talking about any other project but git.git I'd say \"yeah\nthis makes sense\".\n\nBut I think in our case we should keep in mind the main point of this\nexercise is for us to dogfood submodule usage, not just so we get\nwhatever trivial benefits from updating the sha1collision/ directory\nfrom upstream, but so that we run into issues with submodules that we\nsolve for all our users.\n\nIn this case you're basically concerned with:\n\n * We have N mirrors, but the upstream submodule URL is just one URL,\nso let's not point to that, but to our N mirrors\n\nCould also be addressed with a combination of 'pullUrl' for submodules\n(inverse of pushUrl for push) to list the canonical one & list of\nmirrors (or use the relative URL).\n\n * What if upstream say 5 years in the future rewinds their history,\ngithub shuts down or whatever, can we check out and work with older\nversions of git.git?\n\nSeems like it would be useful to have a way to ex-post-facto say \"past\nhistory should use these URLs\". i.e. if all git.git mirrors go down\nand we have to re-host, then you can just clone git.git and off you\ngo, but the same isn't true of past submodule urls, or is it?\n"},{"id":"320557","messageId":"xmqqo9ujk9ii.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"CACBZZX4d4-EGiUtJQT8cvuMzm0c5DUu5sxUb11kUnJu3ocuSHw@mail.gmail.com","subject":"Re: [PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-23T13:06:29Z","receivedAt":"2017-05-23T13:06:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> Seems like it would be useful to have a way to ex-post-facto say \"past\n> history should use these URLs\". i.e. if all git.git mirrors go down\n> and we have to re-host, then you can just clone git.git and off you\n> go, but the same isn't true of past submodule urls, or is it?\n\nI do not know how heavily you are used to use submodules, but I\nthink submodule's URL is copied to the config of the superproject,\nand that URL is what will be used from there on, so \"past history or\nfuture history will use that URL\" is already the case, no?\n"},{"id":"320705","messageId":"CACBZZX5Aa9cQngCgMVP2kb8Jnk_V7coK-f5J6jMOhn=AWCrXzQ@mail.gmail.com","threadId":"45998","inReplyTo":"xmqqo9ujk9ii.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T10:44:34Z","receivedAt":"2017-05-25T10:45:02Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Tue, May 23, 2017 at 3:06 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n>\n>> Seems like it would be useful to have a way to ex-post-facto say \"past\n>> history should use these URLs\". i.e. if all git.git mirrors go down\n>> and we have to re-host, then you can just clone git.git and off you\n>> go, but the same isn't true of past submodule urls, or is it?\n>\n> I do not know how heavily you are used to use submodules, but I\n> think submodule's URL is copied to the config of the superproject,\n> and that URL is what will be used from there on, so \"past history or\n> future history will use that URL\" is already the case, no?\n\nI haven't used them much, just starting to get familiar with them now again.\n\nI thought given your \"if it is ever rewound away in the upstream\nhistory...\" that if we e.g. pegged upstream to that github URL now\nthat if that got rewound, anyone working with git.git in the future\nwould be in for some pain if they needed to check out and test old\ntags.\n\nBut from what you're saying here that seems like a non-issue, i.e. in\nsuch a scenario we'd just mirror the original repo[1], change the URL\nin git.git to that, and then anyone could easily use older history\nsince it would be pointing to the new mirror.\n\nI.e. in the spirit of my last reply, this seems like deviating from\nthe default workflow around submodules out of concern for an extremely\nunlikely scenario, which, if it happened, would be easily mitigated\nfor both past & future git.git history.\n\n1. Or likely just ask upstream kindly to push a tag with the old history.\n"},{"id":"320706","messageId":"CACBZZX43Mrv_7W_Eoo9YOB1zV832GibNj_T+KjQ8QZQNVYo7nw@mail.gmail.com","threadId":"45998","inReplyTo":"xmqqpof3srw4.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH 2/3] sha1dc: use sha1collisiondetection as a submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2017-05-25T10:47:31Z","receivedAt":"2017-05-25T10:47:57Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sat, May 20, 2017 at 1:13 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> Replace the forked sha1dc directory with a copy of the upstream code\n>> imported as a submodule. This is the exact same code as now exists in\n>> the sha1dc/ directory.\n>>\n>> The initial reason for copy/pasting the code into sha1dc and locally\n>> modifying it was that it needed to be altered to work with the git\n>> project.\n>>\n>> The upstream project has accepted my code changes to allow us to use\n>> their code as-is, see the preceding commit for details. So import the\n>> code as a submodule instead, this will make it easier to keep\n>> up-to-date with any upstream fixes or improvements.\n>>\n>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n>> ---\n>>  .gitmodules            | 4 ++++\n>>  Makefile               | 4 ++--\n>>  hash.h                 | 2 +-\n>>  sha1collisiondetection | 1 +\n>>  4 files changed, 8 insertions(+), 3 deletions(-)\n>>  create mode 100644 .gitmodules\n>>  create mode 160000 sha1collisiondetection\n>\n> I am not sure how prepared our .travis.yml is to deal with a\n> submodule, I'd prefer to have this step broken down to two step\n> process.\n\nI've since sent a v2 of this which addresses this by being more\ncareful, but since then I found these Travis docs that seem to\nindicate that cloning the submodule will Just Work:\nhttps://docs.travis-ci.com/user/common-build-problems/#Git-Submodules-are-not-updated-correctly\n"},{"id":"320775","messageId":"xmqqtw48cy4l.fsf@gitster.mtv.corp.google.com","threadId":"45998","inReplyTo":"CACBZZX5Aa9cQngCgMVP2kb8Jnk_V7coK-f5J6jMOhn=AWCrXzQ@mail.gmail.com","subject":"Re: [PATCH v2 0/2] Update sha1dc from upstream & optionally make it a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-05-25T23:31:06Z","receivedAt":"2017-05-25T23:31:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> But from what you're saying here that seems like a non-issue, i.e. in\n> such a scenario we'd just mirror the original repo[1], change the URL\n> in git.git to that, and then anyone could easily use older history\n> since it would be pointing to the new mirror.\n\nThose who cloned before such a switch will still have the URL they\nchose when they cloned and did \"submodule init\" on it, I think, so\nthey need to explicitly choose to switch to the new URL.  So I would\nnot exactly say \"seems like a non-issue\"; it certainly is an easy\nthing to work around.\n"}]}