Skip to content

Commit

Permalink
Select main application
Browse files Browse the repository at this point in the history
WE2-1051

Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Feb 17, 2025
1 parent a9b5da8 commit 5ec2e7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
4 changes: 1 addition & 3 deletions src/electronic-ids/pcsc/FinEID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ namespace electronic_id

byte_vector FinEIDv3::getCertificateImpl(const CertificateType type) const
{
transmitApduWithExpectedResponse(*card, SELECT_MAIN_AID);
return electronic_id::getCertificate(
*card, type.isAuthentication() ? SELECT_AUTH_CERT_FILE : SELECT_SIGN_CERT_FILE_V3);
}
Expand Down Expand Up @@ -162,7 +161,7 @@ byte_vector FinEIDv3::sign(const HashAlgorithm hashAlgo, const byte_vector& hash
ElectronicID::PinRetriesRemainingAndMax FinEIDv3::pinRetriesLeft(byte_type pinReference) const
{
const pcsc_cpp::CommandApdu GET_DATA {
0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}, 0x00};
0x00, 0xCB, 0x00, 0xFF, {0xA0, 0x03, 0x83, 0x01, pinReference}};
const auto response = card->transmit(GET_DATA);
if (!response.isOK()) {
THROW(SmartCardError, "Command GET DATA failed with error " + response);
Expand All @@ -177,7 +176,6 @@ ElectronicID::PinRetriesRemainingAndMax FinEIDv3::pinRetriesLeft(byte_type pinRe

byte_vector FinEIDv4::getCertificateImpl(const CertificateType type) const
{
transmitApduWithExpectedResponse(*card, SELECT_MAIN_AID);
return electronic_id::getCertificate(
*card, type.isAuthentication() ? SELECT_AUTH_CERT_FILE : SELECT_SIGN_CERT_FILE_V4);
}
Expand Down
12 changes: 2 additions & 10 deletions tests/mock/select-certificate-script-FIN-V3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#include "pcsc-mock/pcsc-mock.hpp"

const PcscMock::ApduScript FINEID_V3_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE = {
// Select main AID.
{{0x00, 0xA4, 0x04, 0x0C, 0x0C, 0xa0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4b, 0x43, 0x53, 0x2d,
0x31, 0x35},
{0x90, 0x00}},
// Select authentication certificate file.
{{0x00, 0xA4, 0x08, 0x0C, 0x02, 0x43, 0x31}, {0x90, 0x00}},

Expand Down Expand Up @@ -180,7 +176,7 @@ const PcscMock::ApduScript FINEID_V3_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE =

// 2. PIN Retry count
// Get retry count
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11, 0x00},
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11},
{0xa0, 0x23, 0x83, 0x01, 0x11, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},
Expand Down Expand Up @@ -222,10 +218,6 @@ const PcscMock::ApduScript FINEID_V3_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE =
0x8c, 0x90, 0x00}}};

const PcscMock::ApduScript FINEID_V3_SELECT_SIGN_CERTIFICATE_AND_SIGNING = {
// Select main AID.
{{0x00, 0xA4, 0x04, 0x0C, 0x0C, 0xa0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4b, 0x43, 0x53, 0x2d,
0x31, 0x35},
{0x90, 0x00}},
// Select signing certificate file.
{{0x00, 0xA4, 0x08, 0x0C, 0x04, 0x50, 0x16, 0x43, 0x35}, {0x90, 0x00}},

Expand Down Expand Up @@ -362,7 +354,7 @@ const PcscMock::ApduScript FINEID_V3_SELECT_SIGN_CERTIFICATE_AND_SIGNING = {

// 2. PIN Retry count
// Get retry count
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82, 0x00},
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82},
{0xa0, 0x23, 0x83, 0x01, 0x82, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},
Expand Down
12 changes: 2 additions & 10 deletions tests/mock/select-certificate-script-FIN-V4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#include "pcsc-mock/pcsc-mock.hpp"

const PcscMock::ApduScript FINEID_V4_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE {
// Select main AID.
{{0x00, 0xA4, 0x04, 0x0C, 0x0C, 0xa0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4b, 0x43, 0x53, 0x2d,
0x31, 0x35},
{0x90, 0x00}},
// Select authentication certificate file.
{{0x00, 0xA4, 0x08, 0x0C, 0x02, 0x43, 0x31}, {0x90, 0x00}},

Expand Down Expand Up @@ -132,7 +128,7 @@ const PcscMock::ApduScript FINEID_V4_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE {

// 2. PIN Retry count
// Get retry count
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11, 0x00},
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x11},
{0xa0, 0x23, 0x83, 0x01, 0x11, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},
Expand Down Expand Up @@ -164,10 +160,6 @@ const PcscMock::ApduScript FINEID_V4_SELECT_AUTH_CERTIFICATE_AND_AUTHENTICATE {
0xf6, 0x60, 0x77, 0xf9, 0x80, 0x8c, 0x12, 0xc7, 0x35, 0xa7, 0x65, 0xbf, 0x90, 0x00}}};

const PcscMock::ApduScript FINEID_V4_SELECT_SIGN_CERTIFICATE_AND_SIGNING {
// Select main AID.
{{0x00, 0xA4, 0x04, 0x0C, 0x0C, 0xa0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4b, 0x43, 0x53, 0x2d,
0x31, 0x35},
{0x90, 0x00}},
// Select signing certificate file.
{{0x00, 0xA4, 0x08, 0x0C, 0x04, 0x50, 0x16, 0x43, 0x32}, {0x90, 0x00}},

Expand Down Expand Up @@ -275,7 +267,7 @@ const PcscMock::ApduScript FINEID_V4_SELECT_SIGN_CERTIFICATE_AND_SIGNING {

// 2. PIN Retry count
// Get retry count
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82, 0x00},
{{0x00, 0xcb, 0x00, 0xff, 0x05, 0xa0, 0x03, 0x83, 0x01, 0x82},
{0xa0, 0x23, 0x83, 0x01, 0x82, 0x8c, 0x04, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x04,
0xf0, 0x00, 0x00, 0x00, 0xdf, 0x21, 0x04, 0x05, 0xff, 0xa5, 0x03, 0xdf, 0x27,
0x02, 0xff, 0xff, 0xdf, 0x28, 0x01, 0x0c, 0xdf, 0x2f, 0x01, 0x01, 0x90, 0x00}},
Expand Down

0 comments on commit 5ec2e7f

Please # to comment.