Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORE-7 Add MD5 Support in FIPS mode #17181

Merged

Conversation

michael-redpanda
Copy link
Contributor

Adds support for MD5 message digests in FIPS mode.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x

Release Notes

  • none

Signed-off-by: Michael Boquard <michael@redpanda.com>
@vbotbuildovich
Copy link
Collaborator

vbotbuildovich commented Mar 19, 2024

new failures in https://buildkite.com/redpanda/redpanda/builds/46436#018e5700-6a2a-4590-8a1f-89d7ac6f3e49:

"rptest.tests.offset_for_leader_epoch_archival_test.OffsetForLeaderEpochArchivalTest.test_querying_remote_partitions.remote_reads=.False.True"

new failures in https://buildkite.com/redpanda/redpanda/builds/46459#018e5871-c4e9-4854-acf6-2bcad0b92aa3:

"rptest.tests.controller_log_limiting_test.ControllerLogLimitPartitionBalancerTests.test_partition_balancer_with_limits"

new failures in https://buildkite.com/redpanda/redpanda/builds/46459#018e5871-c4e2-40de-a0d3-4d55e3dfcc5c:

"rptest.tests.offset_for_leader_epoch_test.OffsetForLeaderEpochTest.test_offset_for_leader_epoch"

Copy link
Member

@oleiman oleiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

return uses_default_provider(type);
}
// Validates that the message digest is using the correct provider when in FIPS
// mode. This function will assert if:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: only because I misunderstood it the first time

Suggested change
// mode. This function will assert if:
// mode. This function will assert if all of:

or something

Comment on lines 59 to 62
static const absl::flat_hash_set<digest_type> non_fips_digest_types{
digest_type::MD5};

return non_fips_digest_types.contains(type);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use a static container here rather than like a switch/case? I'm increasingly hip to the argument that any "what is this enum" type operations should fail when the enum list changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that makes sense I can do that :)

Comment on lines 65 to 70
bool digest_type_set = false;
digest_type type;
struct callback_func_data {
bool& digest_type_set;
digest_type& type;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: what is the purpose of the extra indirection? it looks like data and its constituents should have the same lifetime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point!


callback_func_data data{
.digest_type_set = std::ref(digest_type_set), .type = std::ref(type)};
const auto fn = [](const char* name, void* vdata) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double whammy: type erased callback interface that ALSO returns an arbitrary char*? 🤩

Redpanda uses MD5 for checksum operations in the S3 client.  To
continue supporting them, the crypto library and OpenSSL library
context service has been changed to always load the default provider.

Additional checks have been added to ensure that when in FIPS mode,
non-MD5 message digests use the FIPS provider when they are fetched,
otherwise the application will crash.

Signed-off-by: Michael Boquard <michael@redpanda.com>
Signed-off-by: Michael Boquard <michael@redpanda.com>
@michael-redpanda
Copy link
Contributor Author

Force push 49017c8:

  • Updates per PR comments

Copy link
Member

@oleiman oleiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

src/v/crypto/crypto.cc Show resolved Hide resolved
@vbotbuildovich
Copy link
Collaborator

@michael-redpanda michael-redpanda merged commit d617648 into redpanda-data:dev Mar 20, 2024
13 of 16 checks passed
}
};

EVP_MD_names_do_all(md, fn, &data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where can i learn more about lambda's being able to be passed like this i didn't realize they'd have the same calling conventions for C too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to be an implicit conversion: https://en.cppreference.com/w/cpp/language/lambda (section ClosureType::operator ret(*)(params)()). Pretty cool 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants