Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
38c513b9
Commit
38c513b9
authored
Apr 28, 2010
by
Ramsay Jones
Committed by
Andreas Ericsson
May 04, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support to enable the library to use OpenSSL SHA1 functions
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
parent
89217d8f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
22 deletions
+38
-22
Makefile
+10
-0
src/block-sha1/sha1.h
+4
-4
src/hash.c
+13
-13
src/ppc/sha1.h
+4
-4
src/sha1.h
+3
-1
tests/Makefile
+4
-0
No files found.
Makefile
View file @
38c513b9
...
...
@@ -3,6 +3,12 @@ all::
# Define NO_VISIBILITY if your compiler does not support symbol
# visibility in general (and the -fvisibility switch in particular).
#
# Define OPENSSL_SHA1 if you want use the SHA1 routines from the
# OpenSSL crypto library, rather than the built-in C versions.
#
# Define PPC_SHA1 if you want to use the bundled SHA1 routines that
# are optimized for PowerPC, rather than the built-in C versions.
#
DOXYGEN
=
doxygen
INSTALL
=
install
...
...
@@ -75,8 +81,12 @@ ifdef PPC_SHA1
EXTRA_OBJ
+=
src/ppc/sha1ppc.o
EXTRA_CFLAGS
+=
-DPPC_SHA1
else
ifdef
OPENSSL_SHA1
EXTRA_CFLAGS
+=
-DOPENSSL_SHA1
else
EXTRA_SRC
+=
src/block-sha1/sha1.c
endif
endif
BASIC_CFLAGS
:=
-Isrc
ifndef
NO_VISIBILITY
...
...
src/block-sha1/sha1.h
View file @
38c513b9
...
...
@@ -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
src/hash.c
View file @
38c513b9
...
...
@@ -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
);
}
src/ppc/sha1.h
View file @
38c513b9
...
...
@@ -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
src/sha1.h
View file @
38c513b9
#ifndef INCLUDE_sha1_h__
#define INCLUDE_sha1_h__
#if
def 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
...
...
tests/Makefile
View file @
38c513b9
...
...
@@ -59,6 +59,10 @@ ifdef TEST_COVERAGE
EXTRA_LIBS
+=
-O0
-lgcov
endif
ifdef
OPENSSL_SHA1
EXTRA_LIBS
+=
$(CRYPTO_LIB)
endif
BASIC_CFLAGS
:=
-I
../src
ALL_CFLAGS
=
$(CFLAGS)
$(BASIC_CFLAGS)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment