diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-05-29 01:30:53 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-05-29 01:33:18 +0200 |
commit | 99c4031d89ce4f72e3899b3cac660082a1820a48 (patch) | |
tree | 6fc381d9789326a6b132fd17e6cf9a6c3e1dc411 /src/Common/SecurityToken.cpp | |
parent | a0d8b8a3b78b1d0db50de2a7d841efaec2a55c36 (diff) | |
download | VeraCrypt-99c4031d89ce4f72e3899b3cac660082a1820a48.tar.gz VeraCrypt-99c4031d89ce4f72e3899b3cac660082a1820a48.zip |
Windows: better implementation for support of smart card PIN in command line. Supported now also on Format.
Diffstat (limited to 'src/Common/SecurityToken.cpp')
-rw-r--r-- | src/Common/SecurityToken.cpp | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp index 597c6a2f..05defe5b 100644 --- a/src/Common/SecurityToken.cpp +++ b/src/Common/SecurityToken.cpp @@ -36,7 +36,7 @@ using namespace std; namespace VeraCrypt { - SecurityTokenKeyfile::SecurityTokenKeyfile (const SecurityTokenKeyfilePath &path, char* pin) + SecurityTokenKeyfile::SecurityTokenKeyfile (const SecurityTokenKeyfilePath &path) { wstring pathStr = path; unsigned long slotId; @@ -52,7 +52,7 @@ namespace VeraCrypt Id = pathStr.substr (keyIdPos + wstring (L"/" TC_SECURITY_TOKEN_KEYFILE_URL_FILE L"/").size()); - vector <SecurityTokenKeyfile> keyfiles = SecurityToken::GetAvailableKeyfiles (&SlotId, Id, pin); + vector <SecurityTokenKeyfile> keyfiles = SecurityToken::GetAvailableKeyfiles (&SlotId, Id); if (keyfiles.empty()) throw SecurityTokenKeyfileNotFound(); @@ -180,7 +180,7 @@ namespace VeraCrypt throw Pkcs11Exception (status); } - vector <SecurityTokenKeyfile> SecurityToken::GetAvailableKeyfiles (CK_SLOT_ID *slotIdFilter, const wstring keyfileIdFilter, char* pin) + vector <SecurityTokenKeyfile> SecurityToken::GetAvailableKeyfiles (CK_SLOT_ID *slotIdFilter, const wstring keyfileIdFilter) { bool unrecognizedTokenPresent = false; vector <SecurityTokenKeyfile> keyfiles; @@ -194,7 +194,7 @@ namespace VeraCrypt try { - LoginUserIfRequired (slotId, pin); + LoginUserIfRequired (slotId); token = GetTokenInfo (slotId); } catch (UserAbort &) @@ -314,12 +314,7 @@ namespace VeraCrypt void SecurityToken::GetKeyfileData (const SecurityTokenKeyfile &keyfile, vector <byte> &keyfileData) { - GetKeyfileData (keyfile, nullptr, keyfileData); - } - - void SecurityToken::GetKeyfileData (const SecurityTokenKeyfile &keyfile, char* pin, vector <byte> &keyfileData) - { - LoginUserIfRequired (keyfile.SlotId, pin); + LoginUserIfRequired (keyfile.SlotId); GetObjectAttribute (keyfile.SlotId, keyfile.Handle, CKA_VALUE, keyfileData); } @@ -438,7 +433,7 @@ namespace VeraCrypt Sessions[slotId].UserLoggedIn = true; } - void SecurityToken::LoginUserIfRequired (CK_SLOT_ID slotId, char* cmdPin) + void SecurityToken::LoginUserIfRequired (CK_SLOT_ID slotId) { CheckLibraryStatus(); CK_RV status; @@ -479,10 +474,6 @@ namespace VeraCrypt if (status != CKR_OK) throw Pkcs11Exception (status); } - else if (cmdPin && cmdPin [0]) - { - Login (slotId, cmdPin); - } else { string pin = tokenInfo.LabelUtf8; @@ -511,12 +502,6 @@ namespace VeraCrypt } else if (error == CKR_PIN_INCORRECT && !(tokenInfo.Flags & CKF_PROTECTED_AUTHENTICATION_PATH)) { - if (cmdPin && cmdPin [0]) - { - // clear wrong PIN - size_t cmdPinLen = strlen (cmdPin); - burn (cmdPin, cmdPinLen); - } PinCallback->notifyIncorrectPin (); (*WarningCallback) (Pkcs11Exception (CKR_PIN_INCORRECT)); continue; |