Skip to content

Commit 54c077b

Browse files
committed
Fix FinEID v3 pinRetriesLeft command
Signed-off-by: Raul Metsma <raul@metsma.ee>
1 parent a3023e3 commit 54c077b

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

lib/libpcsc-cpp/include/pcsc-cpp/pcsc-cpp.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ struct CommandApdu
172172
byte_vector data, byte_type le) :
173173
CommandApdu {cls, ins, p1, p2, std::move(data)}
174174
{
175+
#if defined(__GNUC__) && __GNUC__ == 15 // Apply workaround for GCC 15
176+
d.reserve(d.size() + 1);
177+
#endif
175178
d.push_back(le);
176179
}
177180

src/electronic-ids/pcsc/FinEID.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,21 @@ byte_vector FinEIDv3::sign(const HashAlgorithm hashAlgo, const byte_vector& hash
106106
}
107107

108108
switch (hashAlgo) {
109-
case HashAlgorithm::SHA224:
110-
case HashAlgorithm::SHA3_224:
109+
using enum HashAlgorithm::HashAlgorithmEnum;
110+
case SHA224:
111+
case SHA3_224:
111112
signatureAlgo |= 0x30;
112113
break;
113-
case HashAlgorithm::SHA256:
114-
case HashAlgorithm::SHA3_256:
114+
case SHA256:
115+
case SHA3_256:
115116
signatureAlgo |= 0x40;
116117
break;
117-
case HashAlgorithm::SHA384:
118-
case HashAlgorithm::SHA3_384:
118+
case SHA384:
119+
case SHA3_384:
119120
signatureAlgo |= 0x50;
120121
break;
121-
case HashAlgorithm::SHA512:
122-
case HashAlgorithm::SHA3_512:
122+
case SHA512:
123+
case SHA3_512:
123124
signatureAlgo |= 0x60;
124125
break;
125126
default:
@@ -161,7 +162,7 @@ byte_vector FinEIDv3::sign(const HashAlgorithm hashAlgo, const byte_vector& hash
161162
ElectronicID::PinRetriesRemainingAndMax FinEIDv3::pinRetriesLeft(byte_type pinReference) const
162163
{
163164
const pcsc_cpp::CommandApdu GET_DATA {
164-
0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}};
165+
0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}, 0x00};
165166
const auto response = card->transmit(GET_DATA);
166167
if (!response.isOK()) {
167168
THROW(SmartCardError, "Command GET DATA failed with error " + response);

tests/mock/select-certificate-script-FIN-V3.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ const PcscMock::ApduScript FINEID_V3_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE =
180180

181181
// 2. PIN Retry count
182182
// Get retry count
183-
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11},
183+
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11, 0x00},
184184
{0xa0, 0x23, 0x83, 0x01, 0x11, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
185185
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
186186
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},
@@ -362,7 +362,7 @@ const PcscMock::ApduScript FINEID_V3_SELECT_SIGN_CERTIFICATE_AND_SIGNING = {
362362

363363
// 2. PIN Retry count
364364
// Get retry count
365-
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82},
365+
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82, 0x00},
366366
{0xa0, 0x23, 0x83, 0x01, 0x82, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
367367
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
368368
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},

tests/mock/select-certificate-script-FIN-V4.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const PcscMock::ApduScript FINEID_V4_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE {
132132

133133
// 2. PIN Retry count
134134
// Get retry count
135-
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11},
135+
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11, 0x00},
136136
{0xa0, 0x23, 0x83, 0x01, 0x11, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
137137
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
138138
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},
@@ -275,7 +275,7 @@ const PcscMock::ApduScript FINEID_V4_SELECT_SIGN_CERTIFICATE_AND_SIGNING {
275275

276276
// 2. PIN Retry count
277277
// Get retry count
278-
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82},
278+
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82, 0x00},
279279
{0xa0, 0x23, 0x83, 0x01, 0x82, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
280280
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
281281
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},

0 commit comments

Comments
 (0)