Securely (or as secure as it can be) store encryption keys
This commit is contained in:
8
src-tauri/src/keys.rs
Normal file
8
src-tauri/src/keys.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
pub struct Keys;
|
||||
|
||||
impl Keys {
|
||||
pub const SERVER_RECEIVE_TRANSFER_KEY: &str = "";
|
||||
pub const SERVER_SEND_TRANSFER_KEY: &str = "";
|
||||
pub const CONFIG_ENCRYPTION_KEY: &str = "";
|
||||
pub const VERSIONS_ENCRYPTION_KEY: &str = "";
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
|
||||
mod keys;
|
||||
|
||||
use futures_util::stream::StreamExt;
|
||||
use std::{
|
||||
fs::{File, create_dir_all},
|
||||
@@ -12,6 +15,7 @@ use tauri_plugin_dialog::{DialogExt, MessageDialogKind};
|
||||
use tauri_plugin_opener::OpenerExt;
|
||||
use tokio::{io::AsyncWriteExt, task::spawn_blocking, time::timeout};
|
||||
use zip::ZipArchive;
|
||||
use keys::Keys;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
use std::{fs, os::unix::fs::PermissionsExt};
|
||||
@@ -207,6 +211,17 @@ fn download_leaderboard(app: AppHandle, content: String) {
|
||||
})
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn get_keys_config(key: i8) -> String {
|
||||
match key {
|
||||
0 => Keys::SERVER_RECEIVE_TRANSFER_KEY.to_string(),
|
||||
1 => Keys::SERVER_SEND_TRANSFER_KEY.to_string(),
|
||||
2 => Keys::CONFIG_ENCRYPTION_KEY.to_string(),
|
||||
3 => Keys::VERSIONS_ENCRYPTION_KEY.to_string(),
|
||||
_ => "".to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run() {
|
||||
#[allow(unused_variables)]
|
||||
tauri::Builder::default()
|
||||
@@ -225,7 +240,8 @@ pub fn run() {
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
download,
|
||||
launch_game,
|
||||
download_leaderboard
|
||||
download_leaderboard,
|
||||
get_keys_config
|
||||
])
|
||||
.setup(|app| {
|
||||
#[cfg(target_os = "windows")]
|
||||
|
||||
Reference in New Issue
Block a user