Click here to Skip to main content
12,304,203 members (77,825 online)
Click here to Skip to main content

Stats

1.8M views
94.8K downloads
308 bookmarked
Posted

A Smart Card Framework for .NET

, 15 May 2015 CPOL
Describes a framework to use the PCSC Smart Card API with .NET.
Interop.GemCardExLib.dll
Interop.SCARDSSPLib.dll
DemoSCFmwk.exe
GemCard.dll
GemCardEx.dll
smartcardapi_doc
banner.jpg
darkcorner.jpg
GemCard
gradleft.jpg
gradtop.jpg
graycorner.jpg
minus.jpg
plus.jpg
titletile.jpg
Smartcard_API
DemoSCFmwk
Properties
GemCardEx
GemCardEx.aps
GemCardEx.def
GemCardEx.rgs
GemCardEx.suo
GemCardEx.vcproj.CORUSCANT.han.user
GemCardEx.vcproj.vspscc
GemCardExps.def
Release
GemCardEx.dll
SCardDatabaseEx.rgs
Smartcard Framework 2005.suo
GemCard
GemCard.csproj.user
SmartcardFramework
DemoSCardService
bin
Release
obj
Properties
Service References
SCardNPService
configuration.svcinfo
configuration91.svcinfo
DemoSCardService.SCardNPService.APDUResponse.datasource
Reference.svcmap
service.wsdl
SCardService
configuration.svcinfo
configuration91.svcinfo
DemoSCardService.SCardService.APDUResponse.datasource
Reference.svcmap
service.wsdl
SCardServiceHost
bin
obj
Properties
Smartcard Framework 2010.suo
Smartcard Framework 2010.v11.suo
Smartcard_API
DemoSCFmwk
bin
x86
obj
x86
Properties
GemCard
bin
x64
x86
GemCard.csproj.user
obj
x64
x86
SmartCardPlayer
bin
x86
obj
x86
Properties
Smartcard_Test
ApduExchange
ApduExchange.csproj.user
App.ico
bin
x86
obj
x86
Thumbs.db
GSMHelper
bin
x86
obj
x86
Properties
ReadPhonebook
bin
x86
obj
x86
Properties
ReadPhonebook.csproj.user
SmartcardService
bin
obj
Properties
SmartcardService.csproj.user
Smartcard_Framework_2010
Smartcard Framework 2010.suo
Smartcard_API
DemoSCFmwk
DemoSCFmwk.csproj.user
Properties
GemCard
GemCard.csproj.user
SmartCardPlayer
Properties
Smartcard_Test
ApduExchange
ApduExchange.csproj.user
App.ico
GSMHelper
Properties
ReadPhonebook
Properties
ReadPhonebook.csproj.user
Smartcard_Framework
Smartcard_API
DemoSCFmwk
Properties
GemCard
GemCard.csproj.user
SmartCardPlayer
Properties
Smartcard_Test
ApduExchange
ApduExchange.csproj.user
App.ico
GSMHelper
Properties
ReadPhonebook
Properties
ReadPhonebook.csproj.user
<!-- saved from url=(0007)http:// -->
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<TITLE>GemCard.APDUPlayer</TITLE>
<LINK REL=STYLESHEET HREF="../CommentReport.css" TYPE="text/css">
</HEAD>
<BODY topmargin=0 rightmargin=0 leftmargin=0 style="background-image: url(../titletile.jpg); background-repeat:repeat-x; background-position: 0 0;" >
<DIV CLASS="PageHeading">GemCard.APDUPlayer Class</DIV>
<DIV CLASS="Description">

This class provides a set of functions to process APDU commands described in
an XML format

The format is the following
<code>
<CommandList>
    <Apdu Name="VerifyCHV" Class="A0" Ins="20" P1="0" P2="1" Lc="8" Le="0" Data="31323334FFFFFFFF" />
	<Apdu Name="Get Response" Class="A0" Ins="C0" P1="0" P2="0" Lc="0" Le="SW2" Data="" />
	<Apdu Name="Select 6F3A" Class="A0" Ins="A4" P1="0" P2="0" Lc="2" Le="0" Data="6F3A" />
	<Apdu Name="Read Record" Class="A0" Ins="B2" P1="1" P2="4" Lc="0" Le="D15" Data="" />
	<Apdu Name="Get OTP ID" Class="A0" Ins="1A" P1="80" P2="2" Lc="0" Le="SW1:6C" Data=""/>
</CommandList>
</code>
<P>

</DIV>
<IMG src="../GradLeft.jpg" width=7 height=378 alt="" border="0" style="position:absolute; left:10; top:18;z-Index:2">
<IMG src="../GradTop.jpg" width=352 height=7 alt="" border="0" align="top" style="position:absolute; left:10; top:18; z-index:1">
<DIV CLASS="Remarks">
<SPAN CLASS="RemarkHdrX">Access: </SPAN>Public</DIV>
<DIV CLASS="Remarks">
<SPAN CLASS="RemarkHdrX">Base Classes: </SPAN>Object</DIV>
<TABLE CLASS="InfoTable" cellpadding=0 cellspacing=0>
<TR height=20>
<TD width=20>&nbsp;</TD>
<TD valign=top align=left width=9 bgcolor="#cccc66"><IMG SRC="../graycorner.jpg" align=top></TD>
<TD CLASS="TableLightLabel" WIDTH=206>Members</TD>
<TD CLASS="TableLightLabel" >Description</TD>
<TD width=20>&nbsp;</TD>
</TR>
<TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP51.HTM" TARGET="CNTFRAME">xmlNodeApdu</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP52.HTM" TARGET="CNTFRAME">xmlNodeSequence</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP53.HTM" TARGET="CNTFRAME">xmlAttrName</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP54.HTM" TARGET="CNTFRAME">xmlAttrClass</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP55.HTM" TARGET="CNTFRAME">xmlAttrIns</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP56.HTM" TARGET="CNTFRAME">xmlAttrP1</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP57.HTM" TARGET="CNTFRAME">xmlAttrP2</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP58.HTM" TARGET="CNTFRAME">xmAttrLe</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP59.HTM" TARGET="CNTFRAME">xmlAttrLc</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP60.HTM" TARGET="CNTFRAME">xmlAttrData</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP61.HTM" TARGET="CNTFRAME">paramSW1</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP62.HTM" TARGET="CNTFRAME">paramSW2</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP63.HTM" TARGET="CNTFRAME">m_bLeSW2</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP64.HTM" TARGET="CNTFRAME">m_bLeData</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP65.HTM" TARGET="CNTFRAME">m_nDataId</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP66.HTM" TARGET="CNTFRAME">m_bSW1Cond</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP67.HTM" TARGET="CNTFRAME">m_bCheckSW1</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP68.HTM" TARGET="CNTFRAME">m_bReplay</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP69.HTM" TARGET="CNTFRAME">m_xmlApduList</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP70.HTM" TARGET="CNTFRAME">m_xmlSequenceList</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP71.HTM" TARGET="CNTFRAME">m_iCard</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP73.HTM" TARGET="CNTFRAME">m_apduResp</A></TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP75.HTM" TARGET="CNTFRAME">APDUPlayer</A></TD>
<TD CLASS="TableLightDesc">
Constructor
<P>
</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP76.HTM" TARGET="CNTFRAME">APDUNames</A></TD>
<TD CLASS="TableLightDesc">
APDUNames property, gets a list of the APDU Names
<P>
</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP78.HTM" TARGET="CNTFRAME">ProcessCommand</A></TD>
<TD CLASS="TableLightDesc">
Process a simple APDU command, Parameters can be provided in the APDUParam object
<P>
</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP79.HTM" TARGET="CNTFRAME">ProcessCommand</A></TD>
<TD CLASS="TableLightDesc">
Process a simple APDU command, all parameters are included in the 
XML description
<P>
</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP80.HTM" TARGET="CNTFRAME">APDUByName</A></TD>
<TD CLASS="TableLightDesc">
Gets an APDU command by name
<P>
</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP81.HTM" TARGET="CNTFRAME">APDUFromXml</A></TD>
<TD CLASS="TableLightDesc">
Builds an APDUCommand object from an XmlNode representing the command.

This command uses the result of a previous command to fill some paramaters
<pre>
Le = "R,0:SW1?xx"
    m_bReplay is set to true
	m_bSW1Cond is set with the value xx
	m_bCheckSW1 is set to true
	When the command is called, if SW1 == xx, the command is played a 
	second time with Le = resp.SW2
</pre>
<pre>
Le = "R,xx:DRyy"
    m_bReplay is set to true
    m_bLeData is set to true
    m_nDataId is set to yy
    Le is set to xx for the first call of the command
    Then the command is replayed with Le = Le + resp.Data[m_nDataId - 1]
</pre>
<pre>
Le = "SW2"
	if SW1 == 0x9F on the previous call to a command, m_bLeSW2 is set to true
	if m_bLeSW2 if true, Le is replaced with resp.SW2
</pre>
<pre>
Le = "Dxx"
	if resp.Data id not null from the previous command,
	xx is used as the index of the byte that gives Le in the response data
	Le = Data[xx]
</pre>	
<P>
</TD>
<TD width=20>&nbsp;</TD>
</TR><TR height=20>
<TD width=20>&nbsp;</TD>
<TD CLASS="TableLightDesc">&nbsp;</TD>
<TD CLASS="TableLightDesc"><A HREF="CWP82.HTM" TARGET="CNTFRAME">ExecuteCommand</A></TD>
<TD CLASS="TableLightDesc">
Executes an APDU command
<P>
</TD>
<TD width=20>&nbsp;</TD>
</TR></TABLE>
</BODY>
</HTML>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

orouit
Architect Consistel - Singapore
Singapore Singapore
Software Architect, COM, .NET and Smartcard based security specialist.

I've been working in the software industry since I graduated in Electrical and Electronics Engineering. I chose software because I preferred digital to analog.

I started to program with 6802 machine code and evolved to the current .NET technologies... that was a long way.

For more than 20 years I have always worked in technical positions as I simply like to get my hands dirty and crack my brain when things don't go right!

After 12 years in the smart card industry I can claim a strong knowledge in security solutions based on those really small computers!
I've been back into business to design the licensing system for the enterprise solution for Consistel using a .NET smart card (yes they can run .NET CLR!)

I'm currently designing a micro-payment solution using the NXP DESFire EV1 with the ACSO6 SAM of ACS. I can then add a full proficient expertise on those systems and NFC payments.
This technology being under strict NDA by NXP I cannot publish any related article about it, however I can provide professional consulting for it.

You can contact me for professional matter by using the forum or via my LinkedIn profile.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160530.1 | Last Updated 15 May 2015
Article Copyright 2006 by orouit
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid