summaryrefslogtreecommitdiff
path: root/lib/nes/app/crypto/sha256.hh
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/crypto/sha256.hh
parent0de4957a22dd408793d0526351bcb7d61786fe86 (diff)
add encryption/decryption
Diffstat (limited to 'lib/nes/app/crypto/sha256.hh')
-rw-r--r--lib/nes/app/crypto/sha256.hh28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/nes/app/crypto/sha256.hh b/lib/nes/app/crypto/sha256.hh
new file mode 100644
index 0000000..55ba202
--- /dev/null
+++ b/lib/nes/app/crypto/sha256.hh
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "nes/common/containers/span.hh"
+#include "nes/common/types.hh"
+
+namespace nes::app
+{
+ class sha256
+ {
+ static constexpr auto length = u32{ 256 / 8 };
+ static constexpr auto block_size = u32{ 512 / 8 };
+
+ u8 data_[length]{};
+
+ public:
+ static auto hash(span<u8 const>) -> sha256;
+
+ auto get_data() const -> span<u8 const, length> { return data_; }
+
+ private:
+ explicit sha256();
+
+ auto combine(span<u8 const, block_size>) -> void;
+
+ auto get(u32 index) -> u32;
+ auto set(u32 index, u32 value) -> void;
+ };
+} // namespace nes::app \ No newline at end of file