@@ -125,6 +125,11 @@ enum IterStateOrCorrupted {
125125
126126#[ inline]
127127pub fn hash_key ( key : & [ u8 ] , salt : & Salt , uniform : bool , db_version : u32 ) -> Key {
128+ use blake2:: {
129+ digest:: { typenum:: U32 , FixedOutput , Update } ,
130+ Blake2bMac ,
131+ } ;
132+
128133 let mut k = Key :: default ( ) ;
129134 if uniform {
130135 if db_version <= 5 {
@@ -137,7 +142,11 @@ pub fn hash_key(key: &[u8], salt: &Salt, uniform: bool, db_version: u32) -> Key
137142 }
138143 }
139144 } else {
140- k. copy_from_slice ( blake2_rfc:: blake2b:: blake2b ( 32 , salt, key) . as_bytes ( ) ) ;
145+ let mut ctx = Blake2bMac :: < U32 > :: new_with_salt_and_personal ( salt, & [ ] , & [ ] )
146+ . expect ( "Salt length (32) is a valid key length (<= 64)" ) ;
147+ ctx. update ( key) ;
148+ let hash = ctx. finalize_fixed ( ) ;
149+ k. copy_from_slice ( & hash) ;
141150 }
142151 k
143152}
@@ -684,6 +693,8 @@ impl HashColumn {
684693 start_chunk : u64 ,
685694 skip_preimage_indexes : bool ,
686695 ) -> Result < ( ) > {
696+ use blake2:: { digest:: typenum:: U32 , Blake2b , Digest } ;
697+
687698 let tables = self . tables . read ( ) ;
688699 let source = & tables. index ;
689700
@@ -702,8 +713,8 @@ impl HashColumn {
702713 } else {
703714 value
704715 } ;
705- let key = blake2_rfc :: blake2b :: blake2b ( 32 , & [ ] , & value) ;
706- let key = self . hash_key ( key. as_bytes ( ) ) ;
716+ let key = Blake2b :: < U32 > :: digest ( & value) ;
717+ let key = self . hash_key ( & key) ;
707718 let state = IterStateOrCorrupted :: Item ( IterState {
708719 chunk_index : index,
709720 key,
0 commit comments