Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3488680
D5927.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
919 B
Referenced Files
None
Subscribers
None
D5927.id.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(
@@ -15,3 +18,13 @@
.await?;
Ok(response.into_inner().to_sign)
}
+
+pub fn sign_string_with_private_key(
+ keypair: &PKey<openssl::pkey::Private>,
+ string_to_be_signed: &str,
+) -> anyhow::Result<String> {
+ let mut signer = Signer::new(MessageDigest::sha256(), &keypair)?;
+ signer.update(string_to_be_signed.as_bytes())?;
+ let signature = signer.sign_to_vec()?;
+ Ok(base64::encode(signature))
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 10:59 AM (1 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2676856
Default Alt Text
D5927.id.diff (919 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