[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 268/282: sha256: Added WinCrypt implementation
From: |
gnunet |
Subject: |
[gnurl] 268/282: sha256: Added WinCrypt implementation |
Date: |
Wed, 01 Apr 2020 14:32:13 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 1369b8ad31d5fff44af1a0f2b5fa8b24b4c24b09
Author: Steve Holme <address@hidden>
AuthorDate: Thu Feb 20 01:49:31 2020 +0000
sha256: Added WinCrypt implementation
Closed #5030
---
lib/sha256.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/lib/sha256.c b/lib/sha256.c
index a14f42aa3..352d577e8 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -192,6 +192,49 @@ static void SHA256_Final(unsigned char *digest, SHA256_CTX
*ctx)
(void) CC_SHA256_Final(digest, ctx);
}
+#elif defined(USE_WIN32_CRYPTO)
+
+#include <wincrypt.h>
+
+typedef struct {
+ HCRYPTPROV hCryptProv;
+ HCRYPTHASH hHash;
+} SHA256_CTX;
+
+#if !defined(CALG_SHA_256)
+#define CALG_SHA_256 0x0000800c
+#endif
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+ if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL,
+ PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
+ CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash);
+ }
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+ CryptHashData(ctx->hHash, (unsigned char *) data, length, 0);
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+ unsigned long length;
+
+ CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
+ if(length == SHA256_DIGEST_LENGTH)
+ CryptGetHashParam(ctx->hHash, HP_HASHVAL, digest, &length, 0);
+
+ if(ctx->hHash)
+ CryptDestroyHash(ctx->hHash);
+
+ if(ctx->hCryptProv)
+ CryptReleaseContext(ctx->hCryptProv, 0);
+}
+
#else
/* When no other crypto library is available we use this code segment */
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 253/282: pause: force a connection (re-)check after unpausing, (continued)
- [gnurl] 253/282: pause: force a connection (re-)check after unpausing, gnunet, 2020/04/01
- [gnurl] 273/282: RELEASE-NOTES: synced, gnunet, 2020/04/01
- [gnurl] 267/282: sha256: Added SecureTransport implementation, gnunet, 2020/04/01
- [gnurl] 265/282: mime: fix the binary encoder to handle large data properly, gnunet, 2020/04/01
- [gnurl] 275/282: runtests: log minimal and maximal used port numbers, gnunet, 2020/04/01
- [gnurl] 279/282: test1129: fix invalid case of closing XML-tag and Content-Length, gnunet, 2020/04/01
- [gnurl] 274/282: sftp: fix segfault regression introduced by #4747, gnunet, 2020/04/01
- [gnurl] 277/282: tests/data: fix static ip:port instead of dynamic values being used, gnunet, 2020/04/01
- [gnurl] 281/282: RELEASE-NOTES: 7.69.1, gnunet, 2020/04/01
- [gnurl] 270/282: cookie: get_top_domain() sets zero length for null domains, gnunet, 2020/04/01
- [gnurl] 268/282: sha256: Added WinCrypt implementation,
gnunet <=
- [gnurl] 264/282: mime: do not perform more than one read in a row, gnunet, 2020/04/01
- [gnurl] 276/282: tests/server: fix missing use of exe_ext helper function, gnunet, 2020/04/01
- [gnurl] 278/282: tests/data: fix static ip instead of dynamic value being used, gnunet, 2020/04/01
- [gnurl] 280/282: THANKS: from the 7.69.1 release, gnunet, 2020/04/01
- [gnurl] 282/282: Merge tag 'curl-7_69_1', gnunet, 2020/04/01