Illustration of a smart card in a reader connected to three operating systems

rDNIe is an open-source Rust library for Spain’s electronic national ID card (DNIe) that talks to the card directly over PC/SC, without PKCS#11, OpenSC or system drivers, and behaves the same on Linux, Windows and macOS. It is a port of JMulticard, the Java driver used by the Spanish government’s AutoFirma signing tool, and its author, developer sgomez, built it to bring his rFirma signing app to macOS without depending on Java. It is released under the EUPL-1.2 on GitHub and crates.io.

Key points about rDNIe in 30 seconds

  • It reads and signs with DNIe 3.0 and 4.0 cards over PC/SC on Linux, Windows and macOS.
  • It never resets the card, so other programs using it keep working.
  • In the author’s test it takes 416 ms against 1,323 ms for JMulticard.
  • It shows remaining PIN attempts and rejects malformed PINs without spending one.
  • The project is very young, created in October 2026.

The motivation will be familiar to anyone who has tried to use a smart card on a Mac. According to the author, macOS’s default smart card driver has a bug that resets the card after about six seconds of inactivity and leaves it unusable. Installing Ludovic Rousseau’s CCID driver fixes it, but asking every user to change their system configuration is not realistic. The alternative was embedding JMulticard, which meant pulling in Java, exactly the dependency he wanted to remove to keep his code fully native.

What it does, and what it doesn’t

rDNIe finds a DNIe 3.0 or 4.0 among the connected readers by its ATR, opens the CWA-14890 secure channel, reads the certificates and the holder’s name and ID number from them, checks the remaining PIN attempts without sending the PIN, and signs SHA-256, SHA-384 or SHA-512 digests with PKCS#1 v1.5. Older DNIe 1.0 and 2.0 cards, NFC and PACE, PIN changes, decryption and other cards are out of scope. On Linux it needs pcscd; on macOS and Windows nothing else is required. It is added with cargo add rdnie and needs Rust 1.87 or later.

The design differences with JMulticard explain the gains. JMulticard resets each reader until it finds a DNIe and resets the card twice when opening it, so OpenSC or Firefox, if they were using the same card, lose their state. rDNIe reads the ATR without a reset and loads only what is requested. In the author’s published benchmark, using one DNIe and one reader, rDNIe takes 416 ms and 42 APDUs to reach the signing certificate, against 1,323 ms and 84 APDUs for JMulticard and 1,526 ms and 130 APDUs for OpenSC. It is a single-card test documented in the repository.

Careful PIN handling

With three attempts before the chip locks, PIN handling is what matters most to users. rDNIe only sends the PIN if the caller has read the remaining attempts in that session, and checks them again right before signing: if they are zero, or differ from what the session expects, it stops without sending the PIN. Each call makes a single attempt and nothing retries on its own. A PIN outside the 8 to 16 character range is rejected before it reaches the card, so a formatting mistake does not use up one of the three attempts. The PIN is wiped from memory afterwards. For a signing app, telling users exactly how many attempts are left, rather than only warning about the last one, is a practical improvement.

As with any component that handles identity certificates, keep in mind that this is a young, single-developer project with little adoption so far. Before using it in production, review the code and the comparison with JMulticard that the repository documents in its parity file.

Frequently asked questions

What is rDNIe?

A Rust library to read certificates and sign with Spain’s DNIe 3.0 and 4.0 over PC/SC on Linux, Windows and macOS.

Does it need Java or OpenSC?

No. It talks to the card directly over PC/SC, without PKCS#11, OpenSC or Java. On Linux it only needs pcscd.

Can it lock my card?

It is designed to avoid that: it checks remaining attempts before sending the PIN, never retries on its own and rejects malformed PINs without spending an attempt.

Sources:

Scroll to Top