From b3730bf7076c6e3a602a56d72e845e7c0732ae75 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 24 Feb 2023 11:00:48 +0100 Subject: [PATCH] downloader: Use built-in MD5 implemention for HTTPDigestAuthorization This code is only compiled when OpenSSL is enabled at the moment, but this will change when webgl-port is merged --- .../downloader/httpDigestAuthorization.cxx | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/panda/src/downloader/httpDigestAuthorization.cxx b/panda/src/downloader/httpDigestAuthorization.cxx index 67d89470a0..1d80164654 100644 --- a/panda/src/downloader/httpDigestAuthorization.cxx +++ b/panda/src/downloader/httpDigestAuthorization.cxx @@ -15,11 +15,10 @@ #ifdef HAVE_OPENSSL -#include "httpChannel.h" +#include "hashVal.h" #include "string_utils.h" -#include "openSSLWrapper.h" // must be included before any other openssl. -#include -#include +#include "urlSpec.h" + #include using std::ostream; @@ -292,19 +291,9 @@ get_hex_nonce_count() const { */ string HTTPDigestAuthorization:: calc_md5(const string &source) { - unsigned char binary[MD5_DIGEST_LENGTH]; - - MD5((const unsigned char *)source.data(), source.length(), binary); - - string result; - result.reserve(MD5_DIGEST_LENGTH * 2); - - for (int i = 0; i < MD5_DIGEST_LENGTH; i++) { - result += hexdigit((binary[i] >> 4) & 0xf); - result += hexdigit(binary[i] & 0xf); - } - - return result; + HashVal hv; + hv.hash_string(source); + return hv.as_hex(); } ostream &