summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRamsay Jones <ramsay@ramsay1.demon.co.uk>2010-04-28 19:07:14 +0100
committerAndreas Ericsson <ae@op5.se>2010-05-04 21:36:12 +0200
commit38c513b9d1f6c19f191927003c5befd2fa70da9a (patch)
treeb4b1f3118c4afc6034b5f99eddd18f7dbf15e5d5 /src
parent89217d8f1a70da2916d611c989e6b046cdb94fca (diff)
downloadlibgit2-38c513b9d1f6c19f191927003c5befd2fa70da9a.tar.gz
Add support to enable the library to use OpenSSL SHA1 functions
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Diffstat (limited to 'src')
-rw-r--r--src/block-sha1/sha1.h8
-rw-r--r--src/hash.c26
-rw-r--r--src/ppc/sha1.h8
-rw-r--r--src/sha1.h4
4 files changed, 24 insertions, 22 deletions
diff --git a/src/block-sha1/sha1.h b/src/block-sha1/sha1.h
index b864df623..bb2bad2a2 100644
--- a/src/block-sha1/sha1.h
+++ b/src/block-sha1/sha1.h
@@ -16,7 +16,7 @@ void blk_SHA1_Init(blk_SHA_CTX *ctx);
void blk_SHA1_Update(blk_SHA_CTX *ctx, const void *dataIn, unsigned long len);
void blk_SHA1_Final(unsigned char hashout[20], blk_SHA_CTX *ctx);
-#define git_SHA_CTX blk_SHA_CTX
-#define git_SHA1_Init blk_SHA1_Init
-#define git_SHA1_Update blk_SHA1_Update
-#define git_SHA1_Final blk_SHA1_Final
+#define SHA_CTX blk_SHA_CTX
+#define SHA1_Init blk_SHA1_Init
+#define SHA1_Update blk_SHA1_Update
+#define SHA1_Final blk_SHA1_Final
diff --git a/src/hash.c b/src/hash.c
index 784b10b4b..1ddf7a3bc 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -28,7 +28,7 @@
#include "sha1.h"
struct git_hash_ctx {
- git_SHA_CTX c;
+ SHA_CTX c;
};
git_hash_ctx *git_hash_new_ctx(void)
@@ -38,7 +38,7 @@ git_hash_ctx *git_hash_new_ctx(void)
if (!ctx)
return NULL;
- git_SHA1_Init(&ctx->c);
+ SHA1_Init(&ctx->c);
return ctx;
}
@@ -51,37 +51,37 @@ void git_hash_free_ctx(git_hash_ctx *ctx)
void git_hash_init(git_hash_ctx *ctx)
{
assert(ctx);
- git_SHA1_Init(&ctx->c);
+ SHA1_Init(&ctx->c);
}
void git_hash_update(git_hash_ctx *ctx, const void *data, size_t len)
{
assert(ctx);
- git_SHA1_Update(&ctx->c, data, len);
+ SHA1_Update(&ctx->c, data, len);
}
void git_hash_final(git_oid *out, git_hash_ctx *ctx)
{
assert(ctx);
- git_SHA1_Final(out->id, &ctx->c);
+ SHA1_Final(out->id, &ctx->c);
}
void git_hash_buf(git_oid *out, const void *data, size_t len)
{
- git_SHA_CTX c;
+ SHA_CTX c;
- git_SHA1_Init(&c);
- git_SHA1_Update(&c, data, len);
- git_SHA1_Final(out->id, &c);
+ SHA1_Init(&c);
+ SHA1_Update(&c, data, len);
+ SHA1_Final(out->id, &c);
}
void git_hash_vec(git_oid *out, git_buf_vec *vec, size_t n)
{
- git_SHA_CTX c;
+ SHA_CTX c;
size_t i;
- git_SHA1_Init(&c);
+ SHA1_Init(&c);
for (i = 0; i < n; i++)
- git_SHA1_Update(&c, vec[i].data, vec[i].len);
- git_SHA1_Final(out->id, &c);
+ SHA1_Update(&c, vec[i].data, vec[i].len);
+ SHA1_Final(out->id, &c);
}
diff --git a/src/ppc/sha1.h b/src/ppc/sha1.h
index c405f734c..70957110c 100644
--- a/src/ppc/sha1.h
+++ b/src/ppc/sha1.h
@@ -19,7 +19,7 @@ int ppc_SHA1_Init(ppc_SHA_CTX *c);
int ppc_SHA1_Update(ppc_SHA_CTX *c, const void *p, unsigned long n);
int ppc_SHA1_Final(unsigned char *hash, ppc_SHA_CTX *c);
-#define git_SHA_CTX ppc_SHA_CTX
-#define git_SHA1_Init ppc_SHA1_Init
-#define git_SHA1_Update ppc_SHA1_Update
-#define git_SHA1_Final ppc_SHA1_Final
+#define SHA_CTX ppc_SHA_CTX
+#define SHA1_Init ppc_SHA1_Init
+#define SHA1_Update ppc_SHA1_Update
+#define SHA1_Final ppc_SHA1_Final
diff --git a/src/sha1.h b/src/sha1.h
index ac3e84651..f4153cc66 100644
--- a/src/sha1.h
+++ b/src/sha1.h
@@ -1,8 +1,10 @@
#ifndef INCLUDE_sha1_h__
#define INCLUDE_sha1_h__
-#ifdef PPC_SHA1
+#if defined(PPC_SHA1)
# include "ppc/sha1.h"
+#elif defined(OPENSSL_SHA1)
+# include <openssl/sha.h>
#else
# include "block-sha1/sha1.h"
#endif