VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/Hash.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-10-14 19:19:53 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 22:24:03 (GMT)
commitf05f6a00a6b0f150b0a0b51cd7b44b9c9193e3de (patch)
tree68ff46ae6fa1575eb6052465a8708fb96311894e /src/Volume/Hash.cpp
parent905a3ff4a5d70a00d9ba7819b9f43ad9ce0654e6 (diff)
downloadVeraCrypt-f05f6a00a6b0f150b0a0b51cd7b44b9c9193e3de.zip
VeraCrypt-f05f6a00a6b0f150b0a0b51cd7b44b9c9193e3de.tar.gz
Integrate SHA-256 support into Linux/MacOSX code. Set PRF priority to SHA-512 -> Whirlpool -> SHA-256 -> RIPEMD-160 .
Diffstat (limited to 'src/Volume/Hash.cpp')
-rw-r--r--src/Volume/Hash.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/Volume/Hash.cpp b/src/Volume/Hash.cpp
index b917a8e..cc582b9 100644
--- a/src/Volume/Hash.cpp
+++ b/src/Volume/Hash.cpp
@@ -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 ()