Expand description
§Wycheproof test vectors
Wycheproof is a set of cryptographic tests created by a team at Google which checks for common bugs and corner cases in cryptographic code.
This crate is a convenient repacking of the Wycheproof JSON-formatted test data with deserialization to easily usable structs.
Hex and base64 encoded data is decoded to binary in the BinaryString
struct which is a light wrapper around Vec<u8>
.
Large integers (such as those used in the RSA test data) are decoded as
big-endian byte arrays into a LargeInteger
struct, which is again a light
wrapper around Vec<u8>
. Additionally if the num-bigint
feature is enabled,
this type also gains a conversion function to num_bigint::BigUint
.
Each submodule of this crate includes a set of structs: a TestName
which
specifies which individual test is desired, a TestSet
which is the set of
data associated with the TestName
. Each TestSet
contains one or more
TestGroups
, which in turn contain some amount of test-specific
configuration information along with a list of Test
which are the actual
tests.
Each test has an expected result which is either Valid
, Invalid
, or
Acceptable
. Acceptable
just means that the test is technically valid but
might still be rejected for various reasons, for instance because the hash
function that was used is too weak for proper security.
§Examples
#[cfg(feature = "aead")]
fn print_gcm() {
// Print all AES-GCM test vector data
let test_set = wycheproof::aead::TestSet::load(wycheproof::aead::TestName::AesGcm).unwrap();
for test_group in test_set.test_groups {
println!(
"* Group key size:{} tag size:{} nonce size:{}",
test_group.key_size, test_group.tag_size, test_group.nonce_size,
);
for test in test_group.tests {
println!(
"Test:{} Key:{} AAD:{} PT:{} CT:{} Tag:{}",
test.tc_id,
data_encoding::HEXLOWER.encode(&test.key),
data_encoding::HEXLOWER.encode(&test.aad),
data_encoding::HEXLOWER.encode(&test.pt),
data_encoding::HEXLOWER.encode(&test.ct),
data_encoding::HEXLOWER.encode(&test.tag)
);
}
}
}
// Iterate over all of the AEAD tests
#[cfg(feature = "aead")]
for aead in wycheproof::aead::TestName::all() {
println!("{:?}", aead);
}
Modules§
- aead
- AEAD tests
- cipher
- IND-CPA cipher tests
- dsa
- DSA verification tests
- ec_
curve - Elliptic Curve Information
- ecdh
- ECDH key agreement tests
- ecdsa
- ECDSA tests
- eddsa
- EdDSA verification tests
- fpe_
list - Format Preseverving Encryption
- fpe_str
- Format Preseverving Encryption
- hkdf
- HKDF tests
- keywrap
- NIST keywrapping tests
- mac
- Message Authentication Code tests
- mac_
with_ nonce - Message Authentication Code tests
- primality
- Primality checking tests
- rsa_
oaep - RSA OAEP decryption tests
- rsa_
pkcs1_ decrypt - RSA PKCS1v1.5 decryption tests
- rsa_
pkcs1_ verify - RSA PKCS1v1.5 verification tests
- rsa_
pss_ verify - RSA PSS verification tests
- xdh
- Montgomery curve ECDH tests
Structs§
- Byte
String - CVE
- DsaPublic
- Ecdsa
Public - Ecdsa
Public Jwk - Eddsa
Public - Eddsa
Public Jwk - Large
Integer - RsaPrivate
- RsaPrivate
Jwk - RsaPublic
- RsaPublic
Jwk - Test
Flag Info - URL
Enums§
- BugType
- Edwards
Curve - Edwards curves
- Elliptic
Curve - Prime order elliptic curves
- Hash
Function - Hash Function identifiers
- Mgf
- MGF identifiers
- Montgomery
Curve - Montgomery curves
- Test
Result - The expected result of a Wycheproof test
- Wycheproof
Error - The error type