Re: Problem about "csptestsuite.exe" result for "CPAcquireContext" fun
- From: Sylvain SF <sylvain@xxxxxxxxxxxxxxx>
- Date: Tue, 30 Jun 2009 23:26:06 +0200
creative22 a écrit :
Any help please?!!!
I've implemented a Smart Card CSP of type "PROV_RSA_SIG", and it's "CPAcquireContext" function is as below:
// 1.Establish the context.
lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
//2.List readers.
lReturn = SCardListReaders(mycsp->hContext,
if(DialogBoxParam (g_hModule, MAKEINTRESOURCE(IDD_DIALOG2),
NULL, SelectReaderProc, (LPARAM) m_ReaderBuff)){
end-user seldom have 12 readers and thus direct selection of the
right reader must be performed by the application among the *1*
or *2* installed readers; also note that letting the user chooses
between reader "boring-not-understandable-name" and "meaningless-
name" is not that useful.
if for some strange reasons, you do have to use a dialog to enforce
the user to choose a reader you should use SCardUIDlgSelectCard(..).
>> reader,//3.Connect to the card.
lReturn = SCardConnect(mycsp->hContext,
>> SCARD_SHARE_EXCLUSIVE,
>> SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1,
1- giving your full listing w/o commenting that fails and what runs
fine, is useless.
2- giving the log of csptestsuite w/o knowing what failed is useless
you may consider these 2 points if you expect help & responses.
if I assume that this call returns 0x8010000b (The smart card cannot
be accessed because of other connections), it means that the smart card
cannot be accessed because of other connections
you should *obviously* try to connect in NOT exclusive mode
(SCARD_SHARE_SHARED) and, if exclusive connection is required for you
(due to security concerns or other reasons), you must investigate which
process is already connected when you run that code, and disable it, or
apply whatever required.
APDU apdu;
apdu.bSend = TRUE;//send APDU command with Data
apdu.CLA = 0x00;
apdu.INS = 0xA4;
apdu.P1 = 0x04;
apdu.P2 = 0x00;
apdu.P3=16;
apdu.Buffer[0]=0xA0;
apdu.Buffer[1]=0x00;
apdu.Buffer[2]=0x00;
apdu.Buffer[3]=0x00;
apdu.Buffer[4]=0x18;
apdu.Buffer[5]=0x30;
apdu.Buffer[6]=0x03;
apdu.Buffer[7]=0x01;
apdu.Buffer[8]=0x00;
apdu.Buffer[9]=0x00;
apdu.Buffer[10]=0x00;
apdu.Buffer[11]=0x00;
apdu.Buffer[12]=0x00;
apdu.Buffer[13]=0x00;
apdu.Buffer[14]=0x00;
apdu.Buffer[15]=0x00;
what stupid/inefficient class !!! where does it come from ??
But when I test it using "csptestsuite.exe", I see this result:
I see useless / un-usable information.
And when I comment out "if" section of this:
//3.Connect to the card.
lReturn = SCardConnect(mycsp->hContext,
if (lReturn != SCARD_S_SUCCESS) return FALSE;
I see "ERROR_INVALID_HANDLE" error in the "csptestsuite.exe" result!!
SCardConnect does connect to the card and does provide a valid handle.
are you actually surprised of that error if you run code with an
invalid handle ?!?
How is the precise work of "csptestsuite.exe"?
(Is there any other document about it than "readme"?)
If you have no idea about what does that code it can be an issue.
but at least you except that it will call your "CPAcquireContext"
function, so did you call that function from a test-console-appl
and check all steps ? apparently not, it's a pity, you will
certainly get valuable info from that.
Sylvain.
.
- Follow-Ups:
- Re: Problem about "csptestsuite.exe" result for "CPAcquireContext"
- From: creative22
- Re: Problem about "csptestsuite.exe" result for "CPAcquireContext"
- Next by Date: RE: Using Win32 CryptDecrypt to Decrypt RijndaelManaged
- Next by thread: Re: Problem about "csptestsuite.exe" result for "CPAcquireContext"
- Index(es):