diff options
author | pixel <pixel> | 2007-09-28 09:23:36 +0000 |
---|---|---|
committer | pixel <pixel> | 2007-09-28 09:23:36 +0000 |
commit | 926d091d36bead33fcd18c1b2d1552a047070a25 (patch) | |
tree | aee0084dda2e76c7f36ee3d993dff183dab869cd /lib/HttpServ.cc | |
parent | 6e53dbca553d1d4567d29c70ae767a43be3ad3d9 (diff) |
Having HashFunction used in the various Http classes
Diffstat (limited to 'lib/HttpServ.cc')
-rw-r--r-- | lib/HttpServ.cc | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/lib/HttpServ.cc b/lib/HttpServ.cc index ff61f1b..23f45d4 100644 --- a/lib/HttpServ.cc +++ b/lib/HttpServ.cc @@ -17,9 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: HttpServ.cc,v 1.57 2007-09-28 09:07:13 pixel Exp $ */ +/* $Id: HttpServ.cc,v 1.58 2007-09-28 09:23:36 pixel Exp $ */ -#include "sha1.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -33,6 +32,7 @@ #include "Task.h" #include "Base64.h" #include "Domain.h" +#include "HashFunction.h" #include "gettext.h" String endhl = "\r\n", endnl = "\n"; @@ -672,24 +672,13 @@ void HttpResponse::PrepareResponse(Handle * b) { break; case HTTP_401_UNAUTHORIZED: if (domain != "") { - String to_digest; - sha1_context sha1; - static const char hconv[] = "0123456789ABCDEF"; - Uint8 sha1sum[20]; - char sha1sum_r[41]; - int i; + SHA1 h; + String digest; - to_digest = location + ":" + ((Uint64) time(0)) + ":" + domain + ":" + rand(); - sha1_starts(&sha1); - sha1_update(&sha1, (const unsigned char *) to_digest.to_charp(), to_digest.strlen()); - sha1_finish(&sha1, sha1sum); + h.Update(location + ":" + ((Uint64) time(0)) + ":" + domain + ":" + rand()); + digest = h.Finish(); - for (i = 0; i < 20; i++) { - sha1sum_r[i * 2 + 0] = hconv[sha1sum[i] >> 4]; - sha1sum_r[i * 2 + 1] = hconv[sha1sum[i] % 16]; - } - sha1sum_r[40] = 0; - (*b) << "WWW-Authenticate: Digest realm=\"" << location << "\", domain=\"" << domain << "\", nonce=\"" << sha1sum_r << "\", algorithm=\"MD5\", qop=\"auth\"\r\n"; + (*b) << "WWW-Authenticate: Digest realm=\"" << location << "\", domain=\"" << domain << "\", nonce=\"" << digest << "\", algorithm=\"MD5\", qop=\"auth\"\r\n"; } else { (*b) << "WWW-Authenticate: Basic realm=\"" << location << "\"\r\n"; } |