#rng #nist #pqc

no-std nist-pqc-seeded-rng

Implementation of the RNG used to produce the KATs in NIST PQC competition

5 releases

0.2.0 Sep 13, 2024
0.1.3 Sep 12, 2024
0.1.2 Jul 16, 2024
0.1.1 Jul 15, 2024
0.1.0 Jul 15, 2024

#787 in Cryptography

Download history 316/week @ 2024-07-15 3/week @ 2024-07-22 5/week @ 2024-07-29 2/week @ 2024-08-19 48/week @ 2024-09-02 357/week @ 2024-09-09 75/week @ 2024-09-16 61/week @ 2024-09-23 51/week @ 2024-09-30 25/week @ 2024-10-07

226 downloads per month
Used in faest

Apache-2.0 OR MIT

12KB
198 lines

NIST PQC: RNG for known answer tests

This crate provides a seedable RNG that produces outputs compatible with rng.c used by submissions to the NIST PQC project to obtain known answer tests from an initial seed.

Security Notes

This crate has received no security audit. Use at your own risk.

Minimum Supported Rust Version

This crate requires Rust 1.70 at a minimum. The MSRV may be changed in the future, but this change will be accompanied by a minor version bump.

License

This crate is licensed under the Apache-2.0 or MIT license.


lib.rs:

Usage

The RNG can be instantiated from a 48 byte seed using various options: first with SeedableRng::from_seed as defined in the interface of seedable API. To avoid the user to handle the conversion to [GenericArray] which is used to represent a seed, convenience implementations of [From] for a u8 array with 48 elements as well as [TryFrom] for a [u8] slice is provided.

The following three examples are functionally equivalent. Let us start with initializing from [Seed]:

use nist_pqc_seeded_rng::{NistPqcAes256CtrRng, Seed, SeedableRng};

let seed: Seed = (*b"012345678901234567890123456789012345678901234567").into();
let rng = NistPqcAes256CtrRng::from_seed(seed);

Using a u8 array:

use nist_pqc_seeded_rng::{NistPqcAes256CtrRng, Seed, SeedableRng};

let seed: [u8; 48] = *b"012345678901234567890123456789012345678901234567";
let rng = NistPqcAes256CtrRng::from(seed);

Using a slice:

use nist_pqc_seeded_rng::{NistPqcAes256CtrRng, Seed, SeedableRng};

let seed = b"012345678901234567890123456789012345678901234567".as_slice();
let rng = NistPqcAes256CtrRng::try_from(seed).expect("seed of invalid length");

Dependencies

~1–1.6MB
~37K SLoC