@@ -6,8 +6,10 @@ extern crate std;
6
6
7
7
use core:: mem:: MaybeUninit ;
8
8
9
- use hmac:: { Hmac , Mac } ;
10
- use pbkdf2:: pbkdf2;
9
+ use pbkdf2:: {
10
+ hmac:: { Hmac , Mac as _} ,
11
+ pbkdf2_hmac,
12
+ } ;
11
13
use sha2:: { Sha256 , Sha384 , Sha512 } ;
12
14
13
15
/// Selects the hash algorithm to use in PBKDF2.
@@ -34,14 +36,16 @@ pub enum Algorithm {
34
36
bitflags:: bitflags! {
35
37
/// Flag that describes what characters are allowed when generating a
36
38
/// password.
39
+ #[ derive( Clone , Copy ) ]
40
+ #[ repr( transparent) ]
37
41
pub struct CharacterSet : u8 {
38
42
const Uppercase = 0b0001 ;
39
43
const Lowercase = 0b0010 ;
40
44
const Numbers = 0b0100 ;
41
45
const Symbols = 0b1000 ;
42
46
43
- const Letters = Self :: Uppercase . bits | Self :: Lowercase . bits;
44
- const All = Self :: Letters . bits | Self :: Numbers . bits | Self :: Symbols . bits;
47
+ const Letters = Self :: Uppercase . bits( ) | Self :: Lowercase . bits( ) ;
48
+ const All = Self :: Letters . bits( ) | Self :: Numbers . bits( ) | Self :: Symbols . bits( ) ;
45
49
}
46
50
}
47
51
@@ -229,13 +233,13 @@ pub fn generate_entropy_to(
229
233
230
234
match algorithm {
231
235
Algorithm :: SHA256 => {
232
- pbkdf2 :: < Hmac < Sha256 > > ( master_password. as_bytes ( ) , salt, iterations, output)
236
+ pbkdf2_hmac :: < Sha256 > ( master_password. as_bytes ( ) , salt, iterations, output)
233
237
}
234
238
Algorithm :: SHA384 => {
235
- pbkdf2 :: < Hmac < Sha384 > > ( master_password. as_bytes ( ) , salt, iterations, output)
239
+ pbkdf2_hmac :: < Sha384 > ( master_password. as_bytes ( ) , salt, iterations, output)
236
240
}
237
241
Algorithm :: SHA512 => {
238
- pbkdf2 :: < Hmac < Sha512 > > ( master_password. as_bytes ( ) , salt, iterations, output)
242
+ pbkdf2_hmac :: < Sha512 > ( master_password. as_bytes ( ) , salt, iterations, output)
239
243
}
240
244
}
241
245
}
0 commit comments