cryptosense / pkcs11

OCaml bindings for the PKCS#11 cryptographic API
BSD 2-Clause "Simplified" License
22 stars 6 forks source link

sample usage? #34

Closed hannesm closed 7 years ago

hannesm commented 7 years ago

Hello,

I don't know much about smartcards etc. My question is: can I use this library (and if so, how) to interact with a PKCS11 smartcard (in my case likely a yubikey (I got some yubikey hardware recently), there seems to be https://developers.yubico.com/yubico-piv-tool/YKCS11_release_notes.html).

Is there by any chance a sample application (whatever, a command-line utility to sign a blob using the key in the smartcard) for this library available?

thanks,

hannes

gram commented 7 years ago

Hi Hannes,

Yubikey PKCS11 - yes should work Sample application - hmm good idea we can probably add something. I'll talk to the team when I get back to France next week.

hannesm commented 7 years ago

@gram thx!

emillon commented 7 years ago

Hello @hannesm,

This looks like a good idea indeed, especially since the API is a bit large.

I can add a sample application that given a DLL, slot number, PIN, key label and plaintext file in argv, computes and displays a RSA PSS signature (the key pair can be generated by other means, for example pkcs11-tool).

In the meantime, if you're looking for an entry point to the API, P11.load_driver will return a packed module of signature P11.S.

hannesm commented 7 years ago

@emillon thx. Sample app would be appreciated :)

hannesm commented 7 years ago

@emillon did you had a chance to look into that? would be nice if I could play a bit with it.

emillon commented 7 years ago

Thanks for the ping - that's still on my radar, I know what I'll include but didn't do it yet :)

In the meantime there's a code sample in #10 that you can play with (the setup code, upto login, is common to all such PKCS11 apps). It generates a key and encrypts a fixed plaintext using unpadded AES ECB.