Skip to content

Commit

Permalink
rgw: under fips & openssl 3.x allow md5 iusage in select rgw ops
Browse files Browse the repository at this point in the history
openssl 3.x (ex:RHEL9) requires a different override mechanism for MD5 usage under FIPS
for non-cryptographic putposes than openssl 1.x (RHEL8)

fixes: https://tracker.ceph.com/issues/58332

Signed-off-by: Mark Kogan <mkogan@redhat.com>
  • Loading branch information
mkogan1 committed Dec 21, 2022
1 parent 8b4db5d commit 448b3d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/common/ceph_crypto.cc
Expand Up @@ -196,14 +196,25 @@ ssl::OpenSSLDigest::OpenSSLDigest(const EVP_MD * _type)

ssl::OpenSSLDigest::~OpenSSLDigest() {
EVP_MD_CTX_destroy(mpContext);
if (mpType_FIPS) {
EVP_MD_free(mpType_FIPS);
}
}

void ssl::OpenSSLDigest::Restart() {
EVP_DigestInit_ex(mpContext, mpType, NULL);
if (mpType_FIPS) {
EVP_DigestInit_ex(mpContext, mpType_FIPS, NULL);
} else {
EVP_DigestInit_ex(mpContext, mpType, NULL);
}
}

void ssl::OpenSSLDigest::SetFlags(int flags) {
EVP_MD_CTX_set_flags(mpContext, flags);
if (flags == EVP_MD_CTX_FLAG_NON_FIPS_ALLOW && OpenSSL_version_num() >= 0x30000000L && mpType == EVP_md5() && !mpType_FIPS) {
mpType_FIPS = EVP_MD_fetch(NULL, "MD5", "fips=no");
} else {
EVP_MD_CTX_set_flags(mpContext, flags);
}
this->Restart();
}

Expand Down
1 change: 1 addition & 0 deletions src/common/ceph_crypto.h
Expand Up @@ -54,6 +54,7 @@ namespace TOPNSPC::crypto {
private:
EVP_MD_CTX *mpContext;
const EVP_MD *mpType;
EVP_MD *mpType_FIPS = nullptr;
public:
OpenSSLDigest (const EVP_MD *_type);
~OpenSSLDigest ();
Expand Down

0 comments on commit 448b3d6

Please sign in to comment.