Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Fix REINER PinPad support
Browse files Browse the repository at this point in the history
WE2-725

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Oct 5, 2023
1 parent d51bd26 commit ab72e8f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/SmartCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace

using namespace pcsc_cpp;

inline SmartCard::Protocol convertToSmartCardProtocol(const DWORD protocol)
constexpr SmartCard::Protocol convertToSmartCardProtocol(const DWORD protocol)
{
switch (protocol) {
case SCARD_PROTOCOL_UNDEFINED:
Expand Down Expand Up @@ -88,11 +88,11 @@ class CardImpl
SCard(Control, cardHandle, DWORD(CM_IOCTL_GET_FEATURE_REQUEST), nullptr, 0U,
feature.data(), DWORD(feature.size()), &size);
for (auto p = feature.cbegin(); DWORD(std::distance(feature.cbegin(), p)) < size;) {
unsigned int tag = *p++;
unsigned int value = 0;
auto tag = DRIVER_FEATURES(*p++);
uint32_t value = 0;
for (unsigned int i = 0, len = *p++; i < len; ++i)
value |= unsigned(*p++) << 8 * i;
features[DRIVER_FEATURES(tag)] = ntohl(value);
value |= uint32_t(*p++) << 8 * i;
features[tag] = ntohl(value);
}
} catch (const ScardError&) {
// Ignore driver errors during card feature requests.
Expand Down Expand Up @@ -157,15 +157,14 @@ class CardImpl
data->bNumberMessage = CCIDDefaultInvitationMessage;
data->wLangId = lang;
data->bMsgIndex = NoInvitationMessage;
data->ulDataLength = uint32_t(commandBytes.size() + 1);
data->ulDataLength = uint32_t(commandBytes.size());
cmd.insert(cmd.cend(), commandBytes.cbegin(), commandBytes.cend());
cmd.resize(cmd.size() + 1);

DWORD ioctl = features.at(features.find(FEATURE_VERIFY_PIN_START) != features.cend()
? FEATURE_VERIFY_PIN_START
: FEATURE_VERIFY_PIN_DIRECT);
byte_vector responseBytes(ResponseApdu::MAX_SIZE, 0);
DWORD responseLength = DWORD(responseBytes.size());
auto responseLength = DWORD(responseBytes.size());
SCard(Control, cardHandle, ioctl, cmd.data(), DWORD(cmd.size()),
LPVOID(responseBytes.data()), DWORD(responseBytes.size()), &responseLength);

Expand Down Expand Up @@ -293,7 +292,7 @@ ResponseApdu SmartCard::transmit(const CommandApdu& command) const

ResponseApdu SmartCard::transmitCTL(const CommandApdu& command, uint16_t lang, uint8_t minlen) const
{
REQUIRE_NON_NULL(card);
REQUIRE_NON_NULL(card)
if (!transactionInProgress) {
THROW(std::logic_error, "Call SmartCard::transmit() inside a transaction");
}
Expand Down

0 comments on commit ab72e8f

Please sign in to comment.