AuroraRuntime/Source/Hashing/CommonDigests.cpp

53 lines
1.6 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: CommonDigests.cpp
Date: 2021-6-12
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "CommonDigests.hpp"
#include <tomcrypt.h>
namespace Aurora::Hashing
{
AUKN_SYM void MD5(const void *buffer, AuMach length, std::array<AuUInt8, 16> &md5)
{
hash_state md;
md5_init(&md);
md5_process(&md, reinterpret_cast<const unsigned char*>(buffer), length);
md5_done(&md, md5.data());
}
AUKN_SYM void SHA1(const void *buffer, AuMach length, std::array<AuUInt8, 20> &sha1)
{
hash_state md;
sha1_init(&md);
sha1_process(&md, reinterpret_cast<const unsigned char*>(buffer), length);
sha1_done(&md, sha1.data());
}
AUKN_SYM void Tiger(const void *buffer, AuMach length, std::array<AuUInt8, 24> &tiger)
{
hash_state md;
tiger_init(&md);
tiger_process(&md, reinterpret_cast<const unsigned char*>(buffer), length);
tiger_done(&md, tiger.data());
}
AUKN_SYM void SHA2(const void *buffer, AuMach length, std::array<AuUInt8, 32> &sha2)
{
hash_state md;
sha256_init(&md);
sha256_process(&md, reinterpret_cast<const unsigned char*>(buffer), length);
sha256_done(&md, sha2.data());
}
AUKN_SYM void SHA2_64(const void *buffer, AuMach length, std::array<AuUInt8, 64> &sha2)
{
hash_state md;
sha512_init(&md);
sha512_process(&md, reinterpret_cast<const unsigned char*>(buffer), length);
sha512_done(&md, sha2.data());
}
}