Skip to content

Commit 0e6dc0b

Browse files
committed
SDSTOR-20907: Backport fix to support OpenSSL >=3.6
1 parent c25cb7d commit 0e6dc0b

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class SISLConan(ConanFile):
1111
name = "sisl"
12-
version = "8.9.4"
12+
version = "8.9.5"
1313
homepage = "https://github.com/eBay/sisl"
1414
description = "Library for fast data structures, utilities"
1515
topics = ("ebay", "components", "core", "efficiency")

src/auth_manager/auth_manager.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <fmt/format.h>
55
extern "C" {
6+
#include <openssl/evp.h>
67
#include <openssl/md5.h>
78
}
89

@@ -11,17 +12,25 @@ extern "C" {
1112
namespace sisl {
1213

1314
static std::string md5_sum(std::string const& s) {
14-
unsigned char digest[MD5_DIGEST_LENGTH];
15-
16-
MD5(reinterpret_cast< unsigned char* >(const_cast< char* >(s.c_str())), s.length(),
17-
reinterpret_cast< unsigned char* >(&digest));
15+
std::array< unsigned char, MD5_DIGEST_LENGTH > result;
16+
uint32_t md_len;
17+
auto mdctx = EVP_MD_CTX_new();
18+
EVP_DigestInit_ex(mdctx, EVP_md5(), nullptr);
19+
EVP_DigestUpdate(mdctx, s.c_str(), s.size());
20+
EVP_DigestFinal_ex(mdctx, result.data(), &md_len);
21+
EVP_MD_CTX_free(mdctx);
22+
if (md_len != MD5_DIGEST_LENGTH) {
23+
LOGERROR("Bad digest length, expected [{}] got [{}]!", MD5_DIGEST_LENGTH, md_len);
24+
return std::string();
25+
}
1826

19-
std::ostringstream out;
20-
out << std::hex;
21-
for (int i = 0; i < MD5_DIGEST_LENGTH; i++) {
22-
out << std::setfill('0') << std::setw(2) << std::hex << (int)(unsigned char)digest[i];
27+
// convert to hex
28+
std::ostringstream ss;
29+
ss << std::hex;
30+
for (auto const c : result) {
31+
ss << std::setw(2) << std::setfill('0') << static_cast< unsigned >(c);
2332
}
24-
return out.str();
33+
return ss.str();
2534
}
2635

2736
struct incomplete_verification_error : std::exception {
@@ -157,4 +166,4 @@ std::string AuthManager::get_app(const jwt::decoded_jwt& decoded) const {
157166
const auto end{client_id.find_first_of(",", start)};
158167
return client_id.substr(start, end - start);
159168
}
160-
} // namespace sisl
169+
} // namespace sisl

0 commit comments

Comments
 (0)