Keypop Calypso Card C++ API 2.0.0
Reference Calypso Card API for C++
|
#include <TransactionManager.hpp>
Public Member Functions | |
virtual T & | prepareSelectFile (const uint16_t lid)=0 |
virtual T & | prepareSelectFile (const SelectFileControl selectFileControl)=0 |
virtual T & | prepareGetData (const GetDataTag tag)=0 |
virtual T & | prepareReadRecord (const uint8_t sfi, const int recordNumber)=0 |
virtual T & | prepareReadRecords (const uint8_t sfi, const int fromRecordNumber, const int toRecordNumber, const int recordSize)=0 |
virtual T & | prepareReadRecordsPartially (const uint8_t sfi, const int fromRecordNumber, const int toRecordNumber, const int offset, const int nbBytesToRead)=0 |
virtual T & | prepareReadBinary (const uint8_t sfi, const int offset, const int nbBytesToRead)=0 |
virtual T & | prepareReadCounter (const uint8_t sfi, const int nbCountersToRead)=0 |
virtual T & | prepareSearchRecords (const SearchCommandData data)=0 |
virtual T & | prepareCheckPinStatus ()=0 |
virtual T & | prepareAppendRecord (const uint8_t sfi, const std::vector< uint8_t > &recordData)=0 |
virtual T & | prepareUpdateRecord (const uint8_t sfi, const int recordNumber, const std::vector< uint8_t > &recordData)=0 |
virtual T & | prepareWriteRecord (const uint8_t sfi, const int recordNumber, const std::vector< uint8_t > &recordData)=0 |
virtual T & | prepareUpdateBinary (const uint8_t sfi, const int offset, const std::vector< uint8_t > &data)=0 |
virtual T & | prepareWriteBinary (const uint8_t sfi, const int offset, const std::vector< uint8_t > &data)=0 |
virtual T & | prepareIncreaseCounter (const uint8_t sfi, const int counterNumber, const int incValue)=0 |
virtual T & | prepareIncreaseCounters (const uint8_t sfi, const std::map< const int, const int > &counterNumberToIncValueMap)=0 |
virtual T & | prepareDecreaseCounter (const uint8_t sfi, const int counterNumber, const int decValue)=0 |
virtual T & | prepareDecreaseCounters (const uint8_t sfi, const std::map< const int, const int > &counterNumberToDecValueMap)=0 |
virtual T & | prepareSetCounter (const uint8_t sfi, const int counterNumber, const int newValue)=0 |
virtual T & | prepareSvReadAllLogs ()=0 |
virtual T & | prepareVerifyPin (const std::vector< uint8_t > &pin)=0 |
virtual T & | prepareChangePin (const std::vector< uint8_t > &newPin)=0 |
virtual T | processCommands (const ChannelControl channelControl)=0 |
const st::vector< std::vector< uint8_t > > & | getTransactionAuditData () const =0 |
Contains operations common to all card transactions.
To exchange data with the card, it is first necessary to prepare the commands to be transmitted to the card and then to process the prepared commands via the processCommands(ChannelControl) method.
The card commands preparation step makes it possible to group commands together in order to minimize network data exchanges (especially useful in a distributed architecture).
The CalypsoCard object registered with the manager is updated during the transaction after each data exchange with the card.
For all "prepare" type commands, unless otherwise specified, here are the ranges of values checked for the various parameters:
<T> | The type of the lowest level child object. |
Definition at line 54 of file TransactionManager.hpp.
|
pure virtual |
Returns the audit data of the transaction containing all APDU exchanges with the card and the cryptographic module.
|
pure virtual |
Schedules the execution of an "Append Record" command to adds the data provided in the indicated "cyclic" file.
A new record is added, the oldest record is deleted.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | The sfi to select. |
recordData | The new record data to write. |
IllegalArgumentException | If one of the provided argument is out of range. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of a "Change PIN" command to replace the current PIN with the new value provided.
This command can be performed only out of a secure session. The new PIN code can be transmitted in plain text or encrypted according to the parameter set in SymmetricCryptoSecuritySetting.
When the PIN is transmitted plain, this command must be preceded by a successful Verify PIN command (see prepareVerifyPin(byte[])).
The PIN status will be available in CalypsoCard using the CalypsoCard#getPinAttemptRemaining() and CalypsoCard#isPinBlocked() methods.
newPin | The new PIN code value (4-byte long byte array). |
UnsupportedOperationException | If the PIN feature is not available for this card. |
IllegalArgumentException | If the provided argument is out of range. |
IllegalStateException | If the command is executed while a secure session is open. |
|
pure virtual |
Schedules the execution of a "Verify Pin" command without PIN presentation in order to get the attempt counter.
The PIN status will be available in CalypsoCard using the CalypsoCard#getPinAttemptRemaining() and CalypsoCard#isPinBlocked() methods.
UnsupportedOperationException | If the PIN feature is not available for this card. |
|
pure virtual |
Schedules the execution of a "Decrease" command to decrease the target counter.
If several counters of the same file have to be decremented at the same time of the transaction, it is recommended to use the method prepareDecreaseCounters(byte, Map) for optimization reasons.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | SFI of the EF to select. |
counterNumber | The number of the counter (must be zero in case of a simulated counter). |
decValue | Value to subtract to the counter (defined as a positive int <=
|
IllegalArgumentException | If one of the provided argument is out of range. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of a "Decrease Multiple" command or multiple "Decrease" commands to decrease multiple target counters at the same time.
The decision to execute one or the other command is made according to the type of card.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | SFI of the EF to select. |
counterNumberToDecValueMap | The map containing the counter numbers to be decremented and their associated decrement values. |
IllegalArgumentException | If one of the provided argument is out of range or if the map is null or empty. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of a "Get Data" command to retrieve the data indicated by the provided tag.
Data will be available in CalypsoCard using the ElementaryFile#getHeader() or CalypsoCard#getDirectoryHeader() methods, depending on the provided tag.
tag | The tag to use. |
UnsupportedOperationException | If the Get Data command with the provided tag is not supported. |
IllegalArgumentException | If tag is null. |
|
pure virtual |
Schedules the execution of an "Increase" command to increase the target counter.
If several counters of the same file have to be incremented at the same time of the transaction, it is recommended to use the method prepareIncreaseCounters(byte, Map) for optimization reasons.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | SFI of the EF to select. |
counterNumber | The number of the counter (must be zero in case of a simulated counter). |
incValue | Value to add to the counter (defined as a positive int <=
|
IllegalArgumentException | If one of the provided argument is out of range. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of an "Increase Multiple" command or multiple "Increase" commands to increase multiple target counters at the same time.
The decision to execute one or the other command is made according to the type of card.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | SFI of the EF to select. |
counterNumberToIncValueMap | The map containing the counter numbers to be incremented and their associated increment values. |
IllegalArgumentException | If one of the provided argument is out of range or if the map is null or empty. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of one or multiple "Read Binary" commands to read all or part of the indicated "binary" EF.
Data will be available in CalypsoCard using the dedicated file and data management methods.
Depending on whether we are inside a secure session, there are two types of behavior following this command:
sfi | The SFI of the EF. |
offset | The offset (0 indicates the first byte). |
nbBytesToRead | The number of bytes to read. |
UnsupportedOperationException | If this command is not supported by this card. |
IllegalArgumentException | If one of the provided argument is out of range. |
|
pure virtual |
Schedules the execution of a "Read Records" command to reads a record of the indicated EF, which should be a "counter" file.
The record will be read up to the counter location indicated in parameter.
Thus, all previous counters will also be read.
Data will be available in CalypsoCard using the dedicated file and data management methods.
Depending on whether we are inside a secure session, there are two types of behavior following this command:
sfi | The SFI of the EF. |
nbCountersToRead | The number of counters to read. |
IllegalArgumentException | If one of the provided argument is out of range. |
|
pure virtual |
Schedules the execution of a "Read Records" command to read a single record from the indicated EF.
Data will be available in CalypsoCard using the dedicated file and data management methods.
Depending on whether we are inside a secure session, there are two types of behavior following this command:
This method should not be used inside a secure session in contact mode because additional exchanges with the card will be operated and will corrupt the security of the session. Instead, use the method prepareReadRecords(byte, int, int, int) for this case and provide valid parameters.
sfi | The SFI of the EF to read. |
recordNumber | The record to read. |
IllegalArgumentException | If one of the provided arguments is out of range. |
IllegalStateException | If this method is called inside a secure session in contact mode. |
|
pure virtual |
Schedules the execution of a "Read Records" command to read one or more records from the indicated EF.
Data will be available in CalypsoCard using the dedicated file and data management methods.
Depending on whether we are inside a secure session, there are two types of behavior following this command:
sfi | The SFI of the EF. |
fromRecordNumber | The number of the first record to read. |
toRecordNumber | The number of the last record to read. |
recordSize | The record length. |
IllegalArgumentException | If one of the provided argument is out of range. |
|
pure virtual |
Schedules the execution of one or multiple "Read Record Multiple" commands to read all or parts of multiple records of the indicated EF.
Data will be available in CalypsoCard using the dedicated file and data management methods.
Depending on whether we are inside a secure session, there are two types of behavior following this command:
sfi | The SFI of the EF. |
fromRecordNumber | The number of the first record to read. |
toRecordNumber | The number of the last record to read. |
offset | The offset in the records where to start reading (0 indicates the first byte). |
nbBytesToRead | The number of bytes to read from each record. |
UnsupportedOperationException | If this command is not supported by this card. |
IllegalArgumentException | If one of the provided argument is out of range. |
|
pure virtual |
Schedules the execution of a "Search Record Multiple" command to search data in the records of the indicated EF, from a given record to the last record of the file. It will return the list of record numbers containing these data, and if requested it will read the first record content.
The command is only possible with a "linear", "cyclic", Counters or Simulated "counter" EF.
The command searches if the given data are present in the records of the file. During the search, an optional mask is applied. The mask allows to specify precisely the bits to be taken into account in the comparison.
See SearchCommandData class for a description of the parameters.
Once this command is processed, the result is available in the provided input/output SearchCommandData object, and the content of the first matching record in CalypsoCard if requested.
Depending on whether we are inside a secure session, there are two types of behavior following this command:
data | The input/output data containing the parameters of the command. |
UnsupportedOperationException | If the "Search Record Multiple" command is not available for this card. |
IllegalArgumentException | If the input data is inconsistent. |
|
pure virtual |
Schedules the execution of a "Select File" command using a navigation selectFileControl defined by the ISO standard.
Data will be available in CalypsoCard using the ElementaryFile#getHeader() method.
selectFileControl | A SelectFileControl enum entry. |
IllegalArgumentException | If selectFileControl is null. |
|
pure virtual |
Schedules the execution of a "Select File" command to select an EF by its LID in the current DF.
Data will be available in CalypsoCard using the CalypsoCard#getFileBySfi(byte)/CalypsoCard#getFileByLid(short) and ElementaryFile#getHeader() methods.
Caution: the command will fail if the selected file is not an EF.
lid | The LID of the EF to select. |
|
pure virtual |
Schedules the execution of an "Increase" or "Decrease" command to set the value of the target counter.
The operation (Increase or Decrease) is selected according to whether the difference between the current value and the desired value is negative (Increase) or positive (Decrease).
Data will be available in CalypsoCard using the dedicated file and data management methods.
Note: it is assumed here that:
counterNumber | >=
|
sfi | SFI of the EF to select. |
newValue | The desired value for the counter (defined as a positive int <=
|
IllegalArgumentException | If one of the provided argument is out of range. |
IllegalStateException | If the current counter value is unknown. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of "Read Records" commands to read all SV logs.
Note: this method requires that the selected application is of type Store Value (file structure 20h).
The SV transaction logs are contained in two files with fixed identifiers:
Data will be available in CalypsoCard in raw format using the dedicated file and data management methods or in the form of dedicated objects using the CalypsoCard#getSvLoadLogRecord() and CalypsoCard#getSvDebitLogAllRecords() methods.
UnsupportedOperationException | If the SV feature is not available for this card. |
|
pure virtual |
Schedules the execution of one or multiple "Update Binary" command to replace the indicated data of a "binary" file with the new data given from the indicated offset.
The data of the file before the offset and after the data given are left unchanged.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | The SFI of the EF to select. |
offset | The offset (0 indicates the first byte). |
data | The new data. |
UnsupportedOperationException | If this command is not supported by this card. |
IllegalArgumentException | If one of the provided argument is out of range. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of an "Update Record" command to overwrites the target file's record contents with the provided data.
If the input data is shorter than the record size, only the first bytes will be overwritten.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | The sfi to select. |
recordNumber | The record to update. |
recordData | The new record data. If length <
|
IllegalArgumentException | If one of the provided argument is out of range. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of a "Verify PIN" command in order to authenticate the cardholder and/or unlock access to certain card files.
This command can be performed both in and out of a secure session. The PIN code can be transmitted in plain text or encrypted according to the parameter set in SymmetricCryptoSecuritySetting.
The PIN status will be available in CalypsoCard using the CalypsoCard#getPinAttemptRemaining() and CalypsoCard#isPinBlocked() methods.
pin | The PIN code value (4-byte long byte array). |
UnsupportedOperationException | If the PIN feature is not available for this card. |
IllegalArgumentException | If the provided argument is out of range. |
|
pure virtual |
Schedules the execution of one or multiple "Write Binary" commands to write over the indicated data of a "binary" file. The new data will be the result of a binary OR operation between the existing data and the data given in the command from the indicated offset.
The data of the file before the offset and after the data given are left unchanged.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | The SFI of the EF to select. |
offset | The offset (0 indicates the first byte). |
data | The data to write over the existing data. |
UnsupportedOperationException | If this command is not supported by this card. |
IllegalArgumentException | If one of the provided argument is out of range. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Schedules the execution of a "Write Record" command to updates the target file's record contents with the result of a binary OR between the existing data and the provided data.
If the input data is shorter than the record size, only the first bytes will be overwritten.
Data will be available in CalypsoCard using the dedicated file and data management methods.
sfi | The sfi to select. |
recordNumber | The record to write. |
recordData | The data to overwrite in the record. If length <
|
IllegalArgumentException | If one of the provided argument is out of range. |
SessionBufferOverflowException | If the command will overflow the modifications buffer size and the multiple session is not allowed. |
|
pure virtual |
Processes all previously prepared commands and closes the physical channel if requested.
All APDUs corresponding to the prepared commands are sent to the card, their responses are retrieved and used to update the CalypsoCard associated with the transaction.
For write commands, the CalypsoCard is updated only when the command is successful.
The process is interrupted at the first failed command.
channelControl | Policy for managing the physical channel after executing commands to the card. |
ReaderIOException | If a communication error with the card reader or the cryptographic module reader occurs. |
CardIOException | If a communication error with the card occurs. |
CryptoIOException | If a communication error with the cryptographic module occurs. |
UnexpectedCommandStatusException | If a command returns an unexpected status. |
InconsistentDataException | If inconsistent data have been detected. |
UnauthorizedKeyException | If the card requires an unauthorized session key. |
CardSignatureNotVerifiableException | If a secure session is open and multiple session mode is enabled and an intermediate session is correctly closed but the cryptographic module is no longer available to verify the card MAC. |
InvalidCardSignatureException | If the card signature is incorrect. In the case of a card transaction secured by "symmetrical" cryptography (e.g. SAM), this indicates that the card has correctly closed the secure session, but the card session is not authentic because the MAC of the card is incorrect. |
SelectFileException | If a "Select File" prepared card command indicated that the file was not found. |