-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Implement Eq and PartialEq for Sensitive and their inner types (
#747)"
- Loading branch information
Showing
17 changed files
with
51 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,7 @@ pub(crate) fn approve_auth_request( | |
let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; | ||
|
||
Ok(AsymmetricEncString::encrypt_rsa2048_oaep_sha1( | ||
key.to_vec(), | ||
key.to_vec().expose(), | ||
&public_key, | ||
)?) | ||
} | ||
|
@@ -107,23 +107,22 @@ pub(crate) fn approve_auth_request( | |
fn test_auth_request() { | ||
let request = new_auth_request("[email protected]").unwrap(); | ||
|
||
let secret = bitwarden_crypto::SensitiveVec::test(&[ | ||
let secret: &[u8] = &[ | ||
111, 32, 97, 169, 4, 241, 174, 74, 239, 206, 113, 86, 174, 68, 216, 238, 52, 85, 156, 27, | ||
134, 149, 54, 55, 91, 147, 45, 130, 131, 237, 51, 31, 191, 106, 155, 14, 160, 82, 47, 40, | ||
96, 31, 114, 127, 212, 187, 167, 110, 205, 116, 198, 243, 218, 72, 137, 53, 248, 43, 255, | ||
67, 35, 61, 245, 93, | ||
]); | ||
]; | ||
|
||
let private_key = SensitiveString::new(Box::new(request.private_key.clone())); | ||
let private_key = | ||
AsymmetricCryptoKey::from_der(private_key.decode_base64(STANDARD).unwrap()).unwrap(); | ||
|
||
let encrypted = | ||
AsymmetricEncString::encrypt_rsa2048_oaep_sha1(secret.clone(), &private_key).unwrap(); | ||
let encrypted = AsymmetricEncString::encrypt_rsa2048_oaep_sha1(secret, &private_key).unwrap(); | ||
|
||
let decrypted = auth_request_decrypt_user_key(request.private_key, encrypted).unwrap(); | ||
|
||
assert_eq!(decrypted.to_vec(), secret); | ||
assert_eq!(decrypted.to_vec().expose(), secret); | ||
} | ||
|
||
#[cfg(test)] | ||
|
@@ -172,12 +171,11 @@ mod tests { | |
let dec = auth_request_decrypt_user_key(private_key.to_owned(), enc_user_key).unwrap(); | ||
|
||
assert_eq!( | ||
dec.to_vec(), | ||
[ | ||
dec.to_vec().expose(), | ||
&[ | ||
201, 37, 234, 213, 21, 75, 40, 70, 149, 213, 234, 16, 19, 251, 162, 245, 161, 74, | ||
34, 245, 211, 151, 211, 192, 95, 10, 117, 50, 88, 223, 23, 157 | ||
] | ||
.as_slice() | ||
); | ||
} | ||
|
||
|
@@ -192,14 +190,13 @@ mod tests { | |
.unwrap(); | ||
|
||
assert_eq!( | ||
dec.to_vec(), | ||
[ | ||
dec.to_vec().expose(), | ||
&[ | ||
109, 128, 172, 147, 206, 123, 134, 95, 16, 36, 155, 113, 201, 18, 186, 230, 216, | ||
212, 173, 188, 74, 11, 134, 131, 137, 242, 105, 178, 105, 126, 52, 139, 248, 91, | ||
215, 21, 128, 91, 226, 222, 165, 67, 251, 34, 83, 81, 77, 147, 225, 76, 13, 41, | ||
102, 45, 183, 218, 106, 89, 254, 208, 251, 101, 130, 10, | ||
] | ||
.as_slice() | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.