mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-12 07:48:16 -05:00
Reformat code with clang format
This commit is contained in:
@ -1,8 +1,9 @@
|
||||
#include "Crypto.h"
|
||||
|
||||
#include "Impl/AlgorithmRSA.h"
|
||||
#include "Impl/AlgorithmSHA1.h"
|
||||
#include "Impl/AlgorithmSalsa20.h"
|
||||
#include "Impl/AlgorithmSHA256.h"
|
||||
#include "Impl/AlgorithmSalsa20.h"
|
||||
|
||||
std::unique_ptr<IHashFunction> Crypto::CreateSHA1()
|
||||
{
|
||||
@ -22,4 +23,4 @@ std::unique_ptr<IStreamCipher> Crypto::CreateSalsa20(const uint8_t* keyBytes, co
|
||||
std::unique_ptr<IPublicKeyAlgorithm> Crypto::CreateRSA(const IPublicKeyAlgorithm::HashingAlgorithm hashingAlgorithm, const RSAPaddingMode paddingMode)
|
||||
{
|
||||
return std::make_unique<AlgorithmRSA>(hashingAlgorithm, paddingMode);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "IHashFunction.h"
|
||||
#include "IPublicKeyAlgorithm.h"
|
||||
#include "IStreamCipher.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
|
||||
#include "IHashFunction.h"
|
||||
#include "IStreamCipher.h"
|
||||
#include "IPublicKeyAlgorithm.h"
|
||||
|
||||
class Crypto
|
||||
{
|
||||
public:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class IPublicKeyAlgorithm
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
class IStreamCipher
|
||||
{
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "AlgorithmRSA.h"
|
||||
#include <cstring>
|
||||
|
||||
#include "CryptoLibrary.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
class AlgorithmRSA::AlgorithmRSAImpl
|
||||
{
|
||||
rsa_key m_key{};
|
||||
@ -11,7 +12,7 @@ class AlgorithmRSA::AlgorithmRSAImpl
|
||||
|
||||
const ltc_hash_descriptor* GetHashDescriptor() const
|
||||
{
|
||||
switch(m_hash)
|
||||
switch (m_hash)
|
||||
{
|
||||
case HashingAlgorithm::RSA_HASH_SHA256:
|
||||
return &sha256_desc;
|
||||
@ -24,7 +25,7 @@ class AlgorithmRSA::AlgorithmRSAImpl
|
||||
|
||||
int GetPaddingMode() const
|
||||
{
|
||||
switch(m_padding)
|
||||
switch (m_padding)
|
||||
{
|
||||
case Crypto::RSAPaddingMode::RSA_PADDING_PKS1:
|
||||
return LTC_PKCS_1_V1_5;
|
||||
@ -56,7 +57,7 @@ public:
|
||||
{
|
||||
return rsa_import(keyData, keySize, &m_key) == CRYPT_OK;
|
||||
}
|
||||
|
||||
|
||||
bool Verify(const uint8_t* signedData, const size_t signedDataSize, const uint8_t* signature, const size_t signatureSize)
|
||||
{
|
||||
const ltc_hash_descriptor* hashDesc = GetHashDescriptor();
|
||||
@ -115,4 +116,4 @@ bool AlgorithmRSA::SetKey(const uint8_t* keyData, size_t keySize)
|
||||
bool AlgorithmRSA::Verify(const uint8_t* signedData, const size_t signedDataSize, const uint8_t* signature, const size_t signatureSize)
|
||||
{
|
||||
return m_impl->Verify(signedData, signedDataSize, signature, signatureSize);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "IPublicKeyAlgorithm.h"
|
||||
#include "Crypto.h"
|
||||
#include "IPublicKeyAlgorithm.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class AlgorithmRSA final : public IPublicKeyAlgorithm
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "AlgorithmSHA1.h"
|
||||
|
||||
#include "CryptoLibrary.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class AlgorithmSHA1::AlgorithmSHA1Impl
|
||||
@ -60,4 +61,4 @@ void AlgorithmSHA1::Process(const void* input, const size_t inputSize)
|
||||
void AlgorithmSHA1::Finish(void* hashBuffer)
|
||||
{
|
||||
m_impl->Finish(hashBuffer);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "AlgorithmSHA256.h"
|
||||
|
||||
#include "CryptoLibrary.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class AlgorithmSHA256::Impl
|
||||
@ -60,4 +61,4 @@ void AlgorithmSHA256::Process(const void* input, const size_t inputSize)
|
||||
void AlgorithmSHA256::Finish(void* hashBuffer)
|
||||
{
|
||||
m_impl->Finish(hashBuffer);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "AlgorithmSalsa20.h"
|
||||
|
||||
#include "salsa20.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <stdexcept>
|
||||
|
||||
@ -25,7 +27,7 @@ public:
|
||||
{
|
||||
assert(ivSize == 8);
|
||||
|
||||
if(ivSize != 8)
|
||||
if (ivSize != 8)
|
||||
{
|
||||
throw std::invalid_argument("Salsa20 IV size must be 8");
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "CryptoLibrary.h"
|
||||
|
||||
#include "tommath.h"
|
||||
|
||||
void CryptoLibrary::Init()
|
||||
@ -11,4 +12,4 @@ void CryptoLibrary::Init()
|
||||
|
||||
ltc_mp = ltm_desc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,4 +7,4 @@ class CryptoLibrary
|
||||
{
|
||||
public:
|
||||
static void Init();
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user