summaryrefslogtreecommitdiff
path: root/cups/hash.c
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/hash.c
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/hash.c')
-rw-r--r--cups/hash.c21
1 files changed, 20 insertions, 1 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);