diff --git a/Cargo.lock b/Cargo.lock index ee79919d0..e2f7fec8d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -139,6 +139,15 @@ version = "0.1.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11a8c0210fa48ba3ea04ac1e9c6e72ae66009db3b1f1745635d4ff2e58eaadd0" +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + [[package]] name = "critical-section" version = "1.2.0" @@ -213,6 +222,7 @@ dependencies = [ "block-buffer", "const-oid", "crypto-common", + "sha2", "subtle", "zeroize", ] @@ -640,6 +650,17 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.11.0-rc.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c5f3b1e2dc8aad28310d8410bd4d7e180eca65fca176c52ab00d364475d0024" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + [[package]] name = "signature" version = "3.0.0-rc.10" diff --git a/Cargo.toml b/Cargo.toml index 960d86e17..79c85b5b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ cast_possible_wrap = "warn" cast_precision_loss = "warn" cast_sign_loss = "warn" checked_conversions = "warn" -doc_markdown = "warn" from_iter_instead_of_collect = "warn" implicit_saturating_sub = "warn" manual_assert = "warn" diff --git a/cipher/README.md b/cipher/README.md index 310b0b3b6..d8b21522a 100644 --- a/cipher/README.md +++ b/cipher/README.md @@ -7,10 +7,10 @@ [![Project Chat][chat-image]][chat-link] [![Build Status][build-image]][build-link] -Traits which define the functionality of [block ciphers] and [stream ciphers]. +Traits which define the functionality of [block ciphers], [block modes] and [stream ciphers]. -See [RustCrypto/block-ciphers] and [RustCrypto/stream-ciphers] for algorithm -implementations which use these traits. +See [RustCrypto/block-ciphers] and [RustCrypto/stream-ciphers] for algorithm implementations which +use these traits. ## SemVer Policy @@ -48,6 +48,7 @@ dual licensed as above, without any additional terms or conditions. [//]: # (general links) [block ciphers]: https://en.wikipedia.org/wiki/Block_cipher +[block modes]: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation [stream ciphers]: https://en.wikipedia.org/wiki/Stream_cipher [RustCrypto/block-ciphers]: https://github.com/RustCrypto/block-ciphers [RustCrypto/stream-ciphers]: https://github.com/RustCrypto/stream-ciphers diff --git a/cipher/src/lib.rs b/cipher/src/lib.rs index 7621062bd..2146eeec2 100644 --- a/cipher/src/lib.rs +++ b/cipher/src/lib.rs @@ -1,12 +1,6 @@ -//! This crate defines a set of traits which describe the functionality of -//! [block ciphers][1], [block modes][2], and [stream ciphers][3]. -//! -//! [1]: https://en.wikipedia.org/wiki/Block_cipher -//! [2]: https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation -//! [3]: https://en.wikipedia.org/wiki/Stream_cipher - #![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" diff --git a/crypto-common/src/lib.rs b/crypto-common/src/lib.rs index 2ee4fe5b2..f3e1b58f7 100644 --- a/crypto-common/src/lib.rs +++ b/crypto-common/src/lib.rs @@ -1,13 +1,11 @@ -//! Common cryptographic traits. - #![no_std] #![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" )] #![forbid(unsafe_code)] -#![warn(missing_docs, rust_2018_idioms, missing_debug_implementations)] /// Hazardous materials. pub mod hazmat; diff --git a/digest/Cargo.toml b/digest/Cargo.toml index 0fde96241..30e0165f7 100644 --- a/digest/Cargo.toml +++ b/digest/Cargo.toml @@ -22,6 +22,9 @@ blobby = { version = "0.4", optional = true } const-oid = { version = "0.10", optional = true } zeroize = { version = "1.7", optional = true, default-features = false } +[dev-dependencies] +sha2 = "0.11.0-rc.5" + [features] default = ["block-api"] block-api = ["block-buffer"] # Enable block API traits diff --git a/digest/README.md b/digest/README.md index e17da08b0..584f95bf4 100644 --- a/digest/README.md +++ b/digest/README.md @@ -39,7 +39,7 @@ hasher.update(data); hasher.update("String data"); // Note that calling `finalize()` consumes hasher let hash = hasher.finalize(); -println!("Result: {:x}", hash); +println!("Result: {:?}", hash); ``` In this example `hash` has type [`Array`][2], which is a generic @@ -49,19 +49,23 @@ Alternatively you can use chained approach, which is equivalent to the previous example: ```rust +use sha2::{Sha256, Digest}; + let hash = Sha256::new() .chain_update(b"Hello world!") .chain_update("String data") .finalize(); -println!("Result: {:x}", hash); +println!("Result: {:?}", hash); ``` If the whole message is available you also can use convenience `digest` method: ```rust +use sha2::{Sha256, Digest}; + let hash = Sha256::digest(b"my message"); -println!("Result: {:x}", hash); +println!("Result: {:?}", hash); ``` ### Generic code diff --git a/digest/src/lib.rs b/digest/src/lib.rs index 1cb025341..0e2e64250 100644 --- a/digest/src/lib.rs +++ b/digest/src/lib.rs @@ -1,7 +1,16 @@ -//! This crate provides traits which describe functionality of cryptographic hash -//! functions and Message Authentication algorithms. +#![no_std] +#![cfg_attr(docsrs, feature(doc_cfg))] +#![doc = include_str!("../README.md")] +#![forbid(unsafe_code)] +#![doc( + html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" +)] +#![warn(missing_docs, rust_2018_idioms, missing_debug_implementations)] + +//! ## Structure //! -//! Traits in this repository are organized into the following levels: +//! Traits in this crate are organized into the following levels: //! //! - **High-level convenience traits**: [`Digest`], [`DynDigest`], [`Mac`]. //! Wrappers around lower-level traits for most common use-cases. Users should @@ -24,15 +33,6 @@ //! //! [`digest-io`]: https://docs.rs/digest-io -#![no_std] -#![cfg_attr(docsrs, feature(doc_cfg))] -#![forbid(unsafe_code)] -#![doc( - html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", - html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" -)] -#![warn(missing_docs, rust_2018_idioms, missing_debug_implementations)] - #[cfg(feature = "alloc")] #[macro_use] extern crate alloc; diff --git a/signature/src/lib.rs b/signature/src/lib.rs index cc916868b..e0a7b3453 100644 --- a/signature/src/lib.rs +++ b/signature/src/lib.rs @@ -1,10 +1,10 @@ #![no_std] +#![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/8f1a9894/logo.svg" )] -#![cfg_attr(docsrs, feature(doc_cfg))] #![forbid(unsafe_code)] #![allow(async_fn_in_trait)] #![warn(