diff options
author | pennae <github@quasiparticle.net> | 2022-07-16 09:14:24 +0200 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-07-16 09:14:24 +0200 |
commit | b64981efd78f3ebecb327188a1ab168921c1698f (patch) | |
tree | 9aa615fa02780b76ab30206c18fdd3c3f0fc1cec /src/crypto.rs | |
parent | 062cd0ff0176f1f9924e3ae89c0eaf01a8d6fd04 (diff) | |
download | minor-skulk-b64981efd78f3ebecb327188a1ab168921c1698f.tar.gz minor-skulk-b64981efd78f3ebecb327188a1ab168921c1698f.tar.xz minor-skulk-b64981efd78f3ebecb327188a1ab168921c1698f.zip |
add test vector for password changes and account reset
these are not "official" test vectors, just an example of what the
implementation does currently. since it works with other parts of the
ecosystem (most importantly firefox itself) they seem good enough to
include.
Diffstat (limited to 'src/crypto.rs')
-rw-r--r-- | src/crypto.rs | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/crypto.rs b/src/crypto.rs index cf1044e..4b379de 100644 --- a/src/crypto.rs +++ b/src/crypto.rs @@ -283,7 +283,9 @@ mod test { use hex_literal::hex; use password_hash::{Output, SaltString}; - use crate::crypto::{KeyBundle, KeyFetchReq, SessionCredentials}; + use crate::crypto::{ + AccountResetReq, KeyBundle, KeyFetchReq, PasswordChangeReq, SessionCredentials, + }; use super::{AuthPW, SecretBytes}; @@ -405,4 +407,49 @@ mod test { ); Ok(()) } + + #[test] + fn test_password_change() { + let req = PasswordChangeReq::from_change_token(&shex!( + "0000000000000000 0000000000000000 0000000000000000 0000000000000000" + )); + assert_eq!( + req.token_id.0, + hex!("5a9f93f66c26fd1c 1ea9826fafc422e9 4b9c9f833cd2bfa5 da18c8d3317224aa") + ); + assert_eq!( + req.req_hmac_key.0, + hex!("31940008f942939a 22d7cf8ad38dc6ac 346a8148439c0d98 d4a6ae8352da4536") + ); + } + + #[test] + fn test_password_forgot() { + let req = PasswordChangeReq::from_forgot_token(&shex!( + "0000000000000000 0000000000000000 0000000000000000 0000000000000000" + )); + assert_eq!( + req.token_id.0, + hex!("570e79050fd157a9 b8e7d7d6f88a3f67 e36207c5dfabe7d8 a80994502a624e07") + ); + assert_eq!( + req.req_hmac_key.0, + hex!("fde451da23c03eec fe94e401eeef8bff 5c51742839b8058e c216214f78742d9a") + ); + } + + #[test] + fn test_account_reset() { + let req = AccountResetReq::from_token(&shex!( + "0000000000000000 0000000000000000 0000000000000000 0000000000000000" + )); + assert_eq!( + req.token_id.0, + hex!("8ade842449ab0285 e7b22de9d428cd5b 3c38ea0aa78e2956 a6a69ec66818d864") + ); + assert_eq!( + req.req_hmac_key.0, + hex!("d17d0a55c5a0451c f21efaf39f3611bc 54ebc530ceb1fe8c 9be330c1b68f989f") + ); + } } |