Browse Source

gnutls: Fix nettle discovery

Commit e06fa7462ac258c removed support for libgcrypt leaving only
support for nettle which has been the default crypto library in
GnuTLS for a long time. There were however a few conditionals on
USE_GNUTLS_NETTLE which cause compilation errors in the metalink
code (as it used the gcrypt fallback instead as a result). See the
below autobuild for an example of the error:

  https://curl.se/dev/log.cgi?id=20210225123226-30704#prob1

This removes all uses of USE_GNUTLS_NETTLE and also removes the
gcrypt support from the metalink code while at it.

Closes #6656
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Daniel Gustafsson 3 years ago
parent
commit
09a5bff1c9
3 changed files with 2 additions and 70 deletions
  1. 0 1
      lib/curl_ntlm_core.h
  2. 0 3
      packages/vms/generate_config_vms_h_curl.com
  3. 2 66
      src/tool_metalink.c

+ 0 - 1
lib/curl_ntlm_core.h

@@ -30,7 +30,6 @@
    then it must be initialized to be used by NTLM. */
 #if !defined(USE_OPENSSL) && \
     !defined(USE_WOLFSSL) && \
-    !defined(USE_GNUTLS_NETTLE) && \
     !defined(USE_GNUTLS) && \
     defined(USE_NSS)
 #define NTLM_NEEDS_NSS_INIT

+ 0 - 3
packages/vms/generate_config_vms_h_curl.com

@@ -331,9 +331,6 @@ $write cvh "#endif"
 $write cvh "#ifdef USE_GNUTLS"
 $write cvh "#undef USE_GNUTLS"
 $write cvh "#endif"
-$write cvh "#ifdef USE_GNUTLS_NETTLE"
-$write cvh "#undef USE_GNUTLS_NETTLE"
-$write cvh "#endif"
 $write cvh "#ifdef USE_LIBRTMP"
 $write cvh "#undef USE_LIBRTMP"
 $write cvh "#endif"

+ 2 - 66
src/tool_metalink.c

@@ -35,17 +35,12 @@
 #ifdef USE_OPENSSL
 #  include <openssl/md5.h>
 #  include <openssl/sha.h>
-#elif defined(USE_GNUTLS_NETTLE)
+#elif defined(USE_GNUTLS)
 #  include <nettle/md5.h>
 #  include <nettle/sha.h>
 #  define MD5_CTX    struct md5_ctx
 #  define SHA_CTX    struct sha1_ctx
 #  define SHA256_CTX struct sha256_ctx
-#elif defined(USE_GNUTLS)
-#  include <gcrypt.h>
-#  define MD5_CTX    gcry_md_hd_t
-#  define SHA_CTX    gcry_md_hd_t
-#  define SHA256_CTX gcry_md_hd_t
 #elif defined(USE_NSS)
 #  include <nss.h>
 #  include <pk11pub.h>
@@ -116,7 +111,7 @@ struct win32_crypto_hash {
 
 #if defined(USE_OPENSSL)
 /* Functions are already defined */
-#elif defined(USE_GNUTLS_NETTLE)
+#elif defined(USE_GNUTLS)
 
 static int MD5_Init(MD5_CTX *ctx)
 {
@@ -172,65 +167,6 @@ static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
   sha256_digest(ctx, 32, digest);
 }
 
-#elif defined(USE_GNUTLS)
-
-static int MD5_Init(MD5_CTX *ctx)
-{
-  gcry_md_open(ctx, GCRY_MD_MD5, 0);
-  return 1;
-}
-
-static void MD5_Update(MD5_CTX *ctx,
-                       const unsigned char *input,
-                       unsigned int inputLen)
-{
-  gcry_md_write(*ctx, input, inputLen);
-}
-
-static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
-{
-  memcpy(digest, gcry_md_read(*ctx, 0), 16);
-  gcry_md_close(*ctx);
-}
-
-static int SHA1_Init(SHA_CTX *ctx)
-{
-  gcry_md_open(ctx, GCRY_MD_SHA1, 0);
-  return 1;
-}
-
-static void SHA1_Update(SHA_CTX *ctx,
-                        const unsigned char *input,
-                        unsigned int inputLen)
-{
-  gcry_md_write(*ctx, input, inputLen);
-}
-
-static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
-{
-  memcpy(digest, gcry_md_read(*ctx, 0), 20);
-  gcry_md_close(*ctx);
-}
-
-static int SHA256_Init(SHA256_CTX *ctx)
-{
-  gcry_md_open(ctx, GCRY_MD_SHA256, 0);
-  return 1;
-}
-
-static void SHA256_Update(SHA256_CTX *ctx,
-                          const unsigned char *input,
-                          unsigned int inputLen)
-{
-  gcry_md_write(*ctx, input, inputLen);
-}
-
-static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
-{
-  memcpy(digest, gcry_md_read(*ctx, 0), 32);
-  gcry_md_close(*ctx);
-}
-
 #elif defined(USE_NSS)
 
 static int nss_hash_init(void **pctx, SECOidTag hash_alg)