-
Notifications
You must be signed in to change notification settings - Fork 311
FSB hash function #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FSB hash function #256
Changes from all commits
f3d81ac
65def13
80bde9c
0b98cdc
8a4dfdd
00f0698
7cbc661
9ca98ef
4823a9b
6c8418b
b917ee9
f2d6451
633d3ae
e7902d1
120eb7a
d787b9a
dddc078
f54633c
f9283fb
a9109b3
e1ba4db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| [workspace] | ||
| members = [ | ||
| "fsb", | ||
| "blake2", | ||
| "gost94", | ||
| "groestl", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /target | ||
| .idea | ||
| Cargo.lock |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| [package] | ||
| name = "fsb" | ||
| version = "0.1.0" | ||
| description = "FSB hash function" | ||
| authors = ["RustCrypto Developers"] | ||
| license = "MIT OR Apache-2.0" | ||
| readme = "README.md" | ||
| edition = "2018" | ||
| repository = "https://github.com/RustCrypto/hashes" | ||
| keywords = ["crypto", "fsb", "hash", "digest"] | ||
| categories = ["cryptography", "no-std"] | ||
|
|
||
| [dependencies] | ||
| whirlpool = { version = "0.9", path = "../whirlpool", default-features = false } | ||
| digest = "0.9" | ||
| block-buffer = { version = "0.9", features = ["block-padding"] } | ||
| opaque-debug = "0.3" | ||
|
|
||
| [dev-dependencies] | ||
| hex-literal = "0.2" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # RustCrypto: FSB | ||
|
|
||
| [![crate][crate-image]][crate-link] | ||
| [![Docs][docs-image]][docs-link] | ||
| [![Build Status][build-image]][build-link] | ||
| ![Apache2/MIT licensed][license-image] | ||
| ![Rust Version][rustc-image] | ||
| [![Project Chat][chat-image]][chat-link] | ||
|
|
||
| Pure Rust implementation of the [FSB hash function][1] family. | ||
|
|
||
| [Documentation][docs-link] | ||
|
|
||
| ## Minimum Supported Rust Version | ||
|
|
||
| Rust **1.41** or higher. | ||
|
|
||
| Minimum supported Rust version can be changed in the future, but it will be | ||
| done with a minor version bump. | ||
|
|
||
| ## SemVer Policy | ||
|
|
||
| - All on-by-default features of this library are covered by SemVer | ||
| - MSRV is considered exempt from SemVer as noted above | ||
|
|
||
| ## License | ||
|
|
||
| Licensed under either of: | ||
|
|
||
| * [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) | ||
| * [MIT license](http://opensource.org/licenses/MIT) | ||
|
|
||
| at your option. | ||
|
|
||
| ### Contribution | ||
|
|
||
| Unless you explicitly state otherwise, any contribution intentionally submitted | ||
| for inclusion in the work by you, as defined in the Apache-2.0 license, shall be | ||
| dual licensed as above, without any additional terms or conditions. | ||
|
|
||
| [//]: # (badges) | ||
|
|
||
| [crate-image]: https://img.shields.io/crates/v/fsb.svg | ||
| [crate-link]: https://crates.io/crates/fsb | ||
| [docs-image]: https://docs.rs/fsb/badge.svg | ||
| [docs-link]: https://docs.rs/fsb/ | ||
| [license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg | ||
| [chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg | ||
| [chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260041-hashes | ||
| [rustc-image]: https://img.shields.io/badge/rustc-1.41+-blue.svg | ||
| [build-image]: https://github.com/RustCrypto/hashes/workflows/fsb/badge.svg?branch=master | ||
| [build-link]: https://github.com/RustCrypto/hashes/actions?query=workflow%3Afsb | ||
|
|
||
| [//]: # (general links) | ||
|
|
||
| [1]: https://www.paris.inria.fr/secret/CBCrypto/index.php?pg=fsb |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| //! An implementation of the [FSB][1] cryptographic hash algorithms. | ||
| //! The FSB hash function was one of the submissions to SHA-3, | ||
| //! the cryptographic hash algorithm competition organized by the NIST. | ||
| //! | ||
| //! There are 5 standard versions of the FSB hash function: | ||
| //! | ||
| //! * `FSB-160` | ||
| //! * `FSB-224` | ||
| //! * `FSB-256` | ||
| //! * `FSB-384` | ||
| //! * `FSB-512` | ||
| //! | ||
| //! # Examples | ||
| //! | ||
| //! Output size of FSB-256 is fixed, so its functionality is usually | ||
| //! accessed via the `Digest` trait: | ||
| //! | ||
| //! ``` | ||
| //! use hex_literal::hex; | ||
| //! use fsb::{Digest, Fsb256}; | ||
| //! | ||
| //! // create a FSB-256 object | ||
| //! let mut hasher = Fsb256::new(); | ||
| //! | ||
| //! // write input message | ||
| //! hasher.update(b"hello"); | ||
| //! | ||
| //! // read hash digest | ||
| //! let result = hasher.finalize(); | ||
| //! | ||
| //! assert_eq!(result[..], hex!(" | ||
| //! 0f036dc3761aed2cba9de586a85976eedde6fa8f115c0190763decc02f28edbc | ||
| //! ")[..]); | ||
| //! ``` | ||
| //! Also see [RustCrypto/hashes][2] readme. | ||
| //! | ||
| //! [1]: https://www.paris.inria.fr/secret/CBCrypto/index.php?pg=fsb | ||
| //! [2]: https://github.com/RustCrypto/hashes | ||
|
|
||
| // #![no_std] | ||
| #![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" | ||
| )] | ||
| #![deny(unsafe_code)] | ||
| #![warn(missing_docs, rust_2018_idioms)] | ||
|
|
||
| #![allow(non_snake_case)] | ||
|
|
||
| #[cfg(feature = "std")] | ||
| extern crate std; | ||
|
|
||
| #[cfg(not(feature = "std"))] | ||
| extern crate alloc; | ||
| use alloc::vec; | ||
|
|
||
| #[macro_use] | ||
| mod macros; | ||
| mod pi; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. GitHub won't even let me leave comments on that module, but... wow 😮
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not my work! Copied that file from the reference implementation |
||
|
|
||
| pub use digest::{self, Digest}; | ||
| use whirlpool::Whirlpool; | ||
|
|
||
| use core::convert::TryInto; | ||
|
|
||
| use block_buffer::BlockBuffer; | ||
| use digest::{generic_array::GenericArray}; | ||
| use digest::{BlockInput, FixedOutputDirty, Reset, Update}; | ||
| use crate::pi::PI; | ||
|
|
||
| fsb_impl!(Fsb160, 160, U60, U20, 5 << 18, 80, 640, 653, 1120, "FSB-160 hash function."); | ||
| fsb_impl!(Fsb224, 224, U84, U28, 7 << 18, 112, 896, 907, 1568, "FSB-224 hash function."); | ||
| fsb_impl!(Fsb256, 256, U96, U32, 1 << 21, 128, 1024, 1061, 1792, "FSB-256 hash function."); | ||
| fsb_impl!(Fsb384, 384, U115, U48, 23 << 16, 184, 1472, 1483, 2392, "FSB-384 hash function."); | ||
| fsb_impl!(Fsb512, 512, U155, U64, 31 << 16, 248, 1984, 1987, 3224, "FSB-512 hash function."); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it truly necessary to allow dead code? It also would be nice to add crate-level docs,
no_stdand other attributes (see other crates for reference).Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
no_std, and I depend onallocnow for dynamically sized arrays. We use them here.