11#![ no_std]
22#![ doc = include_str ! ( "../README.md" ) ]
3- #![ cfg_attr( docsrs, feature( doc_auto_cfg) ) ]
43#![ doc(
54 html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg" ,
65 html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
76) ]
7+ #![ cfg_attr( docsrs, feature( doc_auto_cfg) ) ]
88#![ warn( missing_docs, rust_2018_idioms) ]
99#![ forbid( unsafe_code) ]
1010
@@ -24,6 +24,9 @@ use digest::{
2424 HashMarker , Output ,
2525} ;
2626
27+ #[ cfg( feature = "zeroize" ) ]
28+ use digest:: zeroize:: { Zeroize , ZeroizeOnDrop } ;
29+
2730const U32_MASK : u128 = ( 1 << 32 ) - 1 ;
2831const H0 : [ u32 ; 8 ] = [
2932 0xC8BA94B1 , 0x3BF5080A , 0x8E006D36 , 0xE45D4A58 , 0x9DFA0485 , 0xACC7B61B , 0xC2722E25 , 0x0DCEFD02 ,
@@ -37,6 +40,9 @@ pub struct BeltHashCore {
3740 h : [ u32 ; 8 ] ,
3841}
3942
43+ /// BelT hasher state.
44+ pub type BeltHash = CoreWrapper < BeltHashCore > ;
45+
4046impl BeltHashCore {
4147 fn compress_block ( & mut self , block : & Block < Self > ) {
4248 let x1 = [
@@ -134,8 +140,19 @@ impl AssociatedOid for BeltHashCore {
134140 const OID : ObjectIdentifier = ObjectIdentifier :: new_unwrap ( "1.2.112.0.2.0.34.101.31.81" ) ;
135141}
136142
137- /// BelT hasher state.
138- pub type BeltHash = CoreWrapper < BeltHashCore > ;
143+ impl Drop for BeltHashCore {
144+ fn drop ( & mut self ) {
145+ #[ cfg( feature = "zeroize" ) ]
146+ {
147+ self . r . zeroize ( ) ;
148+ self . s . zeroize ( ) ;
149+ self . h . zeroize ( ) ;
150+ }
151+ }
152+ }
153+
154+ #[ cfg( feature = "zeroize" ) ]
155+ impl ZeroizeOnDrop for BeltHashCore { }
139156
140157/// Compression function described in the section 6.3.2
141158#[ inline( always) ]
0 commit comments