Move away from openssl
This commit is contained in:
2 files changed
+26
-17
No files matched your search
@@ -31,12 +31,13 @@ tauri-plugin-notification = "2.3.3"
|
|||||||
sha2 = "0.11.0"
|
sha2 = "0.11.0"
|
||||||
tauri-plugin-clipboard-manager = "2.3.2"
|
tauri-plugin-clipboard-manager = "2.3.2"
|
||||||
tauri-plugin-prevent-default = "5.0.0"
|
tauri-plugin-prevent-default = "5.0.0"
|
||||||
openssl = { version = "0.10.78", features = ["vendored"] }
|
|
||||||
base64 = "0.22.1"
|
base64 = "0.22.1"
|
||||||
tauri-plugin-http = "2.5.8"
|
tauri-plugin-http = "2.5.8"
|
||||||
dashmap = "6.1.0"
|
dashmap = "6.1.0"
|
||||||
tauri-plugin-store = "2.4.2"
|
tauri-plugin-store = "2.4.2"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
ed25519-dalek = { version = "2.2.0", features = ["pkcs8"] }
|
||||||
|
pem = "3.0.6"
|
||||||
|
|
||||||
[target.'cfg(any(target_os = "windows", target_os = "linux"))'.dependencies]
|
[target.'cfg(any(target_os = "windows", target_os = "linux"))'.dependencies]
|
||||||
sysinfo = "0.38.4"
|
sysinfo = "0.38.4"
|
||||||
|
|||||||
+24
-16
@@ -1,8 +1,9 @@
|
|||||||
use base64::{Engine as _, engine::general_purpose};
|
use base64::Engine;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
|
use ed25519_dalek::pkcs8::DecodePublicKey;
|
||||||
|
use ed25519_dalek::{Signature, Verifier, VerifyingKey};
|
||||||
use futures_util::stream::StreamExt;
|
use futures_util::stream::StreamExt;
|
||||||
use openssl::pkey::PKey;
|
use pem::parse;
|
||||||
use openssl::sign::Verifier;
|
|
||||||
use sha2::{Digest, Sha512};
|
use sha2::{Digest, Sha512};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -509,24 +510,31 @@ fn launch_game(
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn verify_signature(body: String, signature: String, public_key: String) -> bool {
|
fn verify_signature(body: String, signature: String, public_key: String) -> bool {
|
||||||
let Ok(pem) = general_purpose::STANDARD.decode(public_key) else {
|
let Ok(pubkey_pem_bytes) = base64::engine::general_purpose::STANDARD.decode(public_key) else {
|
||||||
return false;
|
|
||||||
};
|
|
||||||
let Ok(pubkey) = PKey::public_key_from_pem(&pem) else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
let Ok(sig) = general_purpose::STANDARD.decode(signature) else {
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut verifier = match Verifier::new_without_digest(&pubkey) {
|
let Ok(sig_bytes) = base64::engine::general_purpose::STANDARD.decode(signature) else {
|
||||||
Ok(v) => v,
|
return false;
|
||||||
Err(_) => return false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
verifier
|
let Ok(pubkey_pem) = String::from_utf8(pubkey_pem_bytes) else {
|
||||||
.verify_oneshot(&sig, body.as_bytes())
|
return false;
|
||||||
.unwrap_or(false)
|
};
|
||||||
|
|
||||||
|
let Ok(parsed) = parse(pubkey_pem) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
let Ok(pubkey) = VerifyingKey::from_public_key_der(&parsed.contents()) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
let Ok(sig) = Signature::from_slice(&sig_bytes) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
pubkey.verify(body.as_bytes(), &sig).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
Reference in new issue
Block a user