mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-12 07:48:16 -05:00
Read IW4 signed headers
This commit is contained in:
@ -2,12 +2,18 @@
|
||||
#include "Impl/AlgorithmRSA.h"
|
||||
#include "Impl/AlgorithmSHA1.h"
|
||||
#include "Impl/AlgorithmSalsa20.h"
|
||||
#include "Impl/AlgorithmSHA256.h"
|
||||
|
||||
IHashFunction* Crypto::CreateSHA1()
|
||||
{
|
||||
return new AlgorithmSHA1();
|
||||
}
|
||||
|
||||
IHashFunction* Crypto::CreateSHA256()
|
||||
{
|
||||
return new AlgorithmSHA256();
|
||||
}
|
||||
|
||||
IStreamCipher* Crypto::CreateSalsa20(const uint8_t* keyBytes, const size_t keySize)
|
||||
{
|
||||
return new AlgorithmSalsa20(keyBytes, keySize);
|
||||
|
@ -13,6 +13,7 @@ public:
|
||||
};
|
||||
|
||||
static IHashFunction* CreateSHA1();
|
||||
static IHashFunction* CreateSHA256();
|
||||
|
||||
static IStreamCipher* CreateSalsa20(const uint8_t* keyBytes, size_t keySize);
|
||||
|
||||
|
63
src/Crypto/Impl/AlgorithmSHA256.cpp
Normal file
63
src/Crypto/Impl/AlgorithmSHA256.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include "AlgorithmSHA256.h"
|
||||
|
||||
#include "CryptoLibrary.h"
|
||||
#include <cstdint>
|
||||
|
||||
class AlgorithmSHA256::Impl
|
||||
{
|
||||
hash_state m_state{};
|
||||
|
||||
public:
|
||||
Impl()
|
||||
{
|
||||
CryptoLibrary::Init();
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
sha256_init(&m_state);
|
||||
}
|
||||
|
||||
void Process(const void* input, const size_t inputSize)
|
||||
{
|
||||
sha256_process(&m_state, static_cast<const uint8_t*>(input), inputSize);
|
||||
}
|
||||
|
||||
void Finish(void* hashBuffer)
|
||||
{
|
||||
sha256_done(&m_state, static_cast<uint8_t*>(hashBuffer));
|
||||
}
|
||||
};
|
||||
|
||||
AlgorithmSHA256::AlgorithmSHA256()
|
||||
{
|
||||
m_impl = new Impl();
|
||||
}
|
||||
|
||||
AlgorithmSHA256::~AlgorithmSHA256()
|
||||
{
|
||||
delete m_impl;
|
||||
m_impl = nullptr;
|
||||
}
|
||||
|
||||
size_t AlgorithmSHA256::GetHashSize()
|
||||
{
|
||||
return HASH_SIZE;
|
||||
}
|
||||
|
||||
void AlgorithmSHA256::Init()
|
||||
{
|
||||
m_impl->Init();
|
||||
}
|
||||
|
||||
void AlgorithmSHA256::Process(const void* input, const size_t inputSize)
|
||||
{
|
||||
m_impl->Process(input, inputSize);
|
||||
}
|
||||
|
||||
void AlgorithmSHA256::Finish(void* hashBuffer)
|
||||
{
|
||||
m_impl->Finish(hashBuffer);
|
||||
}
|
20
src/Crypto/Impl/AlgorithmSHA256.h
Normal file
20
src/Crypto/Impl/AlgorithmSHA256.h
Normal file
@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "IHashFunction.h"
|
||||
|
||||
class AlgorithmSHA256 : public IHashFunction
|
||||
{
|
||||
class Impl;
|
||||
Impl* m_impl;
|
||||
|
||||
public:
|
||||
static const int HASH_SIZE = 32;
|
||||
|
||||
AlgorithmSHA256();
|
||||
~AlgorithmSHA256() override;
|
||||
|
||||
size_t GetHashSize() override;
|
||||
|
||||
void Init() override;
|
||||
void Process(const void* input, size_t inputSize) override;
|
||||
void Finish(void* hashBuffer) override;
|
||||
};
|
Reference in New Issue
Block a user