aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2020-02-20 01:31:06 +0000
committerSteve Holme <steve_holme@hotmail.com>2020-03-03 00:37:21 +0000
commit8fbd93724868f40dfe7d9e415446ff023d8eb89f (patch)
tree97d3642037ffbbda3231da0ff00cf89e4686f833 /lib
parent365f4ea53d1f52c6f7156f0115491c2f2e6fd23a (diff)
sha256: Added GNU TLS gcrypt implementation
Diffstat (limited to 'lib')
-rw-r--r--lib/sha256.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/sha256.c b/lib/sha256.c
index aa2274117..d544381b2 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -71,6 +71,35 @@ static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
sha256_digest(ctx, SHA256_DIGEST_SIZE, digest);
}
+#elif defined(USE_GNUTLS)
+
+#include <gcrypt.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef gcry_md_hd_t SHA256_CTX;
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+ gcry_md_open(ctx, GCRY_MD_SHA256, 0);
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+ gcry_md_write(*ctx, data, length);
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+ memcpy(digest, gcry_md_read(*ctx, 0), SHA256_DIGEST_LENGTH);
+ gcry_md_close(*ctx);
+}
+
#else
/* When no other crypto library is available we use this code segment */