lib.rs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2018-2019, The Tor Project, Inc.
  2. // Copyright (c) 2018, isis agora lovecruft
  3. // See LICENSE for licensing information
  4. //! Common cryptographic functions and utilities.
  5. //!
  6. //! # Hash Digests and eXtendable Output Functions (XOFs)
  7. //!
  8. //! The `digests` module contains submodules for specific hash digests
  9. //! and extendable output functions.
  10. //!
  11. //! ```rust,no_run
  12. //! use crypto::digests::sha2::*;
  13. //!
  14. //! let mut hasher: Sha256 = Sha256::default();
  15. //! let mut result: [u8; 32] = [0u8; 32];
  16. //!
  17. //! hasher.input(b"foo");
  18. //! hasher.input(b"bar");
  19. //! hasher.input(b"baz");
  20. //!
  21. //! result.copy_from_slice(hasher.result().as_slice());
  22. //!
  23. //! assert!(result == [b'X'; DIGEST256_LEN]);
  24. //! ```
  25. // XXX: add missing docs
  26. //#![deny(missing_docs)]
  27. // External crates from cargo or TOR_RUST_DEPENDENCIES.
  28. extern crate digest;
  29. extern crate libc;
  30. extern crate rand_core;
  31. // External dependencies for tests.
  32. #[cfg(test)]
  33. extern crate rand as rand_crate;
  34. // Our local crates.
  35. extern crate external;
  36. #[cfg(not(test))]
  37. #[macro_use]
  38. extern crate tor_log;
  39. pub mod digests; // Unfortunately named "digests" plural to avoid name conflict with the digest crate
  40. pub mod rand;