@@ -179,24 +179,25 @@ pub fn yescrypt_kdf(passwd: &[u8], salt: &[u8], params: &Params, out: &mut [u8])
179179 && params. n / ( params. p as u64 ) * ( params. r as u64 ) >= 0x20000
180180 {
181181 let mut prehash_params = * params;
182- prehash_params. flags |= Flags :: PREHASH ;
183182 prehash_params. n >>= 6 ;
184183 prehash_params. t = 0 ;
185-
186- yescrypt_kdf_body ( passwd, salt, & prehash_params, & mut dk) ?;
184+ yescrypt_kdf_body ( passwd, salt, & prehash_params, true , & mut dk) ?;
187185
188186 // Use derived key as the "password" for the subsequent step
189187 passwd = & dk;
190188 }
191189
192- yescrypt_kdf_body ( passwd, salt, params, out)
190+ yescrypt_kdf_body ( passwd, salt, params, false , out)
193191}
194192
195193/// Compute yescrypt and write the result into `out`.
196- ///
197- /// - `flags` may request special modes.
198- /// - `t` controls computation time while not affecting peak memory usage.
199- fn yescrypt_kdf_body ( passwd : & [ u8 ] , salt : & [ u8 ] , params : & Params , out : & mut [ u8 ] ) -> Result < ( ) > {
194+ fn yescrypt_kdf_body (
195+ passwd : & [ u8 ] ,
196+ salt : & [ u8 ] ,
197+ params : & Params ,
198+ prehash : bool ,
199+ out : & mut [ u8 ] ,
200+ ) -> Result < ( ) > {
200201 let flags: Flags = params. flags ;
201202 let n: u64 = params. n ;
202203 let r: u32 = params. r ;
@@ -220,10 +221,10 @@ fn yescrypt_kdf_body(passwd: &[u8], salt: &[u8], params: &Params, out: &mut [u8]
220221 let mut sha256 = [ 0u8 ; 32 ] ;
221222 if !flags. is_empty ( ) {
222223 sha256 = util:: hmac_sha256 (
223- if flags . has_prehash ( ) {
224- & b"yescrypt-prehash" [ .. ]
224+ if prehash {
225+ b"yescrypt-prehash"
225226 } else {
226- & b"yescrypt" [ .. ]
227+ b"yescrypt"
227228 } ,
228229 passwd,
229230 ) ;
@@ -272,7 +273,7 @@ fn yescrypt_kdf_body(passwd: &[u8], salt: &[u8], params: &Params, out: &mut [u8]
272273 // SCRAM (RFC 5802), so that an extension of SCRAM (with the steps so
273274 // far in place of SCRAM's use of PBKDF2 and with SHA-256 in place of
274275 // SCRAM's use of SHA-1) would be usable with yescrypt hashes.
275- if !flags. is_empty ( ) && !flags . has_prehash ( ) {
276+ if !flags. is_empty ( ) && !prehash {
276277 let dkp = if !flags. is_empty ( ) && out. len ( ) < 32 {
277278 & mut dk
278279 } else {
0 commit comments