Skip to content

Commit

Permalink
sha2: fix missing documentation on compression functions
Browse files Browse the repository at this point in the history
Adds docs, tests all features in CI, and adds doc_cfg setup for docs.rs.
  • Loading branch information
tarcieri committed May 6, 2021
1 parent c1ed4b1 commit 76e307d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/sha2.yml
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions sha2/Cargo.toml
Expand Up @@ -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"]
1 change: 1 addition & 0 deletions sha2/src/lib.rs
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions sha2/src/sha256.rs
Expand Up @@ -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<u8, U64>]) {
// SAFETY: GenericArray<u8, U64> and [u8; 64] have
// exactly the same memory layout
Expand Down
5 changes: 5 additions & 0 deletions sha2/src/sha512.rs
Expand Up @@ -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<u8, U128>]) {
// SAFETY: GenericArray<u8, U128> and [u8; 128] have
// exactly the same memory layout
Expand Down

0 comments on commit 76e307d

Please sign in to comment.