mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2026-05-29 16:00:22 +00:00
Use blake2b as hash for random generator from Argon2 is used.
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "Hash.h"
|
||||
|
||||
#include "Crypto/blake2.h"
|
||||
#include "Crypto/blake2s.h"
|
||||
#include "Crypto/Sha2.h"
|
||||
#include "Crypto/Whirlpool.h"
|
||||
#include "Crypto/Streebog.h"
|
||||
@@ -27,7 +27,7 @@ namespace VeraCrypt
|
||||
l.push_back (shared_ptr <Hash> (new Sha256 ()));
|
||||
#ifndef WOLFCRYPT_BACKEND
|
||||
l.push_back (shared_ptr <Hash> (new Blake2s ()));
|
||||
l.push_back (shared_ptr <Hash> (new Whirlpool ()));
|
||||
l.push_back (shared_ptr <Hash> (new Whirlpool ()));
|
||||
l.push_back (shared_ptr <Hash> (new Streebog ()));
|
||||
#endif
|
||||
return l;
|
||||
@@ -46,7 +46,7 @@ namespace VeraCrypt
|
||||
}
|
||||
|
||||
#ifndef WOLFCRYPT_BACKEND
|
||||
// RIPEMD-160
|
||||
// BLAKE2s
|
||||
Blake2s::Blake2s ()
|
||||
{
|
||||
Context.Allocate (sizeof (blake2s_state), 32);
|
||||
@@ -69,6 +69,30 @@ namespace VeraCrypt
|
||||
if_debug (ValidateDataParameters (data));
|
||||
blake2s_update ((blake2s_state *) Context.Ptr(), data.Get(), data.Size());
|
||||
}
|
||||
|
||||
// BLAKE2b
|
||||
Blake2b::Blake2b ()
|
||||
{
|
||||
Context.Allocate (sizeof (blake2b_state), 32);
|
||||
Init();
|
||||
}
|
||||
|
||||
void Blake2b::GetDigest (const BufferPtr &buffer)
|
||||
{
|
||||
if_debug (ValidateDigestParameters (buffer));
|
||||
blake2b_final ((blake2b_state *) Context.Ptr(), buffer, BLAKE2B_OUTBYTES);
|
||||
}
|
||||
|
||||
void Blake2b::Init ()
|
||||
{
|
||||
blake2b_init ((blake2b_state *) Context.Ptr(), BLAKE2B_OUTBYTES);
|
||||
}
|
||||
|
||||
void Blake2b::ProcessData (const ConstBufferPtr &data)
|
||||
{
|
||||
if_debug (ValidateDataParameters (data));
|
||||
blake2b_update ((blake2b_state *) Context.Ptr(), data.Get(), data.Size());
|
||||
}
|
||||
#endif
|
||||
|
||||
// SHA-256
|
||||
|
||||
@@ -71,6 +71,29 @@ namespace VeraCrypt
|
||||
Blake2s (const Blake2s &);
|
||||
Blake2s &operator= (const Blake2s &);
|
||||
};
|
||||
|
||||
// Blake2b
|
||||
class Blake2b : public Hash
|
||||
{
|
||||
public:
|
||||
Blake2b ();
|
||||
virtual ~Blake2b () { }
|
||||
|
||||
virtual void GetDigest (const BufferPtr &buffer);
|
||||
virtual size_t GetBlockSize () const { return 128; }
|
||||
virtual size_t GetDigestSize () const { return 64; }
|
||||
virtual wstring GetName () const { return L"BLAKE2b-512"; }
|
||||
virtual wstring GetAltName () const { return L"BLAKE2b"; }
|
||||
virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Blake2b); }
|
||||
virtual void Init ();
|
||||
virtual void ProcessData (const ConstBufferPtr &data);
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
Blake2b (const Blake2b &);
|
||||
Blake2b &operator= (const Blake2b &);
|
||||
};
|
||||
#endif
|
||||
|
||||
// SHA-256
|
||||
|
||||
Reference in New Issue
Block a user