mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
EMV keyfile support: Overall code improvements and bug fixes
This commit is contained in:
62
src/Common/SCard.cpp
Normal file
62
src/Common/SCard.cpp
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user