1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Integrate SHA-256 support into Linux/MacOSX code. Set PRF priority to SHA-512 -> Whirlpool -> SHA-256 -> RIPEMD-160 .

This commit is contained in:
Mounir IDRASSI
2014-10-14 21:19:53 +02:00
parent 905a3ff4a5
commit f05f6a00a6
5 changed files with 97 additions and 5 deletions

View File

@@ -17,10 +17,11 @@ namespace VeraCrypt
HashList Hash::GetAvailableAlgorithms ()
{
HashList l;
l.push_back (shared_ptr <Hash> (new Ripemd160 ()));
l.push_back (shared_ptr <Hash> (new Sha512 ()));
l.push_back (shared_ptr <Hash> (new Whirlpool ()));
l.push_back (shared_ptr <Hash> (new Sha256 ()));
l.push_back (shared_ptr <Hash> (new Ripemd160 ()));
return l;
}
@@ -60,6 +61,30 @@ namespace VeraCrypt
if_debug (ValidateDataParameters (data));
RMD160Update ((RMD160_CTX *) Context.Ptr(), data.Get(), (int) data.Size());
}
// SHA-256
Sha256::Sha256 ()
{
Context.Allocate (sizeof (sha256_ctx));
Init();
}
void Sha256::GetDigest (const BufferPtr &buffer)
{
if_debug (ValidateDigestParameters (buffer));
sha256_end (buffer, (sha256_ctx *) Context.Ptr());
}
void Sha256::Init ()
{
sha256_begin ((sha256_ctx *) Context.Ptr());
}
void Sha256::ProcessData (const ConstBufferPtr &data)
{
if_debug (ValidateDataParameters (data));
sha256_hash (data.Get(), (int) data.Size(), (sha256_ctx *) Context.Ptr());
}
// SHA-512
Sha512::Sha512 ()