VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/Pkcs5Kdf.h
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-30 17:01:49 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-30 17:06:20 +0100
commitc178e325b807258199ae45b2c50c265b4d7ce7af (patch)
tree905297a12e86b71d4611ff13d1df7e99c1e20b61 /src/Volume/Pkcs5Kdf.h
parent8d787dcd7128fce554f473da62e20162b0b6c9c4 (diff)
downloadVeraCrypt-c178e325b807258199ae45b2c50c265b4d7ce7af.tar.gz
VeraCrypt-c178e325b807258199ae45b2c50c265b4d7ce7af.zip
Linux/MacOSX: Implement TrueCrypt conversion and loading support. Correct many GTK issues linked to multi-threaded origine of events by implementing an automatic mechanism for handling such requests in the main thread.
Diffstat (limited to 'src/Volume/Pkcs5Kdf.h')
-rw-r--r--src/Volume/Pkcs5Kdf.h39
1 files changed, 21 insertions, 18 deletions
diff --git a/src/Volume/Pkcs5Kdf.h b/src/Volume/Pkcs5Kdf.h
index 19267b0f..b2a13213 100644
--- a/src/Volume/Pkcs5Kdf.h
+++ b/src/Volume/Pkcs5Kdf.h
@@ -25,17 +25,20 @@ namespace VeraCrypt
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt) const;
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const = 0;
- static shared_ptr <Pkcs5Kdf> GetAlgorithm (const wstring &name);
- static shared_ptr <Pkcs5Kdf> GetAlgorithm (const Hash &hash);
- static Pkcs5KdfList GetAvailableAlgorithms ();
+ static shared_ptr <Pkcs5Kdf> GetAlgorithm (const wstring &name, bool truecryptMode);
+ static shared_ptr <Pkcs5Kdf> GetAlgorithm (const Hash &hash, bool truecryptMode);
+ static Pkcs5KdfList GetAvailableAlgorithms (bool truecryptMode);
virtual shared_ptr <Hash> GetHash () const = 0;
virtual int GetIterationCount () const = 0;
virtual wstring GetName () const = 0;
virtual Pkcs5Kdf* Clone () const = 0;
virtual bool IsDeprecated () const { return GetHash()->IsDeprecated(); }
+ bool GetTrueCryptMode () const { return m_truecryptMode;}
+ void SetTrueCryptMode (bool truecryptMode) { m_truecryptMode = truecryptMode;}
protected:
- Pkcs5Kdf ();
+ bool m_truecryptMode;
+ Pkcs5Kdf (bool truecryptMode);
void ValidateParameters (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
@@ -47,14 +50,14 @@ namespace VeraCrypt
class Pkcs5HmacRipemd160 : public Pkcs5Kdf
{
public:
- Pkcs5HmacRipemd160 () { }
+ Pkcs5HmacRipemd160 (bool truecryptMode) : Pkcs5Kdf (truecryptMode) { }
virtual ~Pkcs5HmacRipemd160 () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Ripemd160); }
- virtual int GetIterationCount () const { return 655331; }
+ virtual int GetIterationCount () const { return m_truecryptMode? 2000 : 655331; }
virtual wstring GetName () const { return L"HMAC-RIPEMD-160"; }
- virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacRipemd160(); }
+ virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacRipemd160(m_truecryptMode); }
private:
Pkcs5HmacRipemd160 (const Pkcs5HmacRipemd160 &);
@@ -64,14 +67,14 @@ namespace VeraCrypt
class Pkcs5HmacRipemd160_1000 : public Pkcs5Kdf
{
public:
- Pkcs5HmacRipemd160_1000 () { }
+ Pkcs5HmacRipemd160_1000 (bool truecryptMode) : Pkcs5Kdf(truecryptMode) { }
virtual ~Pkcs5HmacRipemd160_1000 () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Ripemd160); }
- virtual int GetIterationCount () const { return 327661; }
+ virtual int GetIterationCount () const { return m_truecryptMode? 1000 : 327661; }
virtual wstring GetName () const { return L"HMAC-RIPEMD-160"; }
- virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacRipemd160_1000(); }
+ virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacRipemd160_1000(m_truecryptMode); }
private:
Pkcs5HmacRipemd160_1000 (const Pkcs5HmacRipemd160_1000 &);
@@ -81,7 +84,7 @@ namespace VeraCrypt
class Pkcs5HmacSha256_Boot : public Pkcs5Kdf
{
public:
- Pkcs5HmacSha256_Boot () { }
+ Pkcs5HmacSha256_Boot () : Pkcs5Kdf(false) { }
virtual ~Pkcs5HmacSha256_Boot () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
@@ -98,7 +101,7 @@ namespace VeraCrypt
class Pkcs5HmacSha256 : public Pkcs5Kdf
{
public:
- Pkcs5HmacSha256 () { }
+ Pkcs5HmacSha256 () : Pkcs5Kdf(false) { }
virtual ~Pkcs5HmacSha256 () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
@@ -115,14 +118,14 @@ namespace VeraCrypt
class Pkcs5HmacSha512 : public Pkcs5Kdf
{
public:
- Pkcs5HmacSha512 () { }
+ Pkcs5HmacSha512 (bool truecryptMode) : Pkcs5Kdf(truecryptMode) { }
virtual ~Pkcs5HmacSha512 () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha512); }
- virtual int GetIterationCount () const { return 500000; }
+ virtual int GetIterationCount () const { return m_truecryptMode? 1000 : 500000; }
virtual wstring GetName () const { return L"HMAC-SHA-512"; }
- virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacSha512(); }
+ virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacSha512(m_truecryptMode); }
private:
Pkcs5HmacSha512 (const Pkcs5HmacSha512 &);
@@ -132,14 +135,14 @@ namespace VeraCrypt
class Pkcs5HmacWhirlpool : public Pkcs5Kdf
{
public:
- Pkcs5HmacWhirlpool () { }
+ Pkcs5HmacWhirlpool (bool truecryptMode) : Pkcs5Kdf(truecryptMode) { }
virtual ~Pkcs5HmacWhirlpool () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const;
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Whirlpool); }
- virtual int GetIterationCount () const { return 500000; }
+ virtual int GetIterationCount () const { return m_truecryptMode? 1000 : 500000; }
virtual wstring GetName () const { return L"HMAC-Whirlpool"; }
- virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacWhirlpool; }
+ virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacWhirlpool(m_truecryptMode); }
private:
Pkcs5HmacWhirlpool (const Pkcs5HmacWhirlpool &);