summaryrefslogtreecommitdiff
path: root/lib/nes/app/application.cc
diff options
context:
space:
mode:
authorHannes Schulze <haschu0103@outlook.de>2025-02-12 23:57:32 +0100
committerHannes Schulze <haschu0103@outlook.de>2025-02-12 23:57:32 +0100
commitdd22e1ab7ab7b5bac841dae2b62bfa200b36c4d8 (patch)
tree900781940d2ed92df1d87cc7dd6209853492e07f /lib/nes/app/application.cc
parent0de4957a22dd408793d0526351bcb7d61786fe86 (diff)
add encryption/decryption
Diffstat (limited to 'lib/nes/app/application.cc')
-rw-r--r--lib/nes/app/application.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/nes/app/application.cc b/lib/nes/app/application.cc
index 09c9f34..5646fa9 100644
--- a/lib/nes/app/application.cc
+++ b/lib/nes/app/application.cc
@@ -4,6 +4,8 @@
#include "nes/app/ui/screen.hh"
#include "nes/app/graphics/renderer.hh"
#include "nes/app/action.hh"
+#include "nes/app/crypto/aes256.hh"
+#include "nes/app/crypto/sha256.hh"
namespace nes::app
{
@@ -54,6 +56,7 @@ namespace nes::app
, screen_settings_{ input_manager_, preferences_ }
, screen_error_{ keyboard }
, screen_confirm_quit_{ keyboard }
+ , screen_prompt_key_{ keyboard }
{
display_.visible_screen = &screen_title_;
}
@@ -153,6 +156,12 @@ namespace nes::app
display_.visible_screen = nullptr;
break;
}
+ case action::type::prompt_key:
+ {
+ screen_prompt_key_.reset(a.get_file_name());
+ display_.visible_popup = &screen_prompt_key_;
+ break;
+ }
case action::type::launch_game:
{
u8 buffer[sys::cartridge::max_file_size];
@@ -163,6 +172,13 @@ namespace nes::app
break;
}
+ if (!a.get_key().is_empty())
+ {
+ auto const key = span{ reinterpret_cast<u8 const*>(a.get_key().get_data()), a.get_key().get_length() };
+ auto const key_hash = sha256::hash(key);
+ aes256::decrypt(span{ buffer, length }, key_hash.get_data());
+ }
+
console_.emplace(display_, span<u8 const>{ buffer, length });
if (console_->get_status() != status::success)
{