summaryrefslogtreecommitdiff
path: root/cups
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2019-09-03 10:34:51 -0400
committerMichael R Sweet <michael.r.sweet@gmail.com>2019-09-03 10:34:51 -0400
commit68dc110f524f2c382588fbeadd30685111d06054 (patch)
tree55a4aeae4e82f083917a75c278c3f1920c7ba7a1 /cups
parent998a43a0ddc6fa4675e31c5d7fb61736e6a78125 (diff)
downloadcups-68dc110f524f2c382588fbeadd30685111d06054.tar.gz
Use legacy MD5 implementation with GNU TLS since at least some Linux vendors are
disabling MD5 without allowing applications to detect it.
Diffstat (limited to 'cups')
-rw-r--r--cups/hash.c21
-rw-r--r--cups/md5.c4
2 files changed, 22 insertions, 3 deletions
diff --git a/cups/hash.c b/cups/hash.c
index bfec994aa..4fbb443db 100644
--- a/cups/hash.c
+++ b/cups/hash.c
@@ -16,6 +16,7 @@
# include <CommonCrypto/CommonDigest.h>
#elif defined(HAVE_GNUTLS)
# include <gnutls/crypto.h>
+# include "md5-internal.h"
#else
# include "md5-internal.h"
#endif /* __APPLE__ */
@@ -187,7 +188,22 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */
if (!strcmp(algorithm, "md5"))
- alg = GNUTLS_DIG_MD5;
+ {
+ /*
+ * Some versions of GNU TLS disable MD5 without warning...
+ */
+
+ _cups_md5_state_t state; /* MD5 state info */
+
+ if (hashsize < 16)
+ goto too_small;
+
+ _cupsMD5Init(&state);
+ _cupsMD5Append(&state, data, datalen);
+ _cupsMD5Finish(&state, hash);
+
+ return (16);
+ }
else if (!strcmp(algorithm, "sha"))
alg = GNUTLS_DIG_SHA1;
else if (!strcmp(algorithm, "sha2-224"))
@@ -243,6 +259,9 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */
{
_cups_md5_state_t state; /* MD5 state info */
+ if (hashsize < 16)
+ goto too_small;
+
_cupsMD5Init(&state);
_cupsMD5Append(&state, data, datalen);
_cupsMD5Finish(&state, hash);
diff --git a/cups/md5.c b/cups/md5.c
index c3b2768dd..a94646c72 100644
--- a/cups/md5.c
+++ b/cups/md5.c
@@ -43,7 +43,7 @@
#include "md5-internal.h"
#include "string-private.h"
-#if !defined(__APPLE__) && !defined(HAVE_GNUTLS)
+#if !defined(__APPLE__)
# define T1 0xd76aa478
# define T2 0xe8c7b756
# define T3 0x242070db
@@ -338,4 +338,4 @@ _cupsMD5Finish(_cups_md5_state_t *pms, unsigned char digest[16])
for (i = 0; i < 16; ++i)
digest[i] = (unsigned char)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}
-#endif /* !__APPLE__ && !HAVE_GNUTLS */
+#endif /* !__APPLE__ */