feat: seperate keyfiles per agent
This commit is contained in:
@@ -13,7 +13,7 @@ pub struct Agent {
|
||||
unsafe impl Send for Agent {}
|
||||
|
||||
impl Agent {
|
||||
pub(crate) unsafe fn new(path: &Path) -> Result<Self> {
|
||||
pub(crate) unsafe fn new(agent_path: &Path, keyfile_path: &Path) -> Result<Self> {
|
||||
let data_fd = get_shared_mem_fd();
|
||||
let sync_fd = memfd_create("sync\x00".as_ptr() as *const c_char, 0);
|
||||
|
||||
@@ -46,10 +46,10 @@ impl Agent {
|
||||
if child == 0 {
|
||||
// child
|
||||
|
||||
let path = CString::new(path.as_os_str().as_encoded_bytes()).unwrap();
|
||||
let path = CString::new(agent_path.as_os_str().as_encoded_bytes()).unwrap();
|
||||
let data_fd = CString::new(data_fd.to_string()).unwrap();
|
||||
let sync_fd = CString::new(sync_fd.to_string()).unwrap();
|
||||
let keyfile = CString::new(std::env::var("KEY_FILE").expect("KEY_FILE environment variable missing")).unwrap();
|
||||
let keyfile = CString::new(keyfile_path.as_os_str().as_encoded_bytes()).unwrap();
|
||||
let args = [data_fd.as_ptr(), sync_fd.as_ptr(), keyfile.as_ptr(), ptr::null()];
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ use std::{
|
||||
|
||||
static MLKEMAGENT: LazyLock<Mutex<Agent>> = LazyLock::new(|| {
|
||||
let agent_path = std::env::var("MLKEM_AGENT_PATH").expect("MLKEM_AGENT_PATH environment variable missing");
|
||||
let agent = unsafe { Agent::new(Path::new(&agent_path)).expect("Agent failed to start") };
|
||||
let keyfile_path = std::env::var("MLKEM_KEYFILE").expect("MLKEM_KEYFILE environment variable missing");
|
||||
let agent = unsafe { Agent::new(Path::new(&agent_path), Path::new(&keyfile_path)).expect("Agent failed to start") };
|
||||
Mutex::new(agent)
|
||||
});
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ use std::{
|
||||
|
||||
static X25519AGENT: LazyLock<Mutex<Agent>> = LazyLock::new(|| {
|
||||
let agent_path = std::env::var("X25519_AGENT_PATH").expect("X25519_AGENT_PATH environment variable missing");
|
||||
let agent = unsafe { Agent::new(Path::new(&agent_path)).expect("Agent failed to start") };
|
||||
let keyfile_path = std::env::var("X25519_KEYFILE").expect("X25519_KEYFILE environment variable missing");
|
||||
let agent = unsafe { Agent::new(Path::new(&agent_path), Path::new(&keyfile_path)).expect("Agent failed to start") };
|
||||
Mutex::new(agent)
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user