Skip to content

Commit a1e8900

Browse files
authored
FSB hash function (#256)
1 parent 59269ed commit a1e8900

File tree

10 files changed

+17617
-1
lines changed

10 files changed

+17617
-1
lines changed

.github/workflows/workspace.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- uses: actions/checkout@v1
1717
- uses: actions-rs/toolchain@v1
1818
with:
19-
toolchain: 1.41.0 # MSRV
19+
toolchain: 1.47.0
2020
components: clippy
2121
profile: minimal
2222
override: true

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[workspace]
22
members = [
3+
"fsb",
34
"blake2",
45
"gost94",
56
"groestl",

fsb/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
.idea
3+
Cargo.lock

fsb/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "fsb"
3+
version = "0.1.0"
4+
description = "FSB hash function"
5+
authors = ["RustCrypto Developers"]
6+
license = "MIT OR Apache-2.0"
7+
readme = "README.md"
8+
edition = "2018"
9+
repository = "https://github.com/RustCrypto/hashes"
10+
keywords = ["crypto", "fsb", "hash", "digest"]
11+
categories = ["cryptography", "no-std"]
12+
13+
[dependencies]
14+
whirlpool = { version = "0.9", path = "../whirlpool", default-features = false }
15+
digest = "0.9"
16+
block-buffer = { version = "0.9", features = ["block-padding"] }
17+
opaque-debug = "0.3"
18+
19+
[dev-dependencies]
20+
hex-literal = "0.2"

fsb/README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# RustCrypto: FSB
2+
3+
[![crate][crate-image]][crate-link]
4+
[![Docs][docs-image]][docs-link]
5+
[![Build Status][build-image]][build-link]
6+
![Apache2/MIT licensed][license-image]
7+
![Rust Version][rustc-image]
8+
[![Project Chat][chat-image]][chat-link]
9+
10+
Pure Rust implementation of the [FSB hash function][1] family.
11+
12+
[Documentation][docs-link]
13+
14+
## Minimum Supported Rust Version
15+
16+
Rust **1.41** or higher.
17+
18+
Minimum supported Rust version can be changed in the future, but it will be
19+
done with a minor version bump.
20+
21+
## SemVer Policy
22+
23+
- All on-by-default features of this library are covered by SemVer
24+
- MSRV is considered exempt from SemVer as noted above
25+
26+
## License
27+
28+
Licensed under either of:
29+
30+
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
31+
* [MIT license](http://opensource.org/licenses/MIT)
32+
33+
at your option.
34+
35+
### Contribution
36+
37+
Unless you explicitly state otherwise, any contribution intentionally submitted
38+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
39+
dual licensed as above, without any additional terms or conditions.
40+
41+
[//]: # (badges)
42+
43+
[crate-image]: https://img.shields.io/crates/v/fsb.svg
44+
[crate-link]: https://crates.io/crates/fsb
45+
[docs-image]: https://docs.rs/fsb/badge.svg
46+
[docs-link]: https://docs.rs/fsb/
47+
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
48+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg
49+
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260041-hashes
50+
[rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg
51+
[build-image]: https://github.com/RustCrypto/hashes/workflows/fsb/badge.svg?branch=master
52+
[build-link]: https://github.com/RustCrypto/hashes/actions?query=workflow%3Afsb
53+
54+
[//]: # (general links)
55+
56+
[1]: https://www.paris.inria.fr/secret/CBCrypto/index.php?pg=fsb

fsb/src/lib.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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

Comments
 (0)