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

Refactor certificate generation code in CertifyKey #373

Conversation

clundin25
Copy link
Contributor

Refactor certificate generation code in CertifyKey to common code so it can be used in DeriveContext.

@clundin25 clundin25 marked this pull request as ready for review January 13, 2025 21:44
crypto/src/lib.rs Outdated Show resolved Hide resolved
crypto/src/openssl.rs Outdated Show resolved Hide resolved
dpe/src/x509.rs Outdated Show resolved Hide resolved
CertificateType::Exported => {
let cdi = env
.crypto
.derive_exported_cdi(algs, &digest, args.cdi_label)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I wonder if the key derivation code should stay in the CertifyKey command implementation. Since it's not really related to X.509.

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 agree but I could not think of a way to do it.

Since they are an associated type of DpeEnv<impl DpeTypes> I don't think there is a type that we can use in the function signature.

Any ideas?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The CDI is an associated type, but the key pair derivation functions return a raw public key that we can just pass into this function, right?

Copy link
Contributor Author

@clundin25 clundin25 Jan 14, 2025

Choose a reason for hiding this comment

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

I think the private key is still needed for the exported certificate since it's self signed.

This has made me realized that when I refactored the code, I deleted this portion!

Copy link
Collaborator

Choose a reason for hiding this comment

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

As discussed offlne, the cert should still be signed by the alias key

@clundin25 clundin25 force-pushed the refactor-x509 branch 3 times, most recently from 586bb31 to 6ec4eff Compare January 14, 2025 18:47
Comment on lines +2251 to +2253
pub cdi_label: &'a [u8],
pub key_label: &'a [u8],
pub context: &'a [u8],
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Can you comment where each of these are used in derivation? Mainly that context is used for both (I think)

@clundin25 clundin25 merged commit beba58d into chipsalliance:feature/gh-issue-caliptra-sw-1807 Jan 15, 2025
1 of 2 checks passed
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.

2 participants