File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -182,6 +182,8 @@ include shared.mak
182
182
#
183
183
# Define BLK_SHA256 to use the built-in SHA-256 routines.
184
184
#
185
+ # Define NETTLE_SHA256 to use the SHA-256 routines in libnettle.
186
+ #
185
187
# Define GCRYPT_SHA256 to use the SHA-256 routines in libgcrypt.
186
188
#
187
189
# Define OPENSSL_SHA256 to use the SHA-256 routines in OpenSSL.
@@ -1848,6 +1850,10 @@ ifdef OPENSSL_SHA256
1848
1850
EXTLIBS += $(LIB_4_CRYPTO)
1849
1851
BASIC_CFLAGS += -DSHA256_OPENSSL
1850
1852
else
1853
+ ifdef NETTLE_SHA256
1854
+ BASIC_CFLAGS += -DSHA256_NETTLE
1855
+ EXTLIBS += -lnettle
1856
+ else
1851
1857
ifdef GCRYPT_SHA256
1852
1858
BASIC_CFLAGS += -DSHA256_GCRYPT
1853
1859
EXTLIBS += -lgcrypt
@@ -1856,6 +1862,7 @@ else
1856
1862
BASIC_CFLAGS += -DSHA256_BLK
1857
1863
endif
1858
1864
endif
1865
+ endif
1859
1866
1860
1867
ifdef SHA1_MAX_BLOCK_SIZE
1861
1868
LIB_OBJS += compat/sha1-chunked.o
@@ -3094,6 +3101,9 @@ $(SP_OBJ): %.sp: %.c %.o
3094
3101
sparse : $(SP_OBJ )
3095
3102
3096
3103
EXCEPT_HDRS := $(GENERATED_H ) unicode-width.h compat/% xdiff/%
3104
+ ifndef NETTLE_SHA256
3105
+ EXCEPT_HDRS += sha256/nettle.h
3106
+ endif
3097
3107
ifndef GCRYPT_SHA256
3098
3108
EXCEPT_HDRS += sha256/gcrypt.h
3099
3109
endif
Original file line number Diff line number Diff line change 16
16
#include "block-sha1/sha1.h"
17
17
#endif
18
18
19
- #if defined(SHA256_GCRYPT )
19
+ #if defined(SHA256_NETTLE )
20
+ #include "sha256/nettle.h"
21
+ #elif defined(SHA256_GCRYPT )
20
22
#define SHA256_NEEDS_CLONE_HELPER
21
23
#include "sha256/gcrypt.h"
22
24
#elif defined(SHA256_OPENSSL )
Original file line number Diff line number Diff line change
1
+ #ifndef SHA256_NETTLE_H
2
+ #define SHA256_NETTLE_H
3
+
4
+ #include <nettle/sha2.h>
5
+
6
+ typedef struct sha256_ctx nettle_SHA256_CTX ;
7
+
8
+ static inline void nettle_SHA256_Init (nettle_SHA256_CTX * ctx )
9
+ {
10
+ sha256_init (ctx );
11
+ }
12
+
13
+ static inline void nettle_SHA256_Update (nettle_SHA256_CTX * ctx ,
14
+ const void * data ,
15
+ size_t len )
16
+ {
17
+ sha256_update (ctx , len , data );
18
+ }
19
+
20
+ static inline void nettle_SHA256_Final (unsigned char * digest ,
21
+ nettle_SHA256_CTX * ctx )
22
+ {
23
+ sha256_digest (ctx , SHA256_DIGEST_SIZE , digest );
24
+ }
25
+
26
+ #define platform_SHA256_CTX nettle_SHA256_CTX
27
+ #define platform_SHA256_Init nettle_SHA256_Init
28
+ #define platform_SHA256_Update nettle_SHA256_Update
29
+ #define platform_SHA256_Final nettle_SHA256_Final
30
+
31
+ #endif
You can’t perform that action at this time.
0 commit comments