Skip to content

J3R452

2 posts with the tag “J3R452”

Installs fine, runs out of RAM: balancing a Java Card applet suite on the J3R452

Monoid is a set of Java Card applets I work on. Identity holds the card identity, the Secret PIN and the Bundle; Monoid manages keys, data and the Access PIN; Security Key implements FIDO2; an OTP applet that computes TOTP codes came later. The last three share one library package, and they call each other through a Shareable Interface. The suite had already passed its full flow on a D321 card. Moved to a J3R452 (D600), with all four CAP files byte-for-byte identical, LOAD and INSTALL succeeded — and the first Hello came back with an internal error. A diagnostic build named the cause: SystemException.NO_TRANSIENT_SPACE, raised while checking whether a PIN had been set.

This post is what the following rounds of debugging taught me: how Java Card accounts for RAM, why “a power cycle clears RAM” and “there’s plenty left when the command ends” are both unreliable intuitions, which buffers moved to persistent memory, and what it cost when the wrong things moved.

Hardware Ed25519 on the J3R452: recovering the JCOPX API from a CAP file

The J3R452 is a Java Card 3.0.5 Classic card running NXP JCOP 4.5. Its firmware contains a private JCOP eXtended (JCOPX) package that implements Ed25519 signing, verification and X25519 key agreement; the card-side library only calls into it. Curve25519-JavaCard is that thin layer. Its README quotes about 220 ms for an EdDSA signature and about 50 ms for X25519, says the full source is not provided for legal reasons, and invites anyone to disassemble the .cap to check that nothing funny is going on.

I took the invitation. I unpacked Curve25519.cap, recovered the private JCOPX interface it calls from the tokens and bytecode, rewrote the wrapper from source so that it links identically, and ran 20 checks on a real card, most of them byte-for-byte against an independent RFC 8032 / RFC 7748 implementation. This post is the write-up: what the CAP actually contains, how the private API was recovered, how the converter can be made to link against a package that only exists in card ROM, and what the card said when tested — including an X25519 byte-order trap the original README never mentions, and a J3R180 that refuses to load either version.