diff options
Diffstat (limited to 'Utilities/cmcurl/lib/sha256.c')
-rw-r--r-- | Utilities/cmcurl/lib/sha256.c | 73 |
1 files changed, 31 insertions, 42 deletions
diff --git a/Utilities/cmcurl/lib/sha256.c b/Utilities/cmcurl/lib/sha256.c index 60720f5..c96a9fc 100644 --- a/Utilities/cmcurl/lib/sha256.c +++ b/Utilities/cmcurl/lib/sha256.c @@ -57,18 +57,6 @@ #endif #endif /* USE_MBEDTLS */ -/* Please keep the SSL backend-specific #if branches in this order: - * - * 1. USE_OPENSSL - * 2. USE_GNUTLS - * 3. USE_MBEDTLS - * 4. USE_COMMON_CRYPTO - * 5. USE_WIN32_CRYPTO - * - * This ensures that the same SSL branch gets activated throughout this source - * file even if multiple backends are enabled at the same time. - */ - #if defined(USE_OPENSSL_SHA256) /* When OpenSSL or wolfSSL is available is available we use their @@ -80,11 +68,39 @@ #include <wolfssl/openssl/evp.h> #endif -#include "curl_memory.h" +#elif defined(USE_GNUTLS) +#include <nettle/sha.h> +#elif defined(USE_MBEDTLS) +#include <mbedtls/sha256.h> +#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ + (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \ + (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ + (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000)) +#include <CommonCrypto/CommonDigest.h> +#define AN_APPLE_OS +#elif defined(USE_WIN32_CRYPTO) +#include <wincrypt.h> +#endif -/* The last #include file should be: */ +/* The last 3 #include files should be in this order */ +#include "curl_printf.h" +#include "curl_memory.h" #include "memdebug.h" +/* Please keep the SSL backend-specific #if branches in this order: + * + * 1. USE_OPENSSL + * 2. USE_GNUTLS + * 3. USE_MBEDTLS + * 4. USE_COMMON_CRYPTO + * 5. USE_WIN32_CRYPTO + * + * This ensures that the same SSL branch gets activated throughout this source + * file even if multiple backends are enabled at the same time. + */ + +#if defined(USE_OPENSSL_SHA256) + struct sha256_ctx { EVP_MD_CTX *openssl_ctx; }; @@ -115,13 +131,6 @@ static void my_sha256_final(unsigned char *digest, my_sha256_ctx *ctx) #elif defined(USE_GNUTLS) -#include <nettle/sha.h> - -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" - typedef struct sha256_ctx my_sha256_ctx; static CURLcode my_sha256_init(my_sha256_ctx *ctx) @@ -144,13 +153,6 @@ static void my_sha256_final(unsigned char *digest, my_sha256_ctx *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 my_sha256_ctx; static CURLcode my_sha256_init(my_sha256_ctx *ctx) @@ -183,18 +185,7 @@ static void my_sha256_final(unsigned char *digest, my_sha256_ctx *ctx) #endif } -#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \ - (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \ - (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \ - (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000)) - -#include <CommonCrypto/CommonDigest.h> - -#include "curl_memory.h" - -/* The last #include file should be: */ -#include "memdebug.h" - +#elif defined(AN_APPLE_OS) typedef CC_SHA256_CTX my_sha256_ctx; static CURLcode my_sha256_init(my_sha256_ctx *ctx) @@ -217,8 +208,6 @@ static void my_sha256_final(unsigned char *digest, my_sha256_ctx *ctx) #elif defined(USE_WIN32_CRYPTO) -#include <wincrypt.h> - struct sha256_ctx { HCRYPTPROV hCryptProv; HCRYPTHASH hHash; |