Skip to content

Commit

Permalink
Hash Private/Public keys instead of using original string as key
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdelv committed Dec 5, 2024
1 parent 6e21c06 commit 3d43d66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/openssl/openssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class PKeyCache
{
for (auto& c : cache)
{
if (strncmp(std::get<0>(c).c_str(), key, keyLen) == 0)
if (hashc(reinterpret_cast<const byte *>(key), keyLen, 0) == std::get<0>(c))
{
hits++;
return std::get<1>(c);
Expand All @@ -170,7 +170,7 @@ class PKeyCache
BIO_free(bio);
if (pkey)
{
cache.emplace_front(std::string(key, keyLen), pkey);
cache.emplace_front(hashc(reinterpret_cast<const byte *>(key), keyLen, 0), pkey);
if (cache.size() > OPENSSL_MAX_CACHE_SIZE)
{
EVP_PKEY_free(std::get<1>(cache.back()));
Expand All @@ -195,7 +195,7 @@ class PKeyCache
private:
int hits;
int misses;
std::list<std::tuple<std::string, EVP_PKEY *>> cache;
std::list<std::tuple<unsigned, EVP_PKEY *>> cache;
};


Expand Down

0 comments on commit 3d43d66

Please sign in to comment.