2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-24 08:53:04 +00:00

refactor: cryptography component

This commit is contained in:
Jan
2025-04-25 21:26:44 +01:00
committed by Jan Laupetin
parent 60f5c1a18f
commit 5635470b6e
63 changed files with 550 additions and 723 deletions

View File

@@ -17,7 +17,7 @@ class ProcessorAuthedBlocks::Impl
const size_t m_chunk_size;
const unsigned m_max_master_block_count;
const std::unique_ptr<IHashFunction> m_hash_function;
const std::unique_ptr<cryptography::IHashFunction> m_hash_function;
IHashProvider* const m_master_block_hash_provider;
const std::unique_ptr<uint8_t[]> m_chunk_hashes_buffer;
const std::unique_ptr<uint8_t[]> m_current_chunk_hash_buffer;
@@ -34,7 +34,7 @@ public:
const unsigned authedChunkCount,
const size_t chunkSize,
const unsigned maxMasterBlockCount,
std::unique_ptr<IHashFunction> hashFunction,
std::unique_ptr<cryptography::IHashFunction> hashFunction,
IHashProvider* masterBlockHashProvider)
: m_base(base),
m_authed_chunk_count(authedChunkCount),
@@ -141,7 +141,7 @@ public:
ProcessorAuthedBlocks::ProcessorAuthedBlocks(const unsigned authedChunkCount,
const size_t chunkSize,
const unsigned maxMasterBlockCount,
std::unique_ptr<IHashFunction> hashFunction,
std::unique_ptr<cryptography::IHashFunction> hashFunction,
IHashProvider* masterBlockHashProvider)
: m_impl(new Impl(this, authedChunkCount, chunkSize, maxMasterBlockCount, std::move(hashFunction), masterBlockHashProvider))
{

View File

@@ -1,5 +1,6 @@
#pragma once
#include "Crypto.h"
#include "Cryptography.h"
#include "Loading/IHashProvider.h"
#include "Loading/StreamProcessor.h"
@@ -14,7 +15,7 @@ public:
ProcessorAuthedBlocks(unsigned authedChunkCount,
size_t chunkSize,
unsigned maxMasterBlockCount,
std::unique_ptr<IHashFunction> hashFunction,
std::unique_ptr<cryptography::IHashFunction> hashFunction,
IHashProvider* masterBlockHashProvider);
~ProcessorAuthedBlocks() override;
ProcessorAuthedBlocks(const ProcessorAuthedBlocks& other) = delete;

View File

@@ -1,14 +1,8 @@
#include "ProcessorStreamCipher.h"
ProcessorStreamCipher::ProcessorStreamCipher(IStreamCipher* cipher)
ProcessorStreamCipher::ProcessorStreamCipher(std::unique_ptr<cryptography::IStreamCipher> cipher)
: m_cipher(std::move(cipher))
{
m_cipher = cipher;
}
ProcessorStreamCipher::~ProcessorStreamCipher()
{
delete m_cipher;
m_cipher = nullptr;
}
size_t ProcessorStreamCipher::Load(void* buffer, const size_t length)

View File

@@ -1,14 +1,17 @@
#pragma once
#include "Crypto.h"
#include "Cryptography.h"
#include "Loading/StreamProcessor.h"
#include <memory>
class ProcessorStreamCipher final : public StreamProcessor
{
IStreamCipher* m_cipher;
public:
explicit ProcessorStreamCipher(IStreamCipher* cipher);
~ProcessorStreamCipher() override;
explicit ProcessorStreamCipher(std::unique_ptr<cryptography::IStreamCipher> cipher);
size_t Load(void* buffer, size_t length) override;
private:
std::unique_ptr<cryptography::IStreamCipher> m_cipher;
};