| 1 |
#![no_std] |
| 2 |
#![doc = include_str!("../README.md")] |
| 3 |
#![doc( |
| 4 |
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg", |
| 5 |
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" |
| 6 |
)] |
| 7 |
#![cfg_attr(docsrs, feature(doc_cfg))] |
| 8 |
#![warn(missing_docs, unreachable_pub)] |
| 9 |
#![cfg_attr( |
| 10 |
any( |
| 11 |
sha2_backend = "riscv-zknh", |
| 12 |
sha2_256_backend = "riscv-zknh", |
| 13 |
sha2_256_backend = "riscv-zknh", |
| 14 |
), |
| 15 |
feature(riscv_ext_intrinsics) |
| 16 |
)] |
| 17 |
#![allow(clippy::needless_range_loop)] |
| 18 |
|
| 19 |
pub use digest::{self, Digest}; |
| 20 |
|
| 21 |
use digest::{ |
| 22 |
block_api::CtOutWrapper, |
| 23 |
consts::{U28, U32, U48, U64}, |
| 24 |
}; |
| 25 |
|
| 26 |
/// Block-level types |
| 27 |
pub mod block_api; |
| 28 |
|
| 29 |
#[rustfmt::skip] |
| 30 |
mod consts; |
| 31 |
mod sha256; |
| 32 |
mod sha512; |
| 33 |
|
| 34 |
digest::buffer_fixed!( |
| 35 |
/// SHA-256 hasher. |
| 36 |
pub struct Sha256(CtOutWrapper<block_api::Sha256VarCore, U32>); |
| 37 |
oid: "2.16.840.1.101.3.4.2.1"; |
| 38 |
impl: FixedHashTraits; |
| 39 |
); |
| 40 |
digest::buffer_fixed!( |
| 41 |
/// SHA-384 hasher. |
| 42 |
pub struct Sha384(CtOutWrapper<block_api::Sha512VarCore, U48>); |
| 43 |
oid: "2.16.840.1.101.3.4.2.2"; |
| 44 |
impl: FixedHashTraits; |
| 45 |
); |
| 46 |
digest::buffer_fixed!( |
| 47 |
/// SHA-512 hasher. |
| 48 |
pub struct Sha512(CtOutWrapper<block_api::Sha512VarCore, U64>); |
| 49 |
oid: "2.16.840.1.101.3.4.2.3"; |
| 50 |
impl: FixedHashTraits; |
| 51 |
); |
| 52 |
digest::buffer_fixed!( |
| 53 |
/// SHA-224 hasher. |
| 54 |
pub struct Sha224(CtOutWrapper<block_api::Sha256VarCore, U28>); |
| 55 |
oid: "2.16.840.1.101.3.4.2.4"; |
| 56 |
impl: FixedHashTraits; |
| 57 |
); |
| 58 |
digest::buffer_fixed!( |
| 59 |
/// SHA-512/224 hasher. |
| 60 |
pub struct Sha512_224(CtOutWrapper<block_api::Sha512VarCore, U28>); |
| 61 |
oid: "2.16.840.1.101.3.4.2.5"; |
| 62 |
impl: FixedHashTraits; |
| 63 |
); |
| 64 |
digest::buffer_fixed!( |
| 65 |
/// SHA-512/256 hasher. |
| 66 |
pub struct Sha512_256(CtOutWrapper<block_api::Sha512VarCore, U32>); |
| 67 |
oid: "2.16.840.1.101.3.4.2.6"; |
| 68 |
impl: FixedHashTraits; |
| 69 |
); |