[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 221/282: sha256: Added WinCrypt implementation
From: |
gnunet |
Subject: |
[gnurl] 221/282: sha256: Added WinCrypt implementation |
Date: |
Wed, 01 Apr 2020 14:31:26 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit f22a5c35e0ce0891bcfc3078d800df3db7b8ec24
Author: Steve Holme <address@hidden>
AuthorDate: Thu Feb 20 01:49:31 2020 +0000
sha256: Added WinCrypt implementation
---
lib/sha256.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/lib/sha256.c b/lib/sha256.c
index 10ad44b49..6fd283c77 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -179,6 +179,45 @@ 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;
+
+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] 205/282: Revert "mime: latch last read callback status.", (continued)
- [gnurl] 205/282: Revert "mime: latch last read callback status.", gnunet, 2020/04/01
- [gnurl] 210/282: tests: disable 962, 963 and 964 on Windows, gnunet, 2020/04/01
- [gnurl] 208/282: configure: bump the AC_COPYRIGHT year range, gnunet, 2020/04/01
- [gnurl] 192/282: CMake: clean up and improve build procedures, gnunet, 2020/04/01
- [gnurl] 207/282: tests: disable SMTP UTF-8 tests on Windows, gnunet, 2020/04/01
- [gnurl] 203/282: Revert "mime: fix the binary encoder to handle large data properly", gnunet, 2020/04/01
- [gnurl] 213/282: ci/tests: some MacOS builds randomly take longer than 20min, gnunet, 2020/04/01
- [gnurl] 199/282: mime: latch last read callback status., gnunet, 2020/04/01
- [gnurl] 204/282: Revert "mime: do not perform more than one read in a row", gnunet, 2020/04/01
- [gnurl] 222/282: sha256: Tidy up following recent changes, gnunet, 2020/04/01
- [gnurl] 221/282: sha256: Added WinCrypt implementation,
gnunet <=
- [gnurl] 223/282: configure.ac: Disable metalink if mbedTLS is specified, gnunet, 2020/04/01
- [gnurl] 216/282: curl_escape.3: Add a link to curl_free, gnunet, 2020/04/01
- [gnurl] 219/282: sha256: Added mbedtls implementation, gnunet, 2020/04/01
- [gnurl] 225/282: Revert "sha256: Added SecureTransport implementation", gnunet, 2020/04/01
- [gnurl] 209/282: ci/tests: fine-tune Azure Pipeline timeouts with a small puffer, gnunet, 2020/04/01
- [gnurl] 214/282: md4: use init/update/final functions in Secure Transport, gnunet, 2020/04/01
- [gnurl] 220/282: sha256: Added SecureTransport implementation, gnunet, 2020/04/01
- [gnurl] 224/282: dist: include tests/azure.pm in the tarball, gnunet, 2020/04/01
- [gnurl] 217/282: sha256: Added GNU TLS Nettle implementation, gnunet, 2020/04/01
- [gnurl] 200/282: mime: do not perform more than one read in a row, gnunet, 2020/04/01