From 76e307d5606dc014033e00cef518d055aa647eac Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Thu, 6 May 2021 11:17:51 -0700 Subject: [PATCH] sha2: fix missing documentation on compression functions Adds docs, tests all features in CI, and adds doc_cfg setup for docs.rs. --- .github/workflows/sha2.yml | 1 + sha2/Cargo.toml | 3 +++ sha2/src/lib.rs | 1 + sha2/src/sha256.rs | 5 +++++ sha2/src/sha512.rs | 5 +++++ 5 files changed, 15 insertions(+) diff --git a/.github/workflows/sha2.yml b/.github/workflows/sha2.yml index bff23615..75ae8d9a 100644 --- a/.github/workflows/sha2.yml +++ b/.github/workflows/sha2.yml @@ -70,6 +70,7 @@ jobs: - run: cargo test --target ${{ matrix.target }} --release --no-default-features - run: cargo test --target ${{ matrix.target }} --release - run: cargo test --target ${{ matrix.target }} --release --features asm + - run: cargo test --target ${{ matrix.target }} --release --all-features # macOS tests macos: diff --git a/sha2/Cargo.toml b/sha2/Cargo.toml index 46bddad2..42cf40b1 100644 --- a/sha2/Cargo.toml +++ b/sha2/Cargo.toml @@ -39,3 +39,6 @@ compress = [] # Expose compress function force-soft = [] # Force software implementation asm-aarch64 = ["asm"] # DEPRECATED: use `asm` instead +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] diff --git a/sha2/src/lib.rs b/sha2/src/lib.rs index 326211e1..2b5b86ed 100644 --- a/sha2/src/lib.rs +++ b/sha2/src/lib.rs @@ -53,6 +53,7 @@ //! [2]: https://github.com/RustCrypto/hashes #![no_std] +#![cfg_attr(docsrs, feature(doc_cfg))] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg", html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg" diff --git a/sha2/src/sha256.rs b/sha2/src/sha256.rs index fcb959d9..1f089a89 100644 --- a/sha2/src/sha256.rs +++ b/sha2/src/sha256.rs @@ -163,6 +163,11 @@ cfg_if::cfg_if! { } } +/// Raw SHA-256 compression function. +/// +/// This is a low-level "hazmat" API which provides direct access to the core +/// functionality of SHA-256. +#[cfg_attr(docsrs, doc(cfg(feature = "compress")))] pub fn compress256(state: &mut [u32; 8], blocks: &[GenericArray]) { // SAFETY: GenericArray and [u8; 64] have // exactly the same memory layout diff --git a/sha2/src/sha512.rs b/sha2/src/sha512.rs index 27c429f2..02439fd6 100644 --- a/sha2/src/sha512.rs +++ b/sha2/src/sha512.rs @@ -241,6 +241,11 @@ cfg_if::cfg_if! { } } +/// Raw SHA-512 compression function. +/// +/// This is a low-level "hazmat" API which provides direct access to the core +/// functionality of SHA-512. +#[cfg_attr(docsrs, doc(cfg(feature = "compress")))] pub fn compress512(state: &mut [u64; 8], blocks: &[GenericArray]) { // SAFETY: GenericArray and [u8; 128] have // exactly the same memory layout