Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3491094
D5945.id20234.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1012 B
Referenced Files
None
Subscribers
None
D5945.id20234.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,17 @@
};
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)?;
+ verifier.update(string_to_be_signed.as_bytes()).unwrap();
+ verifier.verify(
+ &base64::decode(base64_signature)
+ .expect("Error on decoding the signature from base64"),
+ )
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 6:17 PM (14 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2676851
Default Alt Text
D5945.id20234.diff (1012 B)
Attached To
Mode
D5945: [services] Tunnelbroker - Adding signed string verification function
Attached
Detach File
Event Timeline
Log In to Comment