Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3488666
D6089.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6089.id.diff
View Options
diff --git a/native/native_rust_library/src/crypto_tools.rs b/native/native_rust_library/src/crypto_tools.rs
--- a/native/native_rust_library/src/crypto_tools.rs
+++ b/native/native_rust_library/src/crypto_tools.rs
@@ -1,11 +1,5 @@
use crate::ffi::DeviceType;
-use openssl::hash::MessageDigest;
-use openssl::pkey::PKey;
-use openssl::sign::Signer;
use rand::distributions::{Alphanumeric, DistString};
-
-#[cfg(test)]
-use openssl::{rsa::Rsa, sign::Verifier};
#[cfg(test)]
use regex::Regex;
@@ -39,16 +33,6 @@
Ok(format!("{}:{}", &prefix, &suffix))
}
-pub fn sign_string_with_private_key(
- private_key: &PKey<openssl::pkey::Private>,
- nonce: &str,
-) -> anyhow::Result<String> {
- let mut signer = Signer::new(MessageDigest::sha256(), &private_key)?;
- signer.update(nonce.as_bytes())?;
- let signature = signer.sign_to_vec()?;
- Ok(base64::encode(signature))
-}
-
#[cfg(test)]
mod tests {
use super::*;
@@ -95,29 +79,4 @@
);
}
}
-
- #[test]
- fn verify_signed_string_with_private_key() {
- const NONCE: &str = "Test1ghTCoNquWbO2ST7G1c9";
-
- // Generate a keypair
- let keypair = Rsa::generate(1024).expect("Failed to generate RSA keypair");
- let keypair = PKey::from_rsa(keypair).expect("Failed to get key from rsa");
-
- // Sign the string to be signed with the private key
- let string_signature_base64 = sign_string_with_private_key(&keypair, NONCE)
- .expect("Error on calling the string signer function");
-
- // Verify signature
- let mut verifier =
- Verifier::new(MessageDigest::sha256(), &keypair).unwrap();
- verifier.update(NONCE.as_bytes()).unwrap();
-
- assert!(verifier
- .verify(
- &base64::decode(string_signature_base64)
- .expect("Failed to decode base64"),
- )
- .expect("Error on calling OpenSSL string verifier"));
- }
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 10:59 AM (9 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2676842
Default Alt Text
D6089.id.diff (1 KB)
Attached To
Mode
D6089: [native] Reverting D5999 and D6000
Attached
Detach File
Event Timeline
Log In to Comment