summaryrefslogtreecommitdiff
path: root/cups/md5passwd.c
diff options
context:
space:
mode:
authorMichael R Sweet <michaelrsweet@gmail.com>2017-11-06 16:19:27 -0500
committerMichael R Sweet <michaelrsweet@gmail.com>2017-11-06 16:28:31 -0500
commit7ec11630684301572cb7d19a95c244c104961a2a (patch)
tree75940c5fb6da6293797bae904c7865433ead08e7 /cups/md5passwd.c
parent054eee9cd0555f836ef9ad87f21d6e6ace1d47f1 (diff)
downloadcups-7ec11630684301572cb7d19a95c244c104961a2a.tar.gz
Support the latest HTTP Digest authentication specification (Issue #4862)
Also deprecates all httpMD5* functions. - cgi-bin/var.c: Use cupsHashData to compute SID hash. - cups/auth.c: Rewrite WWW-Authenticate parser to support multiple auth schemes and the new RFC 7616 version of HTTP Digest. - cups/cups.h: Add cupsHashString function to get a hex version of a hash. - cups/hash.c: Add MD5 support. - cups/http.c: Track WWW-Authenticate in a long string, concatenate new set values. - cups/http.h: Deprecate httpMD5* and recommend cupsDoAuth and cupsHash*. - cups/http-private.h: Pull MD5 stuff, nonce_count is unsigned, track WWW-Authenticate header as a potentially long string. - cups/http-support.c: Use cupsHashData to compute UUID hash. - cups/md5.c: Comment everything out if we have an OS-supplied MD5 hash function. - cups/md5passwd.c: Use cupsHash* functions. - cups/tls-*.c: Use cupsHash* functions. - cups/versioning.h: Add CUPS_API_2_3 definition. - scheduler/client.c: Update WWW-Authenticate header to include AuthRef, Local, and PeerCred schemes with parameters as needed.
Diffstat (limited to 'cups/md5passwd.c')
-rw-r--r--cups/md5passwd.c50
1 files changed, 15 insertions, 35 deletions
diff --git a/cups/md5passwd.c b/cups/md5passwd.c
index a9817aaa2..1c3deb5ee 100644
--- a/cups/md5passwd.c
+++ b/cups/md5passwd.c
@@ -1,7 +1,7 @@
/*
- * MD5 password support for CUPS.
+ * MD5 password support for CUPS (deprecated).
*
- * Copyright 2007-2010 by Apple Inc.
+ * Copyright 2007-2017 by Apple Inc.
* Copyright 1997-2005 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
@@ -17,12 +17,15 @@
* Include necessary headers...
*/
+#include <cups/cups.h>
#include "http-private.h"
#include "string-private.h"
/*
* 'httpMD5()' - Compute the MD5 sum of the username:group:password.
+ *
+ * @deprecated@
*/
char * /* O - MD5 sum */
@@ -31,7 +34,6 @@ httpMD5(const char *username, /* I - User name */
const char *passwd, /* I - Password string */
char md5[33]) /* O - MD5 string */
{
- _cups_md5_state_t state; /* MD5 state info */
unsigned char sum[16]; /* Sum data */
char line[256]; /* Line to sum */
@@ -41,15 +43,13 @@ httpMD5(const char *username, /* I - User name */
*/
snprintf(line, sizeof(line), "%s:%s:%s", username, realm, passwd);
- _cupsMD5Init(&state);
- _cupsMD5Append(&state, (unsigned char *)line, (int)strlen(line));
- _cupsMD5Finish(&state, sum);
+ cupsHashData("md5", (unsigned char *)line, strlen(line), sum, sizeof(sum));
/*
* Return the sum...
*/
- return (httpMD5String(sum, md5));
+ return ((char *)cupsHashString(sum, sizeof(sum), md5, 33));
}
@@ -57,6 +57,8 @@ httpMD5(const char *username, /* I - User name */
* 'httpMD5Final()' - Combine the MD5 sum of the username, group, and password
* with the server-supplied nonce value, method, and
* request-uri.
+ *
+ * @deprecated@
*/
char * /* O - New sum */
@@ -65,7 +67,6 @@ httpMD5Final(const char *nonce, /* I - Server nonce value */
const char *resource, /* I - Resource path */
char md5[33]) /* IO - MD5 sum */
{
- _cups_md5_state_t state; /* MD5 state info */
unsigned char sum[16]; /* Sum data */
char line[1024]; /* Line of data */
char a2[33]; /* Hash of method and resource */
@@ -76,9 +77,7 @@ httpMD5Final(const char *nonce, /* I - Server nonce value */
*/
snprintf(line, sizeof(line), "%s:%s", method, resource);
- _cupsMD5Init(&state);
- _cupsMD5Append(&state, (unsigned char *)line, (int)strlen(line));
- _cupsMD5Finish(&state, sum);
+ cupsHashData("md5", (unsigned char *)line, strlen(line), sum, sizeof(sum));
httpMD5String(sum, a2);
/*
@@ -88,17 +87,16 @@ httpMD5Final(const char *nonce, /* I - Server nonce value */
*/
snprintf(line, sizeof(line), "%s:%s:%s", md5, nonce, a2);
+ cupsHashData("md5", (unsigned char *)line, strlen(line), sum, sizeof(sum));
- _cupsMD5Init(&state);
- _cupsMD5Append(&state, (unsigned char *)line, (int)strlen(line));
- _cupsMD5Finish(&state, sum);
-
- return (httpMD5String(sum, md5));
+ return ((char *)cupsHashString(sum, sizeof(sum), md5, 33));
}
/*
* 'httpMD5String()' - Convert an MD5 sum to a character string.
+ *
+ * @deprecated@
*/
char * /* O - MD5 sum in hex */
@@ -106,23 +104,5 @@ httpMD5String(const unsigned char *sum, /* I - MD5 sum data */
char md5[33])
/* O - MD5 sum in hex */
{
- int i; /* Looping var */
- char *md5ptr; /* Pointer into MD5 string */
- static const char hex[] = "0123456789abcdef";
- /* Hex digits */
-
-
- /*
- * Convert the MD5 sum to hexadecimal...
- */
-
- for (i = 16, md5ptr = md5; i > 0; i --, sum ++)
- {
- *md5ptr++ = hex[*sum >> 4];
- *md5ptr++ = hex[*sum & 15];
- }
-
- *md5ptr = '\0';
-
- return (md5);
+ return ((char *)cupsHashString(sum, 16, md5, 33));
}