|
| 1 | +//! An implementation of the [FSB][1] cryptographic hash algorithms. |
| 2 | +//! The FSB hash function was one of the submissions to SHA-3, |
| 3 | +//! the cryptographic hash algorithm competition organized by the NIST. |
| 4 | +//! |
| 5 | +//! There are 5 standard versions of the FSB hash function: |
| 6 | +//! |
| 7 | +//! * `FSB-160` |
| 8 | +//! * `FSB-224` |
| 9 | +//! * `FSB-256` |
| 10 | +//! * `FSB-384` |
| 11 | +//! * `FSB-512` |
| 12 | +//! |
| 13 | +//! # Examples |
| 14 | +//! |
| 15 | +//! Output size of FSB-256 is fixed, so its functionality is usually |
| 16 | +//! accessed via the `Digest` trait: |
| 17 | +//! |
| 18 | +//! ``` |
| 19 | +//! use hex_literal::hex; |
| 20 | +//! use fsb::{Digest, Fsb256}; |
| 21 | +//! |
| 22 | +//! // create a FSB-256 object |
| 23 | +//! let mut hasher = Fsb256::new(); |
| 24 | +//! |
| 25 | +//! // write input message |
| 26 | +//! hasher.update(b"hello"); |
| 27 | +//! |
| 28 | +//! // read hash digest |
| 29 | +//! let result = hasher.finalize(); |
| 30 | +//! |
| 31 | +//! assert_eq!(result[..], hex!(" |
| 32 | +//! 0f036dc3761aed2cba9de586a85976eedde6fa8f115c0190763decc02f28edbc |
| 33 | +//! ")[..]); |
| 34 | +//! ``` |
| 35 | +//! Also see [RustCrypto/hashes][2] readme. |
| 36 | +//! |
| 37 | +//! [1]: https://www.paris.inria.fr/secret/CBCrypto/index.php?pg=fsb |
| 38 | +//! [2]: https://github.com/RustCrypto/hashes |
| 39 | +
|
| 40 | +// #![no_std] |
| 41 | +#![doc( |
| 42 | + html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg", |
| 43 | + html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg" |
| 44 | +)] |
| 45 | +#![deny(unsafe_code)] |
| 46 | +#![warn(missing_docs, rust_2018_idioms)] |
| 47 | + |
| 48 | +#![allow(non_snake_case)] |
| 49 | + |
| 50 | +#[cfg(feature = "std")] |
| 51 | +extern crate std; |
| 52 | + |
| 53 | +#[cfg(not(feature = "std"))] |
| 54 | +extern crate alloc; |
| 55 | +use alloc::vec; |
| 56 | + |
| 57 | +#[macro_use] |
| 58 | +mod macros; |
| 59 | +mod pi; |
| 60 | + |
| 61 | +pub use digest::{self, Digest}; |
| 62 | +use whirlpool::Whirlpool; |
| 63 | + |
| 64 | +use core::convert::TryInto; |
| 65 | + |
| 66 | +use block_buffer::BlockBuffer; |
| 67 | +use digest::{generic_array::GenericArray}; |
| 68 | +use digest::{BlockInput, FixedOutputDirty, Reset, Update}; |
| 69 | +use crate::pi::PI; |
| 70 | + |
| 71 | +fsb_impl!(Fsb160, 160, U60, U20, 5 << 18, 80, 640, 653, 1120, "FSB-160 hash function."); |
| 72 | +fsb_impl!(Fsb224, 224, U84, U28, 7 << 18, 112, 896, 907, 1568, "FSB-224 hash function."); |
| 73 | +fsb_impl!(Fsb256, 256, U96, U32, 1 << 21, 128, 1024, 1061, 1792, "FSB-256 hash function."); |
| 74 | +fsb_impl!(Fsb384, 384, U115, U48, 23 << 16, 184, 1472, 1483, 2392, "FSB-384 hash function."); |
| 75 | +fsb_impl!(Fsb512, 512, U155, U64, 31 << 16, 248, 1984, 1987, 3224, "FSB-512 hash function."); |
0 commit comments