C++
  Home arrow C++ arrow Page 5 - Writing a Smart Card Library
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C++

Writing a Smart Card Library
By: Digvijay Chauhan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 90
    2004-04-26

    Table of Contents:
  • Writing a Smart Card Library
  • The Approach
  • The CPCSCReader Class
  • The CRegListDlg Class
  • The Demo Application: SCardDemo

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Writing a Smart Card Library - The Demo Application: SCardDemo


    (Page 5 of 5 )

    Writing a Smart Card Reader
    Figure 6: The SCardDemo application snapshot

    The demo application demonstrates the use if these classes and you can even use it as a starting point for your Smart Card enabled application. It allows you to first select a reader from the available ones and then fires one command automatically and displays you the response in a Messagebox. Once you've selected a reader you can just type in an APDU in the Command String field and then press the Send Button to sent it to the card and retrieve the response in the Response field as displayed in the snapshot above.

    The Library Code

    The Library code is in two modules, namely DSCPCSC.dll and DSCPCSCOO.dll.

    The DSCPCSC.dll is a pure Win32 DLL and exports four APIs

    • int WINAPI OpenReaderConnection(char* strNameReader, long status)

    • int WINAPI CloseReaderConnection(char* strNameReader, long status)

    • long WINAPI SendCommand(char * strReader, unsigned char* strCommand, int nLengthCmd, long status, unsigned char & strResponse, int & nResponseLen)

    • long WINAPI GetReaderAttribute(char* strReaderName, unsigned long attId, unsigned char& pAttribute, int nAttLength)

    These are the core APIs that do the real work and for a better understanding I'd recommend you to browse through the code once.

    • The other module, DSCPCSCOO.dll, is a MFC extension library and exports all the classes that we discussed above. As a refresher I'll list them again here.

    • CPCSCReader
      The Reader Class, which encapsulates the functionality of a Smart Card Reader.

    • CPCSCCommand
      The APDU or Command Object which encapsulates the APDU Commands functionality that are sent to the card.

    • CRegListDlg
      This class encapsulates the UI to select a reader from the installed readers on the system.

    Points of interest

    The first module is a Pure Win32 library and as I developed the second module DSCPCSCOO.dll as an OO wrapper over it one can use JNI to develop a java wrapper over it and even write Java Applications that re Smart Card enabled.

    Final words

    I hope this would give some of the readers a good introduction to MFC Smart Card programming and will prove to be a starting point for others. In case of any questions regarding this article you can mail me at Digvijay_Chauhan@hotmail.com.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    C++ ARTICLES

    - Paths and Files
    - Directories in C++
    - Focusing on C++ Files
    - Const Correctness in C++
    - Manipulating Streams and Files with C++
    - Streams and Files
    - Multiplying Large Numbers with Karatsuba`s A...
    - Large Numbers
    - Dijkstra`s Shunting Algorithm with STL and C...
    - Brief Introduction to the STL Containers
    - The Standard Template Library
    - Templates in C++
    - C++ Programmer Alerts
    - C++ Programming Tips
    - First Steps in (C) Programming, conclusion






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT