Skip to content

Add NIST SP 800-90A Rev. 1 DRBGs#6

Open
tritoke wants to merge 1 commit into
RustCrypto:masterfrom
tritoke:tritoke/nist-drbgs
Open

Add NIST SP 800-90A Rev. 1 DRBGs#6
tritoke wants to merge 1 commit into
RustCrypto:masterfrom
tritoke:tritoke/nist-drbgs

Conversation

@tritoke

@tritoke tritoke commented Apr 2, 2026

Copy link
Copy Markdown

This PR is a request to upstream our repo: https://github.com/tritoke/nist-drbg-rs here as nist-drbgs.

@tarcieri

tarcieri commented Apr 2, 2026

Copy link
Copy Markdown
Member

Thanks for the PR! Looks like quite a bit of code to look over, even as a subset of that +150 KLOCs. We're in the middle of a large release across the whole project so it might be a bit before I can look this over properly.

@GiacomoPope

Copy link
Copy Markdown

The actual code is much smaller. Almost all the LoC are the KAT files for testing against known values.

@newpavlov

Copy link
Copy Markdown
Member

We certainly do not want to include megabytes of KAT files. Could you convert them to the blobby format? And even after conversion it may be worth to exclude or truncate some tests.

@tritoke

tritoke commented Apr 3, 2026

Copy link
Copy Markdown
Author

Yeah that's fair, I'll have a go once I've had lunch :)

@GiacomoPope

Copy link
Copy Markdown

Because most of the hard work is done by the hash or cipher itself, we could probably just have one or two of each test to ensure rough correctness with the spec and then check things work with various sizes / with various policies as an internal verification?

Eg make sure 8 bytes is the same as asking for one u64 etc.

@tritoke

tritoke commented Apr 3, 2026

Copy link
Copy Markdown
Author

So I wrote a small script which takes the .rsp files and passes them through blobby's encode function, this gives us significantly smaller files. if we also want to reduce the number of test cases per case that we do we can get another choose a number of the 14 tests per case instead.

https://gist.github.com/tritoke/c6e90a06b9b78795943ef0548494b0d1

@tritoke tritoke force-pushed the tritoke/nist-drbgs branch from ede143f to d5b4680 Compare April 3, 2026 19:53
@tritoke

tritoke commented Apr 3, 2026

Copy link
Copy Markdown
Author

I've pushed up the full contents of the KATs in the blobby format now and reworked the tests to use them (apologies for the macro its a pretty hefty but hopefully well commented and readable :) This gives us ~3.7MiB of test vector files, if we took every 14th test case (one from each block of the original KAT files), it takes us down to 396KiB, obviously we could decimate further if you want. Up to you @newpavlov 👍🏻

@tritoke

tritoke commented Apr 3, 2026

Copy link
Copy Markdown
Author

One nice benefit is the line count now correctly shows as 2.5k not 150k 😂

Comment thread nist-drbgs/src/hash.rs Outdated
Comment thread nist-drbgs/src/hash.rs Outdated
Comment thread nist-drbgs/src/arithmetic.rs Outdated
Comment thread nist-drbgs/src/arithmetic.rs Outdated
Comment thread nist-drbgs/src/ctr.rs Outdated
Comment thread nist-drbgs/src/hmac.rs Outdated
Comment thread nist-drbgs/src/lib.rs Outdated
Co-Authored-By: Giacomo Pope <giacomopope@gmail.com>
Co-Authored-By: Sam Leonard <tritoke@protonmail.com>
@tritoke tritoke force-pushed the tritoke/nist-drbgs branch from 2bc1756 to 931c194 Compare April 6, 2026 09:44
@tritoke

tritoke commented Apr 6, 2026

Copy link
Copy Markdown
Author

Thanks for the review @baloo I've addressed all your points now :)

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.

5 participants