summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-20 07:35:17 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-20 07:35:17 -0400
commit152e4a1e5036e9456f98f7c647a3dc72d24b0f5e (patch)
tree1775092939f5d8eecaa7927a9c369fe40ded624c /src
parentb63d6984a612aaeaa5f71e213b4f7a89644559b2 (diff)
parentac1747e47fc8a8486df3844045238f72bd4985fe (diff)
downloadtor-152e4a1e5036e9456f98f7c647a3dc72d24b0f5e.tar.gz
tor-152e4a1e5036e9456f98f7c647a3dc72d24b0f5e.zip
Merge branch 'maint-0.3.4'
Diffstat (limited to 'src')
-rw-r--r--src/rust/crypto/digests/sha2.rs24
-rw-r--r--src/rust/crypto/lib.rs14
2 files changed, 19 insertions, 19 deletions
diff --git a/src/rust/crypto/digests/sha2.rs b/src/rust/crypto/digests/sha2.rs
index 1cbb6c581e..62863aaa44 100644
--- a/src/rust/crypto/digests/sha2.rs
+++ b/src/rust/crypto/digests/sha2.rs
@@ -44,9 +44,9 @@ pub struct Sha256 {
/// # Examples
///
/// ```
-/// use crypto::digest::Sha256;
+/// use crypto::digests::sha2::{Sha256, Digest};
///
-/// let hasher: Sha256 = Sha256::default();
+/// let mut hasher: Sha256 = Sha256::default();
/// ```
///
/// # Returns
@@ -67,12 +67,12 @@ impl BlockInput for Sha256 {
/// # Examples
///
/// ```
-/// use crypto::digest::Sha256;
+/// use crypto::digests::sha2::{Sha256, Digest};
///
-/// let hasher: Sha256 = Sha256::default();
+/// let mut hasher: Sha256 = Sha256::default();
///
-/// hasher.process(b"foo");
-/// hasher.process(b"bar");
+/// hasher.input(b"foo");
+/// hasher.input(b"bar");
/// ```
impl Input for Sha256 {
fn process(&mut self, msg: &[u8]) {
@@ -111,9 +111,9 @@ pub struct Sha512 {
/// # Examples
///
/// ```
-/// use crypto::digest::Sha512;
+/// use crypto::digests::sha2::{Sha512, Digest};
///
-/// let hasher: Sha256 = Sha512::default();
+/// let mut hasher: Sha512 = Sha512::default();
/// ```
///
/// # Returns
@@ -134,12 +134,12 @@ impl BlockInput for Sha512 {
/// # Examples
///
/// ```
-/// use crypto::digest::Sha512;
+/// use crypto::digests::sha2::{Sha512, Digest};
///
-/// let hasher: Sha512 = Sha512::default();
+/// let mut hasher: Sha512 = Sha512::default();
///
-/// hasher.process(b"foo");
-/// hasher.process(b"bar");
+/// hasher.input(b"foo");
+/// hasher.input(b"bar");
/// ```
impl Input for Sha512 {
fn process(&mut self, msg: &[u8]) {
diff --git a/src/rust/crypto/lib.rs b/src/rust/crypto/lib.rs
index b4250dec34..d120635b95 100644
--- a/src/rust/crypto/lib.rs
+++ b/src/rust/crypto/lib.rs
@@ -10,18 +10,18 @@
//! and extendable output functions.
//!
//! ```
-//! use crypto::digests::sha256::Sha256;
+//! use crypto::digests::sha2::*;
//!
-//! let hasher: Sha256 = Sha256::default();
+//! let mut hasher: Sha256 = Sha256::default();
//! let mut result: [u8; 32] = [0u8; 32];
//!
-//! hasher.input("foo");
-//! hasher.input("bar");
-//! hasher.input("baz");
+//! hasher.input(b"foo");
+//! hasher.input(b"bar");
+//! hasher.input(b"baz");
//!
-//! result.copy_from_slice(hasher.result().as_bytes());
+//! result.copy_from_slice(hasher.result().as_slice());
//!
-//! assert!(result == "XXX");
+//! assert!(result == [b'X'; DIGEST256_LEN]);
//! ```
#[deny(missing_docs)]