[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 219/282: sha256: Added mbedtls implementation
From: |
gnunet |
Subject: |
[gnurl] 219/282: sha256: Added mbedtls implementation |
Date: |
Wed, 01 Apr 2020 14:31:24 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 425ceb0150f499db2eec25a289f5eeccadda369c
Author: Steve Holme <address@hidden>
AuthorDate: Tue Feb 25 19:04:49 2020 +0000
sha256: Added mbedtls implementation
---
lib/sha256.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/lib/sha256.c b/lib/sha256.c
index d544381b2..db7e642de 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -36,7 +36,15 @@
#define USE_OPENSSL_SHA256
#endif
+#endif /* USE_OPENSSL */
+
+#ifdef USE_MBEDTLS
+#include <mbedtls/version.h>
+
+#if(MBEDTLS_VERSION_NUMBER >= 0x02070000)
+ #define HAS_RESULT_CODE_BASED_FUNCTIONS
#endif
+#endif /* USE_MBEDTLS */
#if defined(USE_OPENSSL_SHA256)
@@ -100,6 +108,46 @@ static void SHA256_Final(unsigned char *digest, SHA256_CTX
*ctx)
gcry_md_close(*ctx);
}
+#elif defined(USE_MBEDTLS)
+
+#include <mbedtls/sha256.h>
+
+#include "curl_memory.h"
+
+/* The last #include file should be: */
+#include "memdebug.h"
+
+typedef mbedtls_sha256_context SHA256_CTX;
+
+static void SHA256_Init(SHA256_CTX *ctx)
+{
+#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_sha256_starts(ctx, 0);
+#else
+ (void) mbedtls_sha256_starts_ret(ctx, 0);
+#endif
+}
+
+static void SHA256_Update(SHA256_CTX *ctx,
+ const unsigned char *data,
+ unsigned int length)
+{
+#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_sha256_update(ctx, data, length);
+#else
+ (void) mbedtls_sha256_update_ret(ctx, data, length);
+#endif
+}
+
+static void SHA256_Final(unsigned char *digest, SHA256_CTX *ctx)
+{
+#if !defined(HAS_RESULT_CODE_BASED_FUNCTIONS)
+ mbedtls_sha256_finish(ctx, digest);
+#else
+ (void) mbedtls_sha256_finish_ret(ctx, digest);
+#endif
+}
+
#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] 192/282: CMake: clean up and improve build procedures, (continued)
- [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, 2020/04/01
- [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 <=
- [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
- [gnurl] 218/282: sha256: Added GNU TLS gcrypt implementation, gnunet, 2020/04/01
- [gnurl] 215/282: curl_getenv.3: Fix the memory handling description, gnunet, 2020/04/01
- [gnurl] 211/282: http: mark POSTs with no body as "upload done" from the start, gnunet, 2020/04/01