From 5ec2e7f62a81413e49ef2e4289ad9b5599c68dd1 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Mon, 17 Feb 2025 10:33:59 +0200 Subject: [PATCH] Select main application WE2-1051 Signed-off-by: Raul Metsma --- src/electronic-ids/pcsc/FinEID.cpp | 4 +--- tests/mock/select-certificate-script-FIN-V3.hpp | 12 ++---------- tests/mock/select-certificate-script-FIN-V4.hpp | 12 ++---------- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/src/electronic-ids/pcsc/FinEID.cpp b/src/electronic-ids/pcsc/FinEID.cpp index 3b6b064..e9e4175 100644 --- a/src/electronic-ids/pcsc/FinEID.cpp +++ b/src/electronic-ids/pcsc/FinEID.cpp @@ -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); } @@ -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); @@ -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); } diff --git a/tests/mock/select-certificate-script-FIN-V3.hpp b/tests/mock/select-certificate-script-FIN-V3.hpp index fc88d5b..32b66f7 100644 --- a/tests/mock/select-certificate-script-FIN-V3.hpp +++ b/tests/mock/select-certificate-script-FIN-V3.hpp @@ -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}}, @@ -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}}, @@ -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}}, @@ -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}}, diff --git a/tests/mock/select-certificate-script-FIN-V4.hpp b/tests/mock/select-certificate-script-FIN-V4.hpp index b1cd4ec..dbd5185 100644 --- a/tests/mock/select-certificate-script-FIN-V4.hpp +++ b/tests/mock/select-certificate-script-FIN-V4.hpp @@ -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}}, @@ -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}}, @@ -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}}, @@ -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}},