Terminal APIs 3.0 — Changes and Design Rationale


Document status: approved by the CNA TC Terminal. The nine specifications it describes are available as a preview on the documentation site; their formal release is pending.

Preamble

The purpose of this document is to present all the evolutions of the Terminal APIs between the Keypop Java versions currently in production and the current specifications of the CNA Terminal APIs — for validation by the members of the TC Terminal (Technical Committee Terminal) of the Calypso Networks Association (CNA).

Compared versions

The “before” reference consists of the latest published versions of the Keypop Java modules (production tags). The “after” reference consists of the normative specifications (index.adoc) and the associated class diagrams (uml/class-diagram.puml) of each calypsonet-terminal-*-api-spec repository.

APISpecification referenceKeypop Java version in production (before)Specified version (after)
Terminal Reader APICNA-TR-APIkeypop-reader-java-api 2.1.03.0.0
Terminal Card API (internal)CNA-TC-APIkeypop-card-java-api 2.0.13.0.0
Terminal Calypso Card APICNA-TCC-APIkeypop-calypso-card-java-api 2.3.03.0.0
Terminal Reader Definitions API (new)CNA-TRD-API—1.0.0
Terminal Calypso Crypto Legacy SAM APICNA-TCCL-APIkeypop-calypso-crypto-legacysam-java-api 1.0.02.0.0
Terminal Calypso Crypto Symmetric APICNA-TCCS-APIkeypop-calypso-crypto-symmetric-java-api 0.1.10.2.0
Terminal Calypso Crypto Asymmetric APICNA-TCCA-APIkeypop-calypso-crypto-asymmetric-java-api 0.2.00.3.0
Terminal Generic Card APICNA-TGC-APIkeypop-genericcard-jvm-api 1.0.02.0.0
Terminal Storage Card APICNA-TSC-APIkeypop-storagecard-java-api 1.2.02.0.0

All the specifications are currently in …-SNAPSHOT versions.

For each evolution theme, it describes:

  • the motivation (the “why”);
  • the detailed changes in each of the APIs concerned;
  • the design rationale (the “why this choice rather than another”).

Annex A additionally provides an exhaustive, API-by-API mapping between each element of the Java versions in production and what becomes of it in the specifications.

Alignment of the Keypop Java implementations with these versions and the writing of a technical migration guide for integrators will take place subsequently, after validation by the TC Terminal (see §22).

API visibility with respect to audiences

  • The Reader API, the Calypso Card API, the Terminal Reader Definitions API, the Legacy SAM API, the Generic Card API and the Storage Card API are public APIs, directly manipulated by the integrator (application code).
  • The Card API is an internal API: it serves as an integration contract between reader implementations and card extensions. The integrator does not have access to it.
  • The Crypto Symmetric API and Crypto Asymmetric API define the contracts (SPI) between the Calypso Card API and the cryptographic modules; the integrator only uses them indirectly, through the crypto modules it instantiates (for example the Legacy SAM API).

This document describes the evolutions of all impacted APIs because they are coupled at the design level. The evolutions of the internal and contract APIs require no action from the integrator; they are absorbed by the Keypop implementations.

New API: Terminal Reader Definitions API

Version 3.0.0 introduces a new foundation API dedicated to hosting cross-cutting enumerated types of the Terminal APIs. It is created on the occasion of Theme 6 to host RfTechnology and CardType, but its scope is broader: it is intended to potentially host other enumerations that constitute global constants shared by several Terminal APIs. The Terminal Reader API now depends on this new API.

Concretely, this translates into:

  • a new repository: calypsonet-terminal-reader-definitions-api-spec (version 1.0.0-SNAPSHOT);
  • a new Keypop Java module: keypop-reader-definitions-jvm-api (to be created, in accordance with the Keypop naming convention);
  • a declared dependency of the keypop-reader-java-api module on this new module.

New form of the deliverables: language-independent normative specifications

Until now, the Terminal APIs were described by a UML diagram and by the Javadoc of the Keypop Java modules. Each API now has a normative specification (index.adoc), written in a notation independent of the implementation language (inspired by Kotlin), together with its class diagram. This new design proposal aims to broaden the choice of implementation languages for the Terminal APIs beyond Java, for example Kotlin Multiplatform (KMP), Rust, Swift or C#. This change of form affects the way types and operations are expressed; the consequences are described in Theme 10 (§11).


Reference documents

Each calypsonet-terminal-*-api-spec repository hosted on github.com/calypsonet contains, at its root:

  • the normative specification index.adoc;
  • the class diagram uml/class-diagram.puml, whose content is strictly aligned with the specification.
ModuleRepositoryVersion
Terminal Reader APIcalypsonet-terminal-reader-api-spec3.0.0-SNAPSHOT
Terminal Card API (internal)calypsonet-terminal-card-api-spec3.0.0-SNAPSHOT
Terminal Calypso Card APIcalypsonet-terminal-calypso-card-api-spec3.0.0-SNAPSHOT
Terminal Reader Definitions API (new)calypsonet-terminal-reader-definitions-api-spec1.0.0-SNAPSHOT
Terminal Calypso Crypto Legacy SAM APIcalypsonet-terminal-calypso-crypto-legacysam-api-spec2.0.0-SNAPSHOT
Terminal Calypso Crypto Symmetric APIcalypsonet-terminal-calypso-crypto-symmetric-api-spec0.2.0-SNAPSHOT
Terminal Calypso Crypto Asymmetric APIcalypsonet-terminal-calypso-crypto-asymmetric-api-spec0.3.0-SNAPSHOT
Terminal Generic Card APIcalypsonet-terminal-genericcard-api-spec2.0.0-SNAPSHOT
Terminal Storage Card APIcalypsonet-terminal-storagecard-api-spec2.0.0-SNAPSHOT

The former diagrams published in the …-SNAPSHOT/ folders (api_class_diagram.svg and api_class_diagram_diff.svg) reflect an intermediate state of the work and are no longer up to date; the reference is now the index.adoc specification.

Diagram reading conventions:

  • elements in blue are additions or modifications of the new version;
  • elements in grey are under study (“work in progress”): they have never been implemented and are not part of the normative scope (see §21);
  • green classes group data, constants, enumerations and errors;
  • signatures follow the language-independent notation described in Theme 10 (→ Self, T?, val property: Type = default, etc.).

Table of contents

  1. Overview
  2. Theme 1 — Support for multiple logical channels
  3. Theme 2 — Timing countermeasures: relay attack and card emulation
  4. Theme 3 — Simplified observation management
  5. Theme 4 — Knowledge of the current secure session state
  6. Theme 5 — Semantic improvements (renamings and removals)
  7. Theme 6 — Strict typing of RF technologies and card types (ECP support)
  8. Theme 7 — Command identification (commandId)
  9. Theme 8 — Standardised reader discovery and access (CardReaderProvider)
  10. Theme 9 — Redesign of the card selection model
  11. Theme 10 — Implementation-language-independent specification
  12. Theme 11 — Data exposed without computation and access to raw data
  13. Theme 12 — Stored Value (SV) operations
  14. Theme 13 — Tolerance of a missing file or record in a secure session
  15. Theme 14 — Crypto extensions and command interleaving
  16. Theme 15 — Validity of the Calypso HCE token
  17. Theme 16 — Card power and RF field
  18. Theme 17 — Card revocation
  19. Theme 18 — Transaction counter
  20. Normative clarifications
  21. Elements under study
  22. Migration procedure
  23. Next steps and validation by the TC Terminal

1. Overview

The new generation of the Terminal APIs introduces compatibility breaks on all existing APIs, creates a new foundation API (Terminal Reader Definitions API), and comes with a change of form of the deliverables (language-independent normative specifications). The changes are grouped into eighteen themes:

#ThemeReaderCardCalypso CardDefinitionsLegacy SAMCrypto Sym.Crypto Asym.Generic CardStorage Card
1Multiple logical channels●●●————●—
2Relay and emulation countermeasures—●●————●●
3Simplified observation●————————
4Current secure session state——●——————
5Semantic improvements●●●—●●●●●
6RF / card type typing (ECP)●——● (creation)—————
7Command identification (commandId)——●—●——●●
8Standardised reader discovery●————————
9Redesign of the selection model●————————
10Language-independent specification●●●●●●●●●
11Data without computation, raw data—●●—●●●—●
12Stored Value operations——●——————
13Missing file or record tolerated——●——————
14Crypto extensions and interleaving——●—●————
15Calypso HCE token validity——●——————
16Card power and RF field●————————
17Card revocation——●——————
18Transaction counter——●——————

Cross-cutting consequences:

  • Removal of the entire deprecated legacy: all elements marked @Deprecated in the production versions are removed with no compatibility alternative (for example ChannelControl in the Calypso Card API, TransactionManager.processCommands() in the Legacy SAM API, prepareReadSystemBlock() in the Storage Card API).
  • Removal of the “work in progress” elements that appeared in the former diagrams for prospective purposes without ever being implemented: ReaderApiFactory.createMultichannelCardSelector(), MultichannelCardSelector, CardSelectionResult.getCardReader() (Reader API); AsymmetricCryptoSecuritySetting.authorizeAllTrustedCa(), authorizeOnlyConfiguredCa() and revokeCa(byte[]) (Calypso Card API). The elements still under study in the Legacy SAM API are listed in §21.
  • Complete disappearance of ChannelControl (Reader API, Card API, Calypso Card API): closing the channel becomes an explicit operation (closeChannel, transmitCardRequestAndCloseChannel, processCommandsAndCloseChannel).
  • Disappearance of duplicate errors: the InvalidCardResponseException of the reader.selection package, as well as the communication and status errors specific to the Calypso Card API and the Legacy SAM API, disappear in favour of the Reader API errors.
  • Recursive genericity dropped: all interfaces of the form T extends X<T> (transaction managers, selectors, signature data) lose their type parameter; fluent chaining is expressed by the Self return type (see Theme 10).

2. Theme 1 — Support for multiple logical channels

2.1 Motivation

Until now, the API implicitly assumed that only one logical channel was open at a time between the terminal and the card. Version 3.0.0 explicitly introduces the notion of multiple logical channels (ISO cards supporting several simultaneous application selections on distinct logical channels), with two objectives:

  1. to allow several applications of the same card to be selected and handled in parallel;
  2. to clearly distinguish, for each smart card, on which channel it is attached and whether it is still active.

The concrete trigger for this work is the arrival of a new CNA product, OpenSAM, whose usage model relies on the simultaneous coexistence of several security applications accessible in parallel on distinct logical channels. The detailed specifications of OpenSAM are covered by the CNA documentation dedicated to this product.

2.2 Reader API

Multi-channel selection

  • New manager MultichannelCardSelectionManager, obtained through ReaderApiFactory.createMultichannelCardSelectionManager(), whose operation processCardSelectionScenario(reader: CardReader, channelSelectionPolicy: ChannelSelectionPolicy) → MultichannelCardSelectionResult executes the scenario by placing each successful selection on its own logical channel. If the presented card does not support multi-channel, an InvalidCardResponse error is raised at scenario execution time. This manager is part of the overall redesign of the selection described in Theme 9 (§10).
  • New enumeration ChannelSelectionPolicy:
    • ALLOW_BASIC_CHANNEL — allows the use of the basic channel (channel 0) in addition to the additional logical channels;
    • LOGICAL_CHANNEL_ONLY — restricts the selection to the additional logical channels (channel 0 is not used).
  • New result MultichannelCardSelectionResult (cardType, smartCards): all the cards it exposes are active in parallel, each on its own channel. The scheduled mode (selection on card insertion) is not offered in multi-channel mode.

Channel knowledge at card level

  • New operation SmartCard.isActive() → Boolean — the card knows whether it is still active on its channel.
  • New operation IsoSmartCard.isBasicChannel() → Boolean — indicates whether the card is attached to the basic channel or to an additional logical channel.

Multi-channel transaction management

The hierarchy of transaction managers (namespace reader.transaction.spi) is restructured into three levels:

CardTransactionManager  (root interface, non-generic)
  ├─ IsoCardTransactionManager  (new, ISO 7816-4 — carries the conversion to multi-channel)
  └─ MultichannelCardTransactionManager  (new, actual multi-channel)
  • CardTransactionManager (redesigned) — no longer generic; exposes processCommands() → Unit (without parameter). It is the common root interface of all transaction managers.
  • IsoCardTransactionManager — new intermediate interface dedicated to ISO 7816-4 cards. It exposes a single operation asMultichannelCardTransactionManager() → MultichannelCardTransactionManager, which returns a multi-channel view of the manager. The conversion itself never fails: if the underlying card does not support multi-channel, the InvalidCardResponse error is only raised when the commands are processed by the obtained manager (processCommands, processCommandsAndCloseChannel).
  • MultichannelCardTransactionManager — new interface extending CardTransactionManager; exposes:
    • processCommandsAndCloseChannel() → Unit — processes the pending commands and, upon success, closes the channel;
    • closeChannel() → Unit — explicit, idempotent closing of the channel.

Expected anchoring on the consumer API side:

  • APIs targeting ISO 7816-4 cards that are not intrinsically multi-channel (Calypso Card, Generic Card) make their transaction manager extend IsoCardTransactionManager and access multi-channel on demand through asMultichannelCardTransactionManager().
  • APIs targeting intrinsically multi-channel cards (the future Terminal OpenSAM API in particular) make their transaction manager extend MultichannelCardTransactionManager directly.

2.3 Card API

  • New operation SmartCardSpi.deactivate() → Unit — allows the reader to deactivate the card, so that the application immediately sees SmartCard.isActive() switch to false.
  • New SPI interfaces IsoSmartCardSpi (extends SmartCardSpi, marker) and MultichannelSmartCardSpi (extends IsoSmartCardSpi) with getChannel() → Int — multi-channel being a specialisation of ISO/IEC 7816-4, only an ISO selection extension can produce such a smart card (see Theme 9).
  • Redesign of ProxyReaderApi:
    • removed: transmitCardRequest(CardRequestSpi, ChannelControl) and releaseChannel();
    • added:
      • transmitCardRequest(cardRequest: CardRequest, smartCard: SmartCardSpi) → CardResponse;
      • transmitCardRequestAndCloseChannel(cardRequest: CardRequest, multichannelSmartCard: MultichannelSmartCardSpi) → CardResponse;
      • closeChannel(multichannelSmartCard: MultichannelSmartCardSpi) → Unit.
  • Addition of the property CardSelectionResponse.channel: Int — the selection response carries the channel number (0 in single-channel mode).
  • Removal of CardResponseApi.isLogicalChannelOpen() — made redundant by the new model.

2.3.1 Role of the card passed to the ProxyReaderApi

The SmartCardSpi / MultichannelSmartCardSpi parameter is not a mere vehicle for the channel number. It plays up to three roles:

  1. carrying the logical channel number (with MultichannelSmartCardSpi only);
  2. carrying the active state of the card, so that the reader checks that it is still active before any transmission — an inactive card causes the CardBrokenCommunication error;
  3. allowing the reader to deactivate the card (SmartCardSpi.deactivate()), for example after a communication error or on explicit channel closure.

2.3.2 SmartCard lifecycle

The reader keeps the references to the SmartCard instances resulting from the last selection and deactivates them in four cases:

  1. on a new selection in single-channel mode;
  2. on an explicit channel closure request (closeChannel, processCommandsAndCloseChannel);
  3. on the call to CardReader.endCardProcessing();
  4. on an error indicating that the card can no longer be reached (CardCommunication, ReaderCommunication).

This contract, which only appeared as prose in the previous version of this document, is now normative: it is defined in the Reader API specification (description of SmartCard.isActive, SmartCard lifecycle section).

2.4 Calypso Card API

  • The Calypso TransactionManager now extends IsoCardTransactionManager (instead of CardTransactionManager). Multi-channel access is performed without a dedicated operation: the integrator calls asMultichannelCardTransactionManager() and then uses processCommandsAndCloseChannel() / closeChannel().

2.5 Generic Card API

  • The transaction manager (renamed GenericCardTransactionManager, see Theme 5) now extends IsoCardTransactionManager.

2.6 Rationale

“By parameter” control (ChannelControl.KEEP_OPEN / CLOSE_AFTER) relied on an implicit, global notion of a “single current channel”. In a multi-channel context, this model is ambiguous: which channel does CLOSE_AFTER apply to? Moving to a model where the target (the SmartCard(Spi)) is explicitly named in each call removes this ambiguity.

The three-level hierarchy allows each consumer API to anchor itself at the capability level that exactly matches its card model: on-demand conversion for cards for which multi-channel is only an optional capability, direct anchoring for intrinsically multi-channel cards.


3. Theme 2 — Timing countermeasures: relay attack and card emulation

3.1 Motivation

Two threats are detected through the duration of the exchanges, and the new versions introduce a single mechanism for both.

  • A relay attack consists in relaying the dialogue with a card to a remote location, which makes a fraudulent operation possible without the cardholder’s knowledge. The relay adds a transmission delay: an abnormally long exchange can therefore reveal that the card is not actually present in front of the reader.
  • Card emulation consists in having a generic RFID device answer in place of the expected card. Such a device processes the command in software, where the chip answers in hardware: an abnormally long exchange then reveals that the answer does not come from the expected product. This threat mainly concerns storage cards, which have no cryptographic mechanism. The new versions introduce a mechanism for measuring and bounding APDU exchange durations and for bounding the secure session duration.

Threat model

  • Targeted attack surface: application-level attack (software relay of APDUs, card emulation by a generic device), as opposed to attacks at the physical RF transport level, which are covered by hardware countermeasures.
  • Units: every duration carries the suffix of its unit, and the microsecond (...Us) is the unit of the whole family — Card API, Generic Card API and Storage Card API — as well as the unit of the measurement. The effective resolution of the measurement depends on the implementation, which must document it.
  • Measurement location: the Terminal Reader API implementation measures the effective duration of each APDU exchange and compares it with the bound declared on the request. In a Calypso transaction the bounded exchanges are Open Secure Session, Close Secure Session and SV Reload / SV Debit / SV Undebit, each bound covering a single command exchange; the bounds themselves are resolved by the Calypso card extension, not by the application (see §3.3).
  • Behaviour after an overrun: the Card API raises the ApduExchangeDurationExceeded error, which the higher-level extensions intercept and propagate to the application as an InvalidCardResponse. The Calypso Card API now specifies this behaviour: if a secure session is open, it is automatically cancelled before the error is propagated, so that no modification performed during the session is validated by the card; outside a session (SV command), there is nothing to cancel and only the error is propagated to the ticketing layer, which decides what to do according to its own context. In the Generic Card API, an overrun raises InvalidCardResponse, whose message identifies the offending command.

3.2 Card API

  • Request side: ApduRequest.apduExchangeMaxDurationUs: Long? = null — maximum tolerated duration for the exchange (in microseconds); null means “no bound”.
  • Response side: ApduResponse.apduExchangeDurationUs: Long? — effective duration of the exchange; null means “duration not measured”.
  • New error ApduExchangeDurationExceeded — raised by ProxyReaderApi.transmitCardRequest(...) when the effective duration exceeds the declared bound. Like the other APDU errors, it carries cardResponse and isCardResponseComplete.
  • The Card API specification now documents this mechanism as a practical solution for implementing anti-relay countermeasures (APDU exchange execution-time control chapter). It also states who sets the bound: it is not a value an application can know, and is chosen by the card extension from a configuration it obtains by its own means (see §3.3).

3.3 Calypso Card API

No operation. The specification exposes nothing for configuring the countermeasure: it is entirely handled by the implementation, which obtains its configuration by its own means, outside the surface of the API — as a reader driver obtains its technical parameters when it is instantiated.

The reason is that a usable bound is the sum of two budgets held by two different parties: the computation time of the card, which depends on its product type and on the key used, and the latency of the terminal — coupler, antenna, driver, execution platform. Neither is known to the ticketing application, and the calibration that establishes them is performed against the very implementation that will be deployed, which makes the content of that configuration an internal matter.

The Command exchange duration bounds section is therefore addressed to the implementer. It states:

  • the bounded command exchanges — Open Secure Session, Close Secure Session, and SV Reload / SV Debit / SV Undebit (symmetric-key transactions only). Each bound covers a single command exchange, from the transmission of the command to the reception of its response; the other commands of the session or of the SV operation are not counted. Those other commands are not bounded, and an implementation should not bound them: their duration varies with the volume of data exchanged, so a bound would yield false positives without adding protection.
  • the mechanism — the Card API provides a maximum duration declared on each request (ApduRequest.apduExchangeMaxDurationUs, enforced by the reader through ApduExchangeDurationExceeded) and the effective duration measured on each response (ApduResponse.apduExchangeDurationUs). Two ways of applying a bound follow, which are not equivalent: declared on the request, resolved before the exchange and enforced by the reader; or checked on the response, resolved after the exchange — the only way for a bound to depend on what the exchange itself reveals, typically the KIF and KVC returned by Open Secure Session, which identify the key, and therefore the computation time, of the card that has just answered.
  • non-silence — an implementation must not let a transaction pass for a protected one when the countermeasure could not be applied: when no measurement is available, it reports that condition by its own means instead of remaining silent.
  • the behaviour on overrun, unchanged: an open secure session is automatically cancelled before the error is propagated as an InvalidCardResponse; outside a session (SV command), there is nothing to cancel and only the error is propagated.

What the ticketing application sees: it configures nothing and is not told whether a bound applies. InvalidCardResponse may arise from a duration overrun as well as from a malformed response — an application that already handles that error needs no change. Absent a configuration, no bound applies and no protection exists.

Dropped from the working versions of this document: the six assign…MaxDuration…ByCsn/ByFci(...) operations, together with everything they required — the CSN threshold and FCI regular-expression criteria, the portable regex subset, the two-stage resolution rule, the Long.MAX_VALUE sentinel, the duplicate-declaration rules and the FCI integrity caveat. The Calypso Card API no longer declares any duration, which is why it no longer departs from the microsecond.

3.4 Generic Card API

  • GenericCardTransactionManager.prepareCommandWithMaxDuration(commandId: Int, apdu: ByteArray, maxDurationUs: Long) → Self — prepares a command with an identifier (see Theme 7) and a duration bound. If the effective duration exceeds the bound, the InvalidCardResponse error identifies the offending command.

The Generic Card API thus exposes the relay countermeasure at the level of each individual command, consistent with its usage model (APDU sequences without an explicit secure transaction).

3.5 Storage Card API

  • New data class StorageCardSecuritySettings (storagecard.transaction), with the property readCommandMaxDurationsUs: Map<StorageCardProductType, Long> = emptyMap(): maximum duration, in microseconds, of the exchange of a single read command, for each product type. A product type that is absent is not bounded. One instance may be shared by every transaction of a terminal.
  • Factory operation changed: createStorageCardTransactionManager(reader, card, securitySettings) → StorageCardTransactionManager. A default StorageCardSecuritySettings disables every duration bound.
  • Scope: the bound applies to the read commands prepared on the transaction manager (prepareReadBlock, prepareReadBlocks, prepareSt25ReadSystemBlock); it applies neither to the selection, nor to the write and authentication commands. An overrun raises StorageCardInvalidCardResponse, which already carries blockAddress and commandId.

Targeted threat: for storage cards, the threat is not the relay but card emulation by a generic RFID device, which does not answer a read command in the same time as the chip of the expected product.

Storage cards have neither an FCI nor a secure session: the product type is enough to segment the fleet, where the Calypso Card API uses the CSN and the FCI.

3.6 Rationale

Both the relay and the emulation introduce a significant and systematic timing deviation on APDU exchanges; monitoring this deviation at the reader level (Card API), on the bounded commands of a Calypso transaction (Calypso Card API), on each generic command (Generic Card API) and on each storage card read (Storage Card API) covers all the usage scenarios of the Terminal APIs.


4. Theme 3 — Simplified observation management

4.1 Motivation

The production model exposed a complete Observer pattern (addObserver, removeObserver, clearObservers, countObservers, setReaderObservationExceptionHandler) plus two distinct SPIs (CardReaderObserverSpi and CardReaderObservationExceptionHandlerSpi). In practice, a single observer is registered, and the separation between event handler and error handler brought no value.

4.2 Reader API — ObservableCardReader

Removed operations:

  • setReaderObservationExceptionHandler(CardReaderObservationExceptionHandlerSpi)
  • addObserver(CardReaderObserverSpi), removeObserver(CardReaderObserverSpi), clearObservers(), countObservers()
  • startCardDetection(DetectionMode) (single-argument signature)
  • finalizeCardProcessing() (renamed, see below)

Added / redesigned operations:

  • startCardDetection(settings: CardDetectionSettings, eventHandler: CardReaderEventHandler) → Unit — the handler is registered when detection starts, in a single operation, together with the detection settings (see Theme 6).
  • endCardProcessing() → Unit — replaces finalizeCardProcessing(); idempotent; additionally releases the references to the SmartCard instances of the last selection, and is now carried by CardReader so that a non-observable reader can also close the dialogue with the card (see Theme 16 and §2.3.2).
  • clearScheduledCardSelectionScenario() → Unit — new operation that removes the card selection scenario scheduled on the reader. From the next insertion onwards, no scenario is executed and CardReaderEvent.scheduledCardSelectionsResponse is null. Idempotent.

Removed SPIs: CardReaderObserverSpi, CardReaderObservationExceptionHandlerSpi.

Added SPI: CardReaderEventHandler, which merges the two previous SPIs:

  • onReaderEvent(cardReaderEvent: CardReaderEvent) → Unit;
  • onReaderError(context: String, readerName: String, error: Any) → Unit.

4.3 Rationale

This simplification:

  1. reduces the API surface (5 operations and 2 SPIs become 1 operation and 1 SPI);
  2. eliminates invalid states (observer registered without an error handler, detection started without an observer, etc.);
  3. aligns the API with the actual usage observed among integrators.

5. Theme 4 — Knowledge of the current secure session state

5.1 Motivation

On the Calypso side, the application had no direct means of knowing whether a secure session was open, nor its nature (symmetric / asymmetric) or its write access level.

5.2 Calypso Card API

  • New operation TransactionManager.getSecureSessionState() → SecureSessionState — returns the state of the secure session at the moment of the call.
  • New enumeration SecureSessionState:
    • NO_SESSION — no secure session is open: none has been opened yet, or the last one has been closed or cancelled;
    • ASYMMETRIC — PKI session;
    • SYMMETRIC_PERSONALIZATION, SYMMETRIC_LOAD, SYMMETRIC_DEBIT — symmetric session opened with the corresponding write access level.

Change compared with the previous working version of this document: the SecureSessionStatus object (with isOpen, type, writeAccessLevel) / SecureSessionType pair is replaced by a single enumeration. The former form left type and writeAccessLevel undefined when no session was open; the enumeration makes these combinations impossible. The name State (rather than Status) designates one state among mutually exclusive states and avoids any confusion with the status data returned by the card (status word, dfStatus, etc.).

Chosen granularity: the values reflect the cryptographic nature of the session and not the application mode (Regular / Extended); the latter is deduced from the sub-type of the instantiated TransactionManager.

5.3 Rationale

The Calypso TransactionManager can now be introspected about its own secure session, which spares the caller from maintaining its own state tracking.


6. Theme 5 — Semantic improvements (renamings and removals)

This theme groups the renamings and removals motivated by clarity or consistency. The changes resulting from the language-independent notation (Exception, Spi, Api suffixes, nested enumerations, overloads) are described in Theme 10; the exhaustive list is given in Annex A.

6.1 Reader API

Before (Java 2.1.0)After (3.0.0)Rationale
ObservableCardReader.DetectionMode.SINGLESHOTDetectionMode.SINGLE_SHOTUPPER_SNAKE_CASE convention (compound word).
CardReaderEvent.Type.UNAVAILABLECardReaderEventType.READER_UNREGISTEREDThe name describes the actual cause of the event.
ObservableCardReader.NotificationModeCardPresenceNotificationPolicy (namespace reader.selection)The name describes what is notified; the notion belongs to selection.
ObservableCardReader.finalizeCardProcessing()CardReader.endCardProcessing()finalize is loaded in Java (method of Object, deprecated by the JDK); the operation also moves up to CardReader (see Theme 16).

Removals:

  • CardSelectionManager.setMultipleSelectionMode() and prepareReleaseChannel() — see Themes 1 and 9;
  • ChannelControl and CardTransactionManager.processCommands(ChannelControl) — replaced by processCommands();
  • ReaderProtocolNotSupportedException — disappears with ConfigurableCardReader (see Theme 6);
  • reader.selection.InvalidCardResponseException — duplicate of the error of the same name in the reader namespace.

6.2 Card API

  • Removal of ChannelControl, of ProxyReaderApi.releaseChannel() and of CardResponseApi.isLogicalChannelOpen() (see Theme 1).
  • Removal of the abstract error AbstractApduException: its information (cardResponse, isCardResponseComplete) is carried directly by the four errors concerned (ReaderBrokenCommunication, CardBrokenCommunication, UnexpectedStatusWord, ApduExchangeDurationExceeded).

6.3 Calypso Card API

  • Removals:
    • TransactionManager.processCommands(ChannelControl) and ChannelControl (deprecated);
    • the errors UnexpectedCommandStatusException, ReaderIOException, CardIOException (deprecated), covered by InvalidCardResponse, ReaderCommunication and CardCommunication of the Reader API;
    • the SelectFileException error, which has become pointless (see Theme 13);
    • CalypsoCardApiFactory.createSearchCommandData() (see Theme 11).
  • Renaming of overloaded operations (see Theme 10): prepareSelectFile(short) → prepareSelectFileByLid, prepareSelectFile(SelectFileControl) → prepareSelectFileByControl (parameter harmonised as selectFileControl), in CalypsoCardSelectionExtension and TransactionManager.
  • Nested enumerations renamed: CalypsoCard.ProductType → CalypsoCardProductType, ElementaryFile.Type → ElementaryFileType.
  • Collections named in the plural: the counterNumberToDecValueMap / counterNumberToIncValueMap parameters of prepareDecreaseCounters / prepareIncreaseCounters become decrementValues / incrementValues; the kif / kvc properties of DirectoryHeader become kifByAccessLevel / kvcByAccessLevel.
  • Security settings renamed to the plural: SymmetricCryptoSecuritySetting → SymmetricCryptoSecuritySettings, AsymmetricCryptoSecuritySetting → AsymmetricCryptoSecuritySettings; the factory operations follow (createSymmetricCryptoSecuritySettings, createAsymmetricCryptoSecuritySettings), as does the securitySettings parameter of the createSecure…TransactionManager operations.

6.4 Legacy SAM API

  • Removals:
    • TransactionManager.processCommands() (deprecated) and processCommands(ChannelControl): the manager now inherits CardTransactionManager.processCommands() from the Reader API;
    • the errors UnexpectedCommandStatusException, ReaderIOException, SamIOException, covered by the Reader API errors;
    • LegacySamRevocationServiceSpi.isSamRevoked(serialNumber) (variant without counter value): only isSamRevoked(serialNumber: ByteArray, counterValue: Int) → Boolean remains.
  • Renaming of overloaded operations (see Theme 10):
Before (Java 1.0.0)After (2.0.0)
setUnlockData(String, LegacySam.ProductType)setUnlockDataForProductType(unlockData, productType)
setStaticUnlockDataProvider(provider)setStaticUnlockDataProviderWithDeferredReader(provider)
setStaticUnlockDataProvider(provider, targetSamReader)setStaticUnlockDataProvider(provider, targetSamReader) (nominal case, name unchanged)
setDynamicUnlockDataProvider(provider)setDynamicUnlockDataProviderWithDeferredReader(provider)
setDynamicUnlockDataProvider(provider, targetSamReader)setDynamicUnlockDataProvider(provider, targetSamReader) (nominal case, name unchanged)
prepareReadWorkKeyParameters(int) / (byte, byte)prepareReadWorkKeyParametersByRecordNumber / prepareReadWorkKeyParametersByKifKvc
getWorkKeyParameter(int) / (byte, byte)getWorkKeyParametersByRecordNumber / getWorkKeyParametersByKifKvc
prepareTransferWorkKeyDiversified(…, diversifier)prepareTransferWorkKeyDiversifiedWithSpecificDiversifier(…, diversifier)
LegacySam.ProductTypeLegacySamProductType

6.5 Generic Card API

Before (Java 1.0.0)After (2.0.0)Rationale
CardTransactionManagerGenericCardTransactionManagerName specific to the API, with no collision with the Reader API CardTransactionManager it inherits from.
GenericCardApiFactory.createCardTransaction(reader, card)createGenericCardTransactionManager(reader, card)The name designates the created object.
prepareApdu(String)(removed)Conversion from a string is left to the application.
prepareApdu(byte[])prepareCommand(apdu: ByteArray)“Command”-oriented name.
prepareApdu(byte cla, byte ins, byte p1, byte p2, byte[] dataIn, Byte le)(removed)Building APDUs field by field is left to the application.
getResponsesAsByteArrays()getLastExecutionResponses() → List<ByteArray>Specifies the time scope (last execution).
getResponsesAsHexStrings()(removed)The hexadecimal representation is left to the application.

New operations related to Themes 2 and 7: prepareCommandWithId, prepareCommandWithMaxDuration, getLastExecutionResponse (see §8.2).

6.6 Storage Card API

Before (Java 1.2.0)After (2.0.0)Rationale
ProductType (namespace storagecard.card)StorageCardProductTypeName specific to the API, unambiguous with respect to the other product types of the family.
ProductType.getBlockCount(), getBlockSize(), hasSystemBlock(), hasWriteAcknowledgment(), hasAuthentication()properties blockCount, blockSize, hasSystemBlock, hasWriteAcknowledgment, hasAuthentication of the enumerationThese are data specific to each product, exposed as such (see Theme 10).
StorageCard.getUID()StorageCard.getUid()lowerCamelCase convention for acronyms.
prepareMifareClassicAuthenticate(…, byte[] key)prepareMifareClassicAuthenticateWithKey(…, key)Unique operation names (see Theme 10).
prepareMifareClassicAuthenticate(…, int keyNumber)prepareMifareClassicAuthenticateWithKeyNumber(…, keyNumber)(same)
StorageCardTransactionManager.prepareReadSystemBlock(), prepareWriteSystemBlock(byte[]) (deprecated)(removed); prepareSt25ReadSystemBlock() and prepareSt25WriteSystemBlock(commandId, data) remainThe St25 prefix reflects the product-specific nature of the system block.
StorageCardException interface (getBlockAddress())(removed); the errors carry blockAddress: Int? and commandId: Int?The information is carried directly by each error.
SCAuthenticationFailedException extends CardCommunicationExceptionStorageCardAuthenticationFailed (no parent error)An authentication failure is not a communication error.

In addition, StorageCard.getBlock, getBlocks and getSystemBlock now explicitly return ByteArray? (null if the data has not been read).

6.7 Crypto Symmetric and Crypto Asymmetric APIs

The evolutions of these two APIs relate to Themes 10 and 11 (data objects, removal of input/output objects); they are detailed in §11 and §12 and in Annex A.


7. Theme 6 — Strict typing of RF technologies and card types (ECP support)

7.1 Motivation

Two drivers converge:

  1. End of free-form strings for protocols. The production versions configured protocol activation and selection filtering with character strings (physicalProtocolName, logicalProtocolName): non-standardised values, undetected typos, scattered documentation.
  2. Arrival of ECP support (Enhanced Contactless Polling), a mechanism defined by the Apple ECP specification that allows fast detection of cards (notably Calypso) in transit mode on iPhone, and requires sending a specific polling frame when detection starts. The frame is handled as opaque binary data built by the application.

7.2 New foundation API — Terminal Reader Definitions API

The RfTechnology and CardType enumerations are placed in a new foundation API, the Terminal Reader Definitions API, which exposes neither service interface nor SPI; its only purpose is to host the cross-cutting enumerated types shared between Terminal APIs.

Structural consequences

  • New repository: calypsonet-terminal-reader-definitions-api-spec (version 1.0.0-SNAPSHOT).
  • New Keypop Java module: keypop-reader-definitions-jvm-api (to be created).
  • Public and transitive dependency of the Terminal Reader API on the Terminal Reader Definitions API (the enumerations appear in the properties BasicCardSelector.cardType, IsoCardSelector.cardType, CardDetectionSettings.rfTechnologies and …CardSelectionResult.cardType).

Initial content

  • ReaderDefinitionsApiProperties — VERSION constant of the module;
  • RfTechnology: ISO_14443_AB, INNOVATRON_B_PRIME, FELICA, ISO_15693;
  • CardType: ISO_7816_3, ISO_14443_4, ISO_14443_3A_MIFARE_CLASSIC_1K, ISO_14443_3A_MIFARE_CLASSIC_4K, ISO_14443_3A_MIFARE_ULTRALIGHT, ISO_14443_3B_ST25_SRT512, INNOVATRON_B_PRIME, FELICA, ISO_15693, UNKNOWN.

CardType granularity and A/B asymmetry with RfTechnology: RfTechnology is an input (polling) that merges A and B at the ISO 14443 level; CardType is an output that combines protocol level and product identity — a single ISO_14443_4 value for the transport, but a product granularity (ISO_14443_3A_…, ISO_14443_3B_…) for proprietary products.

CardType.UNKNOWN is returned when the card type could not be identified; used as a selection filter, it allows these cards to be captured explicitly.

7.3 Reader API — strict typing

  • Removed: CardSelector.filterByCardProtocol(String logicalProtocolName).
  • Added: the cardType: CardType? = null property of the BasicCardSelector and IsoCardSelector selectors — filters by card type (null disables the filter).
  • Removed entirely: the ConfigurableCardReader interface and its operations activateProtocol(String, String), deactivateProtocol(String), getCurrentProtocol().

7.4 Reader API — detection settings

All detection information is grouped in the data class CardDetectionSettings, built directly by the application:

PropertyTypeDefault valueRole
detectionModeDetectionModeDetectionMode.REPEATINGwhether detection resumes after each card processing
rfTechnologiesSet<RfTechnology>setOf(RfTechnology.ISO_14443_AB)RF technologies activated during polling (no effect on a contact reader)
ecpFrameByteArray?nullECP frame emitted when polling starts (ECP readers only)
  • DetectionMode becomes a top-level enumeration of the reader namespace (it was nested in ObservableCardReader).
  • Tolerance of unsupported settings: a setting not supported by the reader (RF technology, ECP frame) is silently ignored and a WARN-level message is typically logged; no error is raised.

Change compared with the previous working version of this document: CardDetectionSettings is no longer a “builder” interface obtained through ReaderApiFactory.createCardDetectionSettings(), but a data class with default values (see Theme 10).

7.5 Reader API — ObservableCardReader and selection result

  • startCardDetection(settings: CardDetectionSettings, eventHandler: CardReaderEventHandler) → Unit carries the event handler and the detection configuration in a single call.
  • The detected card type is exposed by the cardType: CardType property of the selection results (SingleCardSelectionResult, SequentialCardSelectionResult, MultichannelCardSelectionResult, see Theme 9); UNKNOWN if the type could not be identified.

7.6 Rationale

  • Compile-time safety for values: moving from strings to enumerations eliminates a class of bugs and makes the API self-describing.
  • Simplicity: a single ObservableCardReader, a single detection settings class.
  • Extensibility: adding a polling setting amounts to adding a property with a default value to CardDetectionSettings, without touching the startCardDetection signature.
  • Input / output separation: RfTechnology as input (polling), CardType as output (result) and as a selection criterion.
  • Single, typed declaration: in production, the protocol had to be declared twice (activateProtocol on the reader side, filterByCardProtocol on the selector side); it is now declared only once, in a typed way.
  • Cross-cutting reusability thanks to the extraction of the enumerations into the Terminal Reader Definitions API.

8. Theme 7 — Command identification (commandId)

8.1 Motivation

Several APIs allow several commands to be prepared before executing them as a batch. In production, the application had no direct means of identifying which command caused a problem, nor of accessing the result of a specific command; some APIs relied on mutable container objects for this purpose (KeyPairContainer, SearchCommandData.getMatchingRecordNumbers(), SignatureComputationData.getSignature(), etc.).

The new versions generalise a single mechanism: an integer identifier commandId supplied by the application when preparing the command, then used to retrieve the result of the command or to identify the failing command. The commandId parameter, always placed first, follows the same convention as selectionCaseId in the Reader API (see Theme 9).

The name commandId replaces idCommand from the previous working version of this document, for consistency with selectionCaseId.

8.2 Generic Card API

  • prepareCommandWithId(commandId: Int, apdu: ByteArray) → Self;
  • prepareCommandWithMaxDuration(commandId: Int, apdu: ByteArray, maxDurationUs: Long) → Self (see Theme 2);
  • getLastExecutionResponse(commandId: Int) → ByteArray? — response of the identified command; if several commands share the same identifier, the most recently processed one is returned.
  • prepareCommand(apdu: ByteArray) → Self remains available for unidentified commands.

8.3 Storage Card API

  • prepareWriteBlocks(commandId: Int, fromBlockAddress: Int, data: ByteArray) → Self;
  • prepareSt25WriteSystemBlock(commandId: Int, data: ByteArray) → Self.

For these two write operations, commandId is mandatory (non-nullable). It is returned by the commandId: Int? property of the Storage Card API errors when the identified command caused them (null for commands that carry none, such as reads).

8.4 Calypso Card API

  • prepareSearchRecords(commandId: Int, data: SearchCommandData) → Self;
  • CalypsoCard.getMatchingRecordNumbers(commandId: Int) → List<Int>? — numbers of the records found by the identified search. This operation replaces SearchCommandData.getMatchingRecordNumbers() (see Theme 11).

8.5 Legacy SAM API

The results of the cryptographic commands are no longer read from container objects but from the LegacySam, by identifier:

PreparationReading the result
FreeTransactionManager.prepareGenerateCardAsymmetricKeyPair(commandId: Int)LegacySam.getKeyPair(commandId: Int) → ByteArray?
FreeTransactionManager.prepareComputeCardCertificate(commandId: Int, data: LegacyCardCertificateComputationData)LegacySam.getComputedCardCertificate(commandId: Int) → ByteArray?
prepareComputeSignature(commandId: Int, data: SignatureComputationData) (on FreeTransactionManager and CardTransactionLegacySamExtension)LegacySam.getSignature(commandId: Int) → ByteArray? and, in traceable mode, LegacySam.getSignedData(commandId: Int) → ByteArray?
prepareVerifySignature(commandId: Int, data: SignatureVerificationData) (same)LegacySam.isSignatureValid(commandId: Int) → Boolean?

These reads replace KeyPairContainer.getKeyPair(), LegacyCardCertificateComputationData.getCertificate(), SignatureComputationData.getSignature(), TraceableSignatureComputationData.getSignedData() and SignatureVerificationData.isSignatureValid().

8.6 Rationale

  • Application semantics: the identifier is chosen by the application, which can align it with its own business logic.
  • Immutable data objects: the parameters of a command become pure data (see Theme 10); the result is carried by the live object that receives the responses (CalypsoCard, LegacySam, transaction manager), like all the other data coming from the card.
  • Cross-API consistency: the same pattern (identifier first, read by identifier) applies to all the APIs concerned.

9. Theme 8 — Standardised reader discovery and access (CardReaderProvider)

9.1 Motivation

In production, the Reader API exposed no standard means of discovering the available readers or of obtaining a reference to a reader. The application had to rely on the plugin and pool abstractions of the underlying Keyple framework, which are implementation-specific and not portable.

9.2 Reader API

  • New operation ReaderApiFactory.getCardReaderProvider() → CardReaderProvider — returns the CardReaderProvider of the execution environment; successive calls return the same instance.
  • New interface CardReaderProvider:
    • getReaderNames() → Set<String>;
    • getReaders() → Set<CardReader>;
    • getReader(readerName: String) → CardReader? — exact name match, null if no reader matches;
    • findReader(readerNameRegex: String) → CardReader? — first reader whose name matches the regular expression, null otherwise.

The reader lifecycle remains driven by the execution environment; CardReaderProvider is a read-only view of the readers active at each call.

9.3 Rationale

  • Decoupling from Keyple implementation concepts: the application only knows the Reader API.
  • First-class citizen of the public API for a universal need.
  • Two complementary search modes: exact name and regular expression.

10. Theme 9 — Redesign of the card selection model

10.1 Motivation

In production, the CardSelectionManager gathered all selection modes, driven by a side effect (setMultipleSelectionMode()), and returned a single CardSelectionResult in which some properties could be deduced from others (getActiveSmartCard() and getActiveSelectionIndex() from getSmartCards()). Adding multi-channel made this single result ambiguous (which card is “the” active card when several are active?). The previous working version of this document proposed a SelectionExecutionPolicy parameter; this approach has been abandoned in favour of one manager type per selection mode.

10.2 Reader API — one manager per mode

The selection mode is no longer a parameter: it is carried by the type of the manager, each obtained through its own factory operation and producing its own result type.

ManagerBehaviourExecutionResult
SingleCardSelectionManagersingle-channel; stops at the first matching case: the first card application, or the card itself when it hosts no application (storage card)explicit or scheduledSingleCardSelectionResult
SequentialCardSelectionManagersingle-channel; selects in turn every matching application of the card, only the last one remaining active; not applicable to storage cardsexplicit or scheduledSequentialCardSelectionResult
MultichannelCardSelectionManagermulti-channel ISO 7816-4 cards; every matching application stays active simultaneously, each on its own logical channel; out of scope for storage cardsexplicitMultichannelCardSelectionResult

TC remark (Stéphane): the scenarios discriminate the applications of a single physical card; the API keeps the term card because a selection case also targets cards without any application, such as storage cards. This is now made explicit in the specification, in the CardSelectionManager section.

Compared with the previous working version of this document, MultipleCardSelectionManager is renamed SequentialCardSelectionManager (as are its result and its factory operation): the qualifier describes the scenario execution mode, not a number of cards. Likewise, prepareSelection becomes prepareIsoSelectionCase or prepareBasicSelectionCase, depending on the family of the selector, and selectionId becomes selectionCaseId.

  • Factory: createCardSelectionManager() is replaced by createSingleCardSelectionManager(), createSequentialCardSelectionManager() and createMultichannelCardSelectionManager().
  • CardSelectionManager becomes the common interface and only keeps the mode-independent operations:
    • prepareIsoSelectionCase(selectionCaseId: Int, cardSelector: IsoCardSelector, cardSelectionExtension: IsoCardSelectionExtension) → Self — the selection identifier is chosen by the application (instead of an index returned by the API); it must be unique within the scenario; selections are executed in preparation order;
    • exportCardSelectionScenario() → String;
    • importCardSelectionScenario(cardSelectionScenario: String) → Self — replaces the current scenario (instead of returning the index of the last imported selection);
    • exportProcessedCardSelectionScenario() → String.
  • Operations specific to each manager (typed by their result): processCardSelectionScenario, scheduleCardSelectionScenario, parseScheduledCardSelectionsResponse and prepareBasicSelectionCase (single-channel only), importProcessedCardSelectionScenario (the imported processed scenario must come from a manager of the same type).
  • scheduleCardSelectionScenario(observableCardReader: ObservableCardReader, cardPresenceNotificationPolicy: CardPresenceNotificationPolicy) → Unit no longer has an execution policy parameter.

Selection results

ResultProperties
SingleCardSelectionResultcardType: CardType, selectionCaseId: Int?, smartCard: SmartCard? (both null if no selection succeeded)
SequentialCardSelectionResultcardType: CardType, smartCards: Map<Int, SmartCard>, activeSelectionCaseId: Int? (only the card of the last successful selection remains active)
MultichannelCardSelectionResultcardType: CardType, smartCards: Map<Int, SmartCard> (all active, one per channel)

CardSelectionResult (with getSmartCards(), getActiveSmartCard(), getActiveSelectionIndex()) and SelectionExecutionPolicy disappear.

Selectors

  • BasicCardSelector and IsoCardSelector become data classes built directly by the application (instead of “builder” interfaces created by ReaderApiFactory.createBasicCardSelector() / createIsoCardSelector(), which are removed):
    • BasicCardSelector: cardType: CardType? = null, powerOnDataRegex: String? = null;
    • IsoCardSelector: the same, plus dfName: ByteArray? = null, fileOccurrence: FileOccurrence = FileOccurrence.FIRST, fileControlInformation: FileControlInformation = FileControlInformation.FCI.
  • CardSelector<T> becomes a sealed interface without members, whose only implementations are these two selectors.
  • The intermediate interface CommonIsoCardSelector<T> is removed; its nested enumerations become FileOccurrence and FileControlInformation (namespace reader.selection).
  • filterByDfName(String) (AID in hexadecimal) is removed: dfName is a ByteArray.

Selector and extension pairing

A selection case is the pairing of a card selector with the selection extension of the same family. The preparation operations carry that pairing in their signature, so a mismatch can no longer be expressed:

FamilySelectorSelection extensionPreparation operation
ISO/IEC 7816-4IsoCardSelectorIsoCardSelectionExtensionprepareIsoSelectionCase, on every manager
Non-ISOBasicCardSelectorBasicCardSelectionExtensionprepareBasicSelectionCase, on the single-channel managers only
  • CardSelectionExtension, the former common marker, is removed: no operation accepted it any more, and each card extension now declares its family. CalypsoCardSelectionExtension and GenericCardSelectionExtension are ISO extensions; StorageCardSelectionExtension and LegacySamSelectionExtension are basic ones.
  • Being restricted to ISO/IEC 7816-4 cards, MultichannelCardSelectionManager exposes only the ISO preparation operation: its restriction is no longer a sentence in the documentation but a property of its surface.
  • A single scenario MAY still mix the two families — an ISO case and a basic one, for a terminal accepting both a Calypso card and a storage card — since both operations feed the same scenario.

10.3 Card API — selection SPIs per family

The same pairing applies to the card-extension side:

  • CardSelectionExtensionSpi keeps only getCardSelectionRequest(); the parsing of the selection response moves to BasicCardSelectionExtensionSpi (parse(…) → SmartCardSpi) and IsoCardSelectionExtensionSpi (parse(…) → IsoSmartCardSpi), counterparts of the two public markers.
  • IsoSmartCardSpi is inserted between SmartCardSpi and MultichannelSmartCardSpi, so that the multi-channel facet derives from the ISO one. A card extension that is not ISO can therefore no longer produce a smart card active on a logical channel.
  • The correspondence table of the Card API lists one row per family, and gains the IsoSmartCard / IsoSmartCardSpi row that was missing.

10.4 Rationale

  • No side effect: the selection mode is set when the manager is created.
  • Unambiguous results: each result only exposes what makes sense in its mode; deducible properties and the “channel 0 card” / “first active index” contradiction disappear.
  • Identifiers chosen by the application, consistent with commandId (Theme 7).
  • Naming: Single and Multiple designate the number of successful selections kept in the result, not a number of cards; all the selections of a scenario target the same card.

11. Theme 10 — Implementation-language-independent specification

11.1 Motivation

The Terminal APIs were until now defined by Java interfaces. This model de facto tied the APIs to the JVM and hindered their implementation in other environments (native mobile applications, embedded systems, non-Java terminals). The new design proposal aims to broaden the choice of implementation languages: Kotlin Multiplatform (KMP), Rust, Swift, C#, etc., in addition to Java. The new specifications are therefore written in a language-independent notation, inspired by Kotlin, so that each binding translates the contract into the most idiomatic form of its platform. This notation entails systematic changes of form, described below; most of them do not affect behaviour, but all of them affect the way calling code is written.

11.2 Notation principles

PrincipleIn production (Java)In the specificationsExamples
Basic typesbyte, short, int, long, boolean, byte[], Integer…Byte, Short, Int, Long, Boolean, ByteArray, Int?… (Data types table of each spec)—
Explicit nullabilitynull values documented in the JavadocT? type; otherwise the value is never nullgetFileBySfi(sfi: Byte) → ElementaryFile?
Fluent chainingrecursive genericity T extends X<T>Self return type; no more recursive genericityTransactionManager.prepareReadRecords(...) → Self
Data classes“builder” interfaces (setters) or read interfaces (getters), created by the factoryimmutable data classes with properties (val) and default values, built directly by the application; the corresponding create… operations disappear from the factorySearchCommandData, BasicCardSelector, CardDetectionSettings, ApduRequest
Enumerationsenumerations nested in an interfacetop-level enumerations, named autonomouslyCardReaderEvent.Type → CardReaderEventType
Data specific to an enumeration valuemethods of the enumerationproperties of the enumerationStorageCardProductType.blockSize
Closed typesopen generic interfacesealed interfaceCardSelector, SignatureComputationData, SignatureVerificationData
Interfaces without operationsempty interfacemarker interfaceScheduledCardSelectionsResponse, BasicCardSelectionExtension, IsoCardSelectionExtension
Errors…Exception classes (checked or unchecked)errors named without suffix, carrying message: String and cause: Any?CardCommunicationException → CardCommunication
Technical suffixes…Spi, …Api on the data types of the Card API and the crypto APIsremoved for data; kept for contract interfacesApduRequestSpi → ApduRequest, SvCommandSecurityDataApi → SvCommandSecurityData
Unique operation namesoverloads (same name, different parameters)one unique name per operation within an interface and its hierarchy; By…, With…, For… suffixesprepareSelectFile → prepareSelectFileByLid / prepareSelectFileByControl
Universal typeObject, ThrowableAnyonReaderError(context, readerName, error: Any)
ReflectionClass<E>removedgetCryptoExtension(Class<E>) → getCryptoExtension() (see Theme 14)
Serialisationextends Serializableremoved from the notationApduResponseApi, CardResponseApi

11.3 Normative contracts

Each operation is now described by a normative table that specifies:

  • its signature, its introduction version (Since) and its description;
  • its pre-conditions, each prefixed by its nature, which determines the error raised if it is not met: Argument (invalid argument, including a value outside the bounds of the card or SAM protocol), Range (position outside the bounds of a collection or memory image exposed by the API), State (illegal state), Capability (unsupported operation);
  • its errors, i.e. the situations a correct caller must handle;
  • cross-references to related operations and types.

The specifications also define common rules (non-null results unless stated otherwise, empty collections rather than null, instances not shared between threads, default parameter values) as well as, for the Card API and the crypto APIs, conformance clauses that establish the correspondence between their types and those of the Reader API or the Calypso Card API (for example, any object implementing ProxyReaderApi must also implement CardReader).

11.4 Rationale

  • Portability: the contract no longer imposes any Java-specific mechanism (reflection, recursive genericity, overloads); it can be transposed into any language, including those without overloading or class inheritance (Rust in particular), which paves the way for implementations in Kotlin Multiplatform, Rust, Swift or C#.
  • Robustness: explicit nullability and immutable data eliminate invalid states (incomplete “builder” object, unexpected null value).
  • Precision: typed pre-conditions and errors listed per operation make the contract verifiable.
  • Java binding: the way the Java binding will implement these principles (data classes, Self, default values) is part of the alignment of the Keypop modules and of the migration guide (see §22).

12. Theme 11 — Data exposed without computation and access to raw data

12.1 Motivation

Several data types of the production versions mixed data and computations (decoding a counter from a record, selecting a parameter by number), exposed both a raw value and its decoded fields, or served both as input and output. The specifications apply three rules:

  1. no computational operation on a data type: such computations are performed by the live object that holds the data (CalypsoCard, LegacySam);
  2. no field deducible from other fields in a data class;
  3. no input/output object: inputs are parameters, outputs are returned values.

12.2 Calypso Card API

  • FileData is removed, together with its operations getContent(), getContent(numRecord), getContent(numRecord, dataOffset, dataLength), getAllRecordsContent(), getContentAsCounterValue(numCounter) and getAllCountersValue():
    • the records are exposed directly by the ElementaryFile.records: SortedMap<Int, ByteArray> property (instead of ElementaryFile.getData());
    • counter values are obtained through CalypsoCard.getCounterValuesBySfi(sfi: Byte) → SortedMap<Int, Int>? and CalypsoCard.getCounterValuesByLid(lid: Short) → SortedMap<Int, Int>?.
  • DirectoryHeader: getKif(WriteAccessLevel) and getKvc(WriteAccessLevel) become the properties kifByAccessLevel: Map<WriteAccessLevel, Byte> and kvcByAccessLevel: Map<WriteAccessLevel, Byte>.
  • SearchCommandData becomes an input data class (sfi, searchData, startAtRecord = 1, offset = 0, repeatedOffset = false, mask: ByteArray? = null, fetchFirstMatchingResult = false); the result is read through CalypsoCard.getMatchingRecordNumbers(commandId) (see Theme 7); CalypsoCardApiFactory.createSearchCommandData() disappears.
  • SvLoadLogRecord and SvDebitLogRecord become data classes without the rawData property, which is redundant with the decoded fields. The raw values remain accessible through three new CalypsoCard operations: getSvLoadLogRecordRawData() → ByteArray?, getSvDebitLogLastRecordRawData() → ByteArray? and getSvDebitLogAllRecordsRawData() → List<ByteArray>; each returned decoded object is the decoding of the raw value at the moment of the call.
  • DirectoryHeader, ElementaryFile and FileHeader become data classes.

12.3 Legacy SAM API

  • KeyParameter becomes the KeyParameters data class, renamed to the plural like the getSystemKeyParameters / getWorkKeyParameters… getters that return it (kif, kvc, algorithm, parameterValues: SortedMap<Int, Byte>), without rawData; getParameterValue(parameterNumber) is replaced by the parameterValues property. The raw values are accessible through LegacySam.getSystemKeyParametersRawData(systemKeyType), getWorkKeyParametersRawDataByRecordNumber(recordNumber) and getWorkKeyParametersRawDataByKifKvc(kif, kvc).
  • SamParameters is removed: LegacySam.getSamParameters() directly returns ByteArray?.
  • Counters: getCounter(counterNumber) and getCounterCeiling(counterNumber) are removed (the getCounters() and getCounterCeilings() tables are sufficient); getCounterIncrementAccess(counterNumber) is replaced by getCounterIncrementAccesses() → SortedMap<Int, CounterIncrementAccess>.
  • Command data: LegacyCardCertificateComputationData, BasicSignatureComputationData, TraceableSignatureComputationData, BasicSignatureVerificationData and TraceableSignatureVerificationData become input data classes (properties and default values instead of setters; withSamTraceabilityMode(offset, mode) becomes samTraceabilityMode / traceabilityOffset, withoutBusyMode() becomes busyMode = false); their results are read from the LegacySam by commandId (see §8.5). KeyPairContainer is removed. The create…Data() and createKeyPairContainer() operations disappear from LegacySamApiFactory.
  • SecuritySetting becomes the LegacySamSecuritySettings data class (samReader, controlSam), renamed to the plural like the security settings of the Calypso Card API, and prefixed to avoid the homonymy with the SecuritySettings of the Calypso Card API, instead of setControlSamResource(samReader, controlSam); LegacySamApiFactory.createSecuritySetting() disappears.

12.4 Card API

  • ApduResponse only keeps apdu (and apduExchangeDurationUs): getDataOut() and getStatusWord() are removed, as they can be deduced from apdu.
  • ApduRequestSpi, CardRequestSpi, CardSelectionRequestSpi, ApduResponseApi, CardResponseApi and CardSelectionResponseApi become the data classes ApduRequest, CardRequest, CardSelectionRequest, ApduResponse, CardResponse and CardSelectionResponse. Default values are explicit: successfulStatusWords = setOf(0x9000), successfulSelectionStatusWords = setOf(0x9000), info = null, cardRequest = null.

12.5 Crypto Symmetric API

  • SvCommandSecurityDataApi (input/output object) is replaced:
    • the inputs become parameters: computeSvCommandSecurityData(svGetRequest: ByteArray, svGetResponse: ByteArray, svCommandPartialRequest: ByteArray) → SvCommandSecurityData;
    • the output is the SvCommandSecurityData data class (serialNumber, transactionNumber, terminalChallenge, terminalSvMac, non-nullable).
  • createCardTransactionManager(..., exchangedApdus: MutableList<ByteArray>): the parameter is renamed — the list receives the exchanged APDUs, not transaction audit data — and is explicitly mutable (the crypto module appends its data to it).
  • cipherPinForPresentation and cipherPinForModification take non-nullable kif: Byte and kvc: Byte (instead of boxed Byte).

12.6 Crypto Asymmetric API

  • CaCertificateContentSpi becomes the CaCertificateContent data class; the isAidCheckRequested property is removed, as it can be deduced from aid (null when the AID check is not requested).
  • CardPublicKeySpi is removed: the card public key is a ByteArray (CardCertificateSpi.checkCertificateAndGetPublicKey(...) → ByteArray, AsymmetricCryptoCardTransactionManagerSpi.initTerminalPkiSession(cardPublicKey: ByteArray)).
  • A conformance clause establishes the correspondence between the SPIs of this API and the marker interfaces of the Calypso Card API (PcaCertificate, CaCertificate, CardCertificate, the parsers and the factory).

12.7 Rationale

  • An API describes data and behaviours, not decoding algorithms: computations on data remain the responsibility of the object that holds them.
  • No double truth: a deducible field can diverge from its source; removing it eliminates the risk.
  • Raw access preserved where it has a real use (transmission to the back office, re-injection of key parameters into transfer commands).

13. Theme 12 — Stored Value (SV) operations

13.1 Motivation

The Calypso card specification defines three SV commands — Reload, Debit and Undebit — preceded by an SV Get command, one parameter of which indicates the targeted operation: Reload or Debit/Undebit. The production model additionally introduced a DO/UNDO notion (SvAction) that does not exist for reloading and hid the undebit behind prepareSvDebit.

13.2 Calypso Card API

  • SvAction is removed.
  • prepareSvGet(svOperation: SvOperation) → Self — only takes the operation.
  • SvOperation.DEBIT is renamed DEBIT_UNDEBIT, in accordance with the card specification; RELOAD is unchanged.
  • New operation prepareSvUndebit(amount: Int, date: ByteArray, time: ByteArray) → Self — cancels, totally or partially, a previous debit; amount in 0..32768.
  • prepareSvDebit(amount: Int, date: ByteArray, time: ByteArray) → Self — now only performs the debit; amount in 0..32767.
  • prepareSvReload(amount: Int, date: ByteArray, time: ByteArray, free: ByteArray) → Self — amount in -8388608..8388607 (a negative reload is expressed directly by a negative amount).
  • The overloads without data prepareSvDebit(int) and prepareSvReload(int) are removed: all parameters are mandatory and non-nullable; the date, time and free fields (2 bytes each) are recorded in the SV log.
  • Each command requires an immediately preceding SV Get prepared with the corresponding operation (DEBIT_UNDEBIT for debit and undebit, RELOAD for reload): no other command may come between them. On an automatic session split, the SV Get is re-issued in the new session, right before the SV command.

13.3 Rationale

The model now follows the card specification exactly: three commands, two SV Get contexts. The amount range and the log data are explicit in each operation.


14. Theme 13 — Tolerance of a missing file or record in a secure session

14.1 Motivation

All Calypso cards now tolerate the 6A82h (File Not Found) and 6A83h (Record Not Found) status words in a secure session for read commands (Select File, Get Data, Read Binary, Read Records, Read Record Multiple, Search Record Multiple). On a heterogeneous card fleet, the presence of a file or of a record is not always known in advance, and an unsuccessful read should not cancel the session.

The tolerance is explicitly enabled by the integrator: the default behaviour, stricter, remains the failure of the transaction inside a session.

14.2 Calypso Card API

  • Two new security settings: authorizeFileNotFoundError() → Self and authorizeRecordNotFoundError() → Self, carried by the parent interface SecuritySettings and therefore available in SymmetricCryptoSecuritySettings as well as in AsymmetricCryptoSecuritySettings. They allow the card to answer 6A82h or 6A83h inside a session without failing the transaction: the affected command is simply not applied to the CalypsoCard and the session continues. They are disabled by default.
  • Reads (prepareReadBinary, prepareReadCounter, prepareReadRecords) and file selection (prepareSelectFileByLid, prepareSelectFileByControl): outside a session, a missing file has never caused processing to fail, and this best-effort mode is unchanged; inside a session, processing fails unless the corresponding setting has been enabled. An invalid offset keeps the two modes best-effort (outside a session) and strict (inside a session).
  • The SelectFileException error is removed.
  • The in-session usage restrictions of prepareReadRecord, prepareReadRecordsPartially and prepareSearchRecords are unchanged: these commands must still not be used within a secure session, in both contact and contactless modes. prepareGetData is relaxed for the single tag FCI_FOR_CURRENT_DF, now allowed inside a session so that the integrity of the FCI obtained in response to Select Application can be checked: the following processCommands() raises InconsistentData if the returned FCI differs from that response. The length of the data read being bounded, the session is not exposed; every other tag remains forbidden.

15. Theme 14 — Crypto extensions and command interleaving

15.1 Motivation

During a card transaction, the application must be able to access the specific operations of the crypto module (for example signature computation by a SAM) in order to interleave card commands and crypto commands within the same transaction. The crypto extension is the instance created, for the current transaction, by the crypto module factory attached to the security setting.

15.2 Calypso Card API

  • <E extends CardTransactionCryptoExtension> E getCryptoExtension(Class<E> cryptoExtensionClass) becomes getCryptoExtension() → CardTransactionCryptoExtension:
    • the operation returns the instance created for this transaction; successive calls return the same instance;
    • commands prepared through the extension join the same queue as the card commands, in call order, and are processed by the same processCommands();
    • the caller converts the instance to the concrete type defined by the crypto module in use (for example CardTransactionLegacySamExtension).

15.3 Legacy SAM API

  • CardTransactionLegacySamExtension.prepareComputeSignature(commandId, data) and prepareVerifySignature(commandId, data) follow the commandId model (see §8.5).

15.4 Rationale

The Class<E> parameter only existed to work around the JVM’s type erasure; it has no equivalent in other languages (Rust in particular). The chosen signature is identical in all bindings, and the identity clause guarantees that the obtained extension is indeed the one sharing the transaction’s command queue.


16. Theme 15 — Validity of the Calypso HCE token

16.1 Motivation

The application serial number of a Calypso HCE application is made of two fields: the two most significant bytes, the SN Header, carry the end of validity of the token, coded as the number of half-days elapsed since 1 January 2010 at 0:00 local time; the six remaining bytes identify the application. What that validity materialises depends on the cryptographic nature of the transaction: in symmetric-key mode it is the end of validity of the debit key; in PKI mode it is the expiry date of the key carried by the card certificate. The API names the token, which has a single validity window whatever the mode. Nothing in the card dialogue reveals an outdated header: in symmetric-key mode the header takes part in the diversification of the keys, so a mobile whose validity window has passed still authenticates normally, and in PKI mode the expiry is attested by the card certificate and is not signalled by the card either. The verification therefore belongs to the terminal, and the production versions offered nothing for it — getApplicationSerialNumber() returns the serial number with its two most significant bytes forced to 0, so the header was not even readable.

16.2 Calypso Card API

  • New SPI HceTimeProvider (namespace calypso.card.spi, a new namespace for the services the application provides to the card extension):
    • getCurrentLocalEpochSeconds() → Long — the current time expressed in the same reference as the SN Header, that is local time, as a number of seconds since 1 January 1970 at 0:00 in that reference. The application provides the clock it trusts; the Calypso encoding and the comparison stay in the specification.
  • New factory operation CalypsoCardApiFactory.setHceTimeProvider(provider) → Self — the service is consulted when the selection response is parsed, by the side that holds the card extension, and is never carried by an exported selection scenario.
  • New accessors on CalypsoCard:
    • getHceTokenExpiryLocalEpochSeconds() → Long? — the decoded header, converted into seconds since 1 January 1970 at 0:00 local time; part of the card image and therefore carried by an exported processed scenario; null when the application is not HCE or the header is not significant;
    • isHceTokenValid() → Boolean? — the verdict computed by the card extension, null when no evaluation took place.
  • New setting SecuritySettings.authorizeExpiredHceToken() → Self, on the contract shared by the symmetric and asymmetric settings.
  • New State pre-condition on both prepareOpenSecureSession operations: the card is not a Calypso HCE application whose token has expired or could not be evaluated, unless the authorisation above has been given.
  • getApplicationSerialNumber() now documents the masking of the two most significant bytes for an HCE application.

16.3 Rationale

The card is never hidden: an application whose token has expired is selected like any other and the verdict is exposed, so the ticketing layer can refuse the service, invite the holder to renew the token, or simply log the event. Making the selection fail would have been indistinguishable from an unknown card, leaving the holder without an explanation and masking a provisioning outage from the operator.

The application is asked for a clock, not for a verdict: the half-day encoding and the 2010 epoch are Calypso conventions, which the specification keeps for itself, while the time reference — local, and necessarily the one in which the tokens were provisioned — is the only thing the application can state. The resolution being half a day, a difference of time zone between the terminal and the issuer of the token shifts the boundary of the validity window by the corresponding offset.

The protection is therefore placed where it matters, at the opening of a secure session, and it covers every secure session whatever its mode and its write access level. It is expressed as a pre-condition rather than as an error raised during the exchange, because the verdict is known as soon as the card is selected: an application that prepares such an opening has ignored an answer it already had.


17. Theme 16 — Card power and RF field

17.1 Motivation

Between two transactions, a terminal often needs the card to be de-energised: to bring a security module back to a known state, to comply with a power budget, or to make sure that the next card starts from a clean state. The production versions offered nothing for it at this level, and the only way to end the dialogue with a card was the observation-specific finalizeCardProcessing(), which a non-observable reader did not expose at all.

17.2 Reader API

  • endCardProcessing() moves from ObservableCardReader to CardReader: every reader, observed or not, now has a way to close the dialogue with the card. No existing caller is broken.
  • The operation gains its electrical effects: the power is removed from the card, and the field is switched off on a contactless reader, except while the reader goes on using it. What exactly happens depends on the situation:
SituationEffect
The reader is not observable, or its card detection is not activeCard powered off, field switched off
Card detection is active in REPEATING modeWaiting-for-card-removal phase, then detection of the next card; the field stays on throughout, first to observe the departure, then for the search for the next card
Card detection is active in SINGLE_SHOT modeDetection stops: card powered off, field switched off
  • The operation reports nothing: it raises no error, and failures of the underlying exchanges — including a communication failure with the card or with the reader — are not reported. It is meant to be called in a finally block, where raising would mask the business failure being handled; the condition surfaces at the next operation.
  • startCardDetection() applies the energy the polling requires: the field is switched on on a contactless reader, and a card already present in the slot of a contact reader is powered, then processed as a newly detected one.
  • stopCardDetection() removes the power and switches the field off, no polling remaining to be performed. While a processing cycle is in progress the effect is held back, until endCardProcessing() ends the cycle.
  • isCardPresent() may, on the contrary, require the card to be powered; an implementation may also defer the power-on until the first exchange. It never de-energises a card that is already powered. On a contactless reader it switches the field on, and the field stays on, when a card answers, until the end of the cycle. On a contact reader without a presence switch, the reader either answers true by default or attempts to energise the card and answers according to the outcome — an observable reader uses the second approach, so that its detection does not report a card that is not there.
  • SINGLE_SHOT is clarified: detection stops at the end of the cycle without waiting for the card to leave, which the previous wording suggested.
  • New section Card power and RF field in the architectural overview, which states the principle of these effects and summarises the state targeted after each call:
CallContact, cardContact, no cardContactless, cardContactless, no card
isCardPresent(), detection inactiveReader-dependentOffOnOff
Synchronous selection, detection inactiveOnOffOnOff
startCardDetection()OnOffOnOn
stopCardDetection(), no processing cycle in progressOffOffOffOff
stopCardDetection(), processing cycle in progressHeldOffHeldOff
endCardProcessing(), detection inactiveOffOffOffOff
endCardProcessing(), SINGLE_SHOT modeOffOffOffOff
endCardProcessing(), REPEATING modeOnOffOnOn

On means that the energy is applied — the card is powered on a contact reader, the field is on on a contactless reader; Off means that it is not; Held means that the preceding state is left unchanged for the time being. stopCardDetection() and endCardProcessing() end on Off whichever is called first, and on a contactless reader endCardProcessing() switches the field off even when the cycle amounted to nothing more than a call to isCardPresent().

17.3 Rationale

The specification describes effects, never capabilities: hardware differs too widely for a terminal API to declare what a reader can do. These effects are therefore provided on a best-effort basis — a reader that cannot carry them out performs what it can, raises no error, and reports nothing. An application must not rely on them for a security purpose; it relies on them to leave the reader in a sane state.

Finer control — switching the field on and off on demand, resetting a card, choosing a power policy — stays outside the scope of the Terminal APIs and belongs to the interfaces each reader implementation exposes on its own.


18. Theme 17 — Card revocation

18.1 Motivation

An issuer may withdraw a card from service — one reported lost or stolen, one that is the subject of a dispute, one whose holder’s entitlement has ended. Nothing in the card records that decision: it lives in a list the issuer maintains, outside the card. The production versions offered nothing at this level, so the check was entirely the application’s business, with no contract stating when it had to happen nor what had to follow. The Legacy SAM API already had the equivalent for a SAM — LegacySamRevocationServiceSpi and the SamRevoked error; the card side had nothing.

18.2 Calypso Card API

The design is the one of Theme 15, applied to a second verdict:

  • New SPI CardRevocationStatusProvider (calypso.card.spi):
    • isCardRevoked(applicationSerialNumber: ByteArray) → Boolean — the operation always answers: no third value reports an unavailable list or an incomplete cache, such a fallback belonging to the provider, the only component holding the operational context. The lookup key is the 8-byte application serial number; no partial match is defined, a prefix designating no single card. For an HCE application the two most significant bytes are forced to 0, so the key survives the renewal of the token.
  • New factory operation CalypsoCardApiFactory.setCardRevocationStatusProvider(provider) → Self.
  • New accessor CalypsoCard.isRevoked() → Boolean? — the verdict, part of the card image and therefore carried by an exported processed scenario; null in a single case, when no provider was registered. Not to be confused with isDfInvalidated(), which reports an invalidation carried by the card itself.
  • New setting SecuritySettings.authorizeRevokedCard() → Self, on the contract shared by the symmetric and asymmetric settings.
  • Second State pre-condition on both prepareOpenSecureSession operations: the card is not revoked and its revocation status could be verified, unless the authorisation above has been given.
  • New section Application-supplied services in the architectural overview, stating once the rules shared by this provider and the HCE time provider: consultation when the selection response is parsed, by the side holding the card extension; locality, the verdict alone being exported; and the ban on blocking remote calls, these services running inside the contactless window.

18.3 Rationale

The check is fail-closed, including when no provider is registered. Nothing in a card signals that a revocation check is due — unlike the SN Header, which announces an HCE validity window by its mere presence. The trigger is therefore the opposite one: absent a provider, the status is unverified, and no secure session may be opened until authorizeRevokedCard() is called. Every integration must consequently state something: register a provider, or authorise cards whose revocation status is unknown. This is the doctrine of Theme 2 applied here — a security control must not be silently absent — and the name of the flag states the accepted risk instead of hiding it behind a permissive default.

Two separate SPIs rather than one. The HCE time provider and the revocation status provider share a category, not a contract. A fleet without HCE applications has no clock to provide; a clock is a platform concern and a revocation list a back-office one, implemented by different components on different release cycles; and adding an operation to a published SPI breaks every one of its implementers. The Legacy SAM API makes the same choice, with distinct SPIs for revocation and for unlock data. What the two do share is factored into one architectural section rather than into one interface.

The provider’s answer is not nullable. A third value reporting an unknown status would make a transient condition — a back-office outage — violate a State pre-condition, whereas every pre-condition of the family describes a stable state the application controls. It would also leave an integrator without a way to degrade gracefully, authorizeRevokedCard() being a configuration-time decision rather than a per-transaction one. The fallback therefore stays with the provider, which alone knows the age of its cache and the policy of the operator, and null keeps a single meaning on isRevoked(): no provider was registered. Should distinguishing unknown prove necessary for the ticketing decision, it would call for a typed status, not for a nullable Boolean.

The card is never hidden, as for an expired HCE token: a revoked card is selected like any other and the verdict is exposed, so the ticketing layer can refuse the service, raise an alert or log the event. Making the selection fail would have been indistinguishable from an unknown card.


19. Theme 18 — Transaction counter

19.1 Motivation

A Calypso card decrements a transaction counter each time it performs an operation involving one of its secret keys. The counter only ever decreases, and once it reaches zero the card refuses the operations that consume it — the medium then has to be replaced. A network therefore has an interest in watching that counter, so as to anticipate the renewal of its media rather than discover their exhaustion in front of a gate.

CalypsoCard.getTransactionCounter() existed since version 1.2, but two limits made it unusable for that purpose: it carried a State pre-condition requiring an open secure session, and its value was defined as coming from the last successful Open Secure Session during that session. The value could therefore not be read before or after the transaction — precisely when an application decides whether to renew a medium.

19.2 Calypso Card API

  • getTransactionCounter() → Int? (was → Int): the State pre-condition disappears, and the value is now the one the card reported at the last Open Secure Session, whichever performed it — a session opening operation, or the pre-opening prepared during the card selection.
  • The value is the up-to-date one, returned by the card after the opening has consumed it: it is what the card holds once the session is open, not what it held before. A pre-opened session is not charged twice — the pre-opening consumes one unit and reports the result, and the session opening that consumes it afterwards consumes nothing more and reports that same value.
  • No dedicated command: the value comes from an opening the application performs anyway. Reading the counter without opening a session would require a Get Challenge, which is deliberately not exposed.
  • null until an opening has taken place: at least one secure session opening, or one pre-opening through CalypsoCardSelectionExtension.preparePreOpenSecureSession(), must have been performed for a value to be available.
  • As early as the selection: a pre-opening makes the value available as soon as the selection response is parsed, before any transaction manager exists. The value belongs to the card image, and is therefore carried by an exported processed selection scenario, so that a thin client reads a counter obtained by the side holding the card extension.
  • New section Transaction counter in the architectural overview.

19.3 Rationale

The exposed value is an upper bound, and the specification says so. Operations that consume the counter without returning it — a key or PIN decryption, a Stored Value operation performed outside a secure session — decrement it without this value following. The bias is therefore optimistic: an application watching the counter for renewal purposes may believe more transactions remain than the card will grant. Stating the direction of the error matters more than stating that an error exists, since the whole point of the value is to trigger a decision.

The properties of the counter are not described here. Its width, its initial value, the operations that consume it and whether it is shared by every application of the card depend on the card product and on its revision; older products may even hold one counter per application. These belong to the Calypso card specifications, and this API exposes the value, not those properties.


20. Normative clarifications

The specifications also bring clarifications that do not change signatures but specify the contract:

  • Card API — APDU construction rules: commands must strictly comply with ISO/IEC 7816-3; a case 4 command must include the Le field, for which the value 00h is recommended (it was previously presented as mandatory).
  • Card API — limitations: the transmission of the Select Application by DF name command (reserved to the CardSelectionRequest) and of the Get Response command (status words 61XYh and 6CXYh are handled automatically by the reader implementation) cannot be requested.
  • Card API — timing countermeasures: the APDU exchange execution-time control mechanism is explicitly presented as a countermeasure against both relay and emulation (see Theme 2).
  • Reader API — SmartCard lifecycle: now normative (see §2.3.2).
  • All APIs — pre-condition natures: an explicit criterion distinguishes Range (position in a collection or memory image exposed by the API) from Argument (any other invalid value, including values bounded by the card or SAM protocol).
  • Storage Card API — scope: the Scope section explicitly lists the supported products (MIFARE Ultralight, MIFARE Classic 1K, MIFARE Classic 4K, ST25 SRT512), identified by the values of StorageCardProductType.

21. Elements under study

The following elements appear in grey in the Legacy SAM API diagram; they are not part of the normative scope submitted for validation:

  • LegacySamApiFactory.createSecureReadTransactionManager(samReader, sam, securitySettings) and the SecureReadTransactionManager interface;
  • FreeTransactionManager.preparePlainLoadWorkKey(...) and preparePlainExportWorkKey(...);
  • LegacySamSelectionExtension.prepareReadCaadRecord(...) / prepareReadCaadRecords(...) and their equivalents on ReadTransactionManager;
  • SecureWriteTransactionManager.prepareWriteCaadRecord(...).

22. Migration procedure

Migrating application code from the production versions to the new versions will be covered by a dedicated technical migration guide, published separately after validation by the TC Terminal and after alignment of the associated Keypop Java implementations.

This guide will aim to simplify the transition as much as possible: 1:1 mapping of removed / renamed / redesigned elements (of which Annex A is the basis), rewriting patterns (before / after) for the most common use cases, progressive adoption rules and known pitfalls. It will also describe the Java implementation of the notation principles of Theme 10 (data classes, Self, default values, nullability).


23. Next steps and validation by the TC Terminal

23.1 Scope submitted for validation

This document submits to the validation of the CNA TC Terminal:

  1. The principle of the eighteen evolution themes (§2 to §19) and the overall consistency of the work (versions 3.0.0 for Reader / Card / Calypso Card, 1.0.0 for Definitions, 2.0.0 for Legacy SAM / Generic Card / Storage Card, 0.2.0 for Crypto Symmetric, 0.3.0 for Crypto Asymmetric).
  2. The design choices documented in the “Rationale” sections, in particular:
  • the explicit multi-channel model relying on the SmartCard(Spi) as the named target and the three-level hierarchy of transaction managers (§2);
  • duration bounding at the APDU, generic command and storage card read levels, the Calypso countermeasure being delegated in full to the implementation (§3);
  • the merge of the Observer pattern into a single CardReaderEventHandler SPI (§4);
  • the SecureSessionState enumeration (§5);
  • the extraction of RfTechnology and CardType into the Terminal Reader Definitions API and the CardDetectionSettings detection settings (§7);
  • the generalised commandId model (§8);
  • standardised reader discovery through CardReaderProvider (§9);
  • the hierarchy of selection managers per mode and the three result types (§10);
  • the language-independent notation and its principles, which aim to broaden the choice of implementation languages (KMP, Rust, Swift, etc.) (§11);
  • data without computation and access to raw data (§12);
  • the SV model aligned with the card specification (§13);
  • the tolerance of a missing file in a session (§14);
  • access to the crypto extension with an identity clause (§15);
  • the validity of the Calypso HCE token, verified by the terminal from a clock the application provides (§16);
  • card power and RF field described as effects provided on a best-effort basis rather than as capabilities (§17);
  • the revocation status of a card, obtained from a service the application provides, and checked before any secure session (§18);
  • the transaction counter exposed outside any secure session, fed by the openings the application already performs, for anticipating the renewal of a medium (§19).
  1. The detailed content of the nine specifications and their diagrams (see Reference documents).
  2. The introduction of the new Reader Definitions foundation API.
  3. The principle of a dedicated migration procedure (see §22).

23.2 Points of attention for the review

  • the stability of the initial content of the RfTechnology and CardType enumerations (§7.2), in particular the representation of ISO 14443-4 by a single ISO_14443_4 value;
  • the complete removal of ConfigurableCardReader without a deprecation phase (§7.3);
  • the delegation of the Calypso relay countermeasure to the implementation (§3.3): no configuration operation is exposed, the bound being resolved from a calibration performed against the deployed implementation; the specification only designates the bounded exchanges and the behaviour on overrun;
  • the enforcement of the Calypso duration bounds (§3.1, §3.3): both what is measured (the relevant command exchange alone) and the consequence of an overrun (automatic cancellation of an open session, error propagation outside a session) are now specified;
  • the naming of the HCE token concept (§16), chosen to cover both cryptographic natures — the debit key in symmetric-key mode, the key carried by the card certificate in PKI mode — while an update of the official Calypso specifications is in progress on this subject;
  • the fail-closed default of the card revocation check (§18.3): absent a registered CardRevocationStatusProvider, the status counts as unverified and no secure session may be opened until authorizeRevokedCard() is called — every integration must therefore state one or the other, which the migration guide will have to cover;
  • the three-level gradation of transaction managers (§2.2);
  • the replacement of overloads by unique operation names (§11.2), which changes many operation names for Java integrators;
  • the replacement of “builder” interfaces by data classes (§11.2, §12), whose Java implementation remains to be defined;
  • the change from SvOperation.DEBIT to DEBIT_UNDEBIT and the removal of the SV overloads without data (§13).

23.3 Next steps

The versions were validated by the TC Terminal and the nine specifications are available as a preview on the documentation site. Their formal release is pending, and the following steps remain:

  1. Finalisation of the specifications: moving the repositories from their …-SNAPSHOT versions to their final versions; removal or specification of the elements under study (§21); then tagging and publishing the release.
  2. Writing and publication of the technical migration guide (see §22).
  3. Communication of the availability of the new versions to integrators and to the CNA working groups concerned.

Annex A — Detailed mapping per API

This annex lists, for each API, what becomes of each element of the Java versions in production. Unchanged elements (apart from the move to the Theme 10 notation: basic types, Self, explicit nullability) are not listed. The “after” signatures are expressed in the specification notation.

A.1 Terminal Reader API (Java 2.1.0 → 3.0.0)

Element in productionWhat it becomes
ReaderApiFactory.createCardSelectionManager()Removed → createSingleCardSelectionManager(), createSequentialCardSelectionManager(), createMultichannelCardSelectionManager()
ReaderApiFactory.createBasicCardSelector(), createIsoCardSelector()Removed (selectors = data classes)
—Added: ReaderApiFactory.getCardReaderProvider() → CardReaderProvider; CardReaderProvider interface
ConfigurableCardReader (activateProtocol, deactivateProtocol, getCurrentProtocol)Removed
ObservableCardReader.setReaderObservationExceptionHandler, addObserver, removeObserver, clearObservers, countObserversRemoved
ObservableCardReader.startCardDetection(DetectionMode)→ startCardDetection(settings: CardDetectionSettings, eventHandler: CardReaderEventHandler)
ObservableCardReader.finalizeCardProcessing()→ CardReader.endCardProcessing(), moved up to CardReader and carrying the power-off of the card
—Added: best-effort power and field effects on endCardProcessing() and stopCardDetection(); isCardPresent() may power the card
—Added: ObservableCardReader.clearScheduledCardSelectionScenario()
ObservableCardReader.DetectionMode (REPEATING, SINGLESHOT)→ DetectionMode (REPEATING, SINGLE_SHOT)
ObservableCardReader.NotificationMode→ CardPresenceNotificationPolicy (namespace reader.selection)
CardReaderEvent (interface)→ CardReaderEvent data class (readerName, type, scheduledCardSelectionsResponse?)
CardReaderEvent.Type (…, UNAVAILABLE)→ CardReaderEventType (…, READER_UNREGISTERED)
ChannelControlRemoved
CardCommunicationException, ReaderCommunicationException, InvalidCardResponseException→ CardCommunication, ReaderCommunication, InvalidCardResponse
ReaderProtocolNotSupportedExceptionRemoved
reader.selection.InvalidCardResponseExceptionRemoved (duplicate)
CardSelectionManager.setMultipleSelectionMode(), prepareReleaseChannel()Removed
CardSelectionManager.prepareSelection(CardSelector<?>, CardSelectionExtension) → int→ prepareIsoSelectionCase(selectionCaseId: Int, cardSelector: IsoCardSelector, cardSelectionExtension: IsoCardSelectionExtension) → Self on every manager, and prepareBasicSelectionCase(selectionCaseId: Int, cardSelector: BasicCardSelector, cardSelectionExtension: BasicCardSelectionExtension) → Self on the single-channel managers
CardSelectionExtension (marker)Removed → split into BasicCardSelectionExtension and IsoCardSelectionExtension, each paired with the selector of its family
CardSelectionManager.importCardSelectionScenario(String) → int→ importCardSelectionScenario(cardSelectionScenario: String) → Self (replaces the scenario)
CardSelectionManager.processCardSelectionScenario(CardReader)→ processCardSelectionScenario(reader) on SingleCardSelectionManager / SequentialCardSelectionManager; processCardSelectionScenario(reader, channelSelectionPolicy) on MultichannelCardSelectionManager
CardSelectionManager.scheduleCardSelectionScenario(ObservableCardReader, NotificationMode)→ scheduleCardSelectionScenario(observableCardReader, cardPresenceNotificationPolicy) on the single-channel managers
CardSelectionManager.parseScheduledCardSelectionsResponse(...)→ on the single-channel managers, returns the typed result
CardSelectionManager.importProcessedCardSelectionScenario(String)→ on each manager, returns the typed result
CardSelectionResult (getSmartCards, getActiveSmartCard, getActiveSelectionIndex)Removed → SingleCardSelectionResult, SequentialCardSelectionResult, MultichannelCardSelectionResult
—Added: ChannelSelectionPolicy
CardSelector<T> (filterByCardProtocol, filterByPowerOnData)→ sealed interface CardSelector; filterByCardProtocol removed; filterByPowerOnData → powerOnDataRegex property; cardType property added
BasicCardSelector (interface)→ data class (cardType?, powerOnDataRegex?)
CommonIsoCardSelector<T> (filterByDfName(byte[]), filterByDfName(String), setFileOccurrence, setFileControlInformation)Removed → dfName: ByteArray?, fileOccurrence, fileControlInformation properties of IsoCardSelector; filterByDfName(String) removed
CommonIsoCardSelector.FileOccurrence, .FileControlInformation→ FileOccurrence, FileControlInformation
IsoCardSelector (interface)→ data class
SmartCard.getPowerOnData()→ getPowerOnData() → String?; isActive() → Boolean added
IsoSmartCard.getSelectApplicationResponse()→ getSelectApplicationResponse() → ByteArray?; isBasicChannel() → Boolean added
CardReaderObserverSpi.onReaderEvent(CardReaderEvent)→ CardReaderEventHandler.onReaderEvent(cardReaderEvent: CardReaderEvent)
CardReaderObservationExceptionHandlerSpi.onReaderObservationError(String contextInfo, String readerName, Throwable e)→ CardReaderEventHandler.onReaderError(context: String, readerName: String, error: Any)
CardTransactionManager<T>.processCommands(ChannelControl) → T→ CardTransactionManager.processCommands() → Unit (non-generic)
—Added: IsoCardTransactionManager, MultichannelCardTransactionManager
—Added: CardDetectionSettings data class

A.2 Terminal Card API (Java 2.0.1 → 3.0.0)

Element in productionWhat it becomes
ApduRequestSpi (getApdu, getSuccessfulStatusWords, getInfo)→ ApduRequest data class (apdu, successfulStatusWords = setOf(0x9000), info: String? = null) + apduExchangeMaxDurationUsration: Long? = null
ApduResponseApi (getApdu, getDataOut, getStatusWord, Serializable)→ ApduResponse data class (apdu) + apduExchangeDurationUs: Long?; getDataOut, getStatusWord removed
CardRequestSpi (getApduRequests, stopOnUnsuccessfulStatusWord)→ CardRequest data class
CardResponseApi (getApduResponses, isLogicalChannelOpen)→ CardResponse data class (apduResponses); isLogicalChannelOpen removed
CardSelectionRequestSpi (getSuccessfulSelectionStatusWords, getCardRequest)→ CardSelectionRequest data class (successfulSelectionStatusWords = setOf(0x9000), cardRequest: CardRequest? = null)
CardSelectionResponseApi (getPowerOnData, getSelectApplicationResponse, hasMatched, getCardResponse)→ CardSelectionResponse data class (same information, explicit nullability) + channel: Int
CardSelectionExtensionSpi.getCardSelectionRequest(), parse(CardSelectionResponseApi)→ CardSelectionRequest / CardSelectionResponse types; CardSelectionExtensionSpi now keeps only getCardSelectionRequest(), parse moving to the two family SPIs
SmartCardSpideactivate() → Unit added
—Added: BasicCardSelectionExtensionSpi (parse(…) → SmartCardSpi) and IsoCardSelectionExtensionSpi (parse(…) → IsoSmartCardSpi), counterparts of the two public markers
—Added: IsoSmartCardSpi (marker) and MultichannelSmartCardSpi (getChannel() → Int), the latter now extending the former
ProxyReaderApi.transmitCardRequest(CardRequestSpi, ChannelControl), releaseChannel()Removed → transmitCardRequest(cardRequest, smartCard), transmitCardRequestAndCloseChannel(cardRequest, multichannelSmartCard), closeChannel(multichannelSmartCard)
ChannelControlRemoved
AbstractApduException (getCardResponse, isCardResponseComplete)Removed; cardResponse: CardResponse? and isCardResponseComplete: Boolean properties carried by the APDU errors
CardBrokenCommunicationException, ReaderBrokenCommunicationException, UnexpectedStatusWordException, ParseException→ CardBrokenCommunication (also raised if the card is no longer active), ReaderBrokenCommunication, UnexpectedStatusWord, Parse
—Added: ApduExchangeDurationExceeded error

A.3 Terminal Calypso Card API (Java 2.3.0 → 3.0.0)

Element in productionWhat it becomes
CalypsoCardApiFactory.createSearchCommandData()Removed
CalypsoCard.getProductType() → CalypsoCard.ProductType→ getProductType() → CalypsoCardProductType
CalypsoCard.getDirectoryHeader(), getFileBySfi, getFileByLid, getSvLoadLogRecord, getSvDebitLogLastRecord→ explicit nullable returns
—Added: CalypsoCard.getCounterValuesBySfi, getCounterValuesByLid, getMatchingRecordNumbers(commandId), getSvLoadLogRecordRawData, getSvDebitLogLastRecordRawData, getSvDebitLogAllRecordsRawData
CalypsoCard.ProductType→ CalypsoCardProductType
TransactionManager.prepareDecreaseCounters(sfi, counterNumberToDecValueMap), prepareIncreaseCounters(sfi, counterNumberToIncValueMap)→ parameters renamed decrementValues, incrementValues
SymmetricCryptoSecuritySetting, AsymmetricCryptoSecuritySetting→ SymmetricCryptoSecuritySettings, AsymmetricCryptoSecuritySettings
CalypsoCardApiFactory.createSymmetricCryptoSecuritySetting(...), createAsymmetricCryptoSecuritySetting(...)→ createSymmetricCryptoSecuritySettings(...), createAsymmetricCryptoSecuritySettings(...); securitySetting parameter → securitySettings in createSecure…TransactionManager
CalypsoCardSelectionExtension.prepareSelectFile(short) / prepareSelectFile(SelectFileControl selectControl)→ prepareSelectFileByLid(lid) / prepareSelectFileByControl(selectFileControl)
DirectoryHeader (interface; getKif(level), getKvc(level))→ data class; kifByAccessLevel, kvcByAccessLevel: Map<WriteAccessLevel, Byte>
ElementaryFile (interface; getData())→ data class (sfi, header?, records: SortedMap<Int, ByteArray>)
ElementaryFile.Type→ ElementaryFileType
FileData (all operations)Removed (see §12.2)
FileHeader (interface)→ data class (efType: ElementaryFileType)
SvDebitLogRecord, SvLoadLogRecord (interfaces, getRawData)→ data classes without rawData
SearchCommandData.setSfi, startAtRecord, setOffset, enableRepeatedOffset, setSearchData, setMask, fetchFirstMatchingResult→ properties of the SearchCommandData data class: sfi, startAtRecord = 1, offset = 0, repeatedOffset = false, searchData, mask: ByteArray? = null, fetchFirstMatchingResult = false
SearchCommandData.getMatchingRecordNumbers()→ CalypsoCard.getMatchingRecordNumbers(commandId: Int) → List<Int>?
TransactionManager<T> and generic sub-interfaces→ non-generic, Self returns; TransactionManager extends IsoCardTransactionManager
TransactionManager.prepareSelectFile(short) / (SelectFileControl)→ prepareSelectFileByLid / prepareSelectFileByControl
TransactionManager.prepareSearchRecords(SearchCommandData)→ prepareSearchRecords(commandId: Int, data: SearchCommandData)
TransactionManager.getTransactionAuditData()→ getExchangedApdus()
TransactionManager.processCommands(ChannelControl)Removed (inherited CardTransactionManager.processCommands())
—Added: TransactionManager.getSecureSessionState() → SecureSessionState; SecureSessionState enumeration
SecureTransactionManager.getCryptoExtension(Class<E>) → E→ getCryptoExtension() → CardTransactionCryptoExtension
SecureSymmetricCryptoTransactionManager.prepareSvGet(SvOperation, SvAction)→ prepareSvGet(svOperation: SvOperation)
prepareSvReload(int), prepareSvDebit(int)Removed
—Added: prepareSvUndebit(amount, date, time)
SvActionRemoved
SvOperation.DEBIT→ SvOperation.DEBIT_UNDEBIT
—Added: SecuritySettings interface, parent of SymmetricCryptoSecuritySettings and AsymmetricCryptoSecuritySettings, carrying authorizeFileNotFoundError() and authorizeRecordNotFoundError()
—Added: HceTimeProvider SPI (namespace calypso.card.spi) and CalypsoCardApiFactory.setHceTimeProvider(provider)
—Added: CalypsoCard.getHceTokenExpiryLocalEpochSeconds() → Long? and isHceTokenValid() → Boolean?; SecuritySettings.authorizeExpiredHceToken(); State pre-condition on prepareOpenSecureSession (see Theme 15)
—Added: CardRevocationStatusProvider SPI (namespace calypso.card.spi) and CalypsoCardApiFactory.setCardRevocationStatusProvider(provider)
—Added: CalypsoCard.isRevoked() → Boolean?; SecuritySettings.authorizeRevokedCard(); second State pre-condition on prepareOpenSecureSession (see Theme 17)
CalypsoCard.getTransactionCounter() → Int→ getTransactionCounter() → Int?; the State pre-condition requiring an open secure session is removed, and the value is fed by any Open Secure Session, the pre-opening performed during the selection included (see Theme 18)
ChannelControlRemoved
CardIOException, ReaderIOException, UnexpectedCommandStatusException, SelectFileExceptionRemoved
CardSignatureNotVerifiableException, CryptoException, CryptoIOException, InconsistentDataException, InvalidCardSignatureException, InvalidCertificateException, InvalidPinException, SessionBufferOverflowException, UnauthorizedKeyException→ same names without the Exception suffix

A.4 Terminal Calypso Crypto Legacy SAM API (Java 1.0.0 → 2.0.0)

Element in productionWhat it becomes
LegacySamApiFactory.createSecuritySetting(), createKeyPairContainer(), createLegacyCardCertificateComputationData(), createBasicSignatureComputationData(), createTraceableSignatureComputationData(), createBasicSignatureVerificationData(), createTraceableSignatureVerificationData()Removed (data classes)
LegacySam.getProductType() → LegacySam.ProductType→ getProductType() → LegacySamProductType
LegacySam.getCounter(int), getCounterCeiling(int)Removed (use getCounters(), getCounterCeilings())
LegacySam.getCounterIncrementAccess(int)→ getCounterIncrementAccesses() → SortedMap<Int, CounterIncrementAccess>
LegacySam.getSamParameters() → SamParameters→ getSamParameters() → ByteArray?; SamParameters removed
LegacySam.getSystemKeyParameter(SystemKeyType)→ getSystemKeyParameters(systemKeyType) → KeyParameters?
LegacySam.getWorkKeyParameter(int) / (byte, byte)→ getWorkKeyParametersByRecordNumber / getWorkKeyParametersByKifKvc
—Added: LegacySam.getSystemKeyParametersRawData, getWorkKeyParametersRawDataByRecordNumber, getWorkKeyParametersRawDataByKifKvc, getKeyPair(commandId), getComputedCardCertificate(commandId), getSignature(commandId), getSignedData(commandId), isSignatureValid(commandId)
LegacySam.ProductType→ LegacySamProductType
KeyParameter (interface; getRawData, getParameterValue(int))→ KeyParameters data class (kif, kvc, algorithm, parameterValues)
LegacySamSelectionExtension.setUnlockData(String, ProductType)→ setUnlockDataForProductType(unlockData, productType)
LegacySamSelectionExtension.setStaticUnlockDataProvider(provider) / setDynamicUnlockDataProvider(provider)→ setStaticUnlockDataProviderWithDeferredReader(provider) / setDynamicUnlockDataProviderWithDeferredReader(provider)
LegacySamSelectionExtension.prepareReadWorkKeyParameters(int) / (byte, byte)→ prepareReadWorkKeyParametersByRecordNumber / prepareReadWorkKeyParametersByKifKvc
LegacySamRevocationServiceSpi.isSamRevoked(byte[])Removed (isSamRevoked(serialNumber, counterValue: Int) remains)
TransactionManager<T> and generic sub-interfaces→ non-generic, Self returns
TransactionManager.processCommands(), processCommands(ChannelControl)Removed (inherited CardTransactionManager.processCommands())
ReadTransactionManager.prepareReadWorkKeyParameters(int) / (byte, byte)→ …ByRecordNumber / …ByKifKvc
FreeTransactionManager.prepareGenerateCardAsymmetricKeyPair(KeyPairContainer)→ prepareGenerateCardAsymmetricKeyPair(commandId: Int)
FreeTransactionManager.prepareComputeCardCertificate(data)→ prepareComputeCardCertificate(commandId: Int, data)
FreeTransactionManager / CardTransactionLegacySamExtension .prepareComputeSignature(data), .prepareVerifySignature(data)→ prepareComputeSignature(commandId: Int, data), prepareVerifySignature(commandId: Int, data)
SecureWriteTransactionManager.prepareTransferWorkKeyDiversified(…, diversifier)→ prepareTransferWorkKeyDiversifiedWithSpecificDiversifier(…, diversifier)
KeyPairContainerRemoved
LegacyCardCertificateComputationData.setCardPublicKey, setStartDate, setEndDate, setCardAid, setCardSerialNumber, setCardStartupInfo→ properties of the data class: cardPublicKey, startDate, endDate, cardAid, cardSerialNumber, cardStartupInfo
LegacyCardCertificateComputationData.getCertificate()→ LegacySam.getComputedCardCertificate(commandId: Int) → ByteArray?
SignatureComputationData<T>→ sealed interface SignatureComputationData
SignatureComputationData.setData(byte[] data, byte kif, byte kvc), setSignatureSize(int), setKeyDiversifier(byte[])→ properties data, kif, kvc, signatureSize = 8, keyDiversifier: ByteArray? = null of the data classes
SignatureComputationData.getSignature()→ LegacySam.getSignature(commandId: Int) → ByteArray?
BasicSignatureComputationData, TraceableSignatureComputationData→ data classes implementing SignatureComputationData
TraceableSignatureComputationData.withSamTraceabilityMode(int offset, SamTraceabilityMode mode), withoutBusyMode()→ properties traceabilityOffset = 0, samTraceabilityMode: SamTraceabilityMode? = null, busyMode = true
TraceableSignatureComputationData.getSignedData()→ LegacySam.getSignedData(commandId: Int) → ByteArray?
SignatureVerificationData<T>→ sealed interface SignatureVerificationData
SignatureVerificationData.setData(byte[] data, byte[] signature, byte kif, byte kvc), setKeyDiversifier(byte[])→ properties data, signature, kif, kvc, keyDiversifier: ByteArray? = null of the data classes
SignatureVerificationData.isSignatureValid()→ LegacySam.isSignatureValid(commandId: Int) → Boolean?
BasicSignatureVerificationData, TraceableSignatureVerificationData→ data classes implementing SignatureVerificationData
TraceableSignatureVerificationData.withSamTraceabilityMode(int offset, SamTraceabilityMode mode, LegacySamRevocationServiceSpi service), withoutBusyMode()→ properties traceabilityOffset = 0, samTraceabilityMode: SamTraceabilityMode? = null, samRevocationService: LegacySamRevocationServiceSpi? = null, busyMode = true
SecuritySetting.setControlSamResource(samReader, controlSam)→ LegacySamSecuritySettings data class (samReader, controlSam); securitySetting parameter → securitySettings in createSecureWriteTransactionManager and createAsyncTransactionCreatorManager
ReaderIOException, SamIOException, UnexpectedCommandStatusExceptionRemoved
InconsistentDataException, InvalidSignatureException, SamRevokedException→ InconsistentData, InvalidSignature, SamRevoked

A.5 Terminal Calypso Crypto Symmetric API (Java 0.1.1 → 0.2.0)

Element in productionWhat it becomes
SvCommandSecurityDataApi.getSvGetRequest(), getSvGetResponse(), getSvCommandPartialRequest() (inputs)→ svGetRequest, svGetResponse, svCommandPartialRequest parameters of computeSvCommandSecurityData
SvCommandSecurityDataApi.setSerialNumber, setTransactionNumber, setTerminalChallenge, setTerminalSvMac (outputs)→ serialNumber, transactionNumber, terminalChallenge, terminalSvMac properties of the SvCommandSecurityData data class (namespace calypso.crypto.symmetric.spi)
SymmetricCryptoCardTransactionManagerSpi.computeSvCommandSecurityData(SvCommandSecurityDataApi) → void→ computeSvCommandSecurityData(svGetRequest, svGetResponse, svCommandPartialRequest) → SvCommandSecurityData
SymmetricCryptoCardTransactionManagerSpi.cipherPinForPresentation(…, Byte kif, Byte kvc), cipherPinForModification(…, Byte kif, Byte kvc)→ non-nullable kif: Byte, kvc: Byte
SymmetricCryptoCardTransactionManagerFactorySpi.createCardTransactionManager(…, List<byte[]> transactionAuditData)→ exchangedApdus: MutableList<ByteArray>
SymmetricCryptoException, SymmetricCryptoIOException→ SymmetricCrypto, SymmetricCryptoIO

A.6 Terminal Calypso Crypto Asymmetric API (Java 0.2.0 → 0.3.0)

Element in productionWhat it becomes
CaCertificateContentSpi.getPublicKey, getPublicKeyReference, getStartDate, getEndDate, isAidTruncated, getAid, isCaCertificatesAuthenticationAllowed, isCardCertificatesAuthenticationAllowed→ properties of the CaCertificateContent data class: publicKey, publicKeyReference, startDate, endDate, isAidTruncated, aid: ByteArray?, isCaCertificatesAuthenticationAllowed, isCardCertificatesAuthenticationAllowed
CaCertificateContentSpi.isAidCheckRequested()Removed (deducible from aid, null if the check is not requested)
CaCertificateSpi.checkCertificateAndGetContent(CaCertificateContentSpi) → CaCertificateContentSpi→ checkCertificateAndGetContent(issuerCertificateContent: CaCertificateContent) → CaCertificateContent
PcaCertificateSpi.checkCertificateAndGetContent() → CaCertificateContentSpi→ … → CaCertificateContent
CardCertificateSpi.checkCertificateAndGetPublicKey(CaCertificateContentSpi) → CardPublicKeySpi→ checkCertificateAndGetPublicKey(issuerCertificateContent: CaCertificateContent) → ByteArray
CardPublicKeySpi (getRawValue)Removed
AsymmetricCryptoCardTransactionManagerSpi.initTerminalPkiSession(CardPublicKeySpi)→ initTerminalPkiSession(cardPublicKey: ByteArray)
AsymmetricCryptoException, CertificateValidationException→ AsymmetricCrypto, CertificateValidation

A.7 Terminal Generic Card API (Java 1.0.0 → 2.0.0)

Element in productionWhat it becomes
CardTransactionManager (extends the Reader API CardTransactionManager<…>)→ GenericCardTransactionManager (extends IsoCardTransactionManager)
prepareApdu(String)Removed
prepareApdu(byte[])→ prepareCommand(apdu: ByteArray)
prepareApdu(byte cla, byte ins, byte p1, byte p2, byte[] dataIn, Byte le)Removed
—Added: prepareCommandWithId(commandId, apdu), prepareCommandWithMaxDuration(commandId, apdu, maxDurationUs), getLastExecutionResponse(commandId) → ByteArray?
getResponsesAsByteArrays()→ getLastExecutionResponses() → List<ByteArray>
getResponsesAsHexStrings()Removed
GenericCardApiFactory.createCardTransaction(reader, card)→ createGenericCardTransactionManager(reader, card)

A.8 Terminal Storage Card API (Java 1.2.0 → 2.0.0)

Element in productionWhat it becomes
ProductType (methods getBlockCount, getBlockSize, hasSystemBlock, hasWriteAcknowledgment, hasAuthentication)→ StorageCardProductType with properties blockCount, blockSize, hasSystemBlock, hasWriteAcknowledgment, hasAuthentication
StorageCardApiFactory.createStorageCardSelectionExtension(ProductType)→ productType: StorageCardProductType parameter
StorageCard.getUID()→ getUid()
StorageCard.getSystemBlock(), getBlock(int), getBlocks(int, int)→ ByteArray? returns
StorageCardSelectionExtension / StorageCardTransactionManager .prepareMifareClassicAuthenticate(…, byte[] key) / (…, int keyNumber)→ prepareMifareClassicAuthenticateWithKey / prepareMifareClassicAuthenticateWithKeyNumber
StorageCardTransactionManager (extends CardTransactionManager<…>)→ non-generic, Self returns
StorageCardTransactionManager.prepareReadSystemBlock(), prepareWriteSystemBlock(byte[]) (deprecated)Removed
StorageCardTransactionManager.prepareSt25WriteSystemBlock(byte[])→ prepareSt25WriteSystemBlock(commandId: Int, data: ByteArray)
—Added: StorageCardSecuritySettings data class (readCommandMaxDurations); securitySettings parameter added to StorageCardApiFactory.createStorageCardTransactionManager(...)
StorageCardTransactionManager.prepareWriteBlocks(int, byte[])→ prepareWriteBlocks(commandId: Int, fromBlockAddress: Int, data: ByteArray)
StorageCardException (getBlockAddress)Removed; the errors carry blockAddress: Int? and commandId: Int?
SCAuthenticationFailedException (extends CardCommunicationException)→ StorageCardAuthenticationFailed (no parent error)
SCCardCommunicationException, SCInvalidCardResponseException, SCReaderCommunicationException→ StorageCardCardCommunication, StorageCardInvalidCardResponse, StorageCardReaderCommunication (parents unchanged)

A.9 Terminal Reader Definitions API (new, 1.0.0)

ElementContent
ReaderDefinitionsApiPropertiesVERSION constant
RfTechnologyISO_14443_AB, INNOVATRON_B_PRIME, FELICA, ISO_15693
CardTypeISO_7816_3, ISO_14443_4, ISO_14443_3A_MIFARE_CLASSIC_1K, ISO_14443_3A_MIFARE_CLASSIC_4K, ISO_14443_3A_MIFARE_ULTRALIGHT, ISO_14443_3B_ST25_SRT512, INNOVATRON_B_PRIME, FELICA, ISO_15693, UNKNOWN

End of document.