{"thread":{"id":"20647","subject":"[PATCH] remove ARM and Mozilla SHA1 implementations","startedAt":"2009-08-17T23:56:27Z","lastAt":"2009-08-24T20:10:47Z","messageCount":10,"participants":["Nicolas Pitre","Johannes Schindelin","David Aguilar","Peter Harris"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"121028","messageId":"alpine.LFD.2.00.0908171940540.6044@xanadu.home","threadId":"20647","inReplyTo":null,"subject":"[PATCH] remove ARM and Mozilla SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-17T23:56:27Z","receivedAt":"2009-08-17T23:56:27Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"They are both slower than the new BLK_SHA1 implementation, so it is\npointless to keep them around.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n\nSomeone else would need to make the call for the PPC version.  IMHO it\nprobably should go too, as no Makefile rule ever included it by default\neven on PPC platforms.  Some reports indicate that the BLK_SHA1 version \nis faster on PPC as well.\n\nAnd because the BLK_SHA1 is faster than the openssl version, then the\nBLK_SHA1 could become the default (and only) choice.  But one thing\nat a time.\n\n Makefile            |   26 +------\n arm/sha1.c          |   82 --------------------\n arm/sha1.h          |   23 ------\n arm/sha1_arm.S      |  183 ---------------------------------------------\n block-sha1/sha1.c   |    6 +-\n configure.ac        |   10 +--\n mozilla-sha1/sha1.c |  151 -------------------------------------\n mozilla-sha1/sha1.h |   50 ------------\n 8 files changed, 7 insertions(+), 524 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex f94fe05..4190a5d 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -16,7 +16,7 @@ all::\n # when attempting to read from an fopen'ed directory.\n #\n # Define NO_OPENSSL environment variable if you do not have OpenSSL.\n-# This also implies MOZILLA_SHA1.\n+# This also implies BLK_SHA1.\n #\n # Define NO_CURL if you do not have libcurl installed.  git-http-pull and\n # git-http-push are not built, and you cannot use http:// and https://\n@@ -91,14 +91,6 @@ all::\n # Define PPC_SHA1 environment variable when running make to make use of\n # a bundled SHA1 routine optimized for PowerPC.\n #\n-# Define ARM_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine optimized for ARM.\n-#\n-# Define MOZILLA_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast\n-# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default\n-# choice) has very fast version optimized for i586.\n-#\n # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).\n #\n # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).\n@@ -930,10 +922,6 @@ else\n \tNO_PTHREADS = YesPlease\n endif\n endif\n-ifneq (,$(findstring arm,$(uname_M)))\n-\tARM_SHA1 = YesPlease\n-\tNO_MKSTEMPS = YesPlease\n-endif\n \n -include config.mak.autogen\n -include config.mak\n@@ -1025,7 +1013,7 @@ ifndef NO_OPENSSL\n \tendif\n else\n \tBASIC_CFLAGS += -DNO_OPENSSL\n-\tMOZILLA_SHA1 = 1\n+\tBLK_SHA1 = 1\n \tOPENSSL_LIBSSL =\n endif\n ifdef NEEDS_SSL_WITH_CRYPTO\n@@ -1182,20 +1170,10 @@ ifdef PPC_SHA1\n \tSHA1_HEADER = \"ppc/sha1.h\"\n \tLIB_OBJS += ppc/sha1.o ppc/sha1ppc.o\n else\n-ifdef ARM_SHA1\n-\tSHA1_HEADER = \"arm/sha1.h\"\n-\tLIB_OBJS += arm/sha1.o arm/sha1_arm.o\n-else\n-ifdef MOZILLA_SHA1\n-\tSHA1_HEADER = \"mozilla-sha1/sha1.h\"\n-\tLIB_OBJS += mozilla-sha1/sha1.o\n-else\n \tSHA1_HEADER = <openssl/sha.h>\n \tEXTLIBS += $(LIB_4_CRYPTO)\n endif\n endif\n-endif\n-endif\n ifdef NO_PERL_MAKEMAKER\n \texport NO_PERL_MAKEMAKER\n endif\ndiff --git a/arm/sha1.c b/arm/sha1.c\ndeleted file mode 100644\nindex c61ad4a..0000000\n--- a/arm/sha1.c\n+++ /dev/null\n@@ -1,82 +0,0 @@\n-/*\n- * SHA-1 implementation optimized for ARM\n- *\n- * Copyright:   (C) 2005 by Nicolas Pitre <nico@cam.org>\n- * Created:     September 17, 2005\n- */\n-\n-#include <string.h>\n-#include \"sha1.h\"\n-\n-extern void arm_sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);\n-\n-void arm_SHA1_Init(arm_SHA_CTX *c)\n-{\n-\tc->len = 0;\n-\tc->hash[0] = 0x67452301;\n-\tc->hash[1] = 0xefcdab89;\n-\tc->hash[2] = 0x98badcfe;\n-\tc->hash[3] = 0x10325476;\n-\tc->hash[4] = 0xc3d2e1f0;\n-}\n-\n-void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n)\n-{\n-\tuint32_t workspace[80];\n-\tunsigned int partial;\n-\tunsigned long done;\n-\n-\tpartial = c->len & 0x3f;\n-\tc->len += n;\n-\tif ((partial + n) >= 64) {\n-\t\tif (partial) {\n-\t\t\tdone = 64 - partial;\n-\t\t\tmemcpy(c->buffer + partial, p, done);\n-\t\t\tarm_sha_transform(c->hash, c->buffer, workspace);\n-\t\t\tpartial = 0;\n-\t\t} else\n-\t\t\tdone = 0;\n-\t\twhile (n >= done + 64) {\n-\t\t\tarm_sha_transform(c->hash, p + done, workspace);\n-\t\t\tdone += 64;\n-\t\t}\n-\t} else\n-\t\tdone = 0;\n-\tif (n - done)\n-\t\tmemcpy(c->buffer + partial, p + done, n - done);\n-}\n-\n-void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c)\n-{\n-\tuint64_t bitlen;\n-\tuint32_t bitlen_hi, bitlen_lo;\n-\tunsigned int i, offset, padlen;\n-\tunsigned char bits[8];\n-\tstatic const unsigned char padding[64] = { 0x80, };\n-\n-\tbitlen = c->len << 3;\n-\toffset = c->len & 0x3f;\n-\tpadlen = ((offset < 56) ? 56 : (64 + 56)) - offset;\n-\tarm_SHA1_Update(c, padding, padlen);\n-\n-\tbitlen_hi = bitlen >> 32;\n-\tbitlen_lo = bitlen & 0xffffffff;\n-\tbits[0] = bitlen_hi >> 24;\n-\tbits[1] = bitlen_hi >> 16;\n-\tbits[2] = bitlen_hi >> 8;\n-\tbits[3] = bitlen_hi;\n-\tbits[4] = bitlen_lo >> 24;\n-\tbits[5] = bitlen_lo >> 16;\n-\tbits[6] = bitlen_lo >> 8;\n-\tbits[7] = bitlen_lo;\n-\tarm_SHA1_Update(c, bits, 8);\n-\n-\tfor (i = 0; i < 5; i++) {\n-\t\tuint32_t v = c->hash[i];\n-\t\thash[0] = v >> 24;\n-\t\thash[1] = v >> 16;\n-\t\thash[2] = v >> 8;\n-\t\thash[3] = v;\n-\t\thash += 4;\n-\t}\n-}\ndiff --git a/arm/sha1.h b/arm/sha1.h\ndeleted file mode 100644\nindex b61b618..0000000\n--- a/arm/sha1.h\n+++ /dev/null\n@@ -1,23 +0,0 @@\n-/*\n- * SHA-1 implementation optimized for ARM\n- *\n- * Copyright:\t(C) 2005 by Nicolas Pitre <nico@cam.org>\n- * Created:\tSeptember 17, 2005\n- */\n-\n-#include <stdint.h>\n-\n-typedef struct {\n-\tuint64_t len;\n-\tuint32_t hash[5];\n-\tunsigned char buffer[64];\n-} arm_SHA_CTX;\n-\n-void arm_SHA1_Init(arm_SHA_CTX *c);\n-void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n);\n-void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c);\n-\n-#define git_SHA_CTX\tarm_SHA_CTX\n-#define git_SHA1_Init\tarm_SHA1_Init\n-#define git_SHA1_Update\tarm_SHA1_Update\n-#define git_SHA1_Final\tarm_SHA1_Final\ndiff --git a/arm/sha1_arm.S b/arm/sha1_arm.S\ndeleted file mode 100644\nindex 41e9263..0000000\n--- a/arm/sha1_arm.S\n+++ /dev/null\n@@ -1,183 +0,0 @@\n-/*\n- *  SHA transform optimized for ARM\n- *\n- *  Copyright:\t(C) 2005 by Nicolas Pitre <nico@cam.org>\n- *  Created:\tSeptember 17, 2005\n- *\n- *  This program is free software; you can redistribute it and/or modify\n- *  it under the terms of the GNU General Public License version 2 as\n- *  published by the Free Software Foundation.\n- */\n-\n-\t.text\n-\t.globl\tarm_sha_transform\n-\n-/*\n- * void sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);\n- *\n- * note: the \"data\" pointer may be unaligned.\n- */\n-\n-arm_sha_transform:\n-\n-\tstmfd\tsp!, {r4 - r8, lr}\n-\n-\t@ for (i = 0; i < 16; i++)\n-\t@         W[i] = ntohl(((uint32_t *)data)[i]);\n-\n-#ifdef __ARMEB__\n-\tmov\tr4, r0\n-\tmov\tr0, r2\n-\tmov\tr2, #64\n-\tbl\tmemcpy\n-\tmov\tr2, r0\n-\tmov\tr0, r4\n-#else\n-\tmov\tr3, r2\n-\tmov\tlr, #16\n-1:\tldrb\tr4, [r1], #1\n-\tldrb\tr5, [r1], #1\n-\tldrb\tr6, [r1], #1\n-\tldrb\tr7, [r1], #1\n-\tsubs\tlr, lr, #1\n-\torr\tr5, r5, r4, lsl #8\n-\torr\tr6, r6, r5, lsl #8\n-\torr\tr7, r7, r6, lsl #8\n-\tstr\tr7, [r3], #4\n-\tbne\t1b\n-#endif\n-\n-\t@ for (i = 0; i < 64; i++)\n-\t@         W[i+16] = ror(W[i+13] ^ W[i+8] ^ W[i+2] ^ W[i], 31);\n-\n-\tsub\tr3, r2, #4\n-\tmov\tlr, #64\n-2:\tldr\tr4, [r3, #4]!\n-\tsubs\tlr, lr, #1\n-\tldr\tr5, [r3, #8]\n-\tldr\tr6, [r3, #32]\n-\tldr\tr7, [r3, #52]\n-\teor\tr4, r4, r5\n-\teor\tr4, r4, r6\n-\teor\tr4, r4, r7\n-\tmov\tr4, r4, ror #31\n-\tstr\tr4, [r3, #64]\n-\tbne\t2b\n-\n-\t/*\n-\t * The SHA functions are:\n-\t *\n-\t * f1(B,C,D) = (D ^ (B & (C ^ D)))\n-\t * f2(B,C,D) = (B ^ C ^ D)\n-\t * f3(B,C,D) = ((B & C) | (D & (B | C)))\n-\t *\n-\t * Then the sub-blocks are processed as follows:\n-\t *\n-\t * A' = ror(A, 27) + f(B,C,D) + E + K + *W++\n-\t * B' = A\n-\t * C' = ror(B, 2)\n-\t * D' = C\n-\t * E' = D\n-\t *\n-\t * We therefore unroll each loop 5 times to avoid register shuffling.\n-\t * Also the ror for C (and also D and E which are successivelyderived\n-\t * from it) is applied in place to cut on an additional mov insn for\n-\t * each round.\n-\t */\n-\n-\t.macro\tsha_f1, A, B, C, D, E\n-\tldr\tr3, [r2], #4\n-\teor\tip, \\C, \\D\n-\tadd\t\\E, r1, \\E, ror #2\n-\tand\tip, \\B, ip, ror #2\n-\tadd\t\\E, \\E, \\A, ror #27\n-\teor\tip, ip, \\D, ror #2\n-\tadd\t\\E, \\E, r3\n-\tadd\t\\E, \\E, ip\n-\t.endm\n-\n-\t.macro\tsha_f2, A, B, C, D, E\n-\tldr\tr3, [r2], #4\n-\tadd\t\\E, r1, \\E, ror #2\n-\teor\tip, \\B, \\C, ror #2\n-\tadd\t\\E, \\E, \\A, ror #27\n-\teor\tip, ip, \\D, ror #2\n-\tadd\t\\E, \\E, r3\n-\tadd\t\\E, \\E, ip\n-\t.endm\n-\n-\t.macro\tsha_f3, A, B, C, D, E\n-\tldr\tr3, [r2], #4\n-\tadd\t\\E, r1, \\E, ror #2\n-\torr\tip, \\B, \\C, ror #2\n-\tadd\t\\E, \\E, \\A, ror #27\n-\tand\tip, ip, \\D, ror #2\n-\tadd\t\\E, \\E, r3\n-\tand\tr3, \\B, \\C, ror #2\n-\torr\tip, ip, r3\n-\tadd\t\\E, \\E, ip\n-\t.endm\n-\n-\tldmia\tr0, {r4 - r8}\n-\n-\tmov\tlr, #4\n-\tldr\tr1, .L_sha_K + 0\n-\n-\t/* adjust initial values */\n-\tmov\tr6, r6, ror #30\n-\tmov\tr7, r7, ror #30\n-\tmov\tr8, r8, ror #30\n-\n-3:\tsubs\tlr, lr, #1\n-\tsha_f1\tr4, r5, r6, r7, r8\n-\tsha_f1\tr8, r4, r5, r6, r7\n-\tsha_f1\tr7, r8, r4, r5, r6\n-\tsha_f1\tr6, r7, r8, r4, r5\n-\tsha_f1\tr5, r6, r7, r8, r4\n-\tbne\t3b\n-\n-\tldr\tr1, .L_sha_K + 4\n-\tmov\tlr, #4\n-\n-4:\tsubs\tlr, lr, #1\n-\tsha_f2\tr4, r5, r6, r7, r8\n-\tsha_f2\tr8, r4, r5, r6, r7\n-\tsha_f2\tr7, r8, r4, r5, r6\n-\tsha_f2\tr6, r7, r8, r4, r5\n-\tsha_f2\tr5, r6, r7, r8, r4\n-\tbne\t4b\n-\n-\tldr\tr1, .L_sha_K + 8\n-\tmov\tlr, #4\n-\n-5:\tsubs\tlr, lr, #1\n-\tsha_f3\tr4, r5, r6, r7, r8\n-\tsha_f3\tr8, r4, r5, r6, r7\n-\tsha_f3\tr7, r8, r4, r5, r6\n-\tsha_f3\tr6, r7, r8, r4, r5\n-\tsha_f3\tr5, r6, r7, r8, r4\n-\tbne\t5b\n-\n-\tldr\tr1, .L_sha_K + 12\n-\tmov\tlr, #4\n-\n-6:\tsubs\tlr, lr, #1\n-\tsha_f2\tr4, r5, r6, r7, r8\n-\tsha_f2\tr8, r4, r5, r6, r7\n-\tsha_f2\tr7, r8, r4, r5, r6\n-\tsha_f2\tr6, r7, r8, r4, r5\n-\tsha_f2\tr5, r6, r7, r8, r4\n-\tbne\t6b\n-\n-\tldmia\tr0, {r1, r2, r3, ip, lr}\n-\tadd\tr4, r1, r4\n-\tadd\tr5, r2, r5\n-\tadd\tr6, r3, r6, ror #2\n-\tadd\tr7, ip, r7, ror #2\n-\tadd\tr8, lr, r8, ror #2\n-\tstmia\tr0, {r4 - r8}\n-\n-\tldmfd\tsp!, {r4 - r8, pc}\n-\n-.L_sha_K:\n-\t.word\t0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6\ndiff --git a/block-sha1/sha1.c b/block-sha1/sha1.c\nindex 464cb25..a1228cf 100644\n--- a/block-sha1/sha1.c\n+++ b/block-sha1/sha1.c\n@@ -1,7 +1,9 @@\n /*\n- * Based on the Mozilla SHA1 (see mozilla-sha1/sha1.c),\n- * optimized to do word accesses rather than byte accesses,\n+ * SHA1 routine optimized to do word accesses rather than byte accesses,\n  * and to avoid unnecessary copies into the context array.\n+ *\n+ * This was initially based on the Mozilla SHA1 implementation, although\n+ * none of the original Mozilla code remains.\n  */\n \n #include <string.h>\ndiff --git a/configure.ac b/configure.ac\nindex 3f1922d..b09b8e4 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -156,19 +156,11 @@ AC_MSG_NOTICE([CHECKS for site configuration])\n # tests.  These tests take up a significant amount of the total test time\n # but are not needed unless you plan to talk to SVN repos.\n #\n-# Define MOZILLA_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast\n-# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default\n-# choice) has very fast version optimized for i586.\n-#\n # Define PPC_SHA1 environment variable when running make to make use of\n # a bundled SHA1 routine optimized for PowerPC.\n #\n-# Define ARM_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine optimized for ARM.\n-#\n # Define NO_OPENSSL environment variable if you do not have OpenSSL.\n-# This also implies MOZILLA_SHA1.\n+# This also implies BLK_SHA1.\n #\n # Define OPENSSLDIR=/foo/bar if your openssl header and library files are in\n # /foo/bar/include and /foo/bar/lib directories.\ndiff --git a/mozilla-sha1/sha1.c b/mozilla-sha1/sha1.c\ndeleted file mode 100644\nindex 95a4ebf..0000000\n--- a/mozilla-sha1/sha1.c\n+++ /dev/null\n@@ -1,151 +0,0 @@\n-/*\n- * The contents of this file are subject to the Mozilla Public\n- * License Version 1.1 (the \"License\"); you may not use this file\n- * except in compliance with the License. You may obtain a copy of\n- * the License at http://www.mozilla.org/MPL/\n- *\n- * Software distributed under the License is distributed on an \"AS\n- * IS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or\n- * implied. See the License for the specific language governing\n- * rights and limitations under the License.\n- *\n- * The Original Code is SHA 180-1 Reference Implementation (Compact version)\n- *\n- * The Initial Developer of the Original Code is Paul Kocher of\n- * Cryptography Research.  Portions created by Paul Kocher are\n- * Copyright (C) 1995-9 by Cryptography Research, Inc.  All\n- * Rights Reserved.\n- *\n- * Contributor(s):\n- *\n- *     Paul Kocher\n- *\n- * Alternatively, the contents of this file may be used under the\n- * terms of the GNU General Public License Version 2 or later (the\n- * \"GPL\"), in which case the provisions of the GPL are applicable\n- * instead of those above.  If you wish to allow use of your\n- * version of this file only under the terms of the GPL and not to\n- * allow others to use your version of this file under the MPL,\n- * indicate your decision by deleting the provisions above and\n- * replace them with the notice and other provisions required by\n- * the GPL.  If you do not delete the provisions above, a recipient\n- * may use your version of this file under either the MPL or the\n- * GPL.\n- */\n-\n-#include \"sha1.h\"\n-\n-static void shaHashBlock(moz_SHA_CTX *ctx);\n-\n-void moz_SHA1_Init(moz_SHA_CTX *ctx) {\n-  int i;\n-\n-  ctx->lenW = 0;\n-  ctx->sizeHi = ctx->sizeLo = 0;\n-\n-  /* Initialize H with the magic constants (see FIPS180 for constants)\n-   */\n-  ctx->H[0] = 0x67452301;\n-  ctx->H[1] = 0xefcdab89;\n-  ctx->H[2] = 0x98badcfe;\n-  ctx->H[3] = 0x10325476;\n-  ctx->H[4] = 0xc3d2e1f0;\n-\n-  for (i = 0; i < 80; i++)\n-    ctx->W[i] = 0;\n-}\n-\n-\n-void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *_dataIn, int len) {\n-  const unsigned char *dataIn = _dataIn;\n-  int i;\n-\n-  /* Read the data into W and process blocks as they get full\n-   */\n-  for (i = 0; i < len; i++) {\n-    ctx->W[ctx->lenW / 4] <<= 8;\n-    ctx->W[ctx->lenW / 4] |= (unsigned int)dataIn[i];\n-    if ((++ctx->lenW) % 64 == 0) {\n-      shaHashBlock(ctx);\n-      ctx->lenW = 0;\n-    }\n-    ctx->sizeLo += 8;\n-    ctx->sizeHi += (ctx->sizeLo < 8);\n-  }\n-}\n-\n-\n-void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx) {\n-  unsigned char pad0x80 = 0x80;\n-  unsigned char pad0x00 = 0x00;\n-  unsigned char padlen[8];\n-  int i;\n-\n-  /* Pad with a binary 1 (e.g. 0x80), then zeroes, then length\n-   */\n-  padlen[0] = (unsigned char)((ctx->sizeHi >> 24) & 255);\n-  padlen[1] = (unsigned char)((ctx->sizeHi >> 16) & 255);\n-  padlen[2] = (unsigned char)((ctx->sizeHi >> 8) & 255);\n-  padlen[3] = (unsigned char)((ctx->sizeHi >> 0) & 255);\n-  padlen[4] = (unsigned char)((ctx->sizeLo >> 24) & 255);\n-  padlen[5] = (unsigned char)((ctx->sizeLo >> 16) & 255);\n-  padlen[6] = (unsigned char)((ctx->sizeLo >> 8) & 255);\n-  padlen[7] = (unsigned char)((ctx->sizeLo >> 0) & 255);\n-  moz_SHA1_Update(ctx, &pad0x80, 1);\n-  while (ctx->lenW != 56)\n-    moz_SHA1_Update(ctx, &pad0x00, 1);\n-  moz_SHA1_Update(ctx, padlen, 8);\n-\n-  /* Output hash\n-   */\n-  for (i = 0; i < 20; i++) {\n-    hashout[i] = (unsigned char)(ctx->H[i / 4] >> 24);\n-    ctx->H[i / 4] <<= 8;\n-  }\n-\n-  /*\n-   *  Re-initialize the context (also zeroizes contents)\n-   */\n-  moz_SHA1_Init(ctx);\n-}\n-\n-\n-#define SHA_ROT(X,n) (((X) << (n)) | ((X) >> (32-(n))))\n-\n-static void shaHashBlock(moz_SHA_CTX *ctx) {\n-  int t;\n-  unsigned int A,B,C,D,E,TEMP;\n-\n-  for (t = 16; t <= 79; t++)\n-    ctx->W[t] =\n-      SHA_ROT(ctx->W[t-3] ^ ctx->W[t-8] ^ ctx->W[t-14] ^ ctx->W[t-16], 1);\n-\n-  A = ctx->H[0];\n-  B = ctx->H[1];\n-  C = ctx->H[2];\n-  D = ctx->H[3];\n-  E = ctx->H[4];\n-\n-  for (t = 0; t <= 19; t++) {\n-    TEMP = SHA_ROT(A,5) + (((C^D)&B)^D)     + E + ctx->W[t] + 0x5a827999;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-  for (t = 20; t <= 39; t++) {\n-    TEMP = SHA_ROT(A,5) + (B^C^D)           + E + ctx->W[t] + 0x6ed9eba1;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-  for (t = 40; t <= 59; t++) {\n-    TEMP = SHA_ROT(A,5) + ((B&C)|(D&(B|C))) + E + ctx->W[t] + 0x8f1bbcdc;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-  for (t = 60; t <= 79; t++) {\n-    TEMP = SHA_ROT(A,5) + (B^C^D)           + E + ctx->W[t] + 0xca62c1d6;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-\n-  ctx->H[0] += A;\n-  ctx->H[1] += B;\n-  ctx->H[2] += C;\n-  ctx->H[3] += D;\n-  ctx->H[4] += E;\n-}\ndiff --git a/mozilla-sha1/sha1.h b/mozilla-sha1/sha1.h\ndeleted file mode 100644\nindex aa48a46..0000000\n--- a/mozilla-sha1/sha1.h\n+++ /dev/null\n@@ -1,50 +0,0 @@\n-/*\n- * The contents of this file are subject to the Mozilla Public\n- * License Version 1.1 (the \"License\"); you may not use this file\n- * except in compliance with the License. You may obtain a copy of\n- * the License at http://www.mozilla.org/MPL/\n- *\n- * Software distributed under the License is distributed on an \"AS\n- * IS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or\n- * implied. See the License for the specific language governing\n- * rights and limitations under the License.\n- *\n- * The Original Code is SHA 180-1 Header File\n- *\n- * The Initial Developer of the Original Code is Paul Kocher of\n- * Cryptography Research.  Portions created by Paul Kocher are\n- * Copyright (C) 1995-9 by Cryptography Research, Inc.  All\n- * Rights Reserved.\n- *\n- * Contributor(s):\n- *\n- *     Paul Kocher\n- *\n- * Alternatively, the contents of this file may be used under the\n- * terms of the GNU General Public License Version 2 or later (the\n- * \"GPL\"), in which case the provisions of the GPL are applicable\n- * instead of those above.  If you wish to allow use of your\n- * version of this file only under the terms of the GPL and not to\n- * allow others to use your version of this file under the MPL,\n- * indicate your decision by deleting the provisions above and\n- * replace them with the notice and other provisions required by\n- * the GPL.  If you do not delete the provisions above, a recipient\n- * may use your version of this file under either the MPL or the\n- * GPL.\n- */\n-\n-typedef struct {\n-  unsigned int H[5];\n-  unsigned int W[80];\n-  int lenW;\n-  unsigned int sizeHi,sizeLo;\n-} moz_SHA_CTX;\n-\n-void moz_SHA1_Init(moz_SHA_CTX *ctx);\n-void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *dataIn, int len);\n-void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx);\n-\n-#define git_SHA_CTX\tmoz_SHA_CTX\n-#define git_SHA1_Init\tmoz_SHA1_Init\n-#define git_SHA1_Update\tmoz_SHA1_Update\n-#define git_SHA1_Final\tmoz_SHA1_Final\n"},{"id":"121029","messageId":"alpine.DEB.1.00.0908180208160.8306@pacific.mpi-cbg.de","threadId":"20647","inReplyTo":"alpine.LFD.2.00.0908171940540.6044@xanadu.home","subject":"Re: [PATCH] remove ARM and Mozilla SHA1 implementations","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-18T00:09:03Z","receivedAt":"2009-08-18T00:09:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 17 Aug 2009, Nicolas Pitre wrote:\n\n> They are both slower than the new BLK_SHA1 implementation, so it is\n> pointless to keep them around.\n> \n> Signed-off-by: Nicolas Pitre <nico@cam.org>\n> ---\n> \n> Someone else would need to make the call for the PPC version.\n\nIf I don't forget, I can test tomorrow on 2 different 32-bit PPCs and \npossibly one 64-bit PPC.\n\nCiao,\nDscho\n"},{"id":"121030","messageId":"alpine.LFD.2.00.0908172007590.6044@xanadu.home","threadId":"20647","inReplyTo":"alpine.LFD.2.00.0908171940540.6044@xanadu.home","subject":"[PATCH v2] remove ARM and Mozilla SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-18T00:09:56Z","receivedAt":"2009-08-18T00:09:56Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"They are both slower than the new BLK_SHA1 implementation, so it is\npointless to keep them around.\n\nSigned-off-by: Nicolas Pitre <nico@cam.org>\n---\n\nOne reference to mozilla/sha1.c was missing in the initial patch.\n\n Makefile            |   26 +------\n arm/sha1.c          |   82 --------------------\n arm/sha1.h          |   23 ------\n arm/sha1_arm.S      |  183 ---------------------------------------------\n block-sha1/sha1.c   |    6 +-\n block-sha1/sha1.h   |    6 +-\n configure.ac        |   10 +--\n mozilla-sha1/sha1.c |  151 -------------------------------------\n mozilla-sha1/sha1.h |   50 ------------\n 9 files changed, 11 insertions(+), 526 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex f94fe05..4190a5d 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -16,7 +16,7 @@ all::\n # when attempting to read from an fopen'ed directory.\n #\n # Define NO_OPENSSL environment variable if you do not have OpenSSL.\n-# This also implies MOZILLA_SHA1.\n+# This also implies BLK_SHA1.\n #\n # Define NO_CURL if you do not have libcurl installed.  git-http-pull and\n # git-http-push are not built, and you cannot use http:// and https://\n@@ -91,14 +91,6 @@ all::\n # Define PPC_SHA1 environment variable when running make to make use of\n # a bundled SHA1 routine optimized for PowerPC.\n #\n-# Define ARM_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine optimized for ARM.\n-#\n-# Define MOZILLA_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast\n-# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default\n-# choice) has very fast version optimized for i586.\n-#\n # Define NEEDS_SSL_WITH_CRYPTO if you need -lcrypto with -lssl (Darwin).\n #\n # Define NEEDS_LIBICONV if linking with libc is not enough (Darwin).\n@@ -930,10 +922,6 @@ else\n \tNO_PTHREADS = YesPlease\n endif\n endif\n-ifneq (,$(findstring arm,$(uname_M)))\n-\tARM_SHA1 = YesPlease\n-\tNO_MKSTEMPS = YesPlease\n-endif\n \n -include config.mak.autogen\n -include config.mak\n@@ -1025,7 +1013,7 @@ ifndef NO_OPENSSL\n \tendif\n else\n \tBASIC_CFLAGS += -DNO_OPENSSL\n-\tMOZILLA_SHA1 = 1\n+\tBLK_SHA1 = 1\n \tOPENSSL_LIBSSL =\n endif\n ifdef NEEDS_SSL_WITH_CRYPTO\n@@ -1182,20 +1170,10 @@ ifdef PPC_SHA1\n \tSHA1_HEADER = \"ppc/sha1.h\"\n \tLIB_OBJS += ppc/sha1.o ppc/sha1ppc.o\n else\n-ifdef ARM_SHA1\n-\tSHA1_HEADER = \"arm/sha1.h\"\n-\tLIB_OBJS += arm/sha1.o arm/sha1_arm.o\n-else\n-ifdef MOZILLA_SHA1\n-\tSHA1_HEADER = \"mozilla-sha1/sha1.h\"\n-\tLIB_OBJS += mozilla-sha1/sha1.o\n-else\n \tSHA1_HEADER = <openssl/sha.h>\n \tEXTLIBS += $(LIB_4_CRYPTO)\n endif\n endif\n-endif\n-endif\n ifdef NO_PERL_MAKEMAKER\n \texport NO_PERL_MAKEMAKER\n endif\ndiff --git a/arm/sha1.c b/arm/sha1.c\ndeleted file mode 100644\nindex c61ad4a..0000000\n--- a/arm/sha1.c\n+++ /dev/null\n@@ -1,82 +0,0 @@\n-/*\n- * SHA-1 implementation optimized for ARM\n- *\n- * Copyright:   (C) 2005 by Nicolas Pitre <nico@cam.org>\n- * Created:     September 17, 2005\n- */\n-\n-#include <string.h>\n-#include \"sha1.h\"\n-\n-extern void arm_sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);\n-\n-void arm_SHA1_Init(arm_SHA_CTX *c)\n-{\n-\tc->len = 0;\n-\tc->hash[0] = 0x67452301;\n-\tc->hash[1] = 0xefcdab89;\n-\tc->hash[2] = 0x98badcfe;\n-\tc->hash[3] = 0x10325476;\n-\tc->hash[4] = 0xc3d2e1f0;\n-}\n-\n-void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n)\n-{\n-\tuint32_t workspace[80];\n-\tunsigned int partial;\n-\tunsigned long done;\n-\n-\tpartial = c->len & 0x3f;\n-\tc->len += n;\n-\tif ((partial + n) >= 64) {\n-\t\tif (partial) {\n-\t\t\tdone = 64 - partial;\n-\t\t\tmemcpy(c->buffer + partial, p, done);\n-\t\t\tarm_sha_transform(c->hash, c->buffer, workspace);\n-\t\t\tpartial = 0;\n-\t\t} else\n-\t\t\tdone = 0;\n-\t\twhile (n >= done + 64) {\n-\t\t\tarm_sha_transform(c->hash, p + done, workspace);\n-\t\t\tdone += 64;\n-\t\t}\n-\t} else\n-\t\tdone = 0;\n-\tif (n - done)\n-\t\tmemcpy(c->buffer + partial, p + done, n - done);\n-}\n-\n-void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c)\n-{\n-\tuint64_t bitlen;\n-\tuint32_t bitlen_hi, bitlen_lo;\n-\tunsigned int i, offset, padlen;\n-\tunsigned char bits[8];\n-\tstatic const unsigned char padding[64] = { 0x80, };\n-\n-\tbitlen = c->len << 3;\n-\toffset = c->len & 0x3f;\n-\tpadlen = ((offset < 56) ? 56 : (64 + 56)) - offset;\n-\tarm_SHA1_Update(c, padding, padlen);\n-\n-\tbitlen_hi = bitlen >> 32;\n-\tbitlen_lo = bitlen & 0xffffffff;\n-\tbits[0] = bitlen_hi >> 24;\n-\tbits[1] = bitlen_hi >> 16;\n-\tbits[2] = bitlen_hi >> 8;\n-\tbits[3] = bitlen_hi;\n-\tbits[4] = bitlen_lo >> 24;\n-\tbits[5] = bitlen_lo >> 16;\n-\tbits[6] = bitlen_lo >> 8;\n-\tbits[7] = bitlen_lo;\n-\tarm_SHA1_Update(c, bits, 8);\n-\n-\tfor (i = 0; i < 5; i++) {\n-\t\tuint32_t v = c->hash[i];\n-\t\thash[0] = v >> 24;\n-\t\thash[1] = v >> 16;\n-\t\thash[2] = v >> 8;\n-\t\thash[3] = v;\n-\t\thash += 4;\n-\t}\n-}\ndiff --git a/arm/sha1.h b/arm/sha1.h\ndeleted file mode 100644\nindex b61b618..0000000\n--- a/arm/sha1.h\n+++ /dev/null\n@@ -1,23 +0,0 @@\n-/*\n- * SHA-1 implementation optimized for ARM\n- *\n- * Copyright:\t(C) 2005 by Nicolas Pitre <nico@cam.org>\n- * Created:\tSeptember 17, 2005\n- */\n-\n-#include <stdint.h>\n-\n-typedef struct {\n-\tuint64_t len;\n-\tuint32_t hash[5];\n-\tunsigned char buffer[64];\n-} arm_SHA_CTX;\n-\n-void arm_SHA1_Init(arm_SHA_CTX *c);\n-void arm_SHA1_Update(arm_SHA_CTX *c, const void *p, unsigned long n);\n-void arm_SHA1_Final(unsigned char *hash, arm_SHA_CTX *c);\n-\n-#define git_SHA_CTX\tarm_SHA_CTX\n-#define git_SHA1_Init\tarm_SHA1_Init\n-#define git_SHA1_Update\tarm_SHA1_Update\n-#define git_SHA1_Final\tarm_SHA1_Final\ndiff --git a/arm/sha1_arm.S b/arm/sha1_arm.S\ndeleted file mode 100644\nindex 41e9263..0000000\n--- a/arm/sha1_arm.S\n+++ /dev/null\n@@ -1,183 +0,0 @@\n-/*\n- *  SHA transform optimized for ARM\n- *\n- *  Copyright:\t(C) 2005 by Nicolas Pitre <nico@cam.org>\n- *  Created:\tSeptember 17, 2005\n- *\n- *  This program is free software; you can redistribute it and/or modify\n- *  it under the terms of the GNU General Public License version 2 as\n- *  published by the Free Software Foundation.\n- */\n-\n-\t.text\n-\t.globl\tarm_sha_transform\n-\n-/*\n- * void sha_transform(uint32_t *hash, const unsigned char *data, uint32_t *W);\n- *\n- * note: the \"data\" pointer may be unaligned.\n- */\n-\n-arm_sha_transform:\n-\n-\tstmfd\tsp!, {r4 - r8, lr}\n-\n-\t@ for (i = 0; i < 16; i++)\n-\t@         W[i] = ntohl(((uint32_t *)data)[i]);\n-\n-#ifdef __ARMEB__\n-\tmov\tr4, r0\n-\tmov\tr0, r2\n-\tmov\tr2, #64\n-\tbl\tmemcpy\n-\tmov\tr2, r0\n-\tmov\tr0, r4\n-#else\n-\tmov\tr3, r2\n-\tmov\tlr, #16\n-1:\tldrb\tr4, [r1], #1\n-\tldrb\tr5, [r1], #1\n-\tldrb\tr6, [r1], #1\n-\tldrb\tr7, [r1], #1\n-\tsubs\tlr, lr, #1\n-\torr\tr5, r5, r4, lsl #8\n-\torr\tr6, r6, r5, lsl #8\n-\torr\tr7, r7, r6, lsl #8\n-\tstr\tr7, [r3], #4\n-\tbne\t1b\n-#endif\n-\n-\t@ for (i = 0; i < 64; i++)\n-\t@         W[i+16] = ror(W[i+13] ^ W[i+8] ^ W[i+2] ^ W[i], 31);\n-\n-\tsub\tr3, r2, #4\n-\tmov\tlr, #64\n-2:\tldr\tr4, [r3, #4]!\n-\tsubs\tlr, lr, #1\n-\tldr\tr5, [r3, #8]\n-\tldr\tr6, [r3, #32]\n-\tldr\tr7, [r3, #52]\n-\teor\tr4, r4, r5\n-\teor\tr4, r4, r6\n-\teor\tr4, r4, r7\n-\tmov\tr4, r4, ror #31\n-\tstr\tr4, [r3, #64]\n-\tbne\t2b\n-\n-\t/*\n-\t * The SHA functions are:\n-\t *\n-\t * f1(B,C,D) = (D ^ (B & (C ^ D)))\n-\t * f2(B,C,D) = (B ^ C ^ D)\n-\t * f3(B,C,D) = ((B & C) | (D & (B | C)))\n-\t *\n-\t * Then the sub-blocks are processed as follows:\n-\t *\n-\t * A' = ror(A, 27) + f(B,C,D) + E + K + *W++\n-\t * B' = A\n-\t * C' = ror(B, 2)\n-\t * D' = C\n-\t * E' = D\n-\t *\n-\t * We therefore unroll each loop 5 times to avoid register shuffling.\n-\t * Also the ror for C (and also D and E which are successivelyderived\n-\t * from it) is applied in place to cut on an additional mov insn for\n-\t * each round.\n-\t */\n-\n-\t.macro\tsha_f1, A, B, C, D, E\n-\tldr\tr3, [r2], #4\n-\teor\tip, \\C, \\D\n-\tadd\t\\E, r1, \\E, ror #2\n-\tand\tip, \\B, ip, ror #2\n-\tadd\t\\E, \\E, \\A, ror #27\n-\teor\tip, ip, \\D, ror #2\n-\tadd\t\\E, \\E, r3\n-\tadd\t\\E, \\E, ip\n-\t.endm\n-\n-\t.macro\tsha_f2, A, B, C, D, E\n-\tldr\tr3, [r2], #4\n-\tadd\t\\E, r1, \\E, ror #2\n-\teor\tip, \\B, \\C, ror #2\n-\tadd\t\\E, \\E, \\A, ror #27\n-\teor\tip, ip, \\D, ror #2\n-\tadd\t\\E, \\E, r3\n-\tadd\t\\E, \\E, ip\n-\t.endm\n-\n-\t.macro\tsha_f3, A, B, C, D, E\n-\tldr\tr3, [r2], #4\n-\tadd\t\\E, r1, \\E, ror #2\n-\torr\tip, \\B, \\C, ror #2\n-\tadd\t\\E, \\E, \\A, ror #27\n-\tand\tip, ip, \\D, ror #2\n-\tadd\t\\E, \\E, r3\n-\tand\tr3, \\B, \\C, ror #2\n-\torr\tip, ip, r3\n-\tadd\t\\E, \\E, ip\n-\t.endm\n-\n-\tldmia\tr0, {r4 - r8}\n-\n-\tmov\tlr, #4\n-\tldr\tr1, .L_sha_K + 0\n-\n-\t/* adjust initial values */\n-\tmov\tr6, r6, ror #30\n-\tmov\tr7, r7, ror #30\n-\tmov\tr8, r8, ror #30\n-\n-3:\tsubs\tlr, lr, #1\n-\tsha_f1\tr4, r5, r6, r7, r8\n-\tsha_f1\tr8, r4, r5, r6, r7\n-\tsha_f1\tr7, r8, r4, r5, r6\n-\tsha_f1\tr6, r7, r8, r4, r5\n-\tsha_f1\tr5, r6, r7, r8, r4\n-\tbne\t3b\n-\n-\tldr\tr1, .L_sha_K + 4\n-\tmov\tlr, #4\n-\n-4:\tsubs\tlr, lr, #1\n-\tsha_f2\tr4, r5, r6, r7, r8\n-\tsha_f2\tr8, r4, r5, r6, r7\n-\tsha_f2\tr7, r8, r4, r5, r6\n-\tsha_f2\tr6, r7, r8, r4, r5\n-\tsha_f2\tr5, r6, r7, r8, r4\n-\tbne\t4b\n-\n-\tldr\tr1, .L_sha_K + 8\n-\tmov\tlr, #4\n-\n-5:\tsubs\tlr, lr, #1\n-\tsha_f3\tr4, r5, r6, r7, r8\n-\tsha_f3\tr8, r4, r5, r6, r7\n-\tsha_f3\tr7, r8, r4, r5, r6\n-\tsha_f3\tr6, r7, r8, r4, r5\n-\tsha_f3\tr5, r6, r7, r8, r4\n-\tbne\t5b\n-\n-\tldr\tr1, .L_sha_K + 12\n-\tmov\tlr, #4\n-\n-6:\tsubs\tlr, lr, #1\n-\tsha_f2\tr4, r5, r6, r7, r8\n-\tsha_f2\tr8, r4, r5, r6, r7\n-\tsha_f2\tr7, r8, r4, r5, r6\n-\tsha_f2\tr6, r7, r8, r4, r5\n-\tsha_f2\tr5, r6, r7, r8, r4\n-\tbne\t6b\n-\n-\tldmia\tr0, {r1, r2, r3, ip, lr}\n-\tadd\tr4, r1, r4\n-\tadd\tr5, r2, r5\n-\tadd\tr6, r3, r6, ror #2\n-\tadd\tr7, ip, r7, ror #2\n-\tadd\tr8, lr, r8, ror #2\n-\tstmia\tr0, {r4 - r8}\n-\n-\tldmfd\tsp!, {r4 - r8, pc}\n-\n-.L_sha_K:\n-\t.word\t0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6\ndiff --git a/block-sha1/sha1.c b/block-sha1/sha1.c\nindex 464cb25..a1228cf 100644\n--- a/block-sha1/sha1.c\n+++ b/block-sha1/sha1.c\n@@ -1,7 +1,9 @@\n /*\n- * Based on the Mozilla SHA1 (see mozilla-sha1/sha1.c),\n- * optimized to do word accesses rather than byte accesses,\n+ * SHA1 routine optimized to do word accesses rather than byte accesses,\n  * and to avoid unnecessary copies into the context array.\n+ *\n+ * This was initially based on the Mozilla SHA1 implementation, although\n+ * none of the original Mozilla code remains.\n  */\n \n #include <string.h>\ndiff --git a/block-sha1/sha1.h b/block-sha1/sha1.h\nindex c1ae74d..6ff59b2 100644\n--- a/block-sha1/sha1.h\n+++ b/block-sha1/sha1.h\n@@ -1,7 +1,9 @@\n /*\n- * Based on the Mozilla SHA1 (see mozilla-sha1/sha1.h),\n- * optimized to do word accesses rather than byte accesses,\n+ * SHA1 routine optimized to do word accesses rather than byte accesses,\n  * and to avoid unnecessary copies into the context array.\n+ *\n+ * This was initially based on the Mozilla SHA1 implementation, although\n+ * none of the original Mozilla code remains.\n  */\n \n typedef struct {\ndiff --git a/configure.ac b/configure.ac\nindex 3f1922d..b09b8e4 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -156,19 +156,11 @@ AC_MSG_NOTICE([CHECKS for site configuration])\n # tests.  These tests take up a significant amount of the total test time\n # but are not needed unless you plan to talk to SVN repos.\n #\n-# Define MOZILLA_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine coming from Mozilla. It is GPL'd and should be fast\n-# on non-x86 architectures (e.g. PowerPC), while the OpenSSL version (default\n-# choice) has very fast version optimized for i586.\n-#\n # Define PPC_SHA1 environment variable when running make to make use of\n # a bundled SHA1 routine optimized for PowerPC.\n #\n-# Define ARM_SHA1 environment variable when running make to make use of\n-# a bundled SHA1 routine optimized for ARM.\n-#\n # Define NO_OPENSSL environment variable if you do not have OpenSSL.\n-# This also implies MOZILLA_SHA1.\n+# This also implies BLK_SHA1.\n #\n # Define OPENSSLDIR=/foo/bar if your openssl header and library files are in\n # /foo/bar/include and /foo/bar/lib directories.\ndiff --git a/mozilla-sha1/sha1.c b/mozilla-sha1/sha1.c\ndeleted file mode 100644\nindex 95a4ebf..0000000\n--- a/mozilla-sha1/sha1.c\n+++ /dev/null\n@@ -1,151 +0,0 @@\n-/*\n- * The contents of this file are subject to the Mozilla Public\n- * License Version 1.1 (the \"License\"); you may not use this file\n- * except in compliance with the License. You may obtain a copy of\n- * the License at http://www.mozilla.org/MPL/\n- *\n- * Software distributed under the License is distributed on an \"AS\n- * IS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or\n- * implied. See the License for the specific language governing\n- * rights and limitations under the License.\n- *\n- * The Original Code is SHA 180-1 Reference Implementation (Compact version)\n- *\n- * The Initial Developer of the Original Code is Paul Kocher of\n- * Cryptography Research.  Portions created by Paul Kocher are\n- * Copyright (C) 1995-9 by Cryptography Research, Inc.  All\n- * Rights Reserved.\n- *\n- * Contributor(s):\n- *\n- *     Paul Kocher\n- *\n- * Alternatively, the contents of this file may be used under the\n- * terms of the GNU General Public License Version 2 or later (the\n- * \"GPL\"), in which case the provisions of the GPL are applicable\n- * instead of those above.  If you wish to allow use of your\n- * version of this file only under the terms of the GPL and not to\n- * allow others to use your version of this file under the MPL,\n- * indicate your decision by deleting the provisions above and\n- * replace them with the notice and other provisions required by\n- * the GPL.  If you do not delete the provisions above, a recipient\n- * may use your version of this file under either the MPL or the\n- * GPL.\n- */\n-\n-#include \"sha1.h\"\n-\n-static void shaHashBlock(moz_SHA_CTX *ctx);\n-\n-void moz_SHA1_Init(moz_SHA_CTX *ctx) {\n-  int i;\n-\n-  ctx->lenW = 0;\n-  ctx->sizeHi = ctx->sizeLo = 0;\n-\n-  /* Initialize H with the magic constants (see FIPS180 for constants)\n-   */\n-  ctx->H[0] = 0x67452301;\n-  ctx->H[1] = 0xefcdab89;\n-  ctx->H[2] = 0x98badcfe;\n-  ctx->H[3] = 0x10325476;\n-  ctx->H[4] = 0xc3d2e1f0;\n-\n-  for (i = 0; i < 80; i++)\n-    ctx->W[i] = 0;\n-}\n-\n-\n-void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *_dataIn, int len) {\n-  const unsigned char *dataIn = _dataIn;\n-  int i;\n-\n-  /* Read the data into W and process blocks as they get full\n-   */\n-  for (i = 0; i < len; i++) {\n-    ctx->W[ctx->lenW / 4] <<= 8;\n-    ctx->W[ctx->lenW / 4] |= (unsigned int)dataIn[i];\n-    if ((++ctx->lenW) % 64 == 0) {\n-      shaHashBlock(ctx);\n-      ctx->lenW = 0;\n-    }\n-    ctx->sizeLo += 8;\n-    ctx->sizeHi += (ctx->sizeLo < 8);\n-  }\n-}\n-\n-\n-void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx) {\n-  unsigned char pad0x80 = 0x80;\n-  unsigned char pad0x00 = 0x00;\n-  unsigned char padlen[8];\n-  int i;\n-\n-  /* Pad with a binary 1 (e.g. 0x80), then zeroes, then length\n-   */\n-  padlen[0] = (unsigned char)((ctx->sizeHi >> 24) & 255);\n-  padlen[1] = (unsigned char)((ctx->sizeHi >> 16) & 255);\n-  padlen[2] = (unsigned char)((ctx->sizeHi >> 8) & 255);\n-  padlen[3] = (unsigned char)((ctx->sizeHi >> 0) & 255);\n-  padlen[4] = (unsigned char)((ctx->sizeLo >> 24) & 255);\n-  padlen[5] = (unsigned char)((ctx->sizeLo >> 16) & 255);\n-  padlen[6] = (unsigned char)((ctx->sizeLo >> 8) & 255);\n-  padlen[7] = (unsigned char)((ctx->sizeLo >> 0) & 255);\n-  moz_SHA1_Update(ctx, &pad0x80, 1);\n-  while (ctx->lenW != 56)\n-    moz_SHA1_Update(ctx, &pad0x00, 1);\n-  moz_SHA1_Update(ctx, padlen, 8);\n-\n-  /* Output hash\n-   */\n-  for (i = 0; i < 20; i++) {\n-    hashout[i] = (unsigned char)(ctx->H[i / 4] >> 24);\n-    ctx->H[i / 4] <<= 8;\n-  }\n-\n-  /*\n-   *  Re-initialize the context (also zeroizes contents)\n-   */\n-  moz_SHA1_Init(ctx);\n-}\n-\n-\n-#define SHA_ROT(X,n) (((X) << (n)) | ((X) >> (32-(n))))\n-\n-static void shaHashBlock(moz_SHA_CTX *ctx) {\n-  int t;\n-  unsigned int A,B,C,D,E,TEMP;\n-\n-  for (t = 16; t <= 79; t++)\n-    ctx->W[t] =\n-      SHA_ROT(ctx->W[t-3] ^ ctx->W[t-8] ^ ctx->W[t-14] ^ ctx->W[t-16], 1);\n-\n-  A = ctx->H[0];\n-  B = ctx->H[1];\n-  C = ctx->H[2];\n-  D = ctx->H[3];\n-  E = ctx->H[4];\n-\n-  for (t = 0; t <= 19; t++) {\n-    TEMP = SHA_ROT(A,5) + (((C^D)&B)^D)     + E + ctx->W[t] + 0x5a827999;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-  for (t = 20; t <= 39; t++) {\n-    TEMP = SHA_ROT(A,5) + (B^C^D)           + E + ctx->W[t] + 0x6ed9eba1;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-  for (t = 40; t <= 59; t++) {\n-    TEMP = SHA_ROT(A,5) + ((B&C)|(D&(B|C))) + E + ctx->W[t] + 0x8f1bbcdc;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-  for (t = 60; t <= 79; t++) {\n-    TEMP = SHA_ROT(A,5) + (B^C^D)           + E + ctx->W[t] + 0xca62c1d6;\n-    E = D; D = C; C = SHA_ROT(B, 30); B = A; A = TEMP;\n-  }\n-\n-  ctx->H[0] += A;\n-  ctx->H[1] += B;\n-  ctx->H[2] += C;\n-  ctx->H[3] += D;\n-  ctx->H[4] += E;\n-}\ndiff --git a/mozilla-sha1/sha1.h b/mozilla-sha1/sha1.h\ndeleted file mode 100644\nindex aa48a46..0000000\n--- a/mozilla-sha1/sha1.h\n+++ /dev/null\n@@ -1,50 +0,0 @@\n-/*\n- * The contents of this file are subject to the Mozilla Public\n- * License Version 1.1 (the \"License\"); you may not use this file\n- * except in compliance with the License. You may obtain a copy of\n- * the License at http://www.mozilla.org/MPL/\n- *\n- * Software distributed under the License is distributed on an \"AS\n- * IS\" basis, WITHOUT WARRANTY OF ANY KIND, either express or\n- * implied. See the License for the specific language governing\n- * rights and limitations under the License.\n- *\n- * The Original Code is SHA 180-1 Header File\n- *\n- * The Initial Developer of the Original Code is Paul Kocher of\n- * Cryptography Research.  Portions created by Paul Kocher are\n- * Copyright (C) 1995-9 by Cryptography Research, Inc.  All\n- * Rights Reserved.\n- *\n- * Contributor(s):\n- *\n- *     Paul Kocher\n- *\n- * Alternatively, the contents of this file may be used under the\n- * terms of the GNU General Public License Version 2 or later (the\n- * \"GPL\"), in which case the provisions of the GPL are applicable\n- * instead of those above.  If you wish to allow use of your\n- * version of this file only under the terms of the GPL and not to\n- * allow others to use your version of this file under the MPL,\n- * indicate your decision by deleting the provisions above and\n- * replace them with the notice and other provisions required by\n- * the GPL.  If you do not delete the provisions above, a recipient\n- * may use your version of this file under either the MPL or the\n- * GPL.\n- */\n-\n-typedef struct {\n-  unsigned int H[5];\n-  unsigned int W[80];\n-  int lenW;\n-  unsigned int sizeHi,sizeLo;\n-} moz_SHA_CTX;\n-\n-void moz_SHA1_Init(moz_SHA_CTX *ctx);\n-void moz_SHA1_Update(moz_SHA_CTX *ctx, const void *dataIn, int len);\n-void moz_SHA1_Final(unsigned char hashout[20], moz_SHA_CTX *ctx);\n-\n-#define git_SHA_CTX\tmoz_SHA_CTX\n-#define git_SHA1_Init\tmoz_SHA1_Init\n-#define git_SHA1_Update\tmoz_SHA1_Update\n-#define git_SHA1_Final\tmoz_SHA1_Final\n"},{"id":"121056","messageId":"20090818054913.GB37966@gmail.com","threadId":"20647","inReplyTo":"alpine.LFD.2.00.0908172007590.6044@xanadu.home","subject":"Re: [PATCH v2] remove ARM and Mozilla SHA1 implementations","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-08-18T05:49:15Z","receivedAt":"2009-08-18T05:49:15Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"\nOn Mon, Aug 17, 2009 at 08:09:56PM -0400, Nicolas Pitre wrote:\n> \n>  Makefile            |   26 +------\n>\n> -ifneq (,$(findstring arm,$(uname_M)))\n> -\tARM_SHA1 = YesPlease\n> -\tNO_MKSTEMPS = YesPlease\n> -endif\n\nWhen I added NO_MKSTEMPS I was being conservative when defining\nit on arm (I wasn't able to test that platform).\nLooks like it wasn't needed afterall.\n\nThanks.\n\n-- \n\t\tDavid\n"},{"id":"121093","messageId":"alpine.LFD.2.00.0908180841400.6044@xanadu.home","threadId":"20647","inReplyTo":"20090818054913.GB37966@gmail.com","subject":"Re: [PATCH v2] remove ARM and Mozilla SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-18T12:42:53Z","receivedAt":"2009-08-18T12:42:53Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Mon, 17 Aug 2009, David Aguilar wrote:\n\n> \n> On Mon, Aug 17, 2009 at 08:09:56PM -0400, Nicolas Pitre wrote:\n> > \n> >  Makefile            |   26 +------\n> >\n> > -ifneq (,$(findstring arm,$(uname_M)))\n> > -\tARM_SHA1 = YesPlease\n> > -\tNO_MKSTEMPS = YesPlease\n> > -endif\n> \n> When I added NO_MKSTEMPS I was being conservative when defining\n> it on arm (I wasn't able to test that platform).\n> Looks like it wasn't needed afterall.\n\nIt is a Linux platform after all, which is already taken care of.\n\n\nNicolas\n"},{"id":"121608","messageId":"alpine.LFD.2.00.0908240011010.6044@xanadu.home","threadId":"20647","inReplyTo":"alpine.DEB.1.00.0908180208160.8306@pacific.mpi-cbg.de","subject":"Re: [PATCH] remove ARM and Mozilla SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-24T04:12:22Z","receivedAt":"2009-08-24T04:12:22Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Tue, 18 Aug 2009, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Mon, 17 Aug 2009, Nicolas Pitre wrote:\n> \n> > They are both slower than the new BLK_SHA1 implementation, so it is\n> > pointless to keep them around.\n> > \n> > Signed-off-by: Nicolas Pitre <nico@cam.org>\n> > ---\n> > \n> > Someone else would need to make the call for the PPC version.\n> \n> If I don't forget, I can test tomorrow on 2 different 32-bit PPCs and \n> possibly one 64-bit PPC.\n\nDid you forget?   ;-)\n\n\nNicolas\n"},{"id":"121623","messageId":"alpine.DEB.1.00.0908241333130.11375@intel-tinevez-2-302","threadId":"20647","inReplyTo":"alpine.LFD.2.00.0908240011010.6044@xanadu.home","subject":"Re: [PATCH] remove ARM and Mozilla SHA1 implementations","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-24T11:33:30Z","receivedAt":"2009-08-24T11:33:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 24 Aug 2009, Nicolas Pitre wrote:\n\n> On Tue, 18 Aug 2009, Johannes Schindelin wrote:\n> \n> > On Mon, 17 Aug 2009, Nicolas Pitre wrote:\n> > \n> > > They are both slower than the new BLK_SHA1 implementation, so it is \n> > > pointless to keep them around.\n> > > \n> > > Signed-off-by: Nicolas Pitre <nico@cam.org> ---\n> > > \n> > > Someone else would need to make the call for the PPC version.\n> > \n> > If I don't forget, I can test tomorrow on 2 different 32-bit PPCs and \n> > possibly one 64-bit PPC.\n> \n> Did you forget?  ;-)\n\nYes.\n\nCiao,\nDscho\n"},{"id":"121649","messageId":"alpine.DEB.1.00.0908241849160.8306@pacific.mpi-cbg.de","threadId":"20647","inReplyTo":"alpine.DEB.1.00.0908241333130.11375@intel-tinevez-2-302","subject":"Re: [PATCH] remove ARM and Mozilla SHA1 implementations","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-24T16:52:32Z","receivedAt":"2009-08-24T16:52:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 24 Aug 2009, Johannes Schindelin wrote:\n\n> On Mon, 24 Aug 2009, Nicolas Pitre wrote:\n> \n> > On Tue, 18 Aug 2009, Johannes Schindelin wrote:\n> > \n> > > On Mon, 17 Aug 2009, Nicolas Pitre wrote:\n> > > \n> > > > They are both slower than the new BLK_SHA1 implementation, so it is \n> > > > pointless to keep them around.\n> > > > \n> > > > Signed-off-by: Nicolas Pitre <nico@cam.org> ---\n> > > > \n> > > > Someone else would need to make the call for the PPC version.\n> > > \n> > > If I don't forget, I can test tomorrow on 2 different 32-bit PPCs and \n> > > possibly one 64-bit PPC.\n> > \n> > Did you forget?  ;-)\n> \n> Yes.\n\nAt long last (XTools took a real long time to install here; it is an old \nPowerPC running MacOSX):\n\nBest of 10 \"git rev-list --all\" runs on a full Git repository (including \nmy own tree):\n\nbefore 30ae47b4\n\n\t1.85 real, 1.52 user, 0.28 sys\n\nafter 30ae47b4\n\n\t1.86 real, 1.52 user, 0.28 sys\n\nTo be frank, the 1.85 looks like an outlier, so I think there is exactly 0 \ndifference between the two.\n\nIf you want me to perform other tests, please let me know; I'll be back at \nthis computer tomorrow.\n\nCiao,\nDscho\n"},{"id":"121653","messageId":"alpine.LFD.2.00.0908241318000.6044@xanadu.home","threadId":"20647","inReplyTo":"alpine.DEB.1.00.0908241849160.8306@pacific.mpi-cbg.de","subject":"Re: [PATCH] remove ARM and Mozilla SHA1 implementations","fromName":"Nicolas Pitre","fromEmail":"nico@cam.org","sentAt":"2009-08-24T17:27:46Z","receivedAt":"2009-08-24T17:27:46Z","isPatch":true,"sender":{"key":"nico@fluxnic.net","avatar":"https://avatars.githubusercontent.com/u/702790?v=4"},"body":"On Mon, 24 Aug 2009, Johannes Schindelin wrote:\n\n> Hi,\n> \n> On Mon, 24 Aug 2009, Johannes Schindelin wrote:\n> \n> > On Mon, 24 Aug 2009, Nicolas Pitre wrote:\n> > \n> > > On Tue, 18 Aug 2009, Johannes Schindelin wrote:\n> > > \n> > > > On Mon, 17 Aug 2009, Nicolas Pitre wrote:\n> > > > \n> > > > > They are both slower than the new BLK_SHA1 implementation, so it is \n> > > > > pointless to keep them around.\n> > > > > \n> > > > > Signed-off-by: Nicolas Pitre <nico@cam.org> ---\n> > > > > \n> > > > > Someone else would need to make the call for the PPC version.\n> > > > \n> > > > If I don't forget, I can test tomorrow on 2 different 32-bit PPCs and \n> > > > possibly one 64-bit PPC.\n> > > \n> > > Did you forget?  ;-)\n> > \n> > Yes.\n> \n> At long last (XTools took a real long time to install here; it is an old \n> PowerPC running MacOSX):\n> \n> Best of 10 \"git rev-list --all\" runs on a full Git repository (including \n> my own tree):\n> \n> before 30ae47b4\n> \n> \t1.85 real, 1.52 user, 0.28 sys\n> \n> after 30ae47b4\n> \n> \t1.86 real, 1.52 user, 0.28 sys\n> \n> To be frank, the 1.85 looks like an outlier, so I think there is exactly 0 \n> difference between the two.\n\nMaybe there wasn't any _code_ difference after all.  According to the \nMakefile, only mingw defines NO_OPENSSL (although there might certainly \nbe others).\n\nTRy a build with PPC_SHA1=1, and then compare with BLK_SHA1=1.\nAnd best is to time a fsck --full.\n\n\nNicolas\n"},{"id":"121668","messageId":"eaa105840908241310m5c4007ach19f496fe294eb7ea@mail.gmail.com","threadId":"20647","inReplyTo":"alpine.LFD.2.00.0908241318000.6044@xanadu.home","subject":"Re: [PATCH] remove ARM and Mozilla SHA1 implementations","fromName":"Peter Harris","fromEmail":"git@peter.is-a-geek.org","sentAt":"2009-08-24T20:10:47Z","receivedAt":"2009-08-24T20:10:47Z","isPatch":true,"sender":{"key":"git@peter.is-a-geek.org","avatar":null},"body":"On Mon, Aug 24, 2009 at 1:27 PM, Nicolas Pitre<nico@cam.org> wrote:\n>\n> TRy a build with PPC_SHA1=1, and then compare with BLK_SHA1=1.\n> And best is to time a fsck --full.\n\nI happen to have an old POWER3 AIX box available.\n\nI got tired of waiting for a fsck --full to complete on the git repo,\nso I used git://anongit.freedesktop.org/git/xcb/libxcb instead. Best\nof five runs:\n\nOpenSSL:\n$ time ../git-1.6.4.1/git fsck --full\n\nreal    0m4.120s\nuser    0m3.776s\nsys     0m0.031s\n\nBLK_SHA1:\n$ time ../git-blk/git fsck --full\n\nreal    0m4.231s\nuser    0m3.867s\nsys     0m0.026s\n\nPPC_SHA1:\n\n    CC ppc/sha1ppc.o\nAssembler:\n/tmp//ccdODWpe.s: line 8: 1252-142 Syntax error.\n/tmp//ccdODWpe.s: line 9: 1252-142 Syntax error.\n[same error repeated 42 times]\ngmake: *** [ppc/sha1ppc.o] Error 1\n\nHmm. So that may not help so much after all. Let me know if there are\nany other tests you would like me to run.\n\nThis machine has:\n$ gcc --version\ngcc (GCC) 3.3.2\n\n$ as -v\nas V5.3\n\n$ lsattr -E -l proc0\nfrequency   200000000      Processor Speed       False\nsmt_enabled false          Processor SMT enabled False\nsmt_threads 0              Processor SMT threads False\nstate       enable         Processor state       False\ntype        PowerPC_POWER3 Processor type        False\n\n\nPeter Harris\n"}]}