diff --git a/src/oath/cbindings.rs b/src/oath/cbindings.rs index bf533fe..d63b1b6 100644 --- a/src/oath/cbindings.rs +++ b/src/oath/cbindings.rs @@ -9,22 +9,22 @@ use std::ffi::CStr; use std::time::SystemTime; macro_rules! otp_init { - ($cfg_type: ty, $cfg: ident, $($field: ident, $value: expr), *) => { - if $cfg.is_null() { - Err(ErrorCode::NullPtr) - } else { - let c: &mut $cfg_type = deref_ptr_mut!($cfg, ErrorCode::NullPtr); - c.key = std::ptr::null(); - c.key_len = 0; - c.output_len = crate::oath::DEFAULT_OTP_OUT_LEN; - c.output_base = std::ptr::null(); - c.hash_function = crate::oath::DEFAULT_OTP_HASH; - $( - c.$field = $value; - )* - Ok(c) - } - } + ($cfg_type: ty, $cfg: ident, $($field: ident, $value: expr), *) => { + if $cfg.is_null() { + Err(ErrorCode::NullPtr) + } else { + let c: &mut $cfg_type = deref_ptr_mut!($cfg, ErrorCode::NullPtr); + c.key = std::ptr::null(); + c.key_len = 0; + c.output_len = crate::oath::DEFAULT_OTP_OUT_LEN; + c.output_base = std::ptr::null(); + c.hash_function = crate::oath::DEFAULT_OTP_HASH; + $( + c.$field = $value; + )* + Ok(c) + } + } } /// [C binding] HOTP configuration storage diff --git a/src/oath/hotp.rs b/src/oath/hotp.rs index c407f54..8b9e414 100644 --- a/src/oath/hotp.rs +++ b/src/oath/hotp.rs @@ -1334,9 +1334,9 @@ mod tests { .finalize(); assert_eq!( - uri, - "otpauth://hotp/Provider%201:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider+1&counter=0" - ); + uri, + "otpauth://hotp/Provider%201:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider+1&counter=0" + ); } #[test] @@ -1356,9 +1356,9 @@ mod tests { .finalize(); assert_eq!( - uri, - "otpauth://hotp/Provider%201:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&counter=0" - ); + uri, + "otpauth://hotp/Provider%201:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&counter=0" + ); } #[test] @@ -1373,9 +1373,9 @@ mod tests { .finalize(); assert_eq!( - uri, - "otpauth://hotp/Provider1Label?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1&counter=0" - ); + uri, + "otpauth://hotp/Provider1Label?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1&counter=0" + ); } #[test] @@ -1392,8 +1392,8 @@ mod tests { assert_eq!(uri.len(), 141); assert!(uri.starts_with( - "otpauth://hotp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1&counter=0&" - )); + "otpauth://hotp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1&counter=0&" + )); assert!(uri.contains("&foo=bar+baz")); assert!(uri.contains("&foo+2=%C3%A8_%C3%A9")); } diff --git a/src/oath/totp.rs b/src/oath/totp.rs index a7685e1..306a8de 100644 --- a/src/oath/totp.rs +++ b/src/oath/totp.rs @@ -889,9 +889,9 @@ mod tests { .finalize(); assert_eq!( - uri, - "otpauth://totp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1" - ); + uri, + "otpauth://totp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1" + ); } #[test] @@ -905,9 +905,9 @@ mod tests { .finalize(); assert_eq!( - uri, - "otpauth://totp/%C3%B6_%C3%88%20%E2%80%A6:D%C3%ABrp+toto@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=%C3%B6_%C3%88+%E2%80%A6" - ); + uri, + "otpauth://totp/%C3%B6_%C3%88%20%E2%80%A6:D%C3%ABrp+toto@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=%C3%B6_%C3%88+%E2%80%A6" + ); } #[test] @@ -922,9 +922,9 @@ mod tests { .finalize(); assert_eq!( - uri, - "otpauth://totp/Provider1Label?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1" - ); + uri, + "otpauth://totp/Provider1Label?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1" + ); } #[test] @@ -939,9 +939,9 @@ mod tests { .finalize(); assert_eq!( - uri, - "otpauth://totp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1&foo=bar+baz" - ); + uri, + "otpauth://totp/Provider1:alice@example.com?secret=GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ&issuer=Provider1&foo=bar+baz" + ); } #[test]