Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce --enable-gnutls-relax-mode, apply it in cupsHashData() #5622

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions config-scripts/cups-ssl.m4
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dnl
AC_ARG_ENABLE(ssl, [ --disable-ssl disable SSL/TLS support])
AC_ARG_ENABLE(cdsassl, [ --enable-cdsassl use CDSA for SSL/TLS support, default=first])
AC_ARG_ENABLE(gnutls, [ --enable-gnutls use GNU TLS for SSL/TLS support, default=second])
AC_ARG_ENABLE(gnutls_relax_mode, [ --enable-gnutls-relax-mode use GNU TLS in relax mode for MD5 hash function at non-crypto cases, default=disabled])

SSLFLAGS=""
SSLLIBS=""
Expand Down Expand Up @@ -61,6 +62,10 @@ if test x$enable_ssl != xno; then
AC_CHECK_FUNC(gnutls_transport_set_pull_timeout_function, AC_DEFINE(HAVE_GNUTLS_TRANSPORT_SET_PULL_TIMEOUT_FUNCTION))
AC_CHECK_FUNC(gnutls_priority_set_direct, AC_DEFINE(HAVE_GNUTLS_PRIORITY_SET_DIRECT))
LIBS="$SAVELIBS"

if "x$enable_gnutls_relax_mode" != "xno"; then
AC_DEFINE(HAVE_GNUTLS_RELAX_MODE)
fi
fi
fi
fi
Expand Down
12 changes: 12 additions & 0 deletions cups/hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,13 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */
size_t tempsize = 0; /* Truncate to this size? */

if (!strcmp(algorithm, "md5"))
{
alg = GNUTLS_DIG_MD5;

# if defined(HAVE_GNUTLS_RELAX_MODE)
GNUTLS_FIPS140_SET_LAX_MODE();
# endif
}
else if (!strcmp(algorithm, "sha"))
alg = GNUTLS_DIG_SHA1;
else if (!strcmp(algorithm, "sha2-224"))
Expand Down Expand Up @@ -220,6 +226,7 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */
goto too_small;

gnutls_hash_fast(alg, data, datalen, temp);

memcpy(hash, temp, tempsize);

return ((ssize_t)tempsize);
Expand All @@ -230,6 +237,11 @@ cupsHashData(const char *algorithm, /* I - Algorithm name */

gnutls_hash_fast(alg, data, datalen, hash);

# if defined(HAVE_GNUTLS_RELAX_MODE)
if (!strcmp(algorithm, "md5"))
GNUTLS_FIPS140_SET_STRICT_MODE();
# endif

return ((ssize_t)gnutls_hash_get_len(alg));
}

Expand Down