user2824073
user2824073

Reputation: 2485

Sign file using smartcardio


I'm going to develop a Java class which verifies the smartcard pin and sign documents with the certificate contained in the smart card. So far I've found some basic examples to send APDU commands to the smart card. However I'm a little puzzled about signing documents.

Thanks a lot for shedding some light on this

Upvotes: 1

Views: 692

Answers (1)

Maarten Bodewes
Maarten Bodewes

Reputation: 94038

Yes, you usually can get the certificate from the card. For file based cards that are compatible with ISO/IEC 7816-4, 8 and 15 you can first parse the information found in the 7816-15 file structure, then retrieve the certificates from the file system. This can be done using the commands (loosely) specified in 7816-4 You should also get the reference for the private key on the card.

When you have the certificate and the private key then you can send the 7816-8 COMPUTE DIGITAL SIGNATURE command APDU to the card.

Note that not all smart cards keep to these specifications. You could need additional information from the issuer of the card to exactly know what to do.

Upvotes: 2

Related Questions