For some reason, i really enjoy writing to binary interfaces, like the binary interface for smart cards.
Smart cards communicate devices by sending hex codes (called APDU codes). i have implemented compatibility with a bunch of smart cards but all of them had a published spec for how the interface works. A customer wanted support for smart cards they are using for their Windows PCs. They selected the Gemalto IDPrime 930 smart card because it doesn’t require a separate mini driver in Windows. It isn’t supported on iOS. I’ve added support for other types of cards so I agreed to add support for IDPrime card to Smart Card Utility on iOS. However, the IDPrime cards do not have a publish spec. The cards appear to generally follow the standard ISO 7816 APDU commands with some proprietary commands.
I started by getting a trace of a working smart card session on Windows. Here is the start of a trace:
2026-05-13;09:17:47;Reset
2026-05-13;09:17:48;00 A4 04 00 07 A0 00 00 01 51 00 00
2026-05-13;09:17:48;6A 82
2026-05-13;09:17:48;00 A4 04 00 07 A0 00 00 00 03 00 00
2026-05-13;09:17:48;6A 82
2026-05-13;09:17:48;00 A4 04 00 07 A0 00 00 00 18 43 4D
2026-05-13;09:17:48;61 69
2026-05-13;09:17:48;00 C0 00 00 69
Each APDU command has a instructions, 2 parameters and (optionally) some data. Looking at the example above, the first 2 lines sent return “6A 82” which is like a 404 error in HTTP. Those are good indicators that the driver is probing the card. The third line sent returns a “61 69” which means “Data available of length 69 bytes”. I can then see what data comes back and see if I can recognize it. I know that is a mTLS authentication so I know what generally is needed.
The fun part is once I get the translation layer implemented, it all starts to work in the app to authenticate with the website. I figure out what codes are needed for which operation (certificate reading, PIN validation, hash signing) and like magic, the card starts working with smart card readers and our app. It is like filling in a crossword puzzle to start your car.