git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4 1/3] Provide another level of abstraction for the SHA1 utilities.

From
atousa.p@gmail.com <atousa.p@gmail.com>
Date
Nov 5, 2015, 06:38 UTC
Message-ID
<1446705523-30701-1-git-send-email-apahlevan@ieee.org>
In-Reply-To
<CAPig+cS7NktyhveQUiBFkRtJH1D-Aif861e9qshL2R=ZNg2+Lw@mail.gmail.com>
From: Atousa Pahlevan Duprat <apahlevan@ieee.org>

The git source uses git_SHA1_Update() and friends to call into the code that computes the hashes. This is can then be mapped directly to an implementation that computes the hash, such as platform_SHA1_Update(); or as we will do in a subsequent patch, it can be mapped to something more complex that will in turn call into the platform's SHA implementation.

Signed-off-by: Atousa Pahlevan Duprat <apahlevan@ieee.org>
---
 cache.h | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/cache.h b/cache.h
index a9aaa03..a934a2e 100644
--- a/cache.h
+++ b/cache.h
@@ -12,10 +12,21 @@
 
 #include SHA1_HEADER
 #ifndef git_SHA_CTX
-#define git_SHA_CTX	SHA_CTX
-#define git_SHA1_Init	SHA1_Init
-#define git_SHA1_Update	SHA1_Update
-#define git_SHA1_Final	SHA1_Final
+
+/* platform's underlying implementation of SHA1, could be OpenSSL,
+   blk_SHA, Apple CommonCrypto, etc...  */
+#define platform_SHA_CTX	SHA_CTX
+#define platform_SHA1_Init	SHA1_Init
+#define platform_SHA1_Update	SHA1_Update
+#define platform_SHA1_Final    	SHA1_Final
+
+/* git may call platform's underlying implementation of SHA1 directly,
+   or may call it through a wrapper */
+#define git_SHA_CTX		platform_SHA_CTX
+#define git_SHA1_Init		platform_SHA1_Init
+#define git_SHA1_Update		platform_SHA1_Update
+#define git_SHA1_Final		platform_SHA1_Final
+
 #endif
 
 #include <zlib.h>
-- 
2.4.9 (Apple Git-60)
Next: atousa.p@gmail.com
Message 1 of 7 in “Provide another level of abstraction for the SHA1 utilities.”
  1. 1/3 Provide another level of abstraction for the SHA1 utilities.atousa.p@gmail.com, Nov 5, 2015
  2. 2/3 Limit the size of the data block passed to SHA1_Update()atousa.p@gmail.com, Nov 5, 2015
  3. Junio C HamanoNov 5, 2015
  4. Atousa DupratNov 11, 2015
  5. 3/3 Move all the SHA1 implementations into one directoryatousa.p@gmail.com, Nov 5, 2015
  6. Junio C HamanoNov 5, 2015
  7. Junio C HamanoNov 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.