are there any library or tutorial on how to send APDU command to smart card using C?
Printable View
are there any library or tutorial on how to send APDU command to smart card using C?
Can we assume that you know what "APDU's" are and how to construct them in C, and all you need to know is how to get them from your program onto your smart card?
Like which OS and compiler do you have?
Is the card plugged into a card reader?
Is that card reader connected via serial / parallel / USB / something else to your PC?
i usually do the back end programming like handling the APDUs in the card.so i'm new in the front end side.thats why i'm searching for tutorial.so i think just assume that i know what APDUs but don't know how to construct it in C.I use C to write application in the card that handle the incoming APDU's.but now i'm required to write APIs for sending the APDU to the card.
EDIT: Scrap that... I just looked up what they are... Sending them shouldn't be that hard... if you can already connect to recieve signals.
And constructing them should be as simple as reading them, probably using a structure in order to gather all the data and header and what not, then sending it.
where can i get reference?or sample code? plus i don't know how to connect to the card.
Like which OS and compiler do you have?
Is the card plugged into a card reader?
Is that card reader connected via serial / parallel / USB / something else to your PC?
It gets real old, REAL fast when people can't be arsed to even read the whole post and respond to it.
I mean, is it even worth saying
Code:unsigned char APDU[APDU_PACKET_SIZE];
APDU[0] = AN_OPCODE;
APDU[1] = AN_OPCODE_LEN;
// yada yada
someMagicSendToDevice( APDU );
-pc os win xp, card os multos
-smartdeck c compiler
-yes the card will be slot into the reader
-reader via usb/serial
and one more thing, i will be using 2 reader that is for authentication card with SAM
Care to fill in some missing blanks?
Like which bit of software you're writing, and where you want the information to go, and what is going to deal with that information when it gets there.Code:+===========+ +===========+
| | | |
|Application| |Application|
| Written in| |Written in |
|Smartdeck C| | ??? |
| | | |
+===========+ +===========+
| |
+===========+ +===========+
| | | |
| Multos | | Win32 |
| API | | API |
| | | |
| | | |
+===========+ +===========+
^ ^
| |
| +===========+ |
| | | |
| | Card | |
+------------>| Reader |<--------------+
| | USB Interface
| |
+===========+
i have managed to write the application on the card using smartdeck C.
now my task is write the Win32 API in C++ dll/C lib which will construct all the APDUs that are going to be send to the card. for example if i want to write the name of the card owner into the card. my API will construct the write binary instruction and send it to the card and before the construction could take place the API should first detect the card reader and wether the card have being slot into the reader. If this succeed then can begin constructing and sending the APDUs to the card.
after that i should write a demo application in VB that will call the API to do the transaction with the card like personalize the card or audating data in the card.this part i can do it.only the API part i can't because i have to connect to the reader, constrict the APDU and send it.
Which compiler are you using on your XP box?
When you plug in the card reader, does XP automatically recognise it?
Here's some information on USB
http://www.lvr.com/usb.htm
for the API and VB application i will use VStudio 6.0.
yes after installing the driver XP automatically recognise it coz it is pc/sc reader..
So does XP recognise it as say a "file" device, which explorer can drag and drop files to?
Or something else?
If you can just write files to it, then that's dead easy using any kind of C or C++ program to create files.
no..it just detect it as card reader.
if we want to read, write or other transaction to the card we have to send APDU command to that reader like writing to a port in case if we're using a serial reader which i don't know how.
if using application in VB we can use winscard.dll to do this but now i have to make an API using C or C++ which will do the same thing like the winscard.dll only that the constructing APDU will be in the API too.