Skip to content

Commit

Permalink
Fix doctests where Function is wrapped around the actual test but is …
Browse files Browse the repository at this point in the history
…never called in cipher traits (rosenpass#542)
koraa authored Dec 16, 2024
2 parents 4725a2d + ae3fbde commit 9cc860f
Showing 3 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cipher-traits/Cargo.toml
Original file line number Diff line number Diff line change
@@ -14,3 +14,4 @@ readme = "readme.md"
[dev-dependencies]
rosenpass-oqs = { workspace = true }
rosenpass-secret-memory = { workspace = true }
anyhow = {workspace = true}
17 changes: 7 additions & 10 deletions cipher-traits/src/kem.rs
Original file line number Diff line number Diff line change
@@ -19,11 +19,10 @@
//!```rust
//! use rosenpass_cipher_traits::Kem;
//! use rosenpass_oqs::Kyber512;
//! use rosenpass_secret_memory::Secret;
//! # use rosenpass_secret_memory::{secret_policy_use_only_malloc_secrets, Secret};
//!
//! # fn do_doc_test() -> Result<(), Box<dyn std::error::Error>> {
//! type MyKem = Kyber512;
//!
//! secret_policy_use_only_malloc_secrets();
//! let mut alice_sk: Secret<{ MyKem::SK_LEN }> = Secret::zero();
//! let mut alice_pk: [u8; MyKem::PK_LEN] = [0; MyKem::PK_LEN];
//! MyKem::keygen(alice_sk.secret_mut(), &mut alice_pk)?;
@@ -36,8 +35,7 @@
//! MyKem::decaps(alice_shk.secret_mut(), alice_sk.secret_mut(), &mut bob_ct)?;
//!
//! # assert_eq!(alice_shk.secret(), bob_shk.secret());
//! # Ok(())
//! # }
//! # Ok::<(), anyhow::Error>(())
//!```
//!
//! Implementing the [Kem]-trait for a KEM is easy. Mostly, you must format the KEM's
@@ -109,11 +107,10 @@
//! Ok(())
//! }
//! }
//! # use rosenpass_secret_memory::Secret;
//! # use rosenpass_secret_memory::{secret_policy_use_only_malloc_secrets, Secret};
//! #
//! # fn do_doc_test() -> Result<(), Box<dyn std::error::Error>> {
//! # type MyKem = DummyKem;
//! #
//! # secret_policy_use_only_malloc_secrets();
//! # let mut alice_sk: Secret<{ MyKem::SK_LEN }> = Secret::zero();
//! # let mut alice_pk: [u8; MyKem::PK_LEN] = [0; MyKem::PK_LEN];
//! # MyKem::keygen(alice_sk.secret_mut(), &mut alice_pk)?;
@@ -126,8 +123,8 @@
//! # MyKem::decaps(alice_shk.secret_mut(), alice_sk.secret_mut(), &mut bob_ct)?;
//! #
//! # assert_eq!(alice_shk.secret(), bob_shk.secret());
//! # Ok(())
//! # }
//! #
//! # Ok::<(), String>(())
//!```
//!

0 comments on commit 9cc860f

Please sign in to comment.