From 2ea777e04fb8f5d58e188332f0392b95367b169d Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 8 May 2025 16:02:52 +0800 Subject: [PATCH] fix key encoding bug; set DNA to "0" in emulation mode this matches what's done in hosted mode, allowing the analysis scripts to work on the images generated by this version --- services/keystore/src/platform/hosted.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/keystore/src/platform/hosted.rs b/services/keystore/src/platform/hosted.rs index a586fa537..428bef578 100644 --- a/services/keystore/src/platform/hosted.rs +++ b/services/keystore/src/platform/hosted.rs @@ -32,7 +32,7 @@ pub fn keystore(sid: SID) -> ! { AesOpType::Encrypt => AesOpType::Encrypt, }; let mut ikm = [0u8; 32]; - hex::encode_to_slice(WELL_KNOWN_KEY, &mut ikm).unwrap(); + ikm.copy_from_slice(&hex::decode(WELL_KNOWN_KEY).unwrap()); let hk = Hkdf::::new(None, &ikm); let mut okm = [0u8; 32]; hk.expand(&aes_op.domain.as_bytes(), &mut okm) @@ -68,7 +68,7 @@ pub fn keystore(sid: SID) -> ! { } Opcode::AesKwp => { let mut ikm = [0u8; 32]; - hex::encode_to_slice(WELL_KNOWN_KEY, &mut ikm).unwrap(); + ikm.copy_from_slice(&hex::decode(WELL_KNOWN_KEY).unwrap()); let mut buffer = unsafe { Buffer::from_memory_message_mut(msg.body.memory_message_mut().unwrap()) }; let mut kwp = buffer.to_original::().unwrap(); @@ -149,8 +149,8 @@ pub fn keystore(sid: SID) -> ! { Opcode::GetDna => { // dummy DNA value if let Some(scalar) = msg.body.scalar_message_mut() { - scalar.arg1 = 0x1234_5678; - scalar.arg2 = 0xface_cafe; + scalar.arg1 = 0; + scalar.arg2 = 0; } } Opcode::InvalidCall => {