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

Add generating CWT for tests #4820

Merged
merged 5 commits into from
Feb 21, 2024
Merged

Conversation

ipetr0v
Copy link
Contributor

@ipetr0v ipetr0v commented Feb 21, 2024

This PR adds functions to generate COSE_Sign1, COSE_Key and CWT certificates for testing purposes.

These functions are currently not fully implemented and only provide serializing an HPKE public key.

Ref #3641
Ref #4074
Ref #4627

enum Parameter : int {
// COSE Key Common parameters.
// <https://datatracker.ietf.org/doc/html/rfc8152#section-7.1>
enum CoseKeyCommonParameter : int {
Copy link
Collaborator

Choose a reason for hiding this comment

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

partially pre-existing, but I think that in general using enum class is preferred. See https://abseil.io/tips/86

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to refactor this library as part of #4818

And will implement enum classes

auto serialized_cwt_string = std::string(serialized_cwt->begin(), serialized_cwt->end());

auto deserialized_cwt = Cwt::Deserialize(serialized_cwt_string);
EXPECT_TRUE(deserialized_cwt.ok()) << deserialized_cwt.status();
Copy link
Collaborator

Choose a reason for hiding this comment

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

EXPECT_OK(serialized_cwt)
EXPECT_OK(deserialized_cwt)

I think this will print the status on failure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like EXPECT_OK is not available externally:

cc/utils/cose/cwt_test.cc:72:3: error: 'EXPECT_OK' was not declared in this scope; did you mean 'EXPECT_EQ'?
   72 |   EXPECT_OK(serialized_cwt) << serialized_cwt.status();
      |   ^~~~~~~~~
      |   EXPECT_EQ

cc/utils/cose/cwt.cc Show resolved Hide resolved
@ipetr0v ipetr0v merged commit bbbd05c into project-oak:main Feb 21, 2024
17 checks passed
@ipetr0v ipetr0v deleted the cose_cwt_serialize branch February 21, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants