diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2023-06-29 00:06:20 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2023-06-29 00:06:20 +0200 |
commit | 034b64f4153550cbe5849bcbfc27e187377cc512 (patch) | |
tree | d831496163c3891031765010bf1934406b0c4a3c /src/Common/SCard.cpp | |
parent | 502ab9112a7624dbd7c1c90c2e12ed45512b8b3c (diff) | |
download | VeraCrypt-034b64f4153550cbe5849bcbfc27e187377cc512.tar.gz VeraCrypt-034b64f4153550cbe5849bcbfc27e187377cc512.zip |
EMV keyfile support: Overall code improvements and bug fixes
Diffstat (limited to 'src/Common/SCard.cpp')
-rw-r--r-- | src/Common/SCard.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/Common/SCard.cpp b/src/Common/SCard.cpp new file mode 100644 index 00000000..9f8d1145 --- /dev/null +++ b/src/Common/SCard.cpp @@ -0,0 +1,62 @@ +#include "SCard.h" + +using namespace std; + +namespace VeraCrypt +{ + SCardManager SCard::manager; + + SCard::SCard() : m_reader(NULL) + { + } + + SCard::SCard(size_t slotId) + { + m_reader = SCard::manager.GetReader(slotId); + } + + SCard::~SCard() + { + if (m_reader) + { + m_reader->Disconnect(); + } + } + + SCard::SCard(const SCard& other) : m_reader(other.m_reader) + { + } + + SCard::SCard(SCard&& other) : m_reader(std::move(other.m_reader)) + { + } + + SCard& SCard::operator = (const SCard& other) + { + if (this != &other) + { + m_reader = other.m_reader; + } + return *this; + } + + SCard& SCard::operator = (SCard&& other) + { + if (this != &other) + { + m_reader = std::move(other.m_reader); + } + return *this; + } + + bool SCard::IsCardHandleValid() const + { + bool isValid = false; + if (m_reader) + { + isValid = m_reader->CardHandleStatus() == SCARD_S_SUCCESS; + } + + return isValid; + } +} |