diff options
author | Isis Lovecruft <isis@torproject.org> | 2018-04-21 01:01:04 +0000 |
---|---|---|
committer | Isis Lovecruft <isis@torproject.org> | 2018-05-08 21:03:37 +0000 |
commit | af182d4ab51d6a1a70559bbdcd4ab842aa855684 (patch) | |
tree | a39ec19013bdb85e4ad9aef1dd001747446923f2 /src/rust/crypto/lib.rs | |
parent | 3df37d7b6be4f7d6ece0cd12812595d5f91ea72f (diff) | |
download | tor-af182d4ab51d6a1a70559bbdcd4ab842aa855684.tar.gz tor-af182d4ab51d6a1a70559bbdcd4ab842aa855684.zip |
rust: Add crypto crate and implement Rust wrappers for SHA2 code.
* FIXES #24659: https://bugs.torproject.org/24659
Diffstat (limited to 'src/rust/crypto/lib.rs')
-rw-r--r-- | src/rust/crypto/lib.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/rust/crypto/lib.rs b/src/rust/crypto/lib.rs new file mode 100644 index 0000000000..d0793a8575 --- /dev/null +++ b/src/rust/crypto/lib.rs @@ -0,0 +1,36 @@ +// Copyright (c) 2018, The Tor Project, Inc. +// Copyright (c) 2018, isis agora lovecruft +// See LICENSE for licensing information + +//! Common cryptographic functions and utilities. +//! +//! # Hash Digests and eXtendable Output Functions (XOFs) +//! +//! The `digests` module contains submodules for specific hash digests +//! and extendable output functions. +//! +//! ``` +//! use crypto::digests::sha256::Sha256; +//! +//! let hasher: Sha256 = Sha256::default(); +//! let mut result: [u8; 32] = [0u8; 32]; +//! +//! hasher.input("foo"); +//! hasher.input("bar"); +//! hasher.input("baz"); +//! +//! result.copy_from_slice(hasher.result().as_bytes()); +//! +//! assert!(result == "XXX"); +//! ``` + +#[deny(missing_docs)] + +// External crates from cargo or TOR_RUST_DEPENDENCIES. +extern crate digest; +extern crate libc; + +// Our local crates. +extern crate external; + +mod digests; // Unfortunately named "digests" plural to avoid name conflict with the digest crate |