From 5515af4b9f7b556528156476f24adabf311929b0 Mon Sep 17 00:00:00 2001 From: Mart Somermaa Date: Sat, 12 Jun 2021 00:12:11 +0300 Subject: [PATCH] refactor(verify-pin): remove VerifyPinFailed::Status::UNKNOWN_ERROR, use SmartCardError instead Signed-off-by: Mart Somermaa --- include/electronic-id/electronic-id.hpp | 5 ++--- src/electronic-ids/pcsc/pcsc-common.hpp | 4 ++-- tests/mock/select-certificate-script-EST-GEMALTO.hpp | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/electronic-id/electronic-id.hpp b/include/electronic-id/electronic-id.hpp index 8d612bb..715626f 100644 --- a/include/electronic-id/electronic-id.hpp +++ b/include/electronic-id/electronic-id.hpp @@ -212,9 +212,8 @@ class VerifyPinFailed : public Error INVALID_PIN_LENGTH, PIN_ENTRY_TIMEOUT, PIN_ENTRY_CANCEL, - // Retry not allowed starting from PIN_BLOCKED. - PIN_BLOCKED, - UNKNOWN_ERROR + // Retry not allowed in case of PIN_BLOCKED. + PIN_BLOCKED }; explicit VerifyPinFailed(const Status s, diff --git a/src/electronic-ids/pcsc/pcsc-common.hpp b/src/electronic-ids/pcsc/pcsc-common.hpp index 8113f96..5a98205 100644 --- a/src/electronic-ids/pcsc/pcsc-common.hpp +++ b/src/electronic-ids/pcsc/pcsc-common.hpp @@ -114,8 +114,8 @@ inline void verifyPin(pcsc_cpp::SmartCard& card, pcsc_cpp::byte_vector::value_ty // (re-entered PIN is different) that only apply during PIN change, we treat them as unknown // errors here. - // Other unknown errors. - throw VerifyPinFailed(VerifyPinFailed::Status::UNKNOWN_ERROR, &response); + THROW(SmartCardError, + "Command VERIFY PIN failed with error " + pcsc_cpp::bytes2hexstr(response.toBytes())); } inline pcsc_cpp::byte_vector internalAuthenticate(pcsc_cpp::SmartCard& card, diff --git a/tests/mock/select-certificate-script-EST-GEMALTO.hpp b/tests/mock/select-certificate-script-EST-GEMALTO.hpp index 2eb615a..430c8a2 100644 --- a/tests/mock/select-certificate-script-EST-GEMALTO.hpp +++ b/tests/mock/select-certificate-script-EST-GEMALTO.hpp @@ -182,7 +182,7 @@ const PcscMock::ApduScript ESTEID_GEMALTO_V3_5_8_GET_AUTH_CERTIFICATE_AND_AUTHEN // Get retry count {{0x00, 0xb2, 0x01, 0x04}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x90, 0x00}}, // FIXME: get correct result + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x90, 0x00}}, // TODO: get correct result // 3. Authenticate. // Verify PIN. @@ -199,7 +199,7 @@ const PcscMock::ApduScript ESTEID_GEMALTO_V3_5_8_GET_SIGN_CERTIFICATE_AND_SIGNIN {{0x00, 0xa4, 0x00, 0x0c}, {0x90, 0x00}}, // Select EE directory. {{0x00, 0xa4, 0x01, 0x0c, 0x02, 0xee, 0xee}, {0x90, 0x00}}, - // Select authentication certificate file. + // Select signing certificate file. {{0x00, 0xa4, 0x02, 0x0c, 0x02, 0xdd, 0xce}, {0x90, 0x00}}, // Read data length. @@ -342,7 +342,7 @@ const PcscMock::ApduScript ESTEID_GEMALTO_V3_5_8_GET_SIGN_CERTIFICATE_AND_SIGNIN // Get retry count {{0x00, 0xb2, 0x02, 0x04}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x90, 0x00}}, // FIXME: get correct result + {0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x90, 0x00}}, // TODO: get correct result // 3. Signing. // Verify PIN.