{"thread":{"id":"82","subject":"[PATCH] use gcrypt instead of libssl for hash","startedAt":"2005-04-17T10:52:53Z","lastAt":"2005-04-22T20:29:45Z","messageCount":13,"participants":["Junichi Uekawa","Linus Torvalds","Edgar Toernig","Paul Mackerras","Klaus Robert Suetterlin","Daniel Barkalow"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"463","messageId":"87hdi5oet6.dancerj@netfort.gr.jp","threadId":"82","inReplyTo":null,"subject":"[PATCH] use gcrypt instead of libssl for hash","fromName":"Junichi Uekawa","fromEmail":"dancer@netfort.gr.jp","sentAt":"2005-04-17T10:52:53Z","receivedAt":"2005-04-17T10:52:53Z","isPatch":true,"sender":{"key":"dancer@netfort.gr.jp","avatar":null},"body":"\nHi,\n\nThis is the first  time for me to send you a patch; be gentle.\nthe following patch allows for use of gcrypt.\n\nlibssl seems to have a restrictive licensing wrt GPL applications.\n\nThis patch adds a requirement for libgcrypt11, and \nremoves the requirement for libssl.\n\nI hope I have not overlooked anything.\n\n\nSigned-off-by: Junichi Uekawa <dancer@debian.org>\n\n\nMakefile: 770595e02be4a9a55ff98910c53617c3b0f1e145\n--- Makefile\n+++ Makefile\t2005-04-17 19:38:00.000000000 +0900\n@@ -7,7 +7,7 @@\n # BREAK YOUR LOCAL DIFFS! show-diff and anything using it will likely randomly\n # break unless your underlying filesystem supports those sub-second times\n # (my ext3 doesn't).\n-CFLAGS=-g -O3 -Wall\n+CFLAGS=-g -O3 -Wall $(shell libgcrypt-config --cflags)\n \n CC=gcc\n \n@@ -21,7 +21,7 @@\n install: $(PROG)\n \tinstall $(PROG) $(HOME)/bin/\n \n-LIBS= -lssl -lz\n+LIBS= $(shell libgcrypt-config --libs) -lz\n \n init-db: init-db.o\n \ncache.h: 5948db759b3f6fb5ade3b027f202330f71a8cb6a\n--- cache.h\n+++ cache.h\t2005-04-17 19:25:40.000000000 +0900\n@@ -12,7 +12,7 @@\n #include <sys/mman.h>\n #include <netinet/in.h>\n \n-#include <openssl/sha.h>\n+#include <gcrypt.h>\n #include <zlib.h>\n \n /*\nread-cache.c: 740ffcce7026b268bd4dfe1d0a773ad7e3a24f96\n--- read-cache.c\n+++ read-cache.c\t2005-04-17 19:34:37.000000000 +0900\n@@ -116,11 +116,14 @@\n int check_sha1_signature(unsigned char *sha1, void *map, unsigned long size)\n {\n \tunsigned char real_sha1[20];\n-\tSHA_CTX c;\n+\tgcry_md_hd_t c;\n \n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, map, size);\n-\tSHA1_Final(real_sha1, &c);\n+\tgcry_md_open(&c, GCRY_MD_SHA1, 0);\n+\tgcry_md_write(c, map, size);\n+\tgcry_md_final(c);\n+\tmemcpy(real_sha1, gcry_md_read(c, 0), 20);\n+\tgcry_md_close(c);\n+\t\n \treturn memcmp(sha1, real_sha1, 20) ? -1 : 0;\n }\n \n@@ -203,7 +206,7 @@\n \tchar *compressed;\n \tz_stream stream;\n \tunsigned char sha1[20];\n-\tSHA_CTX c;\n+\tgcry_md_hd_t c;\n \n \t/* Set it up */\n \tmemset(&stream, 0, sizeof(stream));\n@@ -222,9 +225,11 @@\n \tsize = stream.total_out;\n \n \t/* Sha1.. */\n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, compressed, size);\n-\tSHA1_Final(sha1, &c);\n+\tgcry_md_open(&c, GCRY_MD_SHA1, 0);\n+\tgcry_md_write(c, compressed, size);\n+\tgcry_md_final(c);\n+\tmemcpy(sha1, gcry_md_read(c, 0), 20);\n+\tgcry_md_close(c);\n \n \tif (write_sha1_buffer(sha1, compressed, size) < 0)\n \t\treturn -1;\n@@ -425,17 +430,20 @@\n \n static int verify_hdr(struct cache_header *hdr, unsigned long size)\n {\n-\tSHA_CTX c;\n+\tgcry_md_hd_t c;\n \tunsigned char sha1[20];\n \n \tif (hdr->hdr_signature != htonl(CACHE_SIGNATURE))\n \t\treturn error(\"bad signature\");\n \tif (hdr->hdr_version != htonl(1))\n \t\treturn error(\"bad version\");\n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, hdr, offsetof(struct cache_header, sha1));\n-\tSHA1_Update(&c, hdr+1, size - sizeof(*hdr));\n-\tSHA1_Final(sha1, &c);\n+\tgcry_md_open(&c, GCRY_MD_SHA1, 0);\n+\tgcry_md_write(c, hdr, offsetof(struct cache_header, sha1));\n+\tgcry_md_write(c, hdr+1, size - sizeof(*hdr));\n+\tgcry_md_final(c);\n+\tmemcpy(sha1, gcry_md_read(c, 0), 20);\n+\tgcry_md_close(c);\n+\n \tif (memcmp(sha1, hdr->sha1, 20))\n \t\treturn error(\"bad header sha1\");\n \treturn 0;\n@@ -498,7 +506,8 @@\n \n int write_cache(int newfd, struct cache_entry **cache, int entries)\n {\n-\tSHA_CTX c;\n+\tgcry_md_hd_t c;\n+\n \tstruct cache_header hdr;\n \tint i;\n \n@@ -506,14 +515,16 @@\n \thdr.hdr_version = htonl(1);\n \thdr.hdr_entries = htonl(entries);\n \n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, &hdr, offsetof(struct cache_header, sha1));\n+\tgcry_md_open(&c, GCRY_MD_SHA1, 0);\n+\tgcry_md_write(c, &hdr, offsetof(struct cache_header, sha1));\n \tfor (i = 0; i < entries; i++) {\n \t\tstruct cache_entry *ce = cache[i];\n \t\tint size = ce_size(ce);\n-\t\tSHA1_Update(&c, ce, size);\n+\t\tgcry_md_write(c, ce, size);\n \t}\n-\tSHA1_Final(hdr.sha1, &c);\n+\tgcry_md_final(c);\n+\tmemcpy(hdr.sha1, gcry_md_read(c, 0), 20);\n+\tgcry_md_close(c);\n \n \tif (write(newfd, &hdr, sizeof(hdr)) != sizeof(hdr))\n \t\treturn -1;\nupdate-cache.c: 5afecd1a4fd90d2505753ce2d5044d780fe69a7f\n--- update-cache.c\n+++ update-cache.c\t2005-04-17 19:36:40.000000000 +0900\n@@ -22,7 +22,7 @@\n \tvoid *out = malloc(max_out_bytes);\n \tvoid *metadata = malloc(namelen + 200);\n \tvoid *in;\n-\tSHA_CTX c;\n+\tgcry_md_hd_t c;\n \n \tin = \"\";\n \tif (size)\n@@ -54,9 +54,11 @@\n \n \tdeflateEnd(&stream);\n \t\n-\tSHA1_Init(&c);\n-\tSHA1_Update(&c, out, stream.total_out);\n-\tSHA1_Final(ce->sha1, &c);\n+\tgcry_md_open(&c, GCRY_MD_SHA1, 0);\n+\tgcry_md_write(c, out, stream.total_out);\n+\tgcry_md_final(c);\n+\tmemcpy(ce->sha1, gcry_md_read(c, 0), 20);\n+\tgcry_md_close(c);\n \n \treturn write_sha1_buffer(ce->sha1, out, stream.total_out);\n }\nwrite-tree.c: 34a351b20fb38ea588f34bd9634f101b9dc533cb\n\n\nregards,\n\tjunichi\n\n\n-- \nJunichi Uekawa, Debian Developer\n17D6 120E 4455 1832 9423  7447 3059 BF92 CD37 56F4\nhttp://www.netfort.gr.jp/~dancer/\n"},{"id":"507","messageId":"Pine.LNX.4.58.0504171039460.7211@ppc970.osdl.org","threadId":"82","inReplyTo":"87hdi5oet6.dancerj@netfort.gr.jp","subject":"Re: [PATCH] use gcrypt instead of libssl for hash","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-17T17:52:07Z","receivedAt":"2005-04-17T17:52:07Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sun, 17 Apr 2005, Junichi Uekawa wrote:\n> \n> This is the first  time for me to send you a patch; be gentle.\n> the following patch allows for use of gcrypt.\n\nWell, libgcrypt seems to be pretty rare out there - I certainly don't have \nit installed on my machine.\n\n> libssl seems to have a restrictive licensing wrt GPL applications.\n\nIt does? I really don't read it that way. \n\nThe openssl license is BSD+mention, but it only kicks in if you \n_redistribute_ it (and you're not allowed to market things as being \nopenssl based without giving them credit, but that's another thing).\n\nSo yes, the openssl license is incompatible with the GPL in the sense that \nyou cannot actually _mix_ the openssl source-code with the GPL \nsource-code. But that's true of a lot of libraries, the normal system C \nlibrary being just one common example.\n\nThe GPL makes explicit mention of the system libraries (which openssl\ndefinitely is by now), so it's ok by the GPL . And I don't see how you'd\nclaim that the openssl license doesn't allow it. So it all looks ok by me.\n\nThat said, if somebody wants to abstract this out, and have a simple \"sign \nwith sha1\" interface that can be used with both openssl and libgcrypt (or \nany other crypt license), then hey, go wild. Or merge the SHA1 code from \nthe kernel, even, and make the project entirely self-sufficient.\n\nBut requiring libgcrypt seems silly. Especially as the libgcrypt \ninterfaces are horribly ugly, much more so than the openssl ones - so even \nif you use libgcrypt, you don't actually want to use it directly, you want \nto have much nicer wrappers around it.\n\n\t\tLinus\n"},{"id":"559","messageId":"87fyxp1161.dancerj@netfort.gr.jp","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504171039460.7211@ppc970.osdl.org","subject":"Re: [PATCH] use gcrypt instead of libssl for hash","fromName":"Junichi Uekawa","fromEmail":"dancer@netfort.gr.jp","sentAt":"2005-04-17T22:36:06Z","receivedAt":"2005-04-17T22:36:06Z","isPatch":true,"sender":{"key":"dancer@netfort.gr.jp","avatar":null},"body":"Hi,\n\nThanks for your comments.\n\n> > This is the first  time for me to send you a patch; be gentle.\n> > the following patch allows for use of gcrypt.\n> \n> Well, libgcrypt seems to be pretty rare out there - I certainly don't have \n> it installed on my machine.\n\nHmm... okay. Might be the case if you don't use much of GNOME and other\napps.\n\n> > libssl seems to have a restrictive licensing wrt GPL applications.\n> \n> The GPL makes explicit mention of the system libraries (which openssl\n> definitely is by now), so it's ok by the GPL . And I don't see how you'd\n> claim that the openssl license doesn't allow it. So it all looks ok by me.\n\n>From a standpoint of Debian Developer; it feels not-so-clear;\nsince Debian will be distributing openssl and git.\n\nopenssl guys seem to recommend adding a quote, which might be sufficient.\n\"This program is released under the GPL with the additional exemption that compiling, linking, and/or using OpenSSL is allowed.\" \n\thttp://www.openssl.org/support/faq.html#LEGAL2\n\n\n> But requiring libgcrypt seems silly. Especially as the libgcrypt \n> interfaces are horribly ugly, much more so than the openssl ones - so even \n> if you use libgcrypt, you don't actually want to use it directly, you want \n> to have much nicer wrappers around it.\n\nI'll consider wrappers approach.\n\n\nregards,\n\tjunichi\n\n-- \nJunichi Uekawa, Debian Developer\n17D6 120E 4455 1832 9423  7447 3059 BF92 CD37 56F4\nhttp://www.netfort.gr.jp/~dancer/\n"},{"id":"621","messageId":"20050418055824.42d621b8.froese@gmx.de","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504171039460.7211@ppc970.osdl.org","subject":"Re: [PATCH] use gcrypt instead of libssl for hash","fromName":"Edgar Toernig","fromEmail":"froese@gmx.de","sentAt":"2005-04-18T03:58:24Z","receivedAt":"2005-04-18T03:58:24Z","isPatch":true,"sender":{"key":"froese@gmx.de","avatar":null},"body":"Linus Torvalds wrote:\n>\n> Well, libgcrypt seems to be pretty rare out there - I certainly don't have \n> it installed on my machine.\n\nWell, I don't even have openssl ...\n\n> Or merge the SHA1 code from the kernel, even, and make the project\n> entirely self-sufficient.\n\n... so I took the sha1 code from Firefox (it's MPL or GPL - you choose).\n\nHere's the patch.\n\ndiff -ruN git-0.04-orig/Makefile git-0.04/Makefile\n--- git-0.04-orig/Makefile\tMon Apr 11 05:48:10 2005\n+++ git-0.04/Makefile\tMon Apr 18 05:41:49 2005\n@@ -9,42 +9,57 @@\n install: $(PROG)\n \tinstall $(PROG) $(HOME)/bin/\n \n-LIBS= -lssl -lz\n+LIBS= -lz\n \n init-db: init-db.o\n \n-update-cache: update-cache.o read-cache.o\n-\t$(CC) $(CFLAGS) -o update-cache update-cache.o read-cache.o $(LIBS)\n+update-cache: update-cache.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o update-cache update-cache.o read-cache.o sha1.o $(LIBS)\n \n-show-diff: show-diff.o read-cache.o\n-\t$(CC) $(CFLAGS) -o show-diff show-diff.o read-cache.o $(LIBS)\n+show-diff: show-diff.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o show-diff show-diff.o read-cache.o sha1.o $(LIBS)\n \n-write-tree: write-tree.o read-cache.o\n-\t$(CC) $(CFLAGS) -o write-tree write-tree.o read-cache.o $(LIBS)\n+write-tree: write-tree.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o write-tree write-tree.o read-cache.o sha1.o $(LIBS)\n \n-read-tree: read-tree.o read-cache.o\n-\t$(CC) $(CFLAGS) -o read-tree read-tree.o read-cache.o $(LIBS)\n+read-tree: read-tree.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o read-tree read-tree.o read-cache.o sha1.o $(LIBS)\n \n-commit-tree: commit-tree.o read-cache.o\n-\t$(CC) $(CFLAGS) -o commit-tree commit-tree.o read-cache.o $(LIBS)\n+commit-tree: commit-tree.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o commit-tree commit-tree.o read-cache.o sha1.o $(LIBS)\n \n-cat-file: cat-file.o read-cache.o\n-\t$(CC) $(CFLAGS) -o cat-file cat-file.o read-cache.o $(LIBS)\n+cat-file: cat-file.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o cat-file cat-file.o read-cache.o sha1.o $(LIBS)\n \n-fsck-cache: fsck-cache.o read-cache.o\n-\t$(CC) $(CFLAGS) -o fsck-cache fsck-cache.o read-cache.o $(LIBS)\n+fsck-cache: fsck-cache.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o fsck-cache fsck-cache.o read-cache.o sha1.o $(LIBS)\n \n-checkout-cache: checkout-cache.o read-cache.o\n-\t$(CC) $(CFLAGS) -o checkout-cache checkout-cache.o read-cache.o $(LIBS)\n+checkout-cache: checkout-cache.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o checkout-cache checkout-cache.o read-cache.o sha1.o $(LIBS)\n \n-diff-tree: diff-tree.o read-cache.o\n-\t$(CC) $(CFLAGS) -o diff-tree diff-tree.o read-cache.o $(LIBS)\n-\n-read-cache.o: cache.h\n-show-diff.o: cache.h\n+diff-tree: diff-tree.o read-cache.o sha1.o\n+\t$(CC) $(CFLAGS) -o diff-tree diff-tree.o read-cache.o sha1.o $(LIBS)\n \n clean:\n \trm -f *.o $(PROG) temp_git_file_*\n \n backup: clean\n \tcd .. ; tar czvf dircache.tar.gz dir-cache\n+\n+depend:\n+\tmakedepend -Y -- -- *.c 2>/dev/null\n+\n+# DO NOT DELETE\n+\n+cat-file.o: cache.h sha1.h\n+checkout-cache.o: cache.h sha1.h\n+commit-tree.o: cache.h sha1.h\n+diff-tree.o: cache.h sha1.h\n+fsck-cache.o: cache.h sha1.h\n+init-db.o: cache.h sha1.h\n+read-cache.o: cache.h sha1.h\n+read-tree.o: cache.h sha1.h\n+sha1.o: sha1.h\n+show-diff.o: cache.h sha1.h\n+update-cache.o: cache.h sha1.h\n+write-tree.o: cache.h sha1.h\ndiff -ruN git-0.04-orig/cache.h git-0.04/cache.h\n--- git-0.04-orig/cache.h\tSun Apr 10 20:19:02 2005\n+++ git-0.04/cache.h\tMon Apr 18 05:46:47 2005\n@@ -11,7 +11,7 @@\n #include <errno.h>\n #include <sys/mman.h>\n \n-#include <openssl/sha.h>\n+#include \"sha1.h\"\n #include <zlib.h>\n \n /*\ndiff -ruN git-0.04-orig/sha1.c git-0.04/sha1.c\n--- git-0.04-orig/sha1.c\tThu Jan  1 01:00:00 1970\n+++ git-0.04/sha1.c\tMon Apr 18 05:40:25 2005\n@@ -0,0 +1,152 @@\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(SHA_CTX *ctx);\n+\n+void SHA1_Init(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 SHA1_Update(SHA_CTX *ctx, void *_dataIn, int len) {\n+  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 SHA1_Final(unsigned char hashout[20], 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+  SHA1_Update(ctx, &pad0x80, 1);\n+  while (ctx->lenW != 56)\n+    SHA1_Update(ctx, &pad0x00, 1);\n+  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+  SHA1_Init(ctx);\n+}\n+\n+\n+#define SHA_ROT(X,n) (((X) << (n)) | ((X) >> (32-(n))))\n+\n+static void shaHashBlock(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+}\n+\ndiff -ruN git-0.04-orig/sha1.h git-0.04/sha1.h\n--- git-0.04-orig/sha1.h\tThu Jan  1 01:00:00 1970\n+++ git-0.04/sha1.h\tMon Apr 18 05:40:25 2005\n@@ -0,0 +1,45 @@\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+} SHA_CTX;\n+\n+void SHA1_Init(SHA_CTX *ctx);\n+void SHA1_Update(SHA_CTX *ctx, void *dataIn, int len);\n+void SHA1_Final(unsigned char hashout[20], SHA_CTX *ctx);\n\n\nCiao, ET.\n"},{"id":"1181","messageId":"Pine.LNX.4.58.0504211238150.2344@ppc970.osdl.org","threadId":"82","inReplyTo":"20050418055824.42d621b8.froese@gmx.de","subject":"Mozilla SHA1 implementation","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-21T19:48:42Z","receivedAt":"2005-04-21T19:48:42Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nI've just integrated the Mozilla SHA1 library implementation that Adgar\nToernig sent me into the standard git archive (but I did the integration\ndifferently).\n\nThe Mozilla SHA1 code is copyright Paul Kocher and Cryptography Research,\nand is released under a dual MPL/GPL license. Git obviously uses it in the\nGPL version, but I left the MPL choice there too, so that those two files\n(that are in a subdirectory of its own) will continue to be dual-licensed.\n\nNOTE! I left git using the openssl libraries by default, and this is a\nbuilt-time choice in the makefile. You can choose the Mozilla SHA1\nimplementation by doing\n\n\tmake clean\n\tMOZILLA_SHA1=1 make\n\tmake install\n\nbut I suspect that anybody that has openssl installed and is working on an\nx86 is much better off with the i586-optimized openssl version. But if you\ndon't have openssl by default, or if you don't like openssl for some other\nreason, you now have a nice easy choice.\n\nInterestingly, the Mozilla SHA1 code is about twice as fast as the openssl\ncode on my G5, and judging by the disassembly, it's because it's much\nsimpler. I think the openssl people have unrolled all the loops totally,\nwhich tends to be a disaster on any half-way modern CPU. But hey, it could\nbe something as simple as optimization flags too.\n\n\t\t\tLinus\n"},{"id":"1213","messageId":"20050422005928.218a753a.froese@gmx.de","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504211238150.2344@ppc970.osdl.org","subject":"Re: Mozilla SHA1 implementation","fromName":"Edgar Toernig","fromEmail":"froese@gmx.de","sentAt":"2005-04-21T22:59:28Z","receivedAt":"2005-04-21T22:59:28Z","isPatch":false,"sender":{"key":"froese@gmx.de","avatar":null},"body":"Linus Torvalds wrote:\n>\n> I've just integrated the Mozilla SHA1 library implementation into the\n> standard git archive\n\nThanks.\n\nIn the mood for another compatibility hack?  My zlib doesn't have\ndeflateBound and browsing through the git-ml archive it seems I'm\nnot the only one.  How about putting this snippet into some header\nfile?\n\n#if ZLIB_VERNUM < 0x1200\n#define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)\n#endif\n\nThe formula is the conservative upper bound from zlib-1.2.2.\n\nCiao, ET.\n"},{"id":"1241","messageId":"17000.40571.132840.126528@cargo.ozlabs.ibm.com","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504211238150.2344@ppc970.osdl.org","subject":"Re: Mozilla SHA1 implementation","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2005-04-22T06:49:31Z","receivedAt":"2005-04-22T06:49:31Z","isPatch":false,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Linus Torvalds writes:\n\n> I've just integrated the Mozilla SHA1 library implementation that Adgar\n> Toernig sent me into the standard git archive (but I did the integration\n> differently).\n\nHere is a new PPC SHA1 patch that integrates better with this...\n\n> Interestingly, the Mozilla SHA1 code is about twice as fast as the openssl\n> code on my G5, and judging by the disassembly, it's because it's much\n> simpler. I think the openssl people have unrolled all the loops totally,\n> which tends to be a disaster on any half-way modern CPU. But hey, it could\n> be something as simple as optimization flags too.\n\nVery interesting.  On my G4 powerbook (since I am at LCA), for a\nfsck-cache on a linux-2.6 tree, it takes 6.6 seconds with the openssl\nSHA1, 10.7 seconds with the Mozilla SHA1, and ~5.8 seconds with my\nSHA1.  I'll test it on a G5 tonight, hopefully.\n\nPaul.\n\ndiff -urN git.orig/Makefile git/Makefile\n--- git.orig/Makefile\t2005-04-22 16:23:44.000000000 +1000\n+++ git/Makefile\t2005-04-22 16:43:31.000000000 +1000\n@@ -34,9 +34,14 @@\n   SHA1_HEADER=\"mozilla-sha1/sha1.h\"\n   LIB_OBJS += mozilla-sha1/sha1.o\n else\n+ifdef PPC_SHA1\n+  SHA1_HEADER=\"ppc/sha1.h\"\n+  LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o\n+else\n   SHA1_HEADER=<openssl/sha.h>\n   LIBS += -lssl\n endif\n+endif\n \n CFLAGS += '-DSHA1_HEADER=$(SHA1_HEADER)'\n \n@@ -77,7 +82,7 @@\n write-tree.o: $(LIB_H)\n \n clean:\n-\trm -f *.o mozilla-sha1/*.o $(PROG) $(LIB_FILE)\n+\trm -f *.o mozilla-sha1/*.o ppc/*.o $(PROG) $(LIB_FILE)\n \n backup: clean\n \tcd .. ; tar czvf dircache.tar.gz dir-cache\ndiff -urN git.orig/ppc/sha1.c git/ppc/sha1.c\n--- /dev/null\t2005-04-04 12:56:19.000000000 +1000\n+++ git/ppc/sha1.c\t2005-04-22 16:29:19.000000000 +1000\n@@ -0,0 +1,72 @@\n+/*\n+ * SHA-1 implementation.\n+ *\n+ * Copyright (C) 2005 Paul Mackerras <paulus@samba.org>\n+ *\n+ * This version assumes we are running on a big-endian machine.\n+ * It calls an external sha1_core() to process blocks of 64 bytes.\n+ */\n+#include <stdio.h>\n+#include <string.h>\n+#include \"sha1.h\"\n+\n+extern void sha1_core(uint32_t *hash, const unsigned char *p,\n+\t\t      unsigned int nblocks);\n+\n+int SHA1_Init(SHA_CTX *c)\n+{\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+\tc->len = 0;\n+\tc->cnt = 0;\n+\treturn 0;\n+}\n+\n+int SHA1_Update(SHA_CTX *c, const void *ptr, unsigned long n)\n+{\n+\tunsigned long nb;\n+\tconst unsigned char *p = ptr;\n+\n+\tc->len += n << 3;\n+\twhile (n != 0) {\n+\t\tif (c->cnt || n < 64) {\n+\t\t\tnb = 64 - c->cnt;\n+\t\t\tif (nb > n)\n+\t\t\t\tnb = n;\n+\t\t\tmemcpy(&c->buf.b[c->cnt], p, nb);\n+\t\t\tif ((c->cnt += nb) == 64) {\n+\t\t\t\tsha1_core(c->hash, c->buf.b, 1);\n+\t\t\t\tc->cnt = 0;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tnb = n >> 6;\n+\t\t\tsha1_core(c->hash, p, nb);\n+\t\t\tnb <<= 6;\n+\t\t}\n+\t\tn -= nb;\n+\t\tp += nb;\n+\t}\n+\treturn 0;\n+}\t\n+\n+int SHA1_Final(unsigned char *hash, SHA_CTX *c)\n+{\n+\tunsigned int cnt = c->cnt;\n+\n+\tc->buf.b[cnt++] = 0x80;\n+\tif (cnt > 56) {\n+\t\tif (cnt < 64)\n+\t\t\tmemset(&c->buf.b[cnt], 0, 64 - cnt);\n+\t\tsha1_core(c->hash, c->buf.b, 1);\n+\t\tcnt = 0;\n+\t}\n+\tif (cnt < 56)\n+\t\tmemset(&c->buf.b[cnt], 0, 56 - cnt);\n+\tc->buf.l[7] = c->len;\n+\tsha1_core(c->hash, c->buf.b, 1);\n+\tmemcpy(hash, c->hash, 20);\n+\treturn 0;\n+}\ndiff -urN git.orig/ppc/sha1.h git/ppc/sha1.h\n--- /dev/null\t2005-04-04 12:56:19.000000000 +1000\n+++ git/ppc/sha1.h\t2005-04-22 16:45:28.000000000 +1000\n@@ -0,0 +1,20 @@\n+/*\n+ * SHA-1 implementation.\n+ *\n+ * Copyright (C) 2005 Paul Mackerras <paulus@samba.org>\n+ */\n+#include <stdint.h>\n+\n+typedef struct sha_context {\n+\tuint32_t hash[5];\n+\tuint32_t cnt;\n+\tuint64_t len;\n+\tunion {\n+\t\tunsigned char b[64];\n+\t\tuint64_t l[8];\n+\t} buf;\n+} SHA_CTX;\n+\n+int SHA1_Init(SHA_CTX *c);\n+int SHA1_Update(SHA_CTX *c, const void *p, unsigned long n);\n+int SHA1_Final(unsigned char *hash, SHA_CTX *c);\ndiff -urN git.orig/ppc/sha1ppc.S git/ppc/sha1ppc.S\n--- /dev/null\t2005-04-04 12:56:19.000000000 +1000\n+++ git/ppc/sha1ppc.S\t2005-04-22 16:29:19.000000000 +1000\n@@ -0,0 +1,185 @@\n+/*\n+ * SHA-1 implementation for PowerPC.\n+ *\n+ * Copyright (C) 2005 Paul Mackerras.\n+ */\n+#define FS\t80\n+\n+/*\n+ * We roll the registers for T, A, B, C, D, E around on each\n+ * iteration; T on iteration t is A on iteration t+1, and so on.\n+ * We use registers 7 - 12 for this.\n+ */\n+#define RT(t)\t((((t)+5)%6)+7)\n+#define RA(t)\t((((t)+4)%6)+7)\n+#define RB(t)\t((((t)+3)%6)+7)\n+#define RC(t)\t((((t)+2)%6)+7)\n+#define RD(t)\t((((t)+1)%6)+7)\n+#define RE(t)\t((((t)+0)%6)+7)\n+\n+/* We use registers 16 - 31 for the W values */\n+#define W(t)\t(((t)%16)+16)\n+\n+#define STEPD0(t)\t\t\t\t\\\n+\tand\t%r6,RB(t),RC(t);\t\t\\\n+\tandc\t%r0,RD(t),RB(t);\t\t\\\n+\trotlwi\tRT(t),RA(t),5;\t\t\t\\\n+\trotlwi\tRB(t),RB(t),30;\t\t\t\\\n+\tor\t%r6,%r6,%r0;\t\t\t\\\n+\tadd\t%r0,RE(t),%r15;\t\t\t\\\n+\tadd\tRT(t),RT(t),%r6;\t\t\\\n+\tadd\t%r0,%r0,W(t);\t\t\t\\\n+\tadd\tRT(t),RT(t),%r0\n+\n+#define STEPD1(t)\t\t\t\t\\\n+\txor\t%r6,RB(t),RC(t);\t\t\\\n+\trotlwi\tRT(t),RA(t),5;\t\t\t\\\n+\trotlwi\tRB(t),RB(t),30;\t\t\t\\\n+\txor\t%r6,%r6,RD(t);\t\t\t\\\n+\tadd\t%r0,RE(t),%r15;\t\t\t\\\n+\tadd\tRT(t),RT(t),%r6;\t\t\\\n+\tadd\t%r0,%r0,W(t);\t\t\t\\\n+\tadd\tRT(t),RT(t),%r0\n+\n+#define STEPD2(t)\t\t\t\t\\\n+\tand\t%r6,RB(t),RC(t);\t\t\\\n+\tand\t%r0,RB(t),RD(t);\t\t\\\n+\trotlwi\tRT(t),RA(t),5;\t\t\t\\\n+\trotlwi\tRB(t),RB(t),30;\t\t\t\\\n+\tor\t%r6,%r6,%r0;\t\t\t\\\n+\tand\t%r0,RC(t),RD(t);\t\t\\\n+\tor\t%r6,%r6,%r0;\t\t\t\\\n+\tadd\t%r0,RE(t),%r15;\t\t\t\\\n+\tadd\tRT(t),RT(t),%r6;\t\t\\\n+\tadd\t%r0,%r0,W(t);\t\t\t\\\n+\tadd\tRT(t),RT(t),%r0\n+\n+#define LOADW(t)\t\t\t\t\\\n+\tlwz\tW(t),(t)*4(%r4)\n+\n+#define UPDATEW(t)\t\t\t\t\\\n+\txor\t%r0,W((t)-3),W((t)-8);\t\t\\\n+\txor\tW(t),W((t)-16),W((t)-14);\t\\\n+\txor\tW(t),W(t),%r0;\t\t\t\\\n+\trotlwi\tW(t),W(t),1\n+\n+#define STEP0LD4(t)\t\t\t\t\\\n+\tSTEPD0(t);   LOADW((t)+4);\t\t\\\n+\tSTEPD0((t)+1); LOADW((t)+5);\t\t\\\n+\tSTEPD0((t)+2); LOADW((t)+6);\t\t\\\n+\tSTEPD0((t)+3); LOADW((t)+7)\n+\n+#define STEPUP4(t, fn)\t\t\t\t\\\n+\tSTEP##fn(t);   UPDATEW((t)+4);\t\t\\\n+\tSTEP##fn((t)+1); UPDATEW((t)+5);\t\\\n+\tSTEP##fn((t)+2); UPDATEW((t)+6);\t\\\n+\tSTEP##fn((t)+3); UPDATEW((t)+7)\n+\n+#define STEPUP20(t, fn)\t\t\t\t\\\n+\tSTEPUP4(t, fn);\t\t\t\t\\\n+\tSTEPUP4((t)+4, fn);\t\t\t\\\n+\tSTEPUP4((t)+8, fn);\t\t\t\\\n+\tSTEPUP4((t)+12, fn);\t\t\t\\\n+\tSTEPUP4((t)+16, fn)\n+\n+\t.globl\tsha1_core\n+sha1_core:\n+\tstwu\t%r1,-FS(%r1)\n+\tstw\t%r15,FS-68(%r1)\n+\tstw\t%r16,FS-64(%r1)\n+\tstw\t%r17,FS-60(%r1)\n+\tstw\t%r18,FS-56(%r1)\n+\tstw\t%r19,FS-52(%r1)\n+\tstw\t%r20,FS-48(%r1)\n+\tstw\t%r21,FS-44(%r1)\n+\tstw\t%r22,FS-40(%r1)\n+\tstw\t%r23,FS-36(%r1)\n+\tstw\t%r24,FS-32(%r1)\n+\tstw\t%r25,FS-28(%r1)\n+\tstw\t%r26,FS-24(%r1)\n+\tstw\t%r27,FS-20(%r1)\n+\tstw\t%r28,FS-16(%r1)\n+\tstw\t%r29,FS-12(%r1)\n+\tstw\t%r30,FS-8(%r1)\n+\tstw\t%r31,FS-4(%r1)\n+\n+\t/* Load up A - E */\n+\tlwz\tRA(0),0(%r3)\t/* A */\n+\tlwz\tRB(0),4(%r3)\t/* B */\n+\tlwz\tRC(0),8(%r3)\t/* C */\n+\tlwz\tRD(0),12(%r3)\t/* D */\n+\tlwz\tRE(0),16(%r3)\t/* E */\n+\n+\tmtctr\t%r5\n+\n+1:\tLOADW(0)\n+\tLOADW(1)\n+\tLOADW(2)\n+\tLOADW(3)\n+\n+\tlis\t%r15,0x5a82\t/* K0-19 */\n+\tori\t%r15,%r15,0x7999\n+\tSTEP0LD4(0)\n+\tSTEP0LD4(4)\n+\tSTEP0LD4(8)\n+\tSTEPUP4(12, D0)\n+\tSTEPUP4(16, D0)\n+\n+\tlis\t%r15,0x6ed9\t/* K20-39 */\n+\tori\t%r15,%r15,0xeba1\n+\tSTEPUP20(20, D1)\n+\n+\tlis\t%r15,0x8f1b\t/* K40-59 */\n+\tori\t%r15,%r15,0xbcdc\n+\tSTEPUP20(40, D2)\n+\n+\tlis\t%r15,0xca62\t/* K60-79 */\n+\tori\t%r15,%r15,0xc1d6\n+\tSTEPUP4(60, D1)\n+\tSTEPUP4(64, D1)\n+\tSTEPUP4(68, D1)\n+\tSTEPUP4(72, D1)\n+\tSTEPD1(76)\n+\tSTEPD1(77)\n+\tSTEPD1(78)\n+\tSTEPD1(79)\n+\n+\tlwz\t%r20,16(%r3)\n+\tlwz\t%r19,12(%r3)\n+\tlwz\t%r18,8(%r3)\n+\tlwz\t%r17,4(%r3)\n+\tlwz\t%r16,0(%r3)\n+\tadd\t%r20,RE(80),%r20\n+\tadd\tRD(0),RD(80),%r19\n+\tadd\tRC(0),RC(80),%r18\n+\tadd\tRB(0),RB(80),%r17\n+\tadd\tRA(0),RA(80),%r16\n+\tmr\tRE(0),%r20\n+\tstw\tRA(0),0(%r3)\n+\tstw\tRB(0),4(%r3)\n+\tstw\tRC(0),8(%r3)\n+\tstw\tRD(0),12(%r3)\n+\tstw\tRE(0),16(%r3)\n+\n+\taddi\t%r4,%r4,64\n+\tbdnz\t1b\n+\n+\tlwz\t%r15,FS-68(%r1)\n+\tlwz\t%r16,FS-64(%r1)\n+\tlwz\t%r17,FS-60(%r1)\n+\tlwz\t%r18,FS-56(%r1)\n+\tlwz\t%r19,FS-52(%r1)\n+\tlwz\t%r20,FS-48(%r1)\n+\tlwz\t%r21,FS-44(%r1)\n+\tlwz\t%r22,FS-40(%r1)\n+\tlwz\t%r23,FS-36(%r1)\n+\tlwz\t%r24,FS-32(%r1)\n+\tlwz\t%r25,FS-28(%r1)\n+\tlwz\t%r26,FS-24(%r1)\n+\tlwz\t%r27,FS-20(%r1)\n+\tlwz\t%r28,FS-16(%r1)\n+\tlwz\t%r29,FS-12(%r1)\n+\tlwz\t%r30,FS-8(%r1)\n+\tlwz\t%r31,FS-4(%r1)\n+\taddi\t%r1,%r1,FS\n+\tblr\n"},{"id":"1245","messageId":"17000.43340.760901.175004@cargo.ozlabs.ibm.com","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504211238150.2344@ppc970.osdl.org","subject":"Re: Mozilla SHA1 implementation","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2005-04-22T07:35:40Z","receivedAt":"2005-04-22T07:35:40Z","isPatch":false,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Linus Torvalds writes:\n\n> Interestingly, the Mozilla SHA1 code is about twice as fast as the openssl\n> code on my G5, and judging by the disassembly, it's because it's much\n> simpler. I think the openssl people have unrolled all the loops totally,\n> which tends to be a disaster on any half-way modern CPU. But hey, it could\n> be something as simple as optimization flags too.\n\nWhich gcc version are you using?\n\nI get the opposite result on my 2GHz G5: the Mozilla version does\n45MB/s, the openssl version does 135MB/s, and my version does 218MB/s.\nThe time for a fsck-cache on a linux-2.6 tree (cache hot) is 8.0\nseconds for the Mozilla version, 5.2 seconds for the openssl version,\nand 4.4 seconds for my version.\n\nPaul.\n"},{"id":"1283","messageId":"Pine.LNX.4.58.0504220824480.2344@ppc970.osdl.org","threadId":"82","inReplyTo":"17000.43340.760901.175004@cargo.ozlabs.ibm.com","subject":"Re: Mozilla SHA1 implementation","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-22T15:31:55Z","receivedAt":"2005-04-22T15:31:55Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 22 Apr 2005, Paul Mackerras wrote:\n> Linus Torvalds writes:\n> \n> > Interestingly, the Mozilla SHA1 code is about twice as fast as the openssl\n> > code on my G5, and judging by the disassembly, it's because it's much\n> > simpler. I think the openssl people have unrolled all the loops totally,\n> > which tends to be a disaster on any half-way modern CPU. But hey, it could\n> > be something as simple as optimization flags too.\n> \n> Which gcc version are you using?\n\ngcc-3.3.3.\n\nBut it's more likely the precompiled libssl. I'm not compiling the openssl\nthing myself, but just using the standard 0.9.7a version that comes with\nYDL. Which, btw, causes all of \n\n\t/lib/libcrypto.so.4\n\t/usr/lib/libgssapi_krb5.so.2\n\t/usr/lib/libkrb5.so.3\n\t/lib/libcom_err.so.2\n\t/usr/lib/libk5crypto.so.3\n\t/lib/libresolv.so.2\n\t/lib/libdl.so.2\n\nto also be included. Oh, well.\n\n> I get the opposite result on my 2GHz G5: the Mozilla version does\n> 45MB/s, the openssl version does 135MB/s, and my version does 218MB/s.\n> The time for a fsck-cache on a linux-2.6 tree (cache hot) is 8.0\n> seconds for the Mozilla version, 5.2 seconds for the openssl version,\n> and 4.4 seconds for my version.\n\nI get 16 seconds for the openssl one, and 8 for the Mozilla one. I'll try \nyour version.\n\n\t\tLinus\n"},{"id":"1284","messageId":"Pine.LNX.4.58.0504220838340.2344@ppc970.osdl.org","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504220824480.2344@ppc970.osdl.org","subject":"Re: Mozilla SHA1 implementation","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-22T15:40:23Z","receivedAt":"2005-04-22T15:40:23Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 22 Apr 2005, Linus Torvalds wrote:\n> \n> > I get the opposite result on my 2GHz G5: the Mozilla version does\n> > 45MB/s, the openssl version does 135MB/s, and my version does 218MB/s.\n> > The time for a fsck-cache on a linux-2.6 tree (cache hot) is 8.0\n> > seconds for the Mozilla version, 5.2 seconds for the openssl version,\n> > and 4.4 seconds for my version.\n> \n> I get 16 seconds for the openssl one, and 8 for the Mozilla one. I'll try \n> your version.\n\nOk, I get 4.9s on my kernel archive, so this is definitely a big win. \n\nCan you sign off on the thing, since this is real new code? Let's do it \nright.\n\n\t\tLinus\n"},{"id":"1285","messageId":"20050422155845.GC52771@xdt04.mpe-garching.mpg.de","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504220838340.2344@ppc970.osdl.org","subject":"(anal) Q: Are there any coding styles or development guidelines?","fromName":"Klaus Robert Suetterlin","fromEmail":"robert@mpe.mpg.de","sentAt":"2005-04-22T15:58:45Z","receivedAt":"2005-04-22T15:58:45Z","isPatch":false,"sender":{"key":"robert@mpe.mpg.de","avatar":null},"body":"I'm currently doing a source audit of the git core components.\nMainly I want to check if I can spot some left over memory leaks.\n\nUnfortunately ;) I didn't find any so far (after reading five files).\n\nStill I did find quite a lot of stuff that lint would most likely\ncomplain about.  Like not checking return values.  Should this be\nfixed now or isn't it time to do the cleanup, yet?\n\nI also found several literal copies of the same function including\nfunction name, parameter list, etc.  Wouldn't it be better do clean\nthose up and put them in a utility.{c,h} file?  A similar problem\nis the continous reimplementation of linked lists, dynamic memory,\nsmart strings / vectors, etc.  And then there are some stale files\n(i.e. revision.*) that the Changelog already mentions as removed,\nbut which are still active in HEAD.\n\nI am a little reluctant to do the work, as the code still changes\nso fast I do not really know if code I fix will still be there\ntomorrow.\n\nAlso I do not know if there is any notion of coding style published\nsomewhere.  I only noticed, that the code does not look like anything\nI'd have written and seems to follow some general principle.\n\nKind regards,\n\n--Robert Suetterlin (robert@mpe.mpg.de)\nphone: (+49)89 / 30000-3546   fax: (+49)89 / 30000-3950\n"},{"id":"1300","messageId":"Pine.LNX.4.58.0504221044400.2344@ppc970.osdl.org","threadId":"82","inReplyTo":"20050422155845.GC52771@xdt04.mpe-garching.mpg.de","subject":"Re: (anal) Q: Are there any coding styles or development guidelines?","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-04-22T17:50:46Z","receivedAt":"2005-04-22T17:50:46Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 22 Apr 2005, Klaus Robert Suetterlin wrote:\n>\n> I'm currently doing a source audit of the git core components.\n> Mainly I want to check if I can spot some left over memory leaks.\n> \n> Unfortunately ;) I didn't find any so far (after reading five files).\n> \n> Still I did find quite a lot of stuff that lint would most likely\n> complain about.  Like not checking return values.  Should this be\n> fixed now or isn't it time to do the cleanup, yet?\n\nI personally don't think we're quite there yet. You'll note that a lot of \nroutines just call \"die()\" when they don't find the data they want etc. \nAll things that we probably will need to clean up eventually, but is fine \nfor now.\n\n> I also found several literal copies of the same function including\n> function name, parameter list, etc.  Wouldn't it be better do clean\n> those up and put them in a utility.{c,h} file?\n\nYes, we can start doing things like that, especially if they really _do_ \nend up making sense in a bigger picture.\n\nSome of that is because I didn't clean up the Makefile until fairly\nrecently, so it used to be harder than it is now to have a shared object\nfile. In contrast, now you just add it to the list of library objects, and\noff you go.\n\n> A similar problem\n> is the continous reimplementation of linked lists, dynamic memory,\n> smart strings / vectors, etc.\n\nSometimes specific duplication is just _easier_ than trying to be clever \nand having some generic shared version. For example, there's a few \ndata-specific versions of \"insert into sorted array\" there, and the fact \nis, they are so simple that it's likely less work to keep them that way \nthan it would be to create some \"generic\" thing that did it and was passed \nin some descriptor of the data. \n\nGeneric routines aren't always good. Sometimes the abstraction ends up \nadding more of a mental burden than just doing the thing in a simple way \nin the first place. \n\n> And then there are some stale files (i.e. revision.*) that the Changelog\n> already mentions as removed, but which are still active in HEAD.\n\nThey definitely are _not_ active in HEAD, at least not in my version.\n\nYou may have stale copies in your directory, but they should show up as\nbeing stale when you do \"show-files --others\".\n\n\t\tLinus\n"},{"id":"1316","messageId":"Pine.LNX.4.21.0504221625070.30848-100000@iabervon.org","threadId":"82","inReplyTo":"Pine.LNX.4.58.0504220824480.2344@ppc970.osdl.org","subject":"Re: Mozilla SHA1 implementation","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2005-04-22T20:29:45Z","receivedAt":"2005-04-22T20:29:45Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Fri, 22 Apr 2005, Linus Torvalds wrote:\n\n> But it's more likely the precompiled libssl. I'm not compiling the openssl\n> thing myself, but just using the standard 0.9.7a version that comes with\n> YDL. Which, btw, causes all of \n> \n> \t/lib/libcrypto.so.4\n\nThis is the one that actually has the SHA1 stuff, not libssl at all. You\ncan skip at least some of this by just using -lcrypto.\n\n> \t/usr/lib/libgssapi_krb5.so.2\n> \t/usr/lib/libkrb5.so.3\n> \t/lib/libcom_err.so.2\n> \t/usr/lib/libk5crypto.so.3\n> \t/lib/libresolv.so.2\n> \t/lib/libdl.so.2\n\n\t-Daniel\n*This .sig left intentionally blank*\n\n"}]}