Keypop Calypso Card C++ API - 2.2.0
Component of the Keypop C++ API
CalypsoCard.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2025 Calypso Networks Association https://calypsonet.org/ *
3 * *
4 * This program and the accompanying materials are made available under the *
5 * terms of the MIT License which is available at *
6 * https://opensource.org/licenses/MIT. *
7 * *
8 * SPDX-License-Identifier: MIT *
9 ******************************************************************************/
10
11#pragma once
12
13#include <cstdint>
14#include <map>
15#include <memory>
16#include <ostream>
17#include <string>
18#include <vector>
19
24#include "keypop/reader/selection/spi/IsoSmartCard.hpp"
25
26namespace keypop {
27namespace calypso {
28namespace card {
29namespace card {
30
31using keypop::reader::selection::spi::IsoSmartCard;
32
58class CalypsoCard : public IsoSmartCard {
59public:
65 enum class ProductType {
72
79
86
92 LIGHT,
93
99 BASIC,
100
107 UNKNOWN
108 };
109
116 virtual const ProductType& getProductType() const = 0;
117
124 virtual bool isHce() const = 0;
125
143 virtual bool isDfInvalidated() const = 0;
144
161 virtual const std::vector<uint8_t>& getDfName() const = 0;
162
170 virtual const std::vector<uint8_t> getApplicationSerialNumber() const = 0;
171
178 virtual const std::vector<uint8_t>& getStartupInfoRawData() const = 0;
179
186 virtual uint8_t getPlatform() const = 0;
187
195 virtual uint8_t getApplicationType() const = 0;
196
204 virtual uint8_t getApplicationSubtype() const = 0;
205
213 virtual uint8_t getSoftwareIssuer() const = 0;
214
222 virtual uint8_t getSoftwareVersion() const = 0;
223
231 virtual uint8_t getSoftwareRevision() const = 0;
232
243 virtual uint8_t getSessionModification() const = 0;
244
256 virtual const std::vector<uint8_t> getTraceabilityInformation() const = 0;
257
267 virtual const std::vector<std::uint8_t>& getCardPublicKey() const = 0;
268
278 virtual const std::vector<std::uint8_t>& getCardCertificate() const = 0;
279
289 virtual const std::vector<std::uint8_t>& getCaCertificate() const = 0;
290
301 virtual const std::shared_ptr<DirectoryHeader> getDirectoryHeader() const
302 = 0;
303
316 virtual const std::shared_ptr<ElementaryFile>
317 getFileBySfi(const uint8_t sfi) const = 0;
318
331 virtual const std::shared_ptr<ElementaryFile>
332 getFileByLid(const uint16_t lid) const = 0;
333
345 virtual const std::vector<std::shared_ptr<ElementaryFile>>& getFiles() const
346 = 0;
347
359 virtual bool isDfRatified() const = 0;
360
380 virtual int getTransactionCounter() const = 0;
381
391 virtual bool isPkiModeSupported() const = 0;
392
405 virtual bool isExtendedModeSupported() const = 0;
406
416 virtual bool isRatificationOnDeselectSupported() const = 0;
417
426 virtual bool isPinFeatureAvailable() const = 0;
427
438 virtual bool isPinBlocked() const = 0;
439
450 virtual int getPinAttemptRemaining() const = 0;
451
460 virtual bool isSvFeatureAvailable() const = 0;
461
477 virtual int getSvBalance() const = 0;
478
494 virtual int getSvLastTNum() const = 0;
495
510 virtual const std::shared_ptr<SvLoadLogRecord> getSvLoadLogRecord() = 0;
511
526 virtual const std::shared_ptr<SvDebitLogRecord> getSvDebitLogLastRecord()
527 = 0;
528
544 virtual const std::vector<std::shared_ptr<SvDebitLogRecord>>
546
548 inline operator std::string();
549};
550
551inline std::ostream&
552operator<<(std::ostream& os, const CalypsoCard::ProductType& pt) {
553 os << "PRODUCT_TYPE: ";
554
555 switch (pt) {
557 os << "BASIC";
558 break;
560 os << "LIGHT";
561 break;
563 os << "PRIME_REVISION_1";
564 break;
566 os << "PRIME_REVISION_2";
567 break;
569 os << "PRIME_REVISION_3";
570 break;
571 default:
572 os << "UNKNOWN";
573 break;
574 }
575
576 return os;
577}
578
579} /* namespace card */
580} /* namespace card */
581} /* namespace calypso */
582} /* namespace keypop */
Extends the IsoSmartCard interface of the "Keypop Reader API" to provide additional functionality spe...
Definition: CalypsoCard.hpp:58
virtual const std::shared_ptr< ElementaryFile > getFileByLid(const uint16_t lid) const =0
Returns a reference to the ElementaryFile that has the provided LID value.
virtual const std::vector< std::uint8_t > & getCaCertificate() const =0
Returns the CA certificate.
virtual bool isDfInvalidated() const =0
Tells if the current DF is invalidated or not.
virtual const std::vector< std::uint8_t > & getCardCertificate() const =0
Returns the card certificate.
ProductType
All Calypso Card products supported by this API.
Definition: CalypsoCard.hpp:65
@ PRIME_REVISION_1
Card Calypso Prime revision 1.x.
@ UNKNOWN
Application type is equal to 0 or FFh or if the data provided by the selection process is not properl...
@ PRIME_REVISION_2
Card Calypso Prime revision 2.x.
@ PRIME_REVISION_3
Card Calypso Prime revision 3.x.
virtual int getPinAttemptRemaining() const =0
Gives the number of erroneous PIN presentations remaining before blocking.
virtual const std::vector< uint8_t > & getDfName() const =0
Gets the DF name as an array of bytes.
virtual uint8_t getApplicationSubtype() const =0
Gets the Application Subtype that provides a reference to the file structure of the Calypso DF.
virtual const std::vector< uint8_t > getApplicationSerialNumber() const =0
Gets the Calypso application serial number as an array of bytes.
virtual const ProductType & getProductType() const =0
Gets the card product type.
virtual const std::shared_ptr< SvLoadLogRecord > getSvLoadLogRecord()=0
Gets a reference to the last SvLoadLogRecord.
virtual uint8_t getPlatform() const =0
Gets the platform identification byte which is the reference of the chip.
virtual int getTransactionCounter() const =0
Returns the transaction counter value provided in the output data of the last successful "Open Secure...
virtual bool isExtendedModeSupported() const =0
Indicates whether the Extended Mode is supported or not (since rev 3.2).
virtual int getSvBalance() const =0
Gets the current SV balance value.
virtual bool isPkiModeSupported() const =0
Indicates whether the Public Key Authentication is supported or not (since rev 3.3).
virtual const std::shared_ptr< SvDebitLogRecord > getSvDebitLogLastRecord()=0
Gets a reference to the last SvDebitLogRecord.
virtual const std::vector< uint8_t > getTraceabilityInformation() const =0
Gets the traceability information of the product.
virtual bool isHce() const =0
Indicates if the card is a Calypso HCE (Host Card Emulation) .
virtual const std::vector< std::uint8_t > & getCardPublicKey() const =0
Returns the card public key.
virtual bool isSvFeatureAvailable() const =0
Indicates whether the card has the Calypso Stored Value feature.
virtual const std::shared_ptr< ElementaryFile > getFileBySfi(const uint8_t sfi) const =0
Returns a reference to the ElementaryFile that has the provided SFI.
virtual const std::vector< std::shared_ptr< SvDebitLogRecord > > getSvDebitLogAllRecords() const =0
Gets list of references to the SvDebitLogRecord read from the card.
virtual uint8_t getSoftwareVersion() const =0
Gets the Software Version field that may be set to any fixed value by the Software Issuer of the Caly...
virtual bool isDfRatified() const =0
Tells if the last session with this card has been ratified or not.
virtual const std::vector< uint8_t > & getStartupInfoRawData() const =0
Gets the raw Calypso startup information.
virtual int getSvLastTNum() const =0
Gets the last SV transaction number.
virtual const std::shared_ptr< DirectoryHeader > getDirectoryHeader() const =0
Returns the metadata of the current DF.
virtual uint8_t getApplicationType() const =0
Gets the Application Type byte which determines the Calypso product type and various options.
virtual uint8_t getSoftwareRevision() const =0
Gets the Software Revision field that may be set to any fixed value by the Software Issuer of the Cal...
virtual bool isPinBlocked() const =0
Indicates if the PIN is blocked.
virtual uint8_t getSoftwareIssuer() const =0
Gets the Software Issuer byte that indicates the entity responsible for the software of the selected ...
virtual uint8_t getSessionModification() const =0
Gets the session modification byte from the startup info structure.
virtual bool isPinFeatureAvailable() const =0
Indicates whether the card has the Calypso PIN feature.
virtual bool isRatificationOnDeselectSupported() const =0
Indicates if the ratification is done on deselect (ratification command not necessary).
virtual const std::vector< std::shared_ptr< ElementaryFile > > & getFiles() const =0
Returns a reference to the set of all known Elementary Files contains inside the current DF.
std::ostream & operator<<(std::ostream &os, const CalypsoCard::ProductType &pt)