Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3491112
D5927.id19549.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
947 B
Referenced Files
None
Subscribers
None
D5927.id19549.diff
View Options
diff --git a/services/commtest/src/tunnelbroker/new_session.rs b/services/commtest/src/tunnelbroker/new_session.rs
--- a/services/commtest/src/tunnelbroker/new_session.rs
+++ b/services/commtest/src/tunnelbroker/new_session.rs
@@ -2,6 +2,9 @@
use crate::tunnelbroker::tunnelbroker_utils::{
proto::SessionSignatureRequest, TunnelbrokerServiceClient,
};
+use openssl::hash::MessageDigest;
+use openssl::pkey::PKey;
+use openssl::sign::Signer;
use tonic::Request;
pub async fn get_string_to_sign(
@@ -16,3 +19,13 @@
let string_to_sign = response.into_inner().to_sign;
Ok(string_to_sign)
}
+
+pub fn sign_string_with_private_key(
+ keypair: &PKey<openssl::pkey::Private>,
+ string_to_be_signed: &str,
+) -> String {
+ let mut signer = Signer::new(MessageDigest::sha1(), &keypair).unwrap();
+ signer.update(string_to_be_signed.as_bytes()).unwrap();
+ let signature = signer.sign_to_vec().unwrap();
+ base64::encode(signature)
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 6:17 PM (8 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678337
Default Alt Text
D5927.id19549.diff (947 B)
Attached To
Mode
D5927: [services/commtest] Tunnelbroker - Adding of helper function for the string signing with the private key
Attached
Detach File
Event Timeline
Log In to Comment