Adding a new card driver - xhanulik/OpenSC GitHub Wiki
Adding a new card driver
Card driver creation
Basic tasks to hook up a new driver to the OpenSC framework:
- create
card-example.c(based on the structure of some existing driver), - add
exampleto the list ofinternal_card_driversinctx.c, - add
extern sc_card_driver_t *sc_get_example_driver(void);tocards.h, - add
card-example.cto the end of the lists inMakefile.amandMakefile.mak, - re-create Autotools scripts:
./bootstrap.
Creating the skeleton card driver:
- identify any card revisions, to be included in ATR map etc,
- add to the end of enum list in cards.h (+1000 base).
PKCS#15 driver hookup:
- PKCS#15 card formats should need minimal or no modifications, to allow
sc_pkcs15_bindto scan the card and populate in-memory structures, - non-PKCS#15 cards need to create a
pkcs15-example.c, hook it tobuiltin_emulatorslist inpkcs15-syn.cand add to lists inMakefile.amandMakefile.mak, pkcs15-example.ccreates the in-memory structure by linking right objects with their counterparts based on ID codes or whatever information that is necessary.
Windows minidriver support
Microsoft Windows probes the Smart Card security drivers and loads it related features thanks to the ATRs that should registered (see regedit) from the minidriver framework. You should carefully register the ATRs using the OpenSC installer customization based on the following rules.
pbAtrMask bitmask
Optional bitmask to use when comparing the ATRs of smart cards to the ATR supplied in pbAtr.
If this value is non-NULL, it must point to a string of bytes the same length as the ATR string supplied in pbAtr.
When a given ATR string A is compared to the ATR supplied in pbAtr, it matches if and only if A & M = pbAtr, where M is the supplied mask, and & represents bitwise AND.