Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a testing crate #68

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ evercrypt_provider/target
no-std-support-check/target
rust_crypto_provider/target
traits/target/
hpke-rs-tests/target
.DS_Store
/.idea
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ std = []
serialization = ["serde", "tls_codec", "tls_codec/serde", "std"]
hazmat = []
hpke-test = ["std"]
hpke-test-prng = [] # ⚠️ Enable testing PRNG - DO NOT USE
hpke-test-prng = [] # ⚠️ Enable testing PRNG - DO NOT USE

[dev-dependencies]
hpke-rs-crypto = { version = "0.2.0", path = "./traits", features = ["std"] }
Expand All @@ -38,6 +38,7 @@ hpke-rs-rust-crypto = { version = "0.2.0", path = "./rust_crypto_provider", feat
rand = { version = "0.8" }
pretty_env_logger = "0.5"
criterion = { version = "0.5", features = ["html_reports"] }
hpke-rs-tests = { path = "./hpke-rs-tests", version = "*" }

[[bench]]
name = "bench"
Expand Down
25 changes: 25 additions & 0 deletions hpke-rs-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "hpke-rs-tests"
version = "0.1.0"
authors = ["Cryspen"]
edition = "2021"
license = "MPL-2.0"
readme = "Readme.md"
description = "Tests for crypto providers"
repository = "https://github.com/cryspen/hpke-rs"

[dependencies]
hpke-rs = { version = "0.2.0", features = [
"hazmat",
"serialization",
"hpke-test",
], path = "../" }
hpke-rs-crypto = { version = "0.2.0", path = "../traits" }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
rayon = "1.5"
log = "0.4"
pretty_env_logger = "0.5"

[features]
prng = ["hpke-rs/hpke-test-prng"]
24 changes: 24 additions & 0 deletions hpke-rs-tests/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Tests for Crypto Providers

This crate exposes macros that define crypto provider test functions.

## Usage

```rust
struct MyCryptoProvider;

impl hpke_rs_crypto::CryptoProvider for MyCryptoProvider {
// ...
}

#[cfg(tests)]
mod tests {
// the tests names are close to the spec and don't follow rust conventions
#![allow(non_snake_case)]

use super::MyCryptoProvider;

hpke_rs_tests::test_funs!(MyCryptoProvider);
hpke_rs_tests::kat_fun!(MyCryptoProvider);
}
```
9 changes: 9 additions & 0 deletions hpke-rs-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub mod test_hpke;
pub mod test_hpke_kat;

pub use hpke_rs;
pub use hpke_rs_crypto;
pub use serde;
pub use serde_json;

mod util;
Loading
Loading