#vector #nist #testing #kat #algorithm #iterate #bind

katwalk

Utility to iterate over NIST KAT vectors. It allows to bind an action for each test vector supplied by calling code. Hence, making it possible to run KAT testing. This is work in prograess version!!!

12 releases

0.0.12 Nov 14, 2023
0.0.10 Jul 19, 2022
0.0.9 Nov 3, 2021
0.0.7 Jul 30, 2021
0.0.1 Nov 17, 2020

#579 in Cryptography

Download history 2/week @ 2023-12-15 9/week @ 2023-12-29 3/week @ 2024-01-05 25/week @ 2024-01-12 31/week @ 2024-01-19 15/week @ 2024-01-26 44/week @ 2024-02-02 90/week @ 2024-02-09 47/week @ 2024-02-16 42/week @ 2024-02-23 100/week @ 2024-03-01 56/week @ 2024-03-08 37/week @ 2024-03-15 134/week @ 2024-03-22 262/week @ 2024-03-29

538 downloads per month

MIT license

85KB
785 lines

katwalk

Utility to iterate over NIST Known Answer Tests vectors from CAVP. It allows to bind an action for each test vector supplied by calling code.

Supported schemes:

Algorithm NIST Specification name
SHA2 FIPS-180-4
SHA3 FIPS-202
SHAKE FIPS-202
HMAC FIPS-198
Diffie-Hellman SP 800-56A
KDF SP 800-108
DRBG SP 800-90A (without Prediction Resistance)
NIST PQC All KEM & Signature schemes

Example

Here below an example of usage for one vector for SHA3 KAT (FIPS 202).

// Vector copy pasted from NIST specs
let ex = "
Len = 0
Msg = 00
MD = 6b4e03423667dbb73b6e15454f0eb1abd4597f9a1b078e3f5b5a6bc7";

    // Some variables
    let mut count = 0;
    // Create an iterator for HASH algorithm
		let r = KatReader::new(
			std::io::BufReader::new(Cursor::new(ex)),
			AlgType::AlgHash, 1);
		
    // Iterate over all KATS. The ``el`` will contain fields
    // parsed from KAT files. Those fields are used as input
    // to cryptographic implementation and expected output.
		for el in r {
			assert_eq!(el.hash.md.len(), 28);
			assert_eq!(el.hash.len, 0);
			assert_eq!(el.hash.msg, [0x00]);
			assert_eq!(el.hash.md[0..5], [0x6B, 0x4E, 0x03, 0x42, 0x36]);
			count+=1;
		}
		assert_eq!(count, 1);

Used by

It is used by PQC library (here) for functional testing.

Status

Algorithms are added on "as needed" bases. Don't judge implementation, it needs major rewrite.

Dependencies