1- //! Pure Rust implementation of the [BelT] hash function specified in
2- //! [STB 34.101.31-2020].
3- //!
4- //! # Usage
5- //!
6- //! ```rust
7- //! use belt_hash::{BeltHash, Digest};
8- //! use hex_literal::hex;
9- //!
10- //! // create a BelT hasher instance
11- //! let mut hasher = BeltHash::new();
12- //!
13- //! // process input message
14- //! hasher.update(b"hello world");
15- //!
16- //! // acquire hash digest in the form of Array,
17- //! // which in this case is equivalent to [u8; 32]
18- //! let result = hasher.finalize();
19- //! let expected = hex!(
20- //! "afb175816416fbadad4629ecbd78e1887789881f2d2e5b80c22a746b7ac7ba88"
21- //! );
22- //! assert_eq!(result[..], expected[..]);
23- //! ```
24- //!
25- //! Also see [examples] in the RustCrypto/hashes readme.
26- //!
27- //! [BelT]: https://ru.wikipedia.org/wiki/BelT
28- //! [STB 34.101.31-2020]: http://apmi.bsu.by/assets/files/std/belt-spec371.pdf
29- //! [examples]: https://github.com/RustCrypto/hashes#usage
301#![ no_std]
2+ #![ doc = include_str ! ( "../README.md" ) ]
3+ #![ cfg_attr( docsrs, feature( doc_auto_cfg) ) ]
314#![ doc(
325 html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" ,
336 html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
@@ -52,6 +25,9 @@ use digest::{
5225} ;
5326
5427const U32_MASK : u128 = ( 1 << 32 ) - 1 ;
28+ const H0 : [ u32 ; 8 ] = [
29+ 0xC8BA94B1 , 0x3BF5080A , 0x8E006D36 , 0xE45D4A58 , 0x9DFA0485 , 0xACC7B61B , 0xC2722E25 , 0x0DCEFD02 ,
30+ ] ;
5531
5632/// Core BelT hasher state.
5733#[ derive( Clone ) ]
@@ -128,11 +104,7 @@ impl Default for BeltHashCore {
128104 Self {
129105 r : 0 ,
130106 s : [ 0 ; 4 ] ,
131- #[ rustfmt:: skip]
132- h : [
133- 0xC8BA94B1 , 0x3BF5080A , 0x8E006D36 , 0xE45D4A58 ,
134- 0x9DFA0485 , 0xACC7B61B , 0xC2722E25 , 0x0DCEFD02 ,
135- ] ,
107+ h : H0 ,
136108 }
137109 }
138110}
0 commit comments