From 999cb320ede55be906a5f5aaa22a47b43eafb945 Mon Sep 17 00:00:00 2001 From: bunnie Date: Sun, 7 Apr 2024 14:28:31 +0800 Subject: [PATCH] add a function to nab the decrypt buffer HIGHLY unsafe, but saves us a decryption operation as we interleave between the various states of the loader. --- loader/src/platform/cramium/swap.rs | 5 +++++ loader/src/platform/precursor/swap.rs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/loader/src/platform/cramium/swap.rs b/loader/src/platform/cramium/swap.rs index 8f72bc01b..bb0a79a70 100644 --- a/loader/src/platform/cramium/swap.rs +++ b/loader/src/platform/cramium/swap.rs @@ -269,4 +269,9 @@ impl SwapHal { Err(e) => panic!("Decryption error in swap: {:?}", e), } } + + /// Grabs a slice of the internal buffer. Useful for re-using the decrypted page + /// between elements of the bootloader (saving us from redundant decrypt ops), + /// but extremely unsafe because we have to track the use of this buffer manually. + pub unsafe fn get_decrypt(&self) -> &[u8] { &self.buf.data } } diff --git a/loader/src/platform/precursor/swap.rs b/loader/src/platform/precursor/swap.rs index e5252fbc5..82a5de6e9 100644 --- a/loader/src/platform/precursor/swap.rs +++ b/loader/src/platform/precursor/swap.rs @@ -71,4 +71,9 @@ impl SwapHal { Err(e) => panic!("Decryption error in swap: {:?}", e), } } + + /// Grabs a slice of the internal buffer. Useful for re-using the decrypted page + /// between elements of the bootloader (saving us from redundant decrypt ops), + /// but extremely unsafe because we have to track the use of this buffer manually. + pub unsafe fn get_decrypt(&self) -> &[u8] { &self.buf.data } }