Benchmarking two Java Card 3.0.5 cards
It started with one contactless Java Card 3.0.5 card (CPLC D600, commonly JCOP 4.5 / J3R452). Once the benchmark worked, a second card of the same generation but a different model showed up (CPLC D321, commonly JCOP 4 / J3R180). Both ran the same applet version (v10) through the same host code on the same reader, so every difference comes from the card itself — which says more about “Java Card performance” than a single card ever could. The D321 data was later re-measured on another card of the same model, cleaned down to the ISD, the GlobalPlatform support package and the benchmark applet.
The suite lives in the repository’s benchmark/ directory: an on-card applet, a Java driver that keeps one PC/SC session open, and a Node harness that orchestrates and verifies. Cross-card comparison is on the results page, each card’s full data (ATR, CPLC, memory, capabilities and performance tables) is linked from the card signals page, and the method is on the methodology page.
You cannot time a single command
Section titled “You cannot time a single command”Java Card classic has no clock, so the card cannot time itself, and the host can only time an APDU round trip. That fixed cost is not small on a contactless link: about 3.3–4.1 ms for an empty command, and about 9.8–10.7 ms when the applet returns data, because the card answers 61xx and the host sends GET RESPONSE.
So the applet executes the operation n times per command and the host fits:
elapsed(n) = fixed cost + per-operation cost × nThe n = 0 point exists to measure the fixed cost directly; the slope is the per-operation time. Each test warms up, calibrates to about 80 ms, discards one sampling pass, then takes the median of three samples at four points and reports R² plus the coefficient of variation. You can see at a glance whether a number is trustworthy.
Seven things that got in the way
Section titled “Seven things that got in the way”1. No int. The converter rejects int locals, int return types and even int-typed array indexes. Every loop counter has to be a short, which caps a command at 32767 iterations.
2. A card response costs two round trips. When the applet returns data with sendBytesLong, the card first answers 61xx and the host then sends GET RESPONSE. It cancels out in the slope but inflates the intercept past 10 ms; without differential timing it would end up inside the “crypto performance” number.
3. Transient RAM is the binding constraint. With the applet’s own buffers allocated, the D600 card has only about 3.4 KB of transient memory left (1.7 KB before the factory applets were removed) and the D321 card about 2.8 KB, while every KeyPair, Signature and Cipher object takes a slice. Building the P-256 objects first and then generating an RSA key pair returns 6B02 (NO_TRANSIENT_SPACE). The suite therefore runs in four phases and sends RESET between them, where the applet drops all crypto objects and calls requestObjectDeletion().
4. Applets that were already on the card consume memory too. When the first D321 card arrived it reported roughly 2.8 KB of free persistent memory and only 295 B of transient memory — not even enough for the benchmark buffers. After removing the leftover third-party applets and packages (with the user’s permission), the same card reported about 96 KB of persistent memory and 2.8 KB of transient memory. Some of the earlier “algorithm unavailable” conclusions were really memory starvation: clean first, then measure. The D321 data that ended up published came from another card of the same model, cleaned down to the platform packages before the applet was installed, so its baseline is clean.
5. Capability probing is itself misled by transient memory. Probing dozens of algorithms inside one APDU keeps their transient objects alive until the command ends, so a tight card starts answering 0x7F (unexpected exception) partway through, which looks like “unsupported”. The fix was a second applet command that probes exactly one algorithm per APDU (INS 12), with the host retrying every anomalous bulk result. Only then did the real picture appear: on the D321 card even Signature.getInstance for HMAC returns NO_SUCH_ALGORITHM, while the D600 card got as far as building the objects and then rejected every setKey with ILLEGAL_VALUE — which turned out to be the seventh trap below, not missing support.
6. Signature.verify() behaves strangely. For a key pair generated in an earlier command, on-card verify returns false, while the same signature verifies on a PC with the card’s modulus; putting sign and verify in one command succeeds again. Modulus, exponent and signature bytes were all checked. Without a convincing explanation, the honest move is to record it: the standalone RSA and ECDSA verify timings would not be trustworthy, so they are marked “not reported”.
7. HMAC key lengths are in bits. KeyBuilder.buildKey takes its length in bits, but the LENGTH_HMAC_SHA_256_BLOCK_64 constant holds a block size, 64. Passed straight in, it builds a key that holds 8 bytes on the D600 card: an 8 B setKey succeeds and a 16 B one returns ILLEGAL_VALUE. Earlier versions of this applet built every HMAC key that way and published “no HMAC” for the D600 card. Building each key from its byte length times 8 (applet v10) makes HMAC-SHA-1, -256 and -512 work, and HMAC-SHA-256 now measures 36.9 ms per MAC — about fifteen times a 32-byte SHA-256, which this suite does not explain. The D321 card really has none: even building an HMAC key returns NO_SUCH_ALGORITHM. A failed probe is a hypothesis about the card until the call itself has been ruled out.
How the cards differ
Section titled “How the cards differ”| D600 card | D321 card | |
|---|---|---|
| Inferred model | NXP P71D600 / JCOP 4.5 / J3R452 | NXP P71D321 / JCOP 4 / J3R180 |
| ATR (reader-synthesised) | 3B8A80010031C173C8400000900090 |
3B8C80015432433134504A34313890009A |
| Free persistent memory | 335,512 B | 155,124 B |
| Free transient memory (RESET) | 4,609 B | 3,974 B |
| Free transient memory (DESELECT) | 4,608 B | 3,968 B |
| Empty command round trip | 4.1 ms | 3.3 ms |
| 64 B response round trip | 15.7 ms | 6.5 ms |
getVersion() |
0x0300 |
0x0300 |
Link speed and chip speed do not move together: the D321 card’s link is much faster (6.5 ms versus 15.7 ms for a 64 B response), yet its RSA signature is slower (105.8 ms versus 90.2 ms) and re-initialising AES costs much more (init + encrypt 8.0 ms versus 3.1 ms). “The newer card” would have been the wrong conclusion.
Those three rows are read in the benchmark applet’s constructor, before it allocates its own test buffers. That step matters: getAvailableMemory reports what is left at the moment of the call, and allocating a few buffers or installing a couple more applets shifts the reading by kilobytes. The benchmark applet’s own fixed cost is 4,316 B persistent and 1,184 B in each transient view (two views of the same pool, not two pools to add), so while it runs the readings are lower by that much. It also explains an earlier hand measurement of about 3.8 KB: that was the transient baseline before the buffers were allocated (3,974 B on this D321 card), not what was left after the applet was installed. Align that premise before comparing cards — a single “free memory” number can support the opposite conclusion.
One difference remains after cleaning: the D321 card’s clean persistent baseline is only 155.1 KB, about half of the D600 card’s 335.5 KB. That is not applet overhead but a different NVM configuration.
The algorithm sets are almost identical: AES-128 only, no AES-192/256, no AES-GCM, and no default EC curve on either card (P-256 has to be imported, and setG needs the 65-byte 04 || x || y form). HMAC is the one real difference — the D600 card has HMAC-SHA-1/256/512 and the D321 card has none — so “same Java Card version” does not imply “same algorithm set”.
Measured numbers
Section titled “Measured numbers”| Test | D600 card | D321 card |
|---|---|---|
| 16-bit addition (single op) | 33.6 µs | 35.5 µs |
| 16-bit multiply / divide | 47.9 / 45.8 µs | 50.0 / 47.3 µs |
| byte array read / write | 96.9 / 91.5 µs | 86.8 / 82.4 µs |
| AES-128 ECB encrypt (16 B) | 1.66 ms | 1.64 ms |
AES-128 ECB init + encrypt |
3.1 ms | 8.0 ms |
| DES / 3DES ECB (8 B) | 1.66 / 1.73 ms | 1.61 / 1.65 ms |
| SHA-256 (32 B / 1 KiB) | 2.37 / 26.0 ms | 2.38 / 26.0 ms |
| HMAC-SHA-256 (32 B, 16 B key) | 36.9 ms | unsupported |
| secure random (32 B) | 0.91 ms | 0.76 ms |
| ECDSA P-256 sign | 46.8 ms | 53.5 ms |
| ECDH P-256 | 30.8 ms | 38.1 ms |
| RSA-2048 sign / decrypt | 90.2 / 86.8 ms | 105.8 / 102.7 ms |
| RSA-2048 encrypt | 6.9 ms | 8.1 ms |
| key pair generation: P-256 / RSA-2048 | 133.5 ms / 1.7–3.6 s | 142.0 ms / 2.1–8.9 s |
| persistent byte write (changing a value) | 2.84 ms | 2.91 ms |
arrayCopy 64 B (persistent destination) |
3.25 ms | 3.34 ms |
| one transaction per write | 3.13 ms | 3.19 ms |
| block write 16/32/64 B: one transaction | 6.07 / 8.88 / 14.6 ms | 6.90 / 10.5 / 18.0 ms |
block write 16/32/64 B: one arrayCopy |
2.98 / 3.09 / 3.26 ms | 3.07 / 3.14 / 3.29 ms |
| allocate a 32-byte persistent array | 9.2 ms | 9.4 ms |
Persistent reads cost only about 85–87 µs, the same order as the interpreter loop itself; transient reads and writes are 86–99 µs, also in that range. What actually shows the medium is how long changing a value takes: about 2.8–2.9 ms, the same order as the 3.2–3.3 ms 64-byte arrayCopy, because both are dominated by one page program.
For the same 16/32/64 bytes the style still changes the cost by more than five times: one transaction brings 64 B down to 14.6 ms, or 0.23 ms per byte; a single arrayCopy is nearly flat, around 3 ms for both 16 B and 64 B — one copy is about one page program, and a page is roughly 64 bytes. The byte loop without a transaction does not need its own row: it is bytes times the single-byte write (16 B measured 45.5 ms = 16 × 2.836 ms), and the single-byte test already writes 120 adjacent bytes inside one command at 2.84 ms each, so the card does not coalesce consecutive stores within a command. Persistent-write cost on this card therefore follows the number of programs, not the number of bytes. Wrapping each write in its own transaction adds about 0.3 ms for the journal.
The first version of these write tests was wrong: every command wrote the same fixed values, and the card skips programming bits that are already in the target state, so nearly every write in the timed region was a same-value rewrite. The rows measured the interpreter loop (about 84 µs), roughly 30× below real programming, and the occasional 1.4 ms “slow state” was a blend of the two. The fix is a persistent seed advanced on every write command, with all written values derived from it and the seed echoed back so the host can run the same command twice and fail the check if both wrote the same data. Only the allocate+delete row is still below R² 0.99.
Same-version re-run and cross-card comparison
Section titled “Same-version re-run and cross-card comparison”In the first published run the two cards used different applet versions (D600 had v4, D321 had v5). To confirm that this would not contaminate the comparison, the D600 card was measured again with v5: across the 37 valid timing rows the median per-operation deviation was 0.5%, transport round trips differed by under 1.5%, and only the high-variance RSA key generation and allocate+delete rows moved substantially. Both cards’ data now comes from v10: v6 added the pre-allocation memory baseline, v7 changed what the write tests store, v8 added the block-write commands, and v10 builds HMAC keys in bits and adds HMAC probes. On the same D600 card, v6 → v7 moved the 31 non-write rows by a median of 0.32% and raised the four write rows by two orders of magnitude — the evidence that caught the same-value elision; v7 → v8 only adds measurements, and the 36 shared rows moved by a median of 0.24%, with transport round trips under 1%; v8 → v10 moved the 41 shared rows by a median of 0.29% on D600 and 0.16% on D321.
The results page has an interactive cross-card comparison: pick any card as the baseline, which is always shown in the first column, and the other cards show their relative timing change, with a green ↓ for faster and a red ↑ for slower.
What the numbers mean
Section titled “What the numbers mean”They are considerably slower than the “hardware-accelerated Java Card” impression: 1.6 ms per symmetric block, roughly 90–105 ms for an RSA signature, and no AES beyond 128 bits at all. On these cards over this link, crypto acceleration cannot be assumed; which algorithm is usable and how fast it is has to be measured.
The link matters too: a contactless card is powered over RF and is inherently slower than a contact card. The same tool on a contact card and another reader could produce very different conclusions — which is exactly why it is built as a reproducible measurement method rather than a scorecard.
The cross-card comparison is on the results page, where any card can be selected as the baseline; each card’s full tables (fit quality, verification status and capability probes) and identity evidence are linked from the card signals page. To run it on your own card, the benchmark/ directory has the build, install and one-command runner scripts.