Simplify doctests.
This commit is contained in:
parent
d27df1c7e0
commit
a787b9273d
@ -21,7 +21,6 @@
|
||||
//! `agreement::ECDH_P256`/`agreement::ECDH_P384` for `agreement::X25519`.
|
||||
//!
|
||||
//! ```
|
||||
//! # fn x25519_agreement_example() -> Result<(), ring::error::Unspecified> {
|
||||
//! use ring::{agreement, rand};
|
||||
//!
|
||||
//! let rng = rand::SystemRandom::new();
|
||||
@ -55,9 +54,9 @@
|
||||
//! // keys from the result. We omit all that here.
|
||||
//! Ok(())
|
||||
//! },
|
||||
//! )
|
||||
//! # }
|
||||
//! # fn main() { x25519_agreement_example().unwrap() }
|
||||
//! )?;
|
||||
//!
|
||||
//! # Ok::<(), ring::error::Unspecified>(())
|
||||
//! ```
|
||||
|
||||
// The "NSA Guide" steps here are from from section 3.1, "Ephemeral Unified
|
||||
|
@ -62,9 +62,7 @@ use std;
|
||||
/// Ok(bytes)
|
||||
/// }
|
||||
///
|
||||
/// # fn main() {
|
||||
/// # assert!(eight_random_bytes().is_ok());
|
||||
/// # }
|
||||
/// assert!(eight_random_bytes().is_ok());
|
||||
/// ```
|
||||
///
|
||||
/// Experience with using and implementing other crypto libraries like has
|
||||
|
24
src/hmac.rs
24
src/hmac.rs
@ -31,7 +31,6 @@
|
||||
//! ```
|
||||
//! use ring::{digest, hmac, rand};
|
||||
//!
|
||||
//! # fn main_with_result() -> Result<(), ring::error::Unspecified> {
|
||||
//! let rng = rand::SystemRandom::new();
|
||||
//! let key = hmac::Key::generate(&digest::SHA256, &rng)?;
|
||||
//!
|
||||
@ -43,11 +42,8 @@
|
||||
//! // back to us. We need to verify they didn't tamper with it.]
|
||||
//!
|
||||
//! hmac::verify(&key, msg.as_bytes(), tag.as_ref())?;
|
||||
//! #
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! #
|
||||
//! # fn main() { main_with_result().unwrap() }
|
||||
//!
|
||||
//! # Ok::<(), ring::error::Unspecified>(())
|
||||
//! ```
|
||||
//!
|
||||
//! ## Using the one-shot API:
|
||||
@ -56,7 +52,6 @@
|
||||
//! use ring::{digest, hmac, rand};
|
||||
//! use ring::rand::SecureRandom;
|
||||
//!
|
||||
//! # fn main_with_result() -> Result<(), ring::error::Unspecified> {
|
||||
//! let msg = "hello, world";
|
||||
//!
|
||||
//! // The sender generates a secure key value and signs the message with it.
|
||||
@ -73,11 +68,8 @@
|
||||
//! // integrity of the message.
|
||||
//! let v_key = hmac::Key::new(&digest::SHA256, key_value.as_ref());
|
||||
//! hmac::verify(&v_key, msg.as_bytes(), tag.as_ref())?;
|
||||
//! #
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! #
|
||||
//! # fn main() { main_with_result().unwrap() }
|
||||
//!
|
||||
//! # Ok::<(), ring::error::Unspecified>(())
|
||||
//! ```
|
||||
//!
|
||||
//! ## Using the multi-part API:
|
||||
@ -85,7 +77,6 @@
|
||||
//! use ring::{digest, hmac, rand};
|
||||
//! use ring::rand::SecureRandom;
|
||||
//!
|
||||
//! # fn main_with_result() -> Result<(), ring::error::Unspecified> {
|
||||
//! let parts = ["hello", ", ", "world"];
|
||||
//!
|
||||
//! // The sender generates a secure key value and signs the message with it.
|
||||
@ -110,11 +101,8 @@
|
||||
//! msg.extend(part.as_bytes());
|
||||
//! }
|
||||
//! hmac::verify(&v_key, &msg.as_ref(), tag.as_ref())?;
|
||||
//! #
|
||||
//! # Ok(())
|
||||
//! # }
|
||||
//! #
|
||||
//! # fn main() { main_with_result().unwrap() }
|
||||
//!
|
||||
//! # Ok::<(), ring::error::Unspecified>(())
|
||||
//! ```
|
||||
//!
|
||||
//! [RFC 2104]: https://tools.ietf.org/html/rfc2104
|
||||
|
Loading…
x
Reference in New Issue
Block a user