From f4b2b11c105c0e7ebc6e797a73a9e05759d350c2 Mon Sep 17 00:00:00 2001 From: Guybrush <48859004+mcamposv@users.noreply.github.com> Date: Sun, 1 Nov 2026 16:02:35 +0100 Subject: [PATCH] SE050Sim: optional object store persistence via SE050_SIM_STORE The TCP server always started with an empty store. With SE050_SIM_STORE= it uses ObjectStore::with_persistence, so a simulated chip keeps its objects (keys, counters, Authentication Objects) across restarts, like a real one. Unset, nothing changes. Co-Authored-By: Claude Opus 5.5 --- SE050Sim/se050-sim/src/bin/tcp_server.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/SE050Sim/se050-sim/src/bin/tcp_server.rs b/SE050Sim/se050-sim/src/bin/tcp_server.rs index fc50b18..5191266 100644 --- a/SE050Sim/se050-sim/src/bin/tcp_server.rs +++ b/SE050Sim/se050-sim/src/bin/tcp_server.rs @@ -120,7 +120,16 @@ fn main() { eprintln!("[se050-sim] Listening on port {}", port); - let store = Arc::new(Mutex::new(ObjectStore::new())); + // Optional persistence: with SE050_SIM_STORE=/path/store.json the object store survives + // restarts, like a real secure element keeps its objects across power cycles. + let store = match std::env::var("SE050_SIM_STORE") { + Ok(path) if !path.is_empty() => { + eprintln!("[se050-sim] Persisting objects to {}", path); + ObjectStore::with_persistence(std::path::PathBuf::from(path)) + } + _ => ObjectStore::new(), + }; + let store = Arc::new(Mutex::new(store)); for stream in listener.incoming() { match stream {