Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# smartcards programming

Tags:

c#

smartcard

How should I start to programm in C# (.NET) for smartcards? For the beginning I just need to know, what is the name of Card Reader (e.g. Omnikey) and print that out.

Thanks for the answer, Ales.

like image 799
Thorusan86 Avatar asked Jan 31 '11 14:01

Thorusan86


1 Answers

A while back I had to write what I thought was going to be some simple and easy smartcard code and let me tell you, it was no walk in the park. First of all, it turned out that good information on smartcards is hard to come by on the Net. And when I did find several websites, there was a lot of discussion of the underlying Win32 API calls and a whole bunch of other low-level stuff, which isn't quite easy reading.

The thing is that they're called smart cards for a reason. That reason is that you're basically interacting with an embedded microprocessor by sending it commands that it understands and responds to. This can get a bit complicated because many of the manufacturers thought it was a good idea to implement their own commands, so many things are contingent on the type of card that you're using. On top of that there are cards that look like smartcards but aren't really smartcards and don't even use any of the "standard" smartcard interfaces, so you end up using the Windows SmartCard API just to fire up your reader, and the smartcard reader's special API provided as a .lib in some obscure corner of their website for the rest...

Well, I did get my app working eventually but like I said, it wasn't easy. At any rate I made a big mistake by assuming it would not be very difficult to do.

If you really want to get into smartcards I suppose your best bet would be to get a good book on the subject but since I too am little more than a novice, I really can't help you there.

As for websites, the most useful thing in C# terms that I was able to dig up was A Smartcard Framework for .Net. Note that this is not the same article as the one posted by michaelvdnest, although the author is the same. The article I linked to describes a C# wrapper for the native smartcard API, while michaelvdnest's adds XML to the mix, although I don't know exactly in what way because I haven't read it yet.

So start dissecting the code supplied with the article and good luck. If memory serves me, the reader enumeration stuff is pretty easy to find.

like image 90
dandan78 Avatar answered Sep 19 '22 11:09

dandan78