From 8d20977925ce373417a59053d06080fd3cfb4201 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 10:08:34 +0200 Subject: [PATCH 1/8] fix: report the cause in the reader observer callbacks Two format strings passed one argument more than they had placeholders, so the logger threw from inside the error path, and the cause of an observation error was never printed. --- .../UseCase10_SessionTrace_TN313/CardReaderObserver.cpp | 6 +++--- .../main/UseCase2_ScheduledSelection/CardReaderObserver.cpp | 4 ++-- .../main/UseCase4_ScheduledSelection/CardReaderObserver.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/CardReaderObserver.cpp b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/CardReaderObserver.cpp index 375419f..79fd295 100644 --- a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/CardReaderObserver.cpp +++ b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/CardReaderObserver.cpp @@ -151,7 +151,7 @@ CardReaderObserver::onReaderEvent( } catch (const std::exception& e) { mLogger->error( - "%Transaction failed with exception: %%\n", + "%Transaction failed with exception: % %\n", ANSI_RED, e.what(), ANSI_RESET); @@ -188,8 +188,8 @@ CardReaderObserver::onReaderObservationError( const std::string& readerName, const std::shared_ptr e) { mLogger->error( - "An exception occurred in plugin '%', reader '%'\n", + "An exception occurred in plugin '%', reader '%': %\n", pluginName, readerName, - e); + e ? e->what() : "unknown"); } diff --git a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/CardReaderObserver.cpp b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/CardReaderObserver.cpp index 6fe1e76..82df0b7 100644 --- a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/CardReaderObserver.cpp +++ b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/CardReaderObserver.cpp @@ -88,8 +88,8 @@ CardReaderObserver::onReaderObservationError( const std::string& readerName, const std::shared_ptr e) { mLogger->error( - "An exception occurred in plugin '%', reader '%'\n", + "An exception occurred in plugin '%', reader '%': %\n", pluginName, readerName, - e); + e ? e->what() : "unknown"); } diff --git a/Example_Service/src/main/UseCase4_ScheduledSelection/CardReaderObserver.cpp b/Example_Service/src/main/UseCase4_ScheduledSelection/CardReaderObserver.cpp index 2cf9b50..b7dcf70 100644 --- a/Example_Service/src/main/UseCase4_ScheduledSelection/CardReaderObserver.cpp +++ b/Example_Service/src/main/UseCase4_ScheduledSelection/CardReaderObserver.cpp @@ -76,8 +76,8 @@ CardReaderObserver::onReaderObservationError( const std::string& readerName, const std::shared_ptr e) { mLogger->error( - "An exception occurred in plugin '%', reader '%'\n", + "An exception occurred in plugin '%', reader '%': %\n", pluginName, readerName, - e); + e ? e->what() : "unknown"); } From 9119e5e01b8096c598c3cb9d903740f6c21f7597 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 10:08:35 +0200 Subject: [PATCH 2/8] refactor: catch and report the exceptions escaping the examples Each main is now a runExample() called from a main that catches, logs the message and returns 1. An escaping exception used to reach abort() with exit code 3, no message, and the buffered log lost whenever output was redirected. --- .../Main_SessionTrace_TN313_Pcsc.cpp | 16 +++++++++++++-- .../Main_DataSigning_Pcsc.cpp | 16 +++++++++++++-- ...nceMeasurement_EmbeddedValidation_Pcsc.cpp | 18 ++++++++++++++--- ...eMeasurement_DistributedReloading_Pcsc.cpp | 18 ++++++++++++++--- .../Main_ExplicitSelectionAid_Pcsc.cpp | 16 +++++++++++++-- .../Main_ExplicitSelectionAid_Stub.cpp | 16 +++++++++++++-- .../Main_ScheduledSelection_Pcsc.cpp | 16 +++++++++++++-- .../Main_ScheduledSelection_Stub.cpp | 16 +++++++++++++-- .../Main_Rev1Selection_Pcsc.cpp | 16 +++++++++++++-- .../Main_CardAuthentication_Pcsc.cpp | 16 +++++++++++++-- ...Authentication_Pcsc_SamResourceService.cpp | 16 +++++++++++++-- .../Main_CardAuthentication_Stub.cpp | 16 +++++++++++++-- .../Main_MultipleSession_Pcsc.cpp | 16 +++++++++++++-- .../Main_VerifyPin_Pcsc.cpp | 18 ++++++++++++++--- .../Main_StoredValue_SimpleReloading_Pcsc.cpp | 16 +++++++++++++-- .../Main_StoredValue_DebitInSession_Pcsc.cpp | 16 +++++++++++++-- .../Main_ChangePin_Pcsc.cpp | 20 +++++++++++++++---- ...Main_ReaderTypeAutoIdentification_Pcsc.cpp | 17 ++++++++++++++-- .../Main_ExplicitReaderType_Pcsc.cpp | 17 ++++++++++++++-- .../Main_ChangeProtocolRules_Pcsc.cpp | 17 ++++++++++++++-- .../Main_TransmitControl_Pcsc.cpp | 20 +++++++++++++++---- .../Main_BasicSelection_Pcsc.cpp | 16 +++++++++++++-- .../Main_ProtocolBasedSelection_Pcsc.cpp | 16 +++++++++++++-- .../Main_AidBasedSelection_Pcsc.cpp | 16 +++++++++++++-- .../Main_ScheduledSelection_Pcsc.cpp | 16 +++++++++++++-- .../Main_SequentialMultiSelection_Pcsc.cpp | 16 +++++++++++++-- .../Main_GroupedMultiSelection_Pcsc.cpp | 16 +++++++++++++-- .../Main_PluginAndReaderObservation_Pcsc.cpp | 17 ++++++++++++++-- .../Main_CardResourceService_Stub.cpp | 16 +++++++++++++-- 29 files changed, 417 insertions(+), 65 deletions(-) diff --git a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp index 54da9ce..af95c68 100644 --- a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -303,8 +304,8 @@ initSecuritySetting() { symmetricCryptoSecuritySetting->initCryptoContextForNextTransaction(); } -int -main(int argc, char** argv) { +static int +runExample(int argc, char** argv) { parseCommandLine(argc, argv); logger->info( @@ -381,3 +382,14 @@ main(int argc, char** argv) { return 0; } + +int +main(int argc, char** argv) { + try { + return runExample(argc, argv); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase11_DataSigning/Main_DataSigning_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase11_DataSigning/Main_DataSigning_Pcsc.cpp index 45038f8..7d77f0b 100644 --- a/Example_Card_Calypso/src/main/UseCase11_DataSigning/Main_DataSigning_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase11_DataSigning/Main_DataSigning_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -457,8 +458,8 @@ getInput() { return static_cast(getchar()); } -int -main() { +static int +runExample() { /* Initialize the context */ initKeypleService(); initLegacySamExtensionService(); @@ -497,3 +498,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp index 5afb321..2353307 100644 --- a/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -275,8 +276,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "%=============== Performance measurement: validation transaction " "===============\n", @@ -423,7 +424,7 @@ main() { ->initCryptoContextForNextTransaction(); } catch (const std::exception& e) { logger->info( - "%Transaction failed with exception: %s %\n", + "%Transaction failed with exception: % %\n", ANSI_RED, e.what(), ANSI_RESET); @@ -437,3 +438,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp index de5ccc6..be5e638 100644 --- a/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -278,8 +279,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "%=============== Performance measurement: validation transaction " "===============\n", @@ -415,7 +416,7 @@ main() { ANSI_RESET); } catch (const std::exception& e) { logger->info( - "%Transaction failed with exception: %s %\n", + "%Transaction failed with exception: % %\n", ANSI_RED, e.what(), ANSI_RESET); @@ -429,3 +430,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp index 3216169..e075491 100644 --- a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -148,8 +149,8 @@ initCalypsoCardExtensionService() { calypsoCardApiFactory = calypsoExtensionService->getCalypsoCardApiFactory(); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #1: AID based explicit selection " "==================\n"); @@ -210,3 +211,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Stub.cpp b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Stub.cpp index 5f61383..1a199a4 100644 --- a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Stub.cpp +++ b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Stub.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -156,8 +157,8 @@ initCalypsoCardExtensionService() { calypsoCardApiFactory = calypsoExtensionService->getCalypsoCardApiFactory(); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #1: AID based explicit selection " "==================\n"); @@ -223,3 +224,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp index 9eab46f..e872397 100644 --- a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -130,8 +131,8 @@ initCalypsoCardExtensionService() { calypsoCardApiFactory = calypsoExtensionService->getCalypsoCardApiFactory(); } -int -main() { +static int +runExample() { logger->info( "= UseCase Generic #2: scheduled selection ==================\n"); @@ -200,3 +201,14 @@ main() { Thread::sleep(100); } } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Stub.cpp b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Stub.cpp index 4eae008..047178a 100644 --- a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Stub.cpp +++ b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Stub.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -153,8 +154,8 @@ initCalypsoCardExtensionService() { calypsoCardApiFactory = calypsoExtensionService->getCalypsoCardApiFactory(); } -int -main() { +static int +runExample() { logger->info( "= UseCase Generic #2: scheduled selection ==================\n"); @@ -223,3 +224,14 @@ main() { Thread::sleep(100); } } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp index dd608c5..c7ee111 100644 --- a/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -131,8 +132,8 @@ initCalypsoCardExtensionService() { calypsoCardApiFactory = calypsoExtensionService->getCalypsoCardApiFactory(); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #3: selection of a rev1 card " "==================\n"); @@ -215,3 +216,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp index ecbda78..9cadc2e 100644 --- a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -271,8 +272,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #4: Calypso card authentication " "==================\n"); @@ -333,3 +334,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp index 05a6705..93b2ce9 100644 --- a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp +++ b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -365,8 +366,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #4: Calypso card authentication (Card Resource " "Service) ==================\n"); @@ -418,3 +419,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Stub.cpp b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Stub.cpp index 6247814..9939133 100644 --- a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Stub.cpp +++ b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Stub.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -324,8 +325,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #4: Calypso card authentication (Stub, Card " "Resource Service) ==================\n"); @@ -386,3 +387,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp index 15f90a9..f1710ef 100644 --- a/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -254,8 +255,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #5: multiple sessions ==================\n"); @@ -339,3 +340,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp index 144f0a2..9bb0720 100644 --- a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -101,7 +102,7 @@ static const std::string AID = "315449432E49434131"; static const std::vector PIN_OK = {0x30, 0x30, 0x30, 0x30}; static const std::vector PIN_KO = {0x30, 0x30, 0x30, 0x31}; static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KIF = 0x30; -static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x79; +static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x74; /* The plugin used to manage the readers. */ static std::shared_ptr plugin; @@ -253,8 +254,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #6: Calypso card Verify PIN ==================\n"); @@ -370,3 +371,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp index ce168fc..4da7a0b 100644 --- a/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -247,8 +248,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #7: Stored Value reloading ==================\n"); @@ -317,3 +318,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp index cc05483..bb471ea 100644 --- a/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -248,8 +249,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #8: Stored Value debit ==================\n"); @@ -324,3 +325,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp index 1790adf..87ba120 100644 --- a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -98,9 +99,9 @@ static std::unique_ptr logger static const std::string AID = "315449432E49434131"; static const std::uint8_t PIN_MODIFICATION_CIPHERING_KEY_KIF = 0x21; -static const std::uint8_t PIN_MODIFICATION_CIPHERING_KEY_KVC = 0x79; +static const std::uint8_t PIN_MODIFICATION_CIPHERING_KEY_KVC = 0x74; static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KIF = 0x30; -static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x79; +static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x74; /* The plugin used to manage the readers. */ static std::shared_ptr plugin; @@ -252,8 +253,8 @@ selectCard(std::shared_ptr reader, const std::string& aid) { return std::dynamic_pointer_cast(card); } -int -main() { +static int +runExample() { logger->info( "= UseCase Calypso #9: Calypso card Change PIN ==================\n"); @@ -330,3 +331,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Plugin_PCSC/src/main/UseCase1_ReaderTypeAutoIdentification/Main_ReaderTypeAutoIdentification_Pcsc.cpp b/Example_Plugin_PCSC/src/main/UseCase1_ReaderTypeAutoIdentification/Main_ReaderTypeAutoIdentification_Pcsc.cpp index 7e467be..2574d99 100644 --- a/Example_Plugin_PCSC/src/main/UseCase1_ReaderTypeAutoIdentification/Main_ReaderTypeAutoIdentification_Pcsc.cpp +++ b/Example_Plugin_PCSC/src/main/UseCase1_ReaderTypeAutoIdentification/Main_ReaderTypeAutoIdentification_Pcsc.cpp @@ -11,6 +11,8 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include + #include "keyple/core/service/Plugin.hpp" #include "keyple/core/service/SmartCardService.hpp" #include "keyple/core/service/SmartCardServiceProvider.hpp" @@ -75,8 +77,8 @@ static const std::string contactFilter = ".*Identive.*|" ".*00 00.*|" ".*5x21 0.*"; -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ std::shared_ptr smartCardService = SmartCardServiceProvider::getService(); @@ -103,3 +105,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Plugin_PCSC/src/main/UseCase2_ExplicitReaderType/Main_ExplicitReaderType_Pcsc.cpp b/Example_Plugin_PCSC/src/main/UseCase2_ExplicitReaderType/Main_ExplicitReaderType_Pcsc.cpp index 4c75ac0..b5de508 100644 --- a/Example_Plugin_PCSC/src/main/UseCase2_ExplicitReaderType/Main_ExplicitReaderType_Pcsc.cpp +++ b/Example_Plugin_PCSC/src/main/UseCase2_ExplicitReaderType/Main_ExplicitReaderType_Pcsc.cpp @@ -11,6 +11,8 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include + #include "keyple/core/service/Plugin.hpp" #include "keyple/core/service/SmartCardService.hpp" #include "keyple/core/service/SmartCardServiceProvider.hpp" @@ -62,8 +64,8 @@ class Main_ExplicitReaderType_Pcsc { }; static const std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_ExplicitReaderType_Pcsc)); -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ std::shared_ptr smartCardService = SmartCardServiceProvider::getService(); @@ -97,3 +99,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Plugin_PCSC/src/main/UseCase3_ChangeProtocolRules/Main_ChangeProtocolRules_Pcsc.cpp b/Example_Plugin_PCSC/src/main/UseCase3_ChangeProtocolRules/Main_ChangeProtocolRules_Pcsc.cpp index 476f403..8e6683f 100644 --- a/Example_Plugin_PCSC/src/main/UseCase3_ChangeProtocolRules/Main_ChangeProtocolRules_Pcsc.cpp +++ b/Example_Plugin_PCSC/src/main/UseCase3_ChangeProtocolRules/Main_ChangeProtocolRules_Pcsc.cpp @@ -11,6 +11,8 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include + #include "keyple/card/generic/GenericExtensionService.hpp" #include "keyple/core/common/KeypleCardExtension.hpp" #include "keyple/core/service/Plugin.hpp" @@ -73,8 +75,8 @@ static const std::string READER_PROTOCOL_MIFARE_CLASSIC_4_K = "MIFARE_CLASSIC_4K"; static const std::string CARD_PROTOCOL_MIFARE_CLASSIC_4_K = "MIFARE_CLASSIC_4K"; -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ auto smartCardService(SmartCardServiceProvider::getService()); @@ -156,3 +158,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Plugin_PCSC/src/main/UseCase4_TransmitControl/Main_TransmitControl_Pcsc.cpp b/Example_Plugin_PCSC/src/main/UseCase4_TransmitControl/Main_TransmitControl_Pcsc.cpp index 59d9be8..aca8489 100644 --- a/Example_Plugin_PCSC/src/main/UseCase4_TransmitControl/Main_TransmitControl_Pcsc.cpp +++ b/Example_Plugin_PCSC/src/main/UseCase4_TransmitControl/Main_TransmitControl_Pcsc.cpp @@ -12,6 +12,7 @@ ******************************************************************************/ #include +#include #include #include #include @@ -184,18 +185,18 @@ class CardObserver final : public CardReaderObserverSpi, const std::string& readerName, const std::shared_ptr e) override { logger->error( - "An exception occurred in plugin '%', reader '%'\n", + "An exception occurred in plugin '%', reader '%': %\n", pluginName, readerName, - e); + e ? e->what() : "unknown"); } private: std::shared_ptr mPcscReader; }; -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ std::shared_ptr smartCardService( SmartCardServiceProvider::getService()); @@ -282,3 +283,14 @@ main() { while (1) { } } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp b/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp index 3891cfa..1cf4167 100644 --- a/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp @@ -11,6 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include #include #include "keyple/card/generic/ChannelControl.hpp" @@ -202,8 +203,8 @@ selectCard(std::shared_ptr reader) { return selectionResult->getActiveSmartCard(); } -int -main() { +static int +runExample() { Logger::setLoggerLevel(Logger::Level::logTrace); logger->info("= UseCase Generic #1: basic card selection ==============\n"); @@ -237,3 +238,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp b/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp index d7ea631..1029016 100644 --- a/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp @@ -11,6 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include #include #include @@ -201,8 +202,8 @@ selectCard(std::shared_ptr reader) { return selectionResult->getActiveSmartCard(); } -int -main() { +static int +runExample() { logger->info("= UseCase Generic #2: protocol based card selection " "==================\n"); @@ -231,3 +232,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp b/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp index 9300f0b..d18d3ca 100644 --- a/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp @@ -11,6 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include #include #include "common/ConfigurationUtil.hpp" @@ -82,8 +83,8 @@ class Main_AidBasedSelection_Pcsc { }; const std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_AidBasedSelection_Pcsc)); -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ std::shared_ptr smartCardService( SmartCardServiceProvider::getService()); @@ -180,3 +181,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp b/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp index 2002137..ead21a2 100644 --- a/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp @@ -11,6 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include #include #include "CardReaderObserver.hpp" @@ -73,8 +74,8 @@ class Main_ScheduledSelection_Pcsc { }; const std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_ScheduledSelection_Pcsc)); -int -main() { +static int +runExample() { logger->setLoggerLevel(Logger::Level::logTrace); /* Get the instance of the SmartCardService (singleton pattern) */ @@ -167,3 +168,14 @@ main() { while (true); } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp b/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp index f667ce3..7ca15ec 100644 --- a/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp @@ -11,6 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include #include #include "common/ConfigurationUtil.hpp" @@ -130,8 +131,8 @@ doAndAnalyseSelection( } } -int -main() { +static int +runExample() { logger->setLoggerLevel(Logger::Level::logTrace); /* Get the instance of the SmartCardService (singleton pattern) */ @@ -239,3 +240,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp b/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp index 595d540..884f309 100644 --- a/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp @@ -11,6 +11,7 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include #include #include "common/ConfigurationUtil.hpp" @@ -88,8 +89,8 @@ class Main_GroupedMultiSelection_Pcsc { }; const std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_GroupedMultiSelection_Pcsc)); -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ std::shared_ptr smartCardService( SmartCardServiceProvider::getService()); @@ -213,3 +214,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service/src/main/UseCase7_PluginAndReaderObservation/Main_PluginAndReaderObservation_Pcsc.cpp b/Example_Service/src/main/UseCase7_PluginAndReaderObservation/Main_PluginAndReaderObservation_Pcsc.cpp index a87e3d3..09c8cb3 100644 --- a/Example_Service/src/main/UseCase7_PluginAndReaderObservation/Main_PluginAndReaderObservation_Pcsc.cpp +++ b/Example_Service/src/main/UseCase7_PluginAndReaderObservation/Main_PluginAndReaderObservation_Pcsc.cpp @@ -11,6 +11,8 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include + #include "PluginObserver.hpp" #include "keyple/core/service/ObservablePlugin.hpp" @@ -48,8 +50,8 @@ class Main_PluginAndReaderObservation_Pcsc { }; const std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_PluginAndReaderObservation_Pcsc)); -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ std::shared_ptr smartCardService( SmartCardServiceProvider::getService()); @@ -85,3 +87,14 @@ main() { while (true); } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} diff --git a/Example_Service_Resource/src/main/UseCase1_CardResourceService/Main_CardResourceService_Stub.cpp b/Example_Service_Resource/src/main/UseCase1_CardResourceService/Main_CardResourceService_Stub.cpp index 3be42c2..d3d1c81 100644 --- a/Example_Service_Resource/src/main/UseCase1_CardResourceService/Main_CardResourceService_Stub.cpp +++ b/Example_Service_Resource/src/main/UseCase1_CardResourceService/Main_CardResourceService_Stub.cpp @@ -13,6 +13,7 @@ * SPDX-License-Identifier: BSD-3-Clause * ******************************************************************************/ +#include #include #include #include @@ -226,8 +227,8 @@ getInput() { return static_cast(getchar()); } -int -main() { +static int +runExample() { /* Get the instance of the SmartCardService (singleton pattern) */ std::shared_ptr smartCardService = SmartCardServiceProvider::getService(); @@ -429,3 +430,14 @@ main() { return 0; } + +int +main() { + try { + return runExample(); + + } catch (const std::exception& e) { + logger->error("Example terminated on exception: %\n", e.what()); + return 1; + } +} From 40a83d53ade1132094a14b7acbaec13c45fe4b20 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 13:13:00 +0200 Subject: [PATCH 3/8] chore: point the Calypso examples at the current test card AID Thirteen files including the shared CalypsoConstants. The Service and PC/SC examples keep the previous AID because the cards available for those tests carry the old application, and the four stub files keep it because the simulated card IS that application. --- .../Main_SessionTrace_TN313_Pcsc.cpp | 4 ++-- .../Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp | 2 +- .../Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp | 2 +- .../Main_ExplicitSelectionAid_Pcsc.cpp | 2 +- .../Main_ScheduledSelection_Pcsc.cpp | 2 +- .../Main_CardAuthentication_Pcsc.cpp | 2 +- .../Main_CardAuthentication_Pcsc_SamResourceService.cpp | 2 +- .../UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp | 2 +- .../src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp | 2 +- .../Main_StoredValue_SimpleReloading_Pcsc.cpp | 2 +- .../Main_StoredValue_DebitInSession_Pcsc.cpp | 2 +- .../src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp | 2 +- Example_Card_Calypso/src/main/common/CalypsoConstants.cpp | 2 +- 13 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp index af95c68..c86a7c2 100644 --- a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp @@ -97,7 +97,7 @@ static std::string cardReaderRegex = CARD_READER_NAME_REGEX; static std::string samReaderRegex = SAM_READER_NAME_REGEX; /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; static std::string cardAid = AID; @@ -129,7 +129,7 @@ displayUsageAndExit() { << AID << "\" -c=\"" << CARD_READER_NAME_REGEX << "\" -s=\"" << SAM_READER_NAME_REGEX << "\")" << std::endl; std::cout << " -a, --aid=\"APPLICATION_AID\" between 5 and 16 hex " - "bytes (e.g. \"315449432E49434131\")" + "bytes (e.g. \"A000000291FF9101\")" << std::endl; std::cout << " -c, --card=\"CARD_READER_REGEX\" regular expression " "matching the card reader name (e.g. \"ASK Logo.*\")" diff --git a/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp index 2353307..88876a4 100644 --- a/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp @@ -109,7 +109,7 @@ static const std::string samReaderRegex = ConfigurationUtil::SAM_READER_NAME_REGEX; /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string cardAid = "315449432E49434131"; +static const std::string cardAid = "A000000291FF9101"; static const int counterDecrement = 1; static const std::vector newEventRecord( diff --git a/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp index be5e638..4056745 100644 --- a/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp @@ -110,7 +110,7 @@ static const std::string samReaderRegex = ConfigurationUtil::SAM_READER_NAME_REGEX; /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string cardAid = "315449432E49434131"; +static const std::string cardAid = "A000000291FF9101"; static const int counterIncrement = 1; static const std::vector newContractListRecord( diff --git a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp index e075491..0b75529 100644 --- a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp @@ -87,7 +87,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_ExplicitSelectionAid_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; /* File identifiers */ static const std::uint8_t SFI_ENVIRONMENT_AND_HOLDER = 0x07; diff --git a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp index e872397..601f375 100644 --- a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp @@ -72,7 +72,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_ScheduledSelection_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; /* File identifiers */ static const std::uint8_t SFI_ENVIRONMENT_AND_HOLDER = 0x07; diff --git a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp index 9cadc2e..2255b91 100644 --- a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp @@ -100,7 +100,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_CardAuthentication_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; /* File identifiers */ static const std::uint8_t SFI_ENVIRONMENT_AND_HOLDER = 0x07; diff --git a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp index 93b2ce9..a021bb3 100644 --- a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp +++ b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp @@ -112,7 +112,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger( typeid(Main_CardAuthentication_Pcsc_SamResourceService)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; /* File identifiers */ static const std::uint8_t SFI_ENVIRONMENT_AND_HOLDER = 0x07; diff --git a/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp index f1710ef..c758b80 100644 --- a/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp @@ -97,7 +97,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_MultipleSession_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; /* File identifiers */ static const std::uint8_t SFI_EVENT_LOG = 0x08; diff --git a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp index 9bb0720..f34da6c 100644 --- a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp @@ -97,7 +97,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_VerifyPin_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; static const std::vector PIN_OK = {0x30, 0x30, 0x30, 0x30}; static const std::vector PIN_KO = {0x30, 0x30, 0x30, 0x31}; diff --git a/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp index 4da7a0b..e0b3469 100644 --- a/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp @@ -96,7 +96,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_StoredValue_SimpleReloading_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; /* The plugin used to manage the readers. */ static std::shared_ptr plugin; diff --git a/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp index bb471ea..583786a 100644 --- a/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp @@ -97,7 +97,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_StoredValue_DebitInSession_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; /* The plugin used to manage the readers. */ static std::shared_ptr plugin; diff --git a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp index 87ba120..a78b671 100644 --- a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp @@ -96,7 +96,7 @@ static std::unique_ptr logger = LoggerFactory::getLogger(typeid(Main_ChangePin_Pcsc)); /** AID: Keyple test kit profile 1, Application 2 */ -static const std::string AID = "315449432E49434131"; +static const std::string AID = "A000000291FF9101"; static const std::uint8_t PIN_MODIFICATION_CIPHERING_KEY_KIF = 0x21; static const std::uint8_t PIN_MODIFICATION_CIPHERING_KEY_KVC = 0x74; diff --git a/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp b/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp index 61edb0d..9292fcb 100644 --- a/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp +++ b/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp @@ -12,7 +12,7 @@ #include "CalypsoConstants.h" -const std::string CalypsoConstants::AID = "315449432E49434131"; +const std::string CalypsoConstants::AID = "A000000291FF9101"; const uint8_t CalypsoConstants::RECORD_SIZE = 29; const uint8_t CalypsoConstants::RECORD_NUMBER_1 = 1; From 58b2810897d67b33f729aa46d58f4de862c2faa7 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 13:13:00 +0200 Subject: [PATCH 4/8] fix: do not finalize card processing on an UNAVAILABLE event The guard excluded only CARD_REMOVED, so UNAVAILABLE restarted a monitoring job on a reader being unregistered. This does NOT affect reader reconnection detection, which was a PC/SC plugin matter, and the executor now rejects such a post-shutdown job anyway; the guard keeps the log from showing a card removal sequence starting on a reader that just vanished. --- .../ReaderObserver.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Example_Service/src/main/UseCase7_PluginAndReaderObservation/ReaderObserver.cpp b/Example_Service/src/main/UseCase7_PluginAndReaderObservation/ReaderObserver.cpp index d3c4328..9840546 100644 --- a/Example_Service/src/main/UseCase7_PluginAndReaderObservation/ReaderObserver.cpp +++ b/Example_Service/src/main/UseCase7_PluginAndReaderObservation/ReaderObserver.cpp @@ -30,7 +30,13 @@ ReaderObserver::onReaderEvent(const std::shared_ptr event) { event->getReaderName(), event->getType()); - if (event->getType() != CardReaderEvent::Type::CARD_REMOVED) { + /* + * UNAVAILABLE means the reader itself is gone: there is nothing left to + * finalize, and finalizing would restart a monitoring job on a reader that + * is being unregistered and is about to be destroyed. + */ + if (event->getType() != CardReaderEvent::Type::CARD_REMOVED + && event->getType() != CardReaderEvent::Type::UNAVAILABLE) { std::dynamic_pointer_cast( smartCardService->getPlugin(pluginName) ->getReader(event->getReaderName())) From dcadda458cca80db1947e88c90f9ca94c571e5c9 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 14:47:44 +0200 Subject: [PATCH 5/8] fix: select the Innovatron protocol by the name the plugin registers UseCase3 activated the protocol under the name of the deprecated PcscSupportedContactlessProtocol, whose Innovatron constant carries a _CARD suffix, while the plugin keys its default rules from PcscCardCommunicationProtocol, without the suffix. The activation failed with "The card protocol INNOVATRON_B_PRIME_CARD is not supported". The new rule also matches more ATRs than the old one. --- .../main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp index c7ee111..a74ae9c 100644 --- a/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase3_Rev1Selection/Main_Rev1Selection_Pcsc.cpp @@ -27,7 +27,7 @@ #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" #include "keypop/calypso/card/card/CalypsoCardSelectionExtension.hpp" @@ -52,7 +52,7 @@ using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::card::CalypsoCard; using keypop::calypso::card::card::CalypsoCardSelectionExtension; @@ -116,7 +116,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::INNOVATRON_B_PRIME_CARD.getName(), + PcscCardCommunicationProtocol::INNOVATRON_B_PRIME.getName(), ConfigurationUtil::INNOVATRON_CARD_PROTOCOL); } From 755260a7e262264658ed8070daa59bb2d6919918 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 14:47:44 +0200 Subject: [PATCH 6/8] chore: migrate the examples off the deprecated PC/SC protocol classes 19 contactless ISO_14443_4 and 9 contact ISO_7816_3_T0 call sites moved to PcscCardCommunicationProtocol. Both moves are behaviour-neutral: the contactless name is the same string in both classes, and the three contact rules share the same ATR pattern. One call site keeps the deprecated class on purpose, UseCase2_ProtocolBasedSelection, because MIFARE_CLASSIC does not exist in the current one. --- .../Main_SessionTrace_TN313_Pcsc.cpp | 10 ++++------ ..._PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp | 10 ++++------ ...erformanceMeasurement_DistributedReloading_Pcsc.cpp | 10 ++++------ .../Main_ExplicitSelectionAid_Pcsc.cpp | 6 +++--- .../Main_ScheduledSelection_Pcsc.cpp | 6 +++--- .../Main_CardAuthentication_Pcsc.cpp | 10 ++++------ ...Main_CardAuthentication_Pcsc_SamResourceService.cpp | 6 +++--- .../Main_MultipleSession_Pcsc.cpp | 10 ++++------ .../main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp | 10 ++++------ .../Main_StoredValue_SimpleReloading_Pcsc.cpp | 10 ++++------ .../Main_StoredValue_DebitInSession_Pcsc.cpp | 10 ++++------ .../main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp | 10 ++++------ .../Main_BasicSelection_Pcsc.cpp | 6 +++--- .../Main_ProtocolBasedSelection_Pcsc.cpp | 4 +++- .../Main_AidBasedSelection_Pcsc.cpp | 6 +++--- .../Main_ScheduledSelection_Pcsc.cpp | 6 +++--- .../Main_SequentialMultiSelection_Pcsc.cpp | 6 +++--- .../Main_GroupedMultiSelection_Pcsc.cpp | 6 +++--- .../PluginObserver.cpp | 6 +++--- 19 files changed, 66 insertions(+), 82 deletions(-) diff --git a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp index c86a7c2..8c44251 100644 --- a/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase10_SessionTrace_TN313/Main_SessionTrace_TN313_Pcsc.cpp @@ -29,10 +29,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCardSelectionExtension.hpp" @@ -59,10 +58,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCardSelectionExtension; @@ -219,7 +217,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ISO_CARD_PROTOCOL); } @@ -234,7 +232,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp index 88876a4..0066d2c 100644 --- a/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase12_PerformanceMeasurement_EmbeddedValidation/Main_PerformanceMeasurement_EmbeddedValidation_Pcsc.cpp @@ -30,10 +30,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" @@ -65,10 +64,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCard; @@ -163,7 +161,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -178,7 +176,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp index 4056745..3a15ac5 100644 --- a/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase13_PerformanceMeasurement_DistributedReloading/Main_PerformanceMeasurement_DistributedReloading_Pcsc.cpp @@ -30,10 +30,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" @@ -65,10 +64,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCard; @@ -166,7 +164,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -181,7 +179,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp index 0b75529..c481904 100644 --- a/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase1_ExplicitSelectionAid/Main_ExplicitSelectionAid_Pcsc.cpp @@ -25,9 +25,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" #include "keypop/calypso/card/card/CalypsoCardSelectionExtension.hpp" @@ -48,9 +48,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::card::CalypsoCard; using keypop::calypso::card::card::CalypsoCardSelectionExtension; @@ -133,7 +133,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp index 601f375..cc1d8dc 100644 --- a/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase2_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp @@ -24,9 +24,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/Thread.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/card/CalypsoCardSelectionExtension.hpp" #include "keypop/reader/CardReader.hpp" @@ -45,9 +45,9 @@ using keyple::core::service::SmartCardServiceProvider; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::Thread; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::card::CalypsoCardSelectionExtension; using keypop::reader::CardReader; @@ -115,7 +115,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp index 2255b91..ab2f4ed 100644 --- a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc.cpp @@ -27,10 +27,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" @@ -60,10 +59,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCard; @@ -149,7 +147,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -164,7 +162,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp index a021bb3..d69447e 100644 --- a/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp +++ b/Example_Card_Calypso/src/main/UseCase4_CardAuthentication/Main_CardAuthentication_Pcsc_SamResourceService.cpp @@ -36,9 +36,9 @@ #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/Exception.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" @@ -78,9 +78,9 @@ using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::Exception; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCard; @@ -240,7 +240,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp index c758b80..c07b8bf 100644 --- a/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase5_MultipleSession/Main_MultipleSession_Pcsc.cpp @@ -28,10 +28,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" @@ -61,10 +60,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCard; @@ -145,7 +143,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -160,7 +158,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp index f34da6c..5cc29d2 100644 --- a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp @@ -28,10 +28,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" @@ -63,10 +62,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCard; @@ -144,7 +142,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -159,7 +157,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp index e0b3469..87fd4be 100644 --- a/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase7_StoredValue_SimpleReloading/Main_StoredValue_SimpleReloading_Pcsc.cpp @@ -27,10 +27,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" #include "keypop/calypso/card/card/CalypsoCardSelectionExtension.hpp" @@ -61,10 +60,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::card::CalypsoCard; using keypop::calypso::card::card::CalypsoCardSelectionExtension; @@ -138,7 +136,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -153,7 +151,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp index 583786a..cc6865e 100644 --- a/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase8_StoredValue_DebitInSession/Main_StoredValue_DebitInSession_Pcsc.cpp @@ -27,10 +27,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/WriteAccessLevel.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" @@ -62,10 +61,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::WriteAccessLevel; using keypop::calypso::card::card::CalypsoCard; @@ -139,7 +137,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -154,7 +152,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp index a78b671..d200bb7 100644 --- a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp @@ -31,10 +31,9 @@ #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/Thread.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactProtocol.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/calypso/card/CalypsoCardApiFactory.hpp" #include "keypop/calypso/card/card/CalypsoCard.hpp" #include "keypop/calypso/card/card/CalypsoCardSelectionExtension.hpp" @@ -63,10 +62,9 @@ using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::Thread; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; -using keyple::plugin::pcsc::PcscSupportedContactProtocol; using keypop::calypso::card::CalypsoCardApiFactory; using keypop::calypso::card::card::CalypsoCard; using keypop::calypso::card::card::CalypsoCardSelectionExtension; @@ -143,7 +141,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::SHARED, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } @@ -158,7 +156,7 @@ initSamReader() { false, PcscReader::IsoProtocol::ANY, PcscReader::SharingMode::SHARED, - PcscSupportedContactProtocol::ISO_7816_3_T0.getName(), + PcscCardCommunicationProtocol::ISO_7816_3.getName(), ConfigurationUtil::SAM_PROTOCOL); } diff --git a/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp b/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp index 1cf4167..0e80a45 100644 --- a/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp @@ -22,9 +22,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/reader/CardReader.hpp" #include "keypop/reader/ConfigurableCardReader.hpp" #include "keypop/reader/ReaderApiFactory.hpp" @@ -39,9 +39,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::reader::CardReader; using keypop::reader::ConfigurableCardReader; using keypop::reader::ReaderApiFactory; @@ -169,7 +169,7 @@ initCardReader() { true, PcscReader::IsoProtocol::T1, PcscReader::SharingMode::EXCLUSIVE, - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ISO_CARD_PROTOCOL); } diff --git a/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp b/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp index 1029016..a9bcf6c 100644 --- a/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp @@ -23,6 +23,7 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" #include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" @@ -38,6 +39,7 @@ using keyple::core::service::SmartCardServiceProvider; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; @@ -145,7 +147,7 @@ getReader( .setSharingMode(sharingMode); std::dynamic_pointer_cast(reader)->activateProtocol( - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ISO_CARD_PROTOCOL); std::dynamic_pointer_cast(reader)->activateProtocol( diff --git a/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp b/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp index d18d3ca..275925c 100644 --- a/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp @@ -25,9 +25,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/reader/CardReader.hpp" #include "keypop/reader/ConfigurableCardReader.hpp" #include "keypop/reader/ReaderApiFactory.hpp" @@ -45,9 +45,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::reader::CardReader; using keypop::reader::ConfigurableCardReader; using keypop::reader::ReaderApiFactory; @@ -120,7 +120,7 @@ runExample() { .setSharingMode(PcscReader::SharingMode::SHARED); std::dynamic_pointer_cast(cardReader) ->activateProtocol( - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); logger->info("=============== " diff --git a/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp b/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp index ead21a2..3dec445 100644 --- a/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp @@ -23,9 +23,9 @@ #include "keyple/core/service/SmartCardServiceProvider.hpp" #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/reader/ConfigurableCardReader.hpp" #include "keypop/reader/ObservableCardReader.hpp" #include "keypop/reader/ReaderApiFactory.hpp" @@ -38,9 +38,9 @@ using keyple::core::service::SmartCardService; using keyple::core::service::SmartCardServiceProvider; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::reader::ConfigurableCardReader; using keypop::reader::ObservableCardReader; using keypop::reader::ReaderApiFactory; @@ -115,7 +115,7 @@ runExample() { std::dynamic_pointer_cast(observableCardReader) ->activateProtocol( - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); logger->info("=============== " diff --git a/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp b/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp index 7ca15ec..cacd2dc 100644 --- a/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp @@ -25,9 +25,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/reader/CardReader.hpp" #include "keypop/reader/ConfigurableCardReader.hpp" #include "keypop/reader/ReaderApiFactory.hpp" @@ -46,9 +46,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::reader::CardReader; using keypop::reader::ConfigurableCardReader; using keypop::reader::ReaderApiFactory; @@ -170,7 +170,7 @@ runExample() { .setSharingMode(PcscReader::SharingMode::SHARED); std::dynamic_pointer_cast(cardReader) ->activateProtocol( - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); logger->info("=============== " diff --git a/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp b/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp index 884f309..3c781be 100644 --- a/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp @@ -25,9 +25,9 @@ #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" #include "keyple/core/util/cpp/exception/IllegalStateException.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/reader/CardReader.hpp" #include "keypop/reader/ConfigurableCardReader.hpp" #include "keypop/reader/ReaderApiFactory.hpp" @@ -46,9 +46,9 @@ using keyple::core::util::HexUtil; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; using keyple::core::util::cpp::exception::IllegalStateException; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::reader::CardReader; using keypop::reader::ConfigurableCardReader; using keypop::reader::ReaderApiFactory; @@ -126,7 +126,7 @@ runExample() { .setSharingMode(PcscReader::SharingMode::SHARED); std::dynamic_pointer_cast(cardReader) ->activateProtocol( - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); logger->info("=============== " diff --git a/Example_Service/src/main/UseCase7_PluginAndReaderObservation/PluginObserver.cpp b/Example_Service/src/main/UseCase7_PluginAndReaderObservation/PluginObserver.cpp index 2b9b66c..4788fc9 100644 --- a/Example_Service/src/main/UseCase7_PluginAndReaderObservation/PluginObserver.cpp +++ b/Example_Service/src/main/UseCase7_PluginAndReaderObservation/PluginObserver.cpp @@ -20,14 +20,14 @@ #include "common/ConfigurationUtil.hpp" #include "keyple/core/common/KeypleReaderExtension.hpp" +#include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" -#include "keyple/plugin/pcsc/PcscSupportedContactlessProtocol.hpp" #include "keypop/reader/ConfigurableCardReader.hpp" #include "keypop/reader/ObservableCardReader.hpp" using keyple::core::common::KeypleReaderExtension; +using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscReader; -using keyple::plugin::pcsc::PcscSupportedContactlessProtocol; using keypop::reader::ConfigurableCardReader; using keypop::reader::ObservableCardReader; @@ -135,7 +135,7 @@ PluginObserver::setupReader(std::shared_ptr cardReader) { auto configurable = std::dynamic_pointer_cast(cardReader); configurable->activateProtocol( - PcscSupportedContactlessProtocol::ISO_14443_4.getName(), + PcscCardCommunicationProtocol::ISO_14443_4.getName(), ConfigurationUtil::ISO_CARD_PROTOCOL); } From 8e5f8e2d45e9dd320ccf163151a0d664e4b92535 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 14:47:45 +0200 Subject: [PATCH 7/8] fix: take the PIN key references from the shared constants UseCase6 and UseCase9 each declared their own copies of the PIN key references and PIN values, and those copies had drifted away from common/CalypsoConstants, which was until now used by nobody but its own translation unit. Both examples now take the four references from it. One of the four was wrong there: the verification ciphering key carried KVC 79h where the card under test expects 74h, the value both examples shipped. An encrypted Verify PIN answered 63C2, read as a wrong PIN, although the same PIN succeeded in plain form on the line above. With 74h in the shared file, UseCase6 runs its five steps and the attempt counter goes 3, 3, 2, 2, 3 as expected. The modification ciphering key keeps the 21h/79h of the shared file. Note that Change PIN still answers 6988, incorrect cryptogram, with that pair as well as with the 21h/74h the examples shipped, so neither value matches the key this card expects and the right one is still unknown. That is a separate question from the de-duplication done here. --- .../Main_VerifyPin_Pcsc.cpp | 21 ++++++++++--------- .../Main_ChangePin_Pcsc.cpp | 13 +++++------- .../src/main/common/CalypsoConstants.cpp | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp index 5cc29d2..329113c 100644 --- a/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase6_VerifyPin/Main_VerifyPin_Pcsc.cpp @@ -50,6 +50,7 @@ #include "keypop/reader/selection/IsoCardSelector.hpp" #include "keypop/reader/selection/spi/SmartCard.hpp" +#include "../common/CalypsoConstants.h" #include "../common/ConfigurationUtil.hpp" using keyple::card::calypso::CalypsoExtensionService; @@ -97,10 +98,6 @@ static std::unique_ptr logger /** AID: Keyple test kit profile 1, Application 2 */ static const std::string AID = "A000000291FF9101"; -static const std::vector PIN_OK = {0x30, 0x30, 0x30, 0x30}; -static const std::vector PIN_KO = {0x30, 0x30, 0x30, 0x31}; -static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KIF = 0x30; -static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x74; /* The plugin used to manage the readers. */ static std::shared_ptr plugin; @@ -285,14 +282,15 @@ runExample() { cardReader, calypsoCard)); /* Verify the PIN in plain mode without initiating a secure session */ - freeTransactionManager->prepareVerifyPin(PIN_OK).processCommands( - ChannelControl::KEEP_OPEN); + freeTransactionManager->prepareVerifyPin(CalypsoConstants::PIN_OK) + .processCommands(ChannelControl::KEEP_OPEN); logger->info( "Remaining attempts #1: %\n", calypsoCard->getPinAttemptRemaining()); /* Add the key identifiers needed for ciphering the PIN */ symmetricCryptoSecuritySetting->setPinVerificationCipheringKey( - PIN_VERIFICATION_CIPHERING_KEY_KIF, PIN_VERIFICATION_CIPHERING_KEY_KVC); + CalypsoConstants::PIN_VERIFICATION_CIPHERING_KEY_KIF, + CalypsoConstants::PIN_VERIFICATION_CIPHERING_KEY_KVC); /* * Instantiate a Secure Regular Mode Transaction Manager to handle @@ -316,7 +314,8 @@ runExample() { secureRegularModeTransactionManagerBase.get()); /* Verify the PIN in encrypted mode, outside a secure session */ - secureRegularModeTransactionManager->prepareVerifyPin(PIN_OK) + secureRegularModeTransactionManager + ->prepareVerifyPin(CalypsoConstants::PIN_OK) .processCommands(ChannelControl::KEEP_OPEN); /* Log the current counter value (should be 3) */ @@ -330,7 +329,8 @@ runExample() { secureRegularModeTransactionManager->prepareOpenSecureSession( WriteAccessLevel::DEBIT); try { - secureRegularModeTransactionManager->prepareVerifyPin(PIN_KO) + secureRegularModeTransactionManager + ->prepareVerifyPin(CalypsoConstants::PIN_KO) .processCommands(ChannelControl::KEEP_OPEN); } catch (const InvalidPinException& ex) { logger->error("PIN Exception: %\n", ex.what()); @@ -353,7 +353,8 @@ runExample() { logger->info( "Remaining attempts #4: %\n", calypsoCard->getPinAttemptRemaining()); - secureRegularModeTransactionManager->prepareVerifyPin(PIN_OK) + secureRegularModeTransactionManager + ->prepareVerifyPin(CalypsoConstants::PIN_OK) .prepareCloseSecureSession() .processCommands(ChannelControl::CLOSE_AFTER); diff --git a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp index d200bb7..c2ce62d 100644 --- a/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp +++ b/Example_Card_Calypso/src/main/UseCase9_ChangePin/Main_ChangePin_Pcsc.cpp @@ -49,6 +49,7 @@ #include "keypop/reader/selection/IsoCardSelector.hpp" #include "keypop/reader/selection/spi/SmartCard.hpp" +#include "../common/CalypsoConstants.h" #include "../common/ConfigurationUtil.hpp" using keyple::card::calypso::CalypsoExtensionService; @@ -96,10 +97,6 @@ static std::unique_ptr logger /** AID: Keyple test kit profile 1, Application 2 */ static const std::string AID = "A000000291FF9101"; -static const std::uint8_t PIN_MODIFICATION_CIPHERING_KEY_KIF = 0x21; -static const std::uint8_t PIN_MODIFICATION_CIPHERING_KEY_KVC = 0x74; -static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KIF = 0x30; -static const std::uint8_t PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x74; /* The plugin used to manage the readers. */ static std::shared_ptr plugin; @@ -280,11 +277,11 @@ runExample() { /* Add the key identifiers needed for ciphering the PIN */ symmetricCryptoSecuritySetting ->setPinVerificationCipheringKey( - PIN_VERIFICATION_CIPHERING_KEY_KIF, - PIN_VERIFICATION_CIPHERING_KEY_KVC) + CalypsoConstants::PIN_VERIFICATION_CIPHERING_KEY_KIF, + CalypsoConstants::PIN_VERIFICATION_CIPHERING_KEY_KVC) .setPinModificationCipheringKey( - PIN_MODIFICATION_CIPHERING_KEY_KIF, - PIN_MODIFICATION_CIPHERING_KEY_KVC); + CalypsoConstants::PIN_MODIFICATION_CIPHERING_KEY_KIF, + CalypsoConstants::PIN_MODIFICATION_CIPHERING_KEY_KVC); /* * Instantiate a Secure Regular Mode Transaction Manager to handle diff --git a/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp b/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp index 9292fcb..55d1ccc 100644 --- a/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp +++ b/Example_Card_Calypso/src/main/common/CalypsoConstants.cpp @@ -35,7 +35,7 @@ const std::string CalypsoConstants::SAM_PROFILE_NAME = "SAM C1"; const uint8_t CalypsoConstants::PIN_MODIFICATION_CIPHERING_KEY_KIF = 0x21; const uint8_t CalypsoConstants::PIN_MODIFICATION_CIPHERING_KEY_KVC = 0x79; const uint8_t CalypsoConstants::PIN_VERIFICATION_CIPHERING_KEY_KIF = 0x30; -const uint8_t CalypsoConstants::PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x79; +const uint8_t CalypsoConstants::PIN_VERIFICATION_CIPHERING_KEY_KVC = 0x74; const std::vector CalypsoConstants::PIN_OK = {0x30, 0x30, 0x30, 0x30}; const std::vector CalypsoConstants::PIN_KO = {0x30, 0x30, 0x30, 0x31}; From 15c890d3ab0ff17f210985076372628832e4dd77 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Fortune Date: Fri, 11 Sep 2026 14:59:42 +0200 Subject: [PATCH 8/8] fix: check findReader for null before dereferencing the reader findReader returns null when no reader name matches the regex, where the Java original throws. Every caller in the examples then called getName() on that null pointer, so a missing or renamed reader ended in an access violation with no diagnostic at all, the try/catch wrapper seeing no exception to report. Guard the seven call sites with an IllegalStateException naming the regex that matched nothing. The Calypso helper covers the twelve Calypso examples at once, for the card reader and the SAM reader alike. In UseCase4 the test also covers a reader found but not observable, since it applies to the result of the cast to ObservableCardReader. --- .../src/main/common/ConfigurationUtil.cpp | 7 +++++++ .../UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp | 5 +++++ .../Main_ProtocolBasedSelection_Pcsc.cpp | 5 +++++ .../Main_AidBasedSelection_Pcsc.cpp | 7 +++++++ .../Main_ScheduledSelection_Pcsc.cpp | 9 +++++++++ .../Main_SequentialMultiSelection_Pcsc.cpp | 7 +++++++ .../Main_GroupedMultiSelection_Pcsc.cpp | 7 +++++++ 7 files changed, 47 insertions(+) diff --git a/Example_Card_Calypso/src/main/common/ConfigurationUtil.cpp b/Example_Card_Calypso/src/main/common/ConfigurationUtil.cpp index 38194e8..91a5155 100644 --- a/Example_Card_Calypso/src/main/common/ConfigurationUtil.cpp +++ b/Example_Card_Calypso/src/main/common/ConfigurationUtil.cpp @@ -16,8 +16,10 @@ #include #include +#include "keyple/core/util/cpp/exception/IllegalStateException.hpp" #include "keypop/reader/ConfigurableCardReader.hpp" +using keyple::core::util::cpp::exception::IllegalStateException; using keypop::reader::ConfigurableCardReader; const std::string ConfigurationUtil::ISO_CARD_PROTOCOL = "ISO_14443_4_CARD"; @@ -41,6 +43,11 @@ ConfigurationUtil::getReader( const std::string& logicalProtocolName) { std::shared_ptr reader(plugin->findReader(readerNameRegex)); + if (reader == nullptr) { + throw IllegalStateException( + "No reader matching the regex '" + readerNameRegex + "' was found"); + } + std::dynamic_pointer_cast( plugin->getReaderExtension(typeid(PcscReader), reader->getName())) ->setContactless(isContactless) diff --git a/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp b/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp index 0e80a45..c95a59b 100644 --- a/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase1_BasicSelection/Main_BasicSelection_Pcsc.cpp @@ -142,6 +142,11 @@ getReader( const std::string& logicalProtocolName) { const auto reader(_plugin->findReader(readerNameRegex)); + if (reader == nullptr) { + throw IllegalStateException( + "No reader matching the regex '" + readerNameRegex + "' was found"); + } + auto pcscReader(std::dynamic_pointer_cast( _plugin->getReaderExtension(typeid(PcscReader), reader->getName()))); diff --git a/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp b/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp index a9bcf6c..0bf4e17 100644 --- a/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase2_ProtocolBasedSelection/Main_ProtocolBasedSelection_Pcsc.cpp @@ -139,6 +139,11 @@ getReader( const PcscReader::SharingMode sharingMode) { const auto reader(_plugin->findReader(readerNameRegex)); + if (reader == nullptr) { + throw IllegalStateException( + "No reader matching the regex '" + readerNameRegex + "' was found"); + } + auto pcscReader(std::dynamic_pointer_cast( _plugin->getReaderExtension(typeid(PcscReader), reader->getName()))); diff --git a/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp b/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp index 275925c..1192e42 100644 --- a/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase3_AidBasedSelection/Main_AidBasedSelection_Pcsc.cpp @@ -110,6 +110,13 @@ runExample() { std::shared_ptr cardReader( plugin->findReader(ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX)); + if (cardReader == nullptr) { + throw IllegalStateException( + "No reader matching the regex '" + + ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX + + "' was found"); + } + /* * Configure the reader with parameters suitable for contactless operations. */ diff --git a/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp b/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp index 3dec445..ab6495e 100644 --- a/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase4_ScheduledSelection/Main_ScheduledSelection_Pcsc.cpp @@ -23,6 +23,7 @@ #include "keyple/core/service/SmartCardServiceProvider.hpp" #include "keyple/core/util/cpp/Logger.hpp" #include "keyple/core/util/cpp/LoggerFactory.hpp" +#include "keyple/core/util/cpp/exception/IllegalStateException.hpp" #include "keyple/plugin/pcsc/PcscCardCommunicationProtocol.hpp" #include "keyple/plugin/pcsc/PcscPluginFactoryBuilder.hpp" #include "keyple/plugin/pcsc/PcscReader.hpp" @@ -38,6 +39,7 @@ using keyple::core::service::SmartCardService; using keyple::core::service::SmartCardServiceProvider; using keyple::core::util::cpp::Logger; using keyple::core::util::cpp::LoggerFactory; +using keyple::core::util::cpp::exception::IllegalStateException; using keyple::plugin::pcsc::PcscCardCommunicationProtocol; using keyple::plugin::pcsc::PcscPluginFactoryBuilder; using keyple::plugin::pcsc::PcscReader; @@ -103,6 +105,13 @@ runExample() { auto observableCardReader = std::dynamic_pointer_cast( plugin->findReader(ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX)); + if (observableCardReader == nullptr) { + throw IllegalStateException( + "No reader matching the regex '" + + ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX + + "' was found"); + } + /* * Configure the reader with parameters suitable for contactless operations. */ diff --git a/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp b/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp index cacd2dc..164c791 100644 --- a/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase5_SequentialMultiSelection/Main_SequentialMultiSelection_Pcsc.cpp @@ -160,6 +160,13 @@ runExample() { std::shared_ptr cardReader( plugin->findReader(ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX)); + if (cardReader == nullptr) { + throw IllegalStateException( + "No reader matching the regex '" + + ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX + + "' was found"); + } + /* * Configure the reader with parameters suitable for contactless operations. */ diff --git a/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp b/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp index 3c781be..09dfb69 100644 --- a/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp +++ b/Example_Service/src/main/UseCase6_GroupedMultiSelection/Main_GroupedMultiSelection_Pcsc.cpp @@ -116,6 +116,13 @@ runExample() { std::shared_ptr cardReader( plugin->findReader(ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX)); + if (cardReader == nullptr) { + throw IllegalStateException( + "No reader matching the regex '" + + ConfigurationUtil::CONTACTLESS_READER_NAME_REGEX + + "' was found"); + } + /* * Configure the reader with parameters suitable for contactless operations. */