Conversation
This is an extraction of the minified implementation of `HMAC_DRBG` from the `rfc6979` crate. Unfortunately the `hmac-drbg` name is taken and I never got a reply from the owner when I asked about it, so I'm using this name instead as it seems like the best available option. This implementation is sufficient to meet `rfc6979`'s needs but may lack some features for more general purpose use.
newpavlov
reviewed
Jun 29, 2026
| @@ -0,0 +1,25 @@ | |||
| Copyright (c) 2018-2026 RustCrypto Developers | |||
| Pure Rust implementation of the `HMAC_DRBG` HMAC-based deterministic random bit generator as | ||
| described in [NIST SP800-90A]. | ||
|
|
||
| ## Minimum Supported Rust Version |
Member
There was a problem hiding this comment.
We no longer have this section in the recent releases.
| [package] | ||
| name = "hmacdrbg" | ||
| version = "0.0.1" | ||
| description = "Pure Rust implementation of HMAC_DRBG as described in NIST SP800-90A" |
|
|
||
| // ECDSA with K-163+SHA-256. | ||
| #[test] | ||
| fn rfc6979_appendix_a1_k163() { |
Member
There was a problem hiding this comment.
Use this example as a doctest instead of keeping it as a unit test?
|
|
||
| /// Write the next `HMAC_DRBG` output to the given byte slice. | ||
| #[allow(clippy::missing_panics_doc, reason = "should not panic")] | ||
| pub fn fill_bytes(&mut self, out: &mut [u8]) { |
Member
There was a problem hiding this comment.
Implement the rand_core::Rng trait?
| D: Digest + BlockSizeUser + FixedOutputReset, | ||
| { | ||
| /// HMAC key `K` (see RFC 6979 Section 3.2.c) | ||
| k: SimpleHmacReset<D>, |
Member
There was a problem hiding this comment.
I don't think you need to keep the HMAC instance as part of the state.
tarcieri
added a commit
to RustCrypto/signatures
that referenced
this pull request
Jun 30, 2026
These are inspired by part from feedback on RustCrypto/CSRNGs#7
tarcieri
added a commit
to RustCrypto/signatures
that referenced
this pull request
Jun 30, 2026
These are inspired by part from feedback on RustCrypto/CSRNGs#7
tarcieri
added a commit
to RustCrypto/signatures
that referenced
this pull request
Jun 30, 2026
These are inspired by part from feedback on RustCrypto/CSRNGs#7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an extraction of the minified implementation of
HMAC_DRBGfrom therfc6979crate.Unfortunately the
hmac-drbgname is taken and I never got a reply from the owner when I asked about it, so I'm using this name instead as it seems like the best available option.This implementation is sufficient to meet
rfc6979's needs but may lack some features for more general purpose use.