Skip to content

[WIP] Add hmacdrbg#7

Draft
tarcieri wants to merge 1 commit into
masterfrom
hmacdrbg
Draft

[WIP] Add hmacdrbg#7
tarcieri wants to merge 1 commit into
masterfrom
hmacdrbg

Conversation

@tarcieri

Copy link
Copy Markdown
Member

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.

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.
Comment thread hmacdrbg/LICENSE-MIT
@@ -0,0 +1,25 @@
Copyright (c) 2018-2026 RustCrypto Developers

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.

Replace with just 2026.

Comment thread hmacdrbg/README.md
Pure Rust implementation of the `HMAC_DRBG` HMAC-based deterministic random bit generator as
described in [NIST SP800-90A].

## Minimum Supported Rust Version

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.

We no longer have this section in the recent releases.

Comment thread hmacdrbg/Cargo.toml
[package]
name = "hmacdrbg"
version = "0.0.1"
description = "Pure Rust implementation of HMAC_DRBG as described in NIST SP800-90A"

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.

Use the "standard" field order (e.g. see sha2).

Comment thread hmacdrbg/src/lib.rs

// ECDSA with K-163+SHA-256.
#[test]
fn rfc6979_appendix_a1_k163() {

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.

Use this example as a doctest instead of keeping it as a unit test?

Comment thread hmacdrbg/src/lib.rs

/// 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]) {

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.

Implement the rand_core::Rng trait?

Comment thread hmacdrbg/src/lib.rs
D: Digest + BlockSizeUser + FixedOutputReset,
{
/// HMAC key `K` (see RFC 6979 Section 3.2.c)
k: SimpleHmacReset<D>,

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