diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-09-28 00:14:05 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-10-17 18:40:19 +0200 |
commit | 57ce7aab7be0ca2c3e990eaf7d9cf3691efd1ea0 (patch) | |
tree | 3cfd2715c14b191f2817f1bac60f8236a12cb870 /src/Platform/Buffer.h | |
parent | 3e029b0dde5326a4f1221c86a2050aafceaafa3e (diff) | |
download | VeraCrypt-57ce7aab7be0ca2c3e990eaf7d9cf3691efd1ea0.tar.gz VeraCrypt-57ce7aab7be0ca2c3e990eaf7d9cf3691efd1ea0.zip |
Use properly aligned memory in code using Streebog hash implementation that uses SSE.
Diffstat (limited to 'src/Platform/Buffer.h')
-rw-r--r-- | src/Platform/Buffer.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Platform/Buffer.h b/src/Platform/Buffer.h index b47907b3..797cd7ff 100644 --- a/src/Platform/Buffer.h +++ b/src/Platform/Buffer.h @@ -71,17 +71,18 @@ namespace VeraCrypt { public: Buffer (); - Buffer (size_t size); - Buffer (const ConstBufferPtr &bufferPtr) { CopyFrom (bufferPtr); } + Buffer (size_t size, size_t alignment = 0); + Buffer (const ConstBufferPtr &bufferPtr, size_t alignment = 0) { CopyFrom (bufferPtr, alignment); } virtual ~Buffer (); - virtual void Allocate (size_t size); - virtual void CopyFrom (const ConstBufferPtr &bufferPtr); + virtual void Allocate (size_t size, size_t alignment = 0); + virtual void CopyFrom (const ConstBufferPtr &bufferPtr, size_t alignment = 0); virtual byte *Ptr () const { return DataPtr; } virtual void Erase (); virtual void Free (); virtual BufferPtr GetRange (size_t offset, size_t size) const; virtual size_t Size () const { return DataSize; } + virtual size_t Alignment () const { return DataAlignment; } virtual bool IsAllocated () const { return DataSize != 0; } virtual void Zero (); @@ -92,6 +93,7 @@ namespace VeraCrypt protected: byte *DataPtr; size_t DataSize; + size_t DataAlignment; private: Buffer (const Buffer &); @@ -102,11 +104,11 @@ namespace VeraCrypt { public: SecureBuffer () { } - SecureBuffer (size_t size); + SecureBuffer (size_t size, size_t alignment = 0); SecureBuffer (const ConstBufferPtr &bufferPtr) { CopyFrom (bufferPtr); } virtual ~SecureBuffer (); - virtual void Allocate (size_t size); + virtual void Allocate (size_t size, size_t alignment = 0); virtual void Free (); private: |