Question

I need to write PKCS11 library for some smart-card. I am C# developer and I do not want to use other languages. I use platform invoke to comunicate with cards API (it is no PKCS11).

How can I write library with PKCS11 interface in C# that will be available not only for .Net. What technologies i must use, what i must know (I have never done this things before)? I hope, I will be enough some keywords in this subject for start. In what direction i must dig?

Thank you.

Was it helpful?

Solution

Search for "how to create an unmanaged DLL in C#". Yet I should say that the idea to create a PKCS#11 driver DLL in C# is far from ideal due to a number of reasons which you will find in articles found using the above search link.

OTHER TIPS

You can use this library: pkcs11.net

Pkcs11 wrapper for .Net, written in C#. Supported Methods: TokeInfo/SlotInfo, Open/Close Session, Login/Logout, Find Objects, Digest, Sign/Verify, Encrypt/Decrypt

I don't understand why you want to do this, yet PKCS#11 is not a windows things, CSP is, though some apps use PKCS#11 like Mozilla but I really recommend if you wanna do a PKCS#11, do it in C or C++ just for the code to be portable to other platforms, this might need tweaking (#if #else) of course but the main logic code will stay the same and really PKCS#11 is linux/unix/bsd/macosx thing .. also C# can't generate a stdlib , I assume it generates a COM/COM+ object which is totally different than a C library for PKCS#11 ..

You can use NCryptoki, a C# interface to PKCS#11 unmanaged dll. See this: http://www.ncryptoki.com

PKCS#11 can be used not only for PKI functions (keys and certificates) but also for storing and reading data in the smart card. This is why PKCS#11 is needed also on Windows.

I've not worked extensively with security, but many people would probably recommend Bouncy Castle for .NET for dealing with security.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top