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

fix missing #3

Closed
wants to merge 4 commits into from
Closed
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ jobs:
toolchain: ${{ matrix.toolchain }}
override: true

- name: Run cargo test with just secp enabled
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -D warnings -A dead_code -A unused_imports
run: cargo test --no-default-features --features="secp"

- name: Run cargo test with just X25519 enabled
env:
CARGO_INCREMENTAL: 0
Expand Down
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ p384 = ["dep:p384"]
p256 = ["dep:p256"]
p521 = ["dep:p521"]
k256 = ["dep:k256"]
secp = ["bitcoin", "secp256k1/global-context", "secp256k1/rand-std"]
# Include allocating methods like open() and seal()
alloc = []
# Includes an implementation of `std::error::Error` for `HpkeError`. Also does what `alloc` does.
Expand All @@ -29,6 +30,9 @@ std = []
[dependencies]
aead = "0.5"
aes-gcm = "0.10"
bitcoin = { version = "0.32.0", optional = true }
secp256k1 = { version = "0.29", optional = true }
# bitcoin = { git = "https://github.com/rust-bitcoin/rust-bitcoin", commit = "0d1cab68eee59f79c3ec76cf393438471b68fe69", optional = true }
byteorder = { version = "1.4", default-features = false }
chacha20poly1305 = "0.10"
generic-array = { version = "0.14", default-features = false }
Expand Down
5 changes: 5 additions & 0 deletions benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ pub fn benches() {
hpke::kdf::HkdfSha256,
hpke::kem::X25519HkdfSha256,
>("Non-NIST[seclevel=128]", &mut c);

#[cfg(feature = "secp")]
bench_ciphersuite::<hpke::aead::AesGcm128, hpke::kdf::HkdfSha256, hpke::kem::SecpK256HkdfSha256>(
"secp", &mut c,
);
}

criterion_main!(benches);
29 changes: 29 additions & 0 deletions src/aead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,35 @@ mod test {
);
}

#[cfg(all(feature = "secp", any(feature = "alloc", feature = "std")))]
mod secp_tests {
use super::*;

test_export_idempotence!(test_export_idempotence_k256, crate::kem::SecpK256HkdfSha256);
test_exportonly_panics!(
test_exportonly_panics_k256_seal,
test_exportonly_panics_k256_open,
crate::kem::SecpK256HkdfSha256
);
test_overflow!(test_overflow_k256, crate::kem::SecpK256HkdfSha256);

test_ctx_correctness!(
test_ctx_correctness_aes128_k256,
AesGcm128,
crate::kem::SecpK256HkdfSha256
);
test_ctx_correctness!(
test_ctx_correctness_aes256_k256,
AesGcm256,
crate::kem::SecpK256HkdfSha256
);
test_ctx_correctness!(
test_ctx_correctness_chacha_k256,
ChaCha20Poly1305,
crate::kem::SecpK256HkdfSha256
);
}

/// Tests that Serialize::write_exact() panics when given a buffer of incorrect length
#[should_panic]
#[test]
Expand Down
3 changes: 3 additions & 0 deletions src/dhkex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ pub(crate) mod ecdh_nist;

#[cfg(feature = "x25519")]
pub(crate) mod x25519;

#[cfg(feature = "secp")]
pub(crate) mod secp256k1;
Loading
Loading