Reformat RSA

This commit is contained in:
Reece Wilson 2021-07-12 13:17:16 +01:00
parent 8233825353
commit 29e5593308
3 changed files with 33 additions and 34 deletions

View File

@ -60,8 +60,8 @@ namespace Aurora::Crypto::RSA
unsigned long hashSize = hashVec.size();
auto ret = hash_memory(hash,
reinterpret_cast<const unsigned char *>(buffer), length,
reinterpret_cast<unsigned char *>(hashVec.data()), &hashSize);
reinterpret_cast<const unsigned char *>(buffer), length,
reinterpret_cast<unsigned char *>(hashVec.data()), &hashSize);
if (ret != CRYPT_OK)
{
SysPushErrorCrypt("{}", ret);
@ -70,13 +70,13 @@ namespace Aurora::Crypto::RSA
unsigned long len = out.size();
ret = rsa_sign_hash_ex(reinterpret_cast<const unsigned char *>(hashVec.data()), hashSize,
out.data(), &len,
padding,
&yarrow_prng,
::Crypto::gPrngYarrow,
hash,
salt,
&key_);
out.data(), &len,
padding,
&yarrow_prng,
::Crypto::gPrngYarrow,
hash,
salt,
&key_);
if (ret != CRYPT_OK)
{
SysPushErrorCrypt("{}", ret);
@ -86,10 +86,10 @@ namespace Aurora::Crypto::RSA
out.resize(len);
return true;
}
bool PrivateRSA::Sign(const AuList<AuUInt8> &in,
EHashType method, EPaddingType type,
AuList<AuUInt8> &out)
EHashType method, EPaddingType type,
AuList<AuUInt8> &out)
{
return Sign(in.data(), in.size(), method, type, out);
}
@ -140,7 +140,7 @@ namespace Aurora::Crypto::RSA
{
return Decrypt(in.data(), in.size(), type, out);
}
AuSPtr<IRSAPublic> PrivateRSA::ToPublic()
{
return std::make_shared<PublicRSA>(key_);

View File

@ -50,8 +50,8 @@ namespace Aurora::Crypto::RSA
unsigned long hashSize = hashVec.size();
auto ret = hash_memory(hash,
reinterpret_cast<const unsigned char *>(buffer), length,
reinterpret_cast<unsigned char *>(hashVec.data()), &hashSize);
reinterpret_cast<const unsigned char *>(buffer), length,
reinterpret_cast<unsigned char *>(hashVec.data()), &hashSize);
if (ret != CRYPT_OK)
{
SysPushErrorCrypt("{}", ret);
@ -61,8 +61,8 @@ namespace Aurora::Crypto::RSA
int ok = 0;
ret = rsa_verify_hash_ex(reinterpret_cast<const unsigned char *>(sigBuffer), sigLength,
reinterpret_cast<const unsigned char *>(hashVec.data()), hashSize,
padding, hash, 0, &ok, &key_);
reinterpret_cast<const unsigned char *>(hashVec.data()), hashSize,
padding, hash, 0, &ok, &key_);
if (ret != CRYPT_OK)
{
SysPushErrorCrypt("{}", ret);
@ -105,12 +105,12 @@ namespace Aurora::Crypto::RSA
unsigned long len = out.size();
auto ret = rsa_encrypt_key_ex(reinterpret_cast<const unsigned char *>(buffer), length,
out.data(), &len,
NULL, 0,
&yarrow_prng, prng_idx,
0,
padding,
&key_);
out.data(), &len,
NULL, 0,
&yarrow_prng, prng_idx,
0,
padding,
&key_);
if (ret != CRYPT_OK)
{
SysPushErrorCrypt("{}", ret);

View File

@ -18,8 +18,7 @@ namespace Aurora::Memory
{
public:
InternalHeap() : base_(nullptr), mutex_(nullptr), heap_(nullptr), _count(0)
{
}
{ }
~InternalHeap();
@ -49,24 +48,22 @@ namespace Aurora::Memory
void *_FRealloc(void *buffer, Types::size_t length) override;
void *_FRealloc(void *buffer, Types::size_t length, Types::size_t align) override;
void _Free(void *buffer) override;
void TryRelease();
void RequestTermination();
private:
Threading::Primitives::MutexUnique_t mutex_;
void *base_{};
O1HeapInstance *heap_{};
int _count{};
bool _isDangling{};
void *base_ {};
O1HeapInstance *heap_ {};
int _count {};
bool _isDangling {};
};
InternalHeap::~InternalHeap()
{
SysAssertDbgExp(_count == 0);
mutex_.reset();
if (base_)
{
o1HeapReleaseCpp(heap_);// ->~O1HeapInstance(); // TODO: make free func
@ -75,6 +72,8 @@ namespace Aurora::Memory
base_ = nullptr;
mi_collect(false);
}
mutex_.reset();
}
bool InternalHeap::Init(AuUInt length)
@ -222,7 +221,7 @@ namespace Aurora::Memory
return heap;
}
AUKN_SYM void AllocHeapRelease(Heap *heap)
AUKN_SYM void AllocHeapRelease(Heap *heap)
{
dynamic_cast<InternalHeap *>(heap)->RequestTermination();
}