AuroraRuntime/Source/Crypto/PBKDF2/PBKDF2.cpp

29 lines
1.0 KiB
C++
Raw Normal View History

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: PBKDF2.cpp
Date: 2022-10-08
Author: Reece
***/
#include <Source/RuntimeInternal.hpp>
#include "../Crypto.hpp"
namespace Aurora::Crypto::PBKDF2
{
AUKN_SYM bool PBKDF2(const Memory::MemoryViewRead &salt,
const Memory::MemoryViewRead &password,
Hashing::EHashType hashType,
AuUInt32 uIterations,
const Memory::MemoryViewWrite &out)
{
unsigned long len = out.length;
return ::pkcs_5_alg2(password.Begin<unsigned char>(),
password.length,
salt.Begin<unsigned char>(),
salt.length,
uIterations,
::Crypto::HashMethodToId(hashType),
out.Begin<unsigned char>(),
&len) == CRYPT_OK && len == out.length;
}
}