|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: RE : Smart Card Transmit Problem
From: Vivek Ambildhag (vivek.ambildhag
SLSSOFTWARE.COM)
Date: Tue Oct 14 2003 - 08:16:02 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
My ATR String :
3B 68 00 00 80 66 A2 06 02 01 32 0E
Can anyone please figure out..
Thanks
Vivek
-----Original Message-----
From: Reganas [mailto:reganas
TISCALI.FR]
Sent: Tuesday, October 14, 2003 6:34 PM
To: SmartCardSDK
DISCUSS.MICROSOFT.COM
Subject: RE : Smart Card Transmit Problem
This command is well working, but I think that Vivek doesn't have an
MPCOS
card.
Regards
Patrick
-----Message d'origine-----
De : SmartCardSDK [mailto:SmartCardSDK
DISCUSS.MICROSOFT.COM] De la
part de
Tom the Libertarian
Envoyé : mardi 14 octobre 2003 14:48
À : SmartCardSDK
DISCUSS.MICROSOFT.COM
Objet : Re: Smart Card Transmit Problem
Note that I have sent a 2 (byte 4) for the data length, and a 7 for
the
packet length. 0 in byte 2 indicates an EF, and the address of the EF
is in
the data at bytes 5 and 6 (3F00 is the master file).
Private Sub SelectMF()
Dim lngReturnedLength As Long
abyADPU(0) = &H0
abyADPU(1) = &HA4
abyADPU(2) = &H0
abyADPU(3) = &H0
abyADPU(4) = &H2
abyADPU(5) = &H3F
abyADPU(6) = &H0
lngReturnedLength = SendCommand(7, "select MASTER")
End Sub
----- Original Message -----
From: "Vivek Ambildhag" <vivek.ambildhag
SLSSOFTWARE.COM>
To: <SmartCardSDK
DISCUSS.MICROSOFT.COM>
Sent: Monday, October 13, 2003 2:08 AM
Subject: Re: Smart Card Transmit Problem
Hi Thomas,
I really appreciate your concern & help. I tried your code in my
application
But it gives me same error as '6D 00'; Also I have certain queries
like 1.
What are you sending as strAddress in function SelectDF? 2. If it is
the
address of file then how to obtain it? 3. Do the addresses depend on
specific card? 4. Is there any other way to select DF other than
sending
their address to SCardTransmit?
Could you please send me 'SelectMF' function of yours and is it card
specific again.
Thanks and Regards,
Vivek Ambildhag,
Sr. Software Programmer,
SLS Software Pvt. Ltd.
Camel House,
Nashik - 11.
Ph : (0253) -2594231 (extn : 386)
-----Original Message-----
From: Thomas Mobley [mailto:TomTheLibertarian
HOTMAIL.COM]
Sent: Sunday, October 12, 2003 7:47 PM
To: SmartCardSDK
DISCUSS.MICROSOFT.COM
Subject: Re: Smart Card Transmit Problem
It looks to me like you selected a df and you have an incorrect field
length. You don't have a read file (B0) command here either. The
following
functions are what I use in a number of applications. SendCommand is
a
function used to send all adpu, the functions are just where I build
them
prior to sending. Select your df, then your ef, then read the ef. The
return from selecting ef will tell you how many bytes long the files
is and
you can use that to read the file as needed. Hope it helps. (these
are not
record files)
Private Function SelectDF(strAddress As String) As Boolean
SelectMF
Dim lngReturnedLength As Long
abyADPU(0) = &H0
abyADPU(1) = &HA4
abyADPU(2) = &H1
abyADPU(3) = &H0
abyADPU(4) = &H2
abyADPU(5) = Val("&H" & Left$(strAddress, 2))
abyADPU(6) = IIf(Len(strAddress) = 4, Val("&H" &
Right$(strAddress, 2)),
0)
lngReturnedLength = SendCommand(7, "select DF_" & strAddress)
SelectDF = abyRecvBuffer(0) = &H85 And abyRecvBuffer(1) = &H10 End
Function
Private Function SelectEF(strAddress As String) As Boolean
Dim lngReturnedLength As Long
abyADPU(0) = &H0
abyADPU(1) = &HA4
abyADPU(2) = &H2
abyADPU(3) = &H0
abyADPU(4) = &H2
abyADPU(5) = Val("&H" & Left$(strAddress, 2))
abyADPU(6) = Val("&H" & Right$(strAddress, 2))
lngReturnedLength = SendCommand(7, "select EF_" & strAddress)
SelectEF = abyRecvBuffer(0) = &H85 And abyRecvBuffer(1) = &H10 End
Function
Private Sub ReadBinary(lngCard As Long, FileID As String, numBytes As
Byte)
Dim lngReturnedLength As Long
Erase abyRecvBuffer
abyADPU(0) = &H0
abyADPU(1) = &HB0
abyADPU(2) = Val("&H" & Left(FileID, 2))
abyADPU(3) = Val("&H" & Right(FileID, 2))
abyADPU(4) = numBytes
abyADPU(5) = &H0
abyADPU(6) = &H0
lngReturnedLength = SendCommand(5, "ReadBinary " & FileID) End Sub
Private Function SendCommand(SendBytes As Integer, strCommand As
String) As
Long
On Error Resume Next
Dim lngReturnedLength As Long
Dim lngresult As Long
' structure for card communication
Dim pioSendPci As SCARD_IO_REQUEST
Erase abyRecvBuffer
pioSendPci.dwProtocol = SCARD_PROTOCOL_T0
pioSendPci.dbPciLength = Len(pioSendPci)
lngReturnedLength = 260
lngresult = SCardTransmit(lngCard, pioSendPci, abyADPU(0), _
SendBytes, _
pioSendPci, abyRecvBuffer(0), _
lngReturnedLength)
outputline "returned length is " & lngReturnedLength
Call EvaluateResult("SCardTransmit..." & strCommand, lngresult)
outputline "ADPU = " & ADPUTOSTR(SendBytes) & vbCrLf
If lngresult = 0 Then
PrintStatus abyRecvBuffer, lngReturnedLength
If abyRecvBuffer(0) = &H61 And Not booCancelOperation And
lngReturnedLength = 2 Then
booResponse = GetResponse(lngCard, abyRecvBuffer(1))
End If
End If
SendCommand = lngReturnedLength
End Function
----- Original Message -----
From: "Vivek Ambildhag" <vivek.ambildhag
SLSSOFTWARE.COM>
To: <SmartCardSDK
DISCUSS.MICROSOFT.COM>
Sent: Saturday, October 11, 2003 6:12 AM
Subject: Smart Card Transmit Problem
Hi,
Currently I am facing problem regarding the Smart Card transmit
function
I am programming winscard.dll using VB.
I am able to perform the operations like ScardConnect,
ScardEstablishContext, ScardListReaders successfully
But when I am Transmitting bytes(APDU) to the reader, I am getting
return
bytes 6D 00 as status bytes (Sw1, sw2) as opposed to 90 00
I am using Reader: Gemplus PC 410-SL on Windows 2000
Professional
Please guide me on following Sample Code snippet regarding, where
am
lacking.
Function: SCardTransmit
Dim byReadBuffer As BytArray
Dim bytCommand As BytArray
bytCommand.byBytes(0) = &H0
bytCommand.byBytes(1) = &HA4
bytCommand.byBytes(2) = &H1
bytCommand.byBytes(3) = &H0
bytCommand.byBytes(4) = &H5
Dim leng As Long
leng = 255
lResult = SCardTransmit(hCard, 0, bytCommand, 7, 0, byReadBuffer,
leng)
If lResult <> SCARD_S_SUCCESS Then ' It returns Success
MsgBox "Select File Failed", vbInformation
Exit Sub
End If
szMessage = "MessageRead: " + DecimalToString(byReadBuffer, leng,
True)
Message.Text = szMessage ' Gives status bytes as 6D 00
Thanks and Regards,
Vivek Ambildhag
Sr. Software Programmer
SLS Software Pvt. Ltd.
Camel House,
Nashik - 11
Ph : (0253) -2594231 (extn : 386)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]