VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/Keyfile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Volume/Keyfile.cpp')
-rw-r--r--src/Volume/Keyfile.cpp81
1 files changed, 42 insertions, 39 deletions
diff --git a/src/Volume/Keyfile.cpp b/src/Volume/Keyfile.cpp
index 9527fd11..24b40709 100644
--- a/src/Volume/Keyfile.cpp
+++ b/src/Volume/Keyfile.cpp
@@ -18,7 +18,7 @@
#include "VolumeException.h"
namespace VeraCrypt
{
- void Keyfile::Apply (const BufferPtr &pool, bool EMVOption) const
+ void Keyfile::Apply (const BufferPtr &pool, bool emvSupportEnabled) const
{
if (Path.IsDirectory())
throw ParameterIncorrect (SRC_POS);
@@ -32,57 +32,60 @@ namespace VeraCrypt
SecureBuffer keyfileBuf (File::GetOptimalReadSize());
- std::wcout << wstring (Path) << std::endl;
- if (Token::IsKeyfilePathValid (Path, EMVOption)) {
- // Apply keyfile generated by a security token
- vector <byte> keyfileData;
- Token::getTokenKeyfile(wstring(Path))->GetKeyfileData(keyfileData);
+ if (Token::IsKeyfilePathValid (Path, emvSupportEnabled))
+ {
+ // Apply keyfile generated by a security token
+ vector <byte> keyfileData;
+ Token::getTokenKeyfile(wstring(Path))->GetKeyfileData(keyfileData);
- if (keyfileData.size() < MinProcessedLength)
- throw InsufficientData(SRC_POS, Path);
+ if (keyfileData.size() < MinProcessedLength)
+ throw InsufficientData(SRC_POS, Path);
- for (size_t i = 0; i < keyfileData.size(); i++) {
- uint32 crc = crc32.Process(keyfileData[i]);
+ for (size_t i = 0; i < keyfileData.size(); i++)
+ {
+ uint32 crc = crc32.Process(keyfileData[i]);
- pool[poolPos++] += (byte)(crc >> 24);
- pool[poolPos++] += (byte)(crc >> 16);
- pool[poolPos++] += (byte)(crc >> 8);
- pool[poolPos++] += (byte) crc;
+ pool[poolPos++] += (byte)(crc >> 24);
+ pool[poolPos++] += (byte)(crc >> 16);
+ pool[poolPos++] += (byte)(crc >> 8);
+ pool[poolPos++] += (byte) crc;
- if (poolPos >= pool.Size())
- poolPos = 0;
+ if (poolPos >= pool.Size())
+ poolPos = 0;
- if (++totalLength >= MaxProcessedLength)
- break;
- }
+ if (++totalLength >= MaxProcessedLength)
+ break;
+ }
- burn(&keyfileData.front(), keyfileData.size());
- goto done;
- }
+ burn(&keyfileData.front(), keyfileData.size());
+ goto done;
+ }
- file.Open (Path, File::OpenRead, File::ShareRead);
+ file.Open (Path, File::OpenRead, File::ShareRead);
- while ((readLength = file.Read (keyfileBuf)) > 0) {
- for (size_t i = 0; i < readLength; i++) {
- uint32 crc = crc32.Process(keyfileBuf[i]);
- pool[poolPos++] += (byte)(crc >> 24);
- pool[poolPos++] += (byte)(crc >> 16);
- pool[poolPos++] += (byte)(crc >> 8);
- pool[poolPos++] += (byte) crc;
- if (poolPos >= pool.Size())
- poolPos = 0;
- if (++totalLength >= MaxProcessedLength)
- goto done;
- }
- }
- done:
+ while ((readLength = file.Read (keyfileBuf)) > 0)
+ {
+ for (size_t i = 0; i < readLength; i++)
+ {
+ uint32 crc = crc32.Process(keyfileBuf[i]);
+ pool[poolPos++] += (byte)(crc >> 24);
+ pool[poolPos++] += (byte)(crc >> 16);
+ pool[poolPos++] += (byte)(crc >> 8);
+ pool[poolPos++] += (byte) crc;
+ if (poolPos >= pool.Size())
+ poolPos = 0;
+ if (++totalLength >= MaxProcessedLength)
+ goto done;
+ }
+ }
+ done:
if (totalLength < MinProcessedLength)
throw InsufficientData (SRC_POS, Path);
}
- shared_ptr <VolumePassword> Keyfile::ApplyListToPassword (shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> password, bool EMVOption)
+ shared_ptr <VolumePassword> Keyfile::ApplyListToPassword (shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> password, bool emvSupportEnabled)
{
if (!password)
password.reset (new VolumePassword);
@@ -139,7 +142,7 @@ namespace VeraCrypt
// Apply all keyfiles
foreach_ref (const Keyfile &k, keyfilesExp)
{
- k.Apply (keyfilePool, EMVOption);
+ k.Apply (keyfilePool, emvSupportEnabled);
}
newPassword->Set (keyfilePool);