@@ -87,16 +87,22 @@ const STEAM_CHARS: &str = "23456789BCDFGHJKMNPQRTVWXY";
8787#[ derive( Debug , Copy , Clone , Eq , PartialEq ) ]
8888#[ cfg_attr( feature = "serde_support" , derive( Serialize , Deserialize ) ) ]
8989pub enum Algorithm {
90+ /// HMAC-SHA1 is the default algorithm of most TOTP implementations.
91+ /// Some will outright ignore the algorithm parameter to force using SHA1, leading to confusion.
9092 SHA1 ,
93+ /// HMAC-SHA256. Supported in theory according to [yubico](https://docs.yubico.com/yesdk/users-manual/application-oath/uri-string-format.html).
94+ /// Ignored in practice by most.
9195 SHA256 ,
96+ /// HMAC-SHA512. Supported in theory according to [yubico](https://docs.yubico.com/yesdk/users-manual/application-oath/uri-string-format.html).
97+ /// Ignored in practice by most.
9298 SHA512 ,
9399 #[ cfg( feature = "steam" ) ]
94100 #[ cfg_attr( docsrs, doc( cfg( feature = "steam" ) ) ) ]
95- /// Steam TOTP token algorithm
101+ /// Steam TOTP token algorithm.
96102 Steam ,
97103}
98104
99- impl std :: default :: Default for Algorithm {
105+ impl Default for Algorithm {
100106 fn default ( ) -> Self {
101107 Algorithm :: SHA1
102108 }
@@ -486,7 +492,7 @@ impl TOTP {
486492 /// Will return the base32 representation of the secret, which might be useful when users want to manually add the secret to their authenticator
487493 pub fn get_secret_base32 ( & self ) -> String {
488494 base32:: encode (
489- base32:: Alphabet :: RFC4648 { padding : false } ,
495+ base32:: Alphabet :: Rfc4648 { padding : false } ,
490496 self . secret . as_ref ( ) ,
491497 )
492498 }
@@ -586,7 +592,7 @@ impl TOTP {
586592 }
587593 "secret" => {
588594 secret = base32:: decode (
589- base32:: Alphabet :: RFC4648 { padding : false } ,
595+ base32:: Alphabet :: Rfc4648 { padding : false } ,
590596 value. as_ref ( ) ,
591597 )
592598 . ok_or_else ( || TotpUrlError :: Secret ( value. to_string ( ) ) ) ?;
@@ -1056,7 +1062,7 @@ mod tests {
10561062 assert_eq ! (
10571063 totp. secret,
10581064 base32:: decode(
1059- base32:: Alphabet :: RFC4648 { padding: false } ,
1065+ base32:: Alphabet :: Rfc4648 { padding: false } ,
10601066 "KRSXG5CTMVRXEZLUKN2XAZLSKNSWG4TFOQ"
10611067 )
10621068 . unwrap( )
@@ -1074,7 +1080,7 @@ mod tests {
10741080 assert_eq ! (
10751081 totp. secret,
10761082 base32:: decode(
1077- base32:: Alphabet :: RFC4648 { padding: false } ,
1083+ base32:: Alphabet :: Rfc4648 { padding: false } ,
10781084 "KRSXG5CTMVRXEZLUKN2XAZLSKNSWG4TFOQ"
10791085 )
10801086 . unwrap( )
@@ -1092,7 +1098,7 @@ mod tests {
10921098 assert_eq ! (
10931099 totp. secret,
10941100 base32:: decode(
1095- base32:: Alphabet :: RFC4648 { padding: false } ,
1101+ base32:: Alphabet :: Rfc4648 { padding: false } ,
10961102 "KRSXG5CTMVRXEZLUKN2XAZLSKNSWG4TFOQ"
10971103 )
10981104 . unwrap( )
@@ -1127,7 +1133,7 @@ mod tests {
11271133 assert_eq ! (
11281134 totp. secret,
11291135 base32:: decode(
1130- base32:: Alphabet :: RFC4648 { padding: false } ,
1136+ base32:: Alphabet :: Rfc4648 { padding: false } ,
11311137 "KRSXG5CTMVRXEZLUKN2XAZLSKNSWG4TFOQ"
11321138 )
11331139 . unwrap( )
@@ -1201,7 +1207,7 @@ mod tests {
12011207 assert_eq ! (
12021208 totp. secret,
12031209 base32:: decode(
1204- base32:: Alphabet :: RFC4648 { padding: false } ,
1210+ base32:: Alphabet :: Rfc4648 { padding: false } ,
12051211 "KRSXG5CTMVRXEZLUKN2XAZLSKNSWG4TFOQ"
12061212 )
12071213 . unwrap( )
0 commit comments