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 ANSI-X9.63-KDF #102

Merged
merged 17 commits into from
Oct 14, 2024
Merged

Add ANSI-X9.63-KDF #102

merged 17 commits into from
Oct 14, 2024

Conversation

nemynm
Copy link
Contributor

@nemynm nemynm commented Oct 5, 2024

Adding support for ANSI X9.63 Key Derivation Function (ANSI-X9.63-KDF).

ANSI-X9.63-KDF is defined in SEC.1 and is the recommended KDF to be used for CMS with ECC - as per RFC 5753.

This would close issue #101.

Overview:
This pull request:

  • adds ansi-x963-kdf crate with:
    • ansi_x963_kdf::derive_key_into function
    • tests for SHA254, SHA256 and SHA512 hash functions
  • updates repository README.md with ansi-x963-kdf

Notes:

  • As concat-kdf and ANSI-X9.63-KDF are close and essentially differ in the order in which the data is concatenated, most of the code for this ansi-x963-kdf implementation has been adapted from concat-kdf.
  • I did not find public test vectors, so the test cases have been generated using a Java-based implementation of ANSI-X9.63-KDF
  • I added one "unsafe" test case to test the input overflow case. As I am not an "unsafe" specialist, carefull review of this one is particularly appreciated.

@nemynm nemynm marked this pull request as ready for review October 5, 2024 17:49
Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

I have several comments, but otherwise looks good!

Please also add a CI job to test this crate (see the .github/workflows folder).

ansi-x963-kdf/src/lib.rs Outdated Show resolved Hide resolved
ansi-x963-kdf/src/lib.rs Show resolved Hide resolved
ansi-x963-kdf/src/lib.rs Outdated Show resolved Hide resolved
ansi-x963-kdf/src/lib.rs Outdated Show resolved Hide resolved
ansi-x963-kdf/src/lib.rs Outdated Show resolved Hide resolved
ansi-x963-kdf/src/lib.rs Outdated Show resolved Hide resolved
ansi-x963-kdf/tests/tests.rs Show resolved Hide resolved
@newpavlov
Copy link
Member

You can update the Clippy version to 1.81 in the workspace.yml config to fix the failing CI.

@nemynm
Copy link
Contributor Author

nemynm commented Oct 10, 2024

I have several comments, but otherwise looks good!

Please also add a CI job to test this crate (see the .github/workflows folder).

Thanks for reviewing! I tried and addressed your comments. The MSRV bump does trigger a failing clippy at workspace level though.

@newpavlov
Copy link
Member

Thank you!

@newpavlov newpavlov merged commit 80622b1 into RustCrypto:master Oct 14, 2024
21 checks passed
@nemynm
Copy link
Contributor Author

nemynm commented Oct 14, 2024

Thanks for the review and the tweaks!

  • you probably have noted it, but just in case, on README.md, it seems that the badge MSRV 1.81 and crate on crates.io are not-rendering/missing.
  • I think some of these changes could be applied to concat-kdf (e.g. doctests, MSRV, std vs alloc)

In the meantime, I'll close the issue.

@nemynm nemynm mentioned this pull request Oct 14, 2024
@newpavlov
Copy link
Member

the badge MSRV 1.81 and crate on crates.io are not-rendering/missing.

The MSRV badge (rustc 1.81+) renders fine for me. Docs and crates.io badges require publishing to crates.io, which we will do after releasing digest v0.11.

I think some of these changes could be applied to concat-kdf (e.g. doctests, MSRV, std vs alloc)

Yes. I plan to do it a bit later.

@nemynm nemynm deleted the ANSI-X9.63-KDF branch October 14, 2024 13:06
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