summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2020-02-20 01:25:27 +0000
committerSteve Holme <steve_holme@hotmail.com>2020-03-03 00:37:17 +0000
commit365f4ea53d1f52c6f7156f0115491c2f2e6fd23a (patch)
tree213e187648adff41ad187d7ce9b700e2e59b8e09 /lib
parent256a29361f7a4c3d3e09fcb18fcdfce36f821bd3 (diff)
downloadcurl-365f4ea53d1f52c6f7156f0115491c2f2e6fd23a.tar.gz
sha256: Added GNU TLS Nettle implementation
Diffstat (limited to 'lib')
-rw-r--r--lib/sha256.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/lib/sha256.c b/lib/sha256.c
index 656f9894a..aa2274117 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -38,9 +38,39 @@
#endif
-#ifdef USE_OPENSSL_SHA256
+#if defined(USE_OPENSSL_SHA256)
+
/* When OpenSSL is available we use the SHA256-function from OpenSSL */
#include <openssl/sha.h>
+
+#elif defined(USE_GNUTLS_NETTLE)
+
+#include <nettle/sha.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef struct sha256_ctx SHA256_CTX;
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+ sha256_init(ctx);
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+ sha256_update(ctx, length, data);
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+ sha256_digest(ctx, SHA256_DIGEST_SIZE, digest);
+}
+
#else
/* When no other crypto library is available we use this code segment */