Skip to content

Add ANSI-X9.63-KDF - #102

Merged
newpavlov merged 17 commits into
RustCrypto:masterfrom
nemynm:ANSI-X9.63-KDF
Oct 14, 2024
Merged

newpavlov merged 17 commits into
RustCrypto:masterfrom
nemynm:ANSI-X9.63-KDF

Conversation

@nemynm

@nemynm nemynm commented Oct 5, 2024

Copy link
Copy Markdown
Contributor

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

@newpavlov newpavlov left a comment

Copy link
Copy Markdown
Member

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).

Comment thread ansi-x963-kdf/src/lib.rs Outdated
Comment thread ansi-x963-kdf/src/lib.rs
Comment thread ansi-x963-kdf/src/lib.rs Outdated
Comment thread ansi-x963-kdf/src/lib.rs Outdated
Comment thread ansi-x963-kdf/src/lib.rs Outdated
Comment thread ansi-x963-kdf/src/lib.rs Outdated
Comment thread ansi-x963-kdf/tests/tests.rs
@newpavlov

Copy link
Copy Markdown
Member

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

@nemynm

nemynm commented Oct 10, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Member

Thank you!

@newpavlov
newpavlov merged commit 80622b1 into RustCrypto:master Oct 14, 2024
@nemynm

nemynm commented Oct 14, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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