C # Smart Card Programming

How do I start programming in C # (.NET) for smart cards? For starters, I just need to know the name of the Card Reader (like Omnikey) and print this out.

Thanks for the answer, Ales.

+8
c # smartcard
source share
4 answers

And back I had to write what I thought would be a simple and easy smart card code, and let me tell you that there was no walk in the park. First of all, it turned out that good information about smart cards is difficult to find on the Web. And when I found several websites, there was a lot of discussion of the main calls of the Win32 API and a whole group of other low-level materials, which is not so easy to read.

The fact is that they are called smart cards for some reason. The reason is that you basically interact with the built-in microprocessor by sending him commands that he understands and answers. This can get a little complicated, because many manufacturers believe that it would be nice to implement their own teams, so many things depend on the type of card you use. In addition, there are cards that look like smart cards, but are not really smart cards and don't even use any “standard” smart card interfaces, so you end up using the Windows SmartCard API to launch your reader, and smartcard reader a special API provided as .lib in some obscure corner of their site for the rest ...

Well, in the end I got my application, but, as I said, it was not easy. In any case, I made a big mistake, assuming that it would not be very difficult.

If you really want to get into smart cards, I believe that your best bet is to get a good book on this topic, but since I'm also a little more than a beginner, I really can't help you.

As for websites, the most useful thing in C # terms that I could dig up was the Smart Card Framework for .Net . Please note that this is not the same article as published by michaelvdnest, although the author is the same. The article in which I linked describes the C # wrapper for the native smart card API, and michaelvdnest adds XML to the mix, although I don’t know exactly how, because I haven’t read it yet.

So, begin to analyze the code contained in the article, and good luck. If I need memory, reader listing material is pretty easy to find.

+14
source share

Check Smart Card Framework for .NET in your code project. It describes the XML framework for .NET for programming smart card applications.

+3
source share

I know this late ........

but

You can get a very easy to use and free for personal use professional library here:

https://www.smartcard-api.com/

There is also a community (completely free to use) of the smart card library

https://www.nuget.org/packages/PCSC

In recent years, I have preferred to use Nu-get rather than smart card APIs if you need commercial support, however the smart card API library is the best choice.

With this, you should begin to understand the APDUs and how to move them back and forth from the card to the terminal.

This is a really huge question, I have a code that will read all the common elements on a standard Chip & Unfortunately, the EMV card PIN was written for a financial services client, so I can’t give it to you, but I can explain that you need to take to read the map.

As for other cards, right down to the card itself, for example, I have a card reader and empty cards, and I have some user data for some of them, which only I know how to access, but still I have there is some old satellite and road maps that are again different.

You can get some ideas here:

How to read PAN from EMV SmartCard from Java

and there’s a lot of information about smart cards:

https://web.archive.org/web/20160329205518/http://wrankl.de/SCTables/SCTables.html

especially common things (of which there are some)

+2
source share

I am working on a smart card reader application in Visual Studio 2015. What you want to do is connect USB devices to your computer that are smart card readers. Then try to return the information you are looking for. Although readers have many properties, here are those that I have chosen to use. Hope this gives you a start in the right direction:

static List<USBDeviceInfo> GetUSBDevices() { List<USBDeviceInfo> devices = new List<USBDeviceInfo>(); ManagementObjectCollection collection; using (var searcher = new ManagementObjectSearcher(@"Select * FROM Win32_PnPEntity where Description Like ""%Smart%card%""")) collection = searcher.Get(); string Device_ID = ""; foreach (var device in collection) { devices.Add(new USBDeviceInfo( (string)device.GetPropertyValue("DeviceID"), (string)device.GetPropertyValue("PNPDeviceID"), (string)device.GetPropertyValue("Name"), (string)device.GetPropertyValue("Description"), (string)device.GetPropertyValue("Status"))); Device_ID = (string)device.GetPropertyValue("DeviceID"); } collection.Dispose(); return devices; } 
0
source share

All Articles