Reputation: 101
I want to read fundamental data like name, address and such from a german insurance health card (egK). I got a scm sdi011 card reader and i use c#. I already get the ATR String from card/cardreader but I don't know how to go on. Would be nice if someone can tell me what to do now.
Here is my code:
WinSCard card = new WinSCard();
try {
card.EstablishContext();
card.ListReaders();
string szReader = card.ReaderNames[1];
card.Connect(szReader);
string ATRStr = card.AtrString;
ATRBox.Text = ATRStr;
} catch (WinSCardException exception) {
richTextBox1.Text = exception.WinSCardFunctionName + " Error 0x" + exception.Status.ToString("X08") + ": " + exception.Message;
} finally {
card.Disconnect();
}
Upvotes: 3
Views: 1576
Reputation: 5333
The rough sequence is as follows (I leave out extended length and access rights):
In the following square brackets denote optional parts.
The sendbuffer has to contain the command APDU, i. e. CLA, INS, P1, P2, [LC, data], [LE] Its easiest, to specify LE=0, since then the card sends as much as possible and you have an idea, by which value to increment P1/P2.
The answer contains [data] SW1/SW2, so at least two bytes should be returned. If you get less, this might indicate, that your command was malformed and rejected by winscard directly, without having been sent to the card.
Upvotes: 1