Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3494434
D5945.id19721.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
961 B
Referenced Files
None
Subscribers
None
D5945.id19721.diff
View Options
diff --git a/services/tunnelbroker/src/server/tools.rs b/services/tunnelbroker/src/server/tools.rs
--- a/services/tunnelbroker/src/server/tools.rs
+++ b/services/tunnelbroker/src/server/tools.rs
@@ -1,4 +1,7 @@
use crate::server::GRPCStatusCodes;
+use openssl::pkey::PKey;
+use openssl::sign::Verifier;
+use openssl::{error::ErrorStack, hash::MessageDigest};
use tonic::{Code, Status};
pub fn create_tonic_status(code: GRPCStatusCodes, text: &str) -> Status {
@@ -24,3 +27,15 @@
};
Status::new(status, text)
}
+
+pub fn verify_signed_string(
+ public_key_pem: &str,
+ string_to_be_signed: &str,
+ base64_signature: &str,
+) -> Result<bool, ErrorStack> {
+ let public_key = PKey::public_key_from_pem(public_key_pem.as_bytes())?;
+ let mut verifier =
+ Verifier::new(MessageDigest::sha256(), &public_key).unwrap();
+ verifier.update(string_to_be_signed.as_bytes()).unwrap();
+ verifier.verify(&base64::decode(base64_signature).unwrap())
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 5:38 AM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678329
Default Alt Text
D5945.id19721.diff (961 B)
Attached To
Mode
D5945: [services] Tunnelbroker - Adding signed string verification function
Attached
Detach File
Event Timeline
Log In to Comment