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

Define CKD_SHA256_KDF transformation #213

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

freedge
Copy link

@freedge freedge commented Aug 9, 2024

Define CKD_SHA256_KDF transformation to be used with CKM_ECDH1_DERIVE.

Some HSM with FIPS restriction will refuse to derive keys with CKD_NULL. CKD_SHA256_KDF will do fine though.

Unfortunately this is not implemented on softHSM
(opendnssec/SoftHSMv2#599) so I provide no test. This was tested fine against Thales DPOD.

@wiktor-k
Copy link
Collaborator

I think it looks good. 👍

Unfortunately due to a new Rust version the lints started to pop up.

We could fix them in a similar way as in the tpm repo. What do you think @ionut-arm ?

wiktor-k
wiktor-k previously approved these changes Aug 10, 2024
/// The sha256 transformation as defined in the x9 standard. The
/// derived key is produced by concatenating hashes of the shared
/// value followed by 00000001, 00000002, etc. until we find
/// enough bytes to feel the CKA_VALUE_LEN of the derived key.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// enough bytes to feel the CKA_VALUE_LEN of the derived key.
/// enough bytes to fill the `CKA_VALUE_LEN` of the derived key.

Define CKD_SHA256_KDF transformation to be used with CKM_ECDH1_DERIVE.

Some HSM with FIPS restriction will refuse to derive keys with
CKD_NULL. CKD_SHA256_KDF will do fine though.

Unfortunately this is not implemented on softHSM
(opendnssec/SoftHSMv2#599)
so I provide no test. This was tested fine against Thales DPOD.

Signed-off-by: François Rigault <[email protected]>
@keldonin
Copy link
Collaborator

@freedge if that helps, the CI bot seems to work now, after the merge of PR #218. You might want to sync up your branch on your repo with the upstream one, to incorporate the latest fixes and get through these issues. I experienced the same and that solved the Execute CI script failures.

Copy link
Member

@ionut-arm ionut-arm left a comment

Choose a reason for hiding this comment

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

Thanks for the patch!

@@ -93,6 +93,17 @@ impl<'a> EcKdf<'a> {
}
}

/// The sha256 transformation as defined in the x9 standard. The
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// The sha256 transformation as defined in the x9 standard. The
/// The key derivation function based on sha256 as defined in the ANSI X9.63 standard. The

I'd recommend this change to make the reference clearer. If you'd like to put in a link to the standard that'd be even nicer 😉

/// derived key is produced by concatenating hashes of the shared
/// value followed by 00000001, 00000002, etc. until we find
/// enough bytes to fill the `CKA_VALUE_LEN` of the derived key.
pub fn sha256_x9() -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn sha256_x9() -> Self {
pub fn sha256() -> Self {

I think SHA256 is actually specific enough here, since the type makes it clear it's a KDF.

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.

4 participants