22#include "CalypsoCard.h"
23#include "DirectoryHeader.h"
24#include "ElementaryFile.h"
27#include "ApduResponseApi.h"
28#include "SmartCardSpi.h"
36#include "LoggerFactory.h"
43using namespace calypsonet::terminal::calypso::card;
44using namespace calypsonet::terminal::card;
45using namespace calypsonet::terminal::card::spi;
46using namespace keyple::core::util::cpp;
73 void initializeWithPowerOnData(
const std::string& powerOnData);
83 void initializeWithFci(
const std::shared_ptr<ApduResponseApi> selectApplicationResponse);
97 bool isHce()
const override;
104 const std::vector<uint8_t>& getDfName()
const override;
117 const std::vector<uint8_t>& getCalypsoSerialNumberFull()
const;
124 const std::vector<uint8_t> getApplicationSerialNumber()
const override;
131 const std::vector<uint8_t>& getStartupInfoRawData()
const override;
140 uint8_t getPayloadCapacity()
const;
152 bool isModificationsCounterInBytes()
const;
164 int getModificationsCounter()
const;
171 uint8_t getPlatform()
const override;
178 uint8_t getApplicationType()
const override;
185 bool isExtendedModeSupported()
const override;
192 bool isRatificationOnDeselectSupported()
const override;
199 bool isSvFeatureAvailable()
const override;
206 bool isPinFeatureAvailable()
const override;
213 bool isPkiModeSupported()
const override;
220 uint8_t getApplicationSubtype()
const override;
227 uint8_t getSoftwareIssuer()
const override;
234 uint8_t getSoftwareVersion()
const override;
241 uint8_t getSoftwareRevision()
const override;
248 uint8_t getSessionModification()
const override;
255 const std::vector<uint8_t> getTraceabilityInformation()
const override;
262 bool isDfInvalidated()
const override;
269 bool isDfRatified()
const override;
276 int getTransactionCounter()
const override;
285 void setTransactionCounter(
const int transactionCounter);
300 void setSvData(
const uint8_t svKvc,
301 const std::vector<uint8_t>& svGetHeader,
302 const std::vector<uint8_t>& svGetData,
304 const int svLastTNum,
305 const std::shared_ptr<SvLoadLogRecord> svLoadLogRecord,
306 const std::shared_ptr<SvDebitLogRecord> svDebitLogRecord);
313 int getSvBalance()
const override;
320 int getSvLastTNum()
const override;
327 const std::shared_ptr<SvLoadLogRecord> getSvLoadLogRecord()
override;
334 const std::shared_ptr<SvDebitLogRecord> getSvDebitLogLastRecord()
override;
341 const std::vector<std::shared_ptr<SvDebitLogRecord>> getSvDebitLogAllRecords()
const override;
350 void setDfRatified(
const bool dfRatified);
366 const std::shared_ptr<DirectoryHeader> getDirectoryHeader()
const override;
377 CalypsoCard& setDirectoryHeader(
const std::shared_ptr<DirectoryHeader> directoryHeader);
384 const std::shared_ptr<ElementaryFile> getFileBySfi(
const uint8_t sfi)
const override;
391 const std::shared_ptr<ElementaryFile> getFileByLid(
const uint16_t lid)
const override;
399 const std::map<const uint8_t, const std::shared_ptr<ElementaryFile>> getAllFiles()
const
407 const std::vector<std::shared_ptr<ElementaryFile>>& getFiles()
const override;
414 bool isPinBlocked()
const override;
421 int getPinAttemptRemaining()
const override;
432 void setPinAttemptRemaining(
const int pinAttemptCounter);
443 void setFileHeader(
const uint8_t sfi,
const std::shared_ptr<FileHeaderAdapter> header);
456 void setContent(
const uint8_t sfi,
457 const uint8_t numRecord,
458 const std::vector<uint8_t>& content);
470 void setCounter(
const uint8_t sfi,
const uint8_t numCounter,
const std::vector<uint8_t>& content);
486 void setContent(
const uint8_t sfi,
487 const uint8_t numRecord,
488 const std::vector<uint8_t>& content,
489 const uint8_t offset);
504 void fillContent(
const uint8_t sfi,
505 const uint8_t numRecord,
506 const std::vector<uint8_t>& content,
507 const uint8_t offset);
521 void addCyclicContent(
const uint8_t sfi,
const std::vector<uint8_t> content);
547 const std::string& getPowerOnData()
const override;
554 const std::vector<uint8_t> getSelectApplicationResponse()
const override;
563 void setCardChallenge(
const std::vector<uint8_t>& cardChallenge);
573 void setTraceabilityInformation(
const std::vector<uint8_t>& traceabilityInformation);
582 void setSvOperationSignature(
const std::vector<uint8_t>& svOperationSignature);
592 const std::vector<uint8_t>& getCardChallenge()
const;
601 uint8_t getSvKvc()
const;
611 const std::vector<uint8_t>& getSvGetHeader()
const;
621 const std::vector<uint8_t>& getSvGetData()
const;
630 const std::vector<uint8_t>& getSvOperationSignature()
const;
642 std::ostream& os,
const std::shared_ptr<CalypsoCardAdapter> cca);
648 const std::unique_ptr<Logger> mLogger = LoggerFactory::getLogger(
typeid(
CalypsoCardAdapter));
653 static const std::string PATTERN_1_BYTE_HEX;
654 static const std::string PATTERN_2_BYTES_HEX;
659 static const int CARD_REV1_ATR_LENGTH;
660 static const int REV1_CARD_DEFAULT_WRITE_OPERATIONS_NUMBER_SUPPORTED_PER_SESSION;
661 static const int REV2_CARD_DEFAULT_WRITE_OPERATIONS_NUMBER_SUPPORTED_PER_SESSION;
662 static const int SI_BUFFER_SIZE_INDICATOR;
663 static const int SI_PLATFORM;
664 static const int SI_APPLICATION_TYPE;
665 static const int SI_APPLICATION_SUBTYPE;
666 static const int SI_SOFTWARE_ISSUER;
667 static const int SI_SOFTWARE_VERSION;
668 static const int SI_SOFTWARE_REVISION;
669 static const uint8_t PAY_LOAD_CAPACITY;
674 static const uint8_t APP_TYPE_WITH_CALYPSO_PIN;
675 static const uint8_t APP_TYPE_WITH_CALYPSO_SV;
676 static const uint8_t APP_TYPE_RATIFICATION_COMMAND_REQUIRED;
677 static const uint8_t APP_TYPE_CALYPSO_REV_32_MODE;
678 static const uint8_t APP_TYPE_WITH_PUBLIC_AUTHENTICATION;
683 static const std::vector<int> BUFFER_SIZE_INDICATOR_TO_BUFFER_SIZE;
688 std::shared_ptr<ApduResponseApi> mSelectApplicationResponse;
693 std::string mPowerOnData;
698 bool mIsExtendedModeSupported =
false;
703 bool mIsRatificationOnDeselectSupported =
false;
708 bool mIsSvFeatureAvailable =
false;
713 bool mIsPinFeatureAvailable =
false;
718 bool mIsPkiModeSupported =
false;
723 bool mIsDfInvalidated =
false;
733 std::vector<uint8_t> mCalypsoSerialNumber;
738 std::vector<uint8_t> mStartupInfo;
748 std::vector<uint8_t> mDfName;
753 int mModificationsCounterMax;
758 bool mIsModificationCounterInBytes =
false;
763 std::shared_ptr<DirectoryHeader> mDirectoryHeader;
768 std::vector<std::shared_ptr<ElementaryFile>> mFiles;
773 std::vector<std::shared_ptr<ElementaryFile>> mFilesBackup;
783 uint16_t mCurrentLid;
788 std::shared_ptr<bool> mIsDfRatified;
793 std::shared_ptr<int> mTransactionCounter =
nullptr;
798 std::shared_ptr<int> mPinAttemptCounter;
803 std::shared_ptr<int> mSvBalance;
813 std::shared_ptr<SvLoadLogRecord> mSvLoadLogRecord;
818 std::shared_ptr<SvDebitLogRecord> mSvDebitLogRecord;
828 std::vector<uint8_t> mCardChallenge;
833 std::vector<uint8_t> mTraceabilityInformation;
843 std::vector<uint8_t> mSvGetHeader;
848 std::vector<uint8_t> mSvGetData;
853 std::vector<uint8_t> mSvOperationSignature;
858 uint8_t mApplicationSubType;
863 uint8_t mApplicationType;
868 uint8_t mSessionModification;
884 void updateCurrentSfi(
const uint8_t sfi);
892 void updateCurrentLid(
const uint16_t lid);
903 const std::shared_ptr<ElementaryFileAdapter> getOrCreateFile();
912 static void copyFiles(
const std::vector<std::shared_ptr<ElementaryFile>>& src,
913 std::vector<std::shared_ptr<ElementaryFile>>& dest);
#define KEYPLECARDCALYPSO_API
CalypsoSam::ProductType ProductType
std::ostream & operator<<(std::ostream &os, const std::shared_ptr< ApduRequestAdapter > ara)