Comments (20)
A bit more research... The '1' in dwProtocol for T0 is is clearly correct. The question is why 0 is sent from that piece of C-code, because that seems to be why the C code works.... Here is the same snippet of gdb from stepping through pcscd when calling the C program:
03558356 winscard_svc.c:351:ContextThread() Received command: TRANSMIT from client 14
353 switch (header.command)
(gdb)
621 READ_BODY(trStr)
(gdb)
623 if (MSGCheckHandleAssociation(trStr.hCard, threadContext))
(gdb) p trStr
$1 = {hCard = 781293158, ioSendPciProtocol = 0, ioSendPciLength = 6299704, cbSendLength = 6, ioRecvPciProtocol = 3, ioRecvPciLength = 16,
pcbRecvLength = 266, rv = 0}
from pyscard.
Why don't you use the value returned by SCardConnect()
in dwActiveProtocol
to use it in SCardTransmit()
?
from pyscard.
You are using SCARD_SHARE_DIRECT
. This imply a different protocol negotiation.
But that does not explain why the C code "works".
from pyscard.
Sure but the case statement in _Transmit in scard.i makes that impossible
from pyscard.
Yes but I use SCARD_SHARE_DIRECT in the pyscard code too - I just left that out for brevity
from pyscard.
dwActiveProtocol is 0 btw which hits the default case in _Transmit and causes an Invalid Parameter exception. This seems inconsistent with the behaviour of the C library where passing 0 while using DIRECT triggers the desired behavior in the driver
from pyscard.
Here is a patch that "fixes" this. Review pls...
diff --git a/smartcard/scard/scard.i b/smartcard/scard/scard.i
index 76f63ad..87f38fa 100644
--- a/smartcard/scard/scard.i
+++ b/smartcard/scard/scard.i
@@ -672,8 +672,12 @@ static SCARDRETCODE _Transmit(
)
{
PSCARD_IO_REQUEST piorequest=NULL;
+ SCARD_IO_REQUEST unknown;
long ret;
+ unknown.dwProtocol = 0;
+ unknown.cbPciLength = 0;
+
pblRecvBuffer->ab = (unsigned char*)mem_Malloc(MAX_BUFFER_SIZE_EXTENDED*sizeof(unsigned char));
pblRecvBuffer->cBytes = MAX_BUFFER_SIZE_EXTENDED;
@@ -692,6 +696,10 @@ static SCARDRETCODE _Transmit(
piorequest=(PSCARD_IO_REQUEST)myg_prgSCardRawPci;
break;
+ case 0x00:
+ piorequest = &unknown;
+ break;
+
default:
return SCARD_E_INVALID_PARAMETER
from pyscard.
I guess your C code works because you go in the default case and pioSendPci
is not initialized.
With luck you have pioSendPci.dwProtocol = 0
and 0
is SCARD_PROTOCOL_UNDEFINED
.
What is the value of dwActiveProtocol
after the SCardConnect()
?
If you add a the line pioSendPci.dwProtocol = SCARD_PROTOCOL_T0
before the switch(dwActiveProtocol)
the C program should also fail. Do you confirm?
from pyscard.
Skickat från min iPhone
21 okt. 2016 kl. 21:28 skrev Ludovic Rousseau [email protected]:
I guess your C code works because you go in the default case and pioSendPci is not initialized.
With luck you have pioSendPci.dwProtocol = 0 and 0 is SCARD_PROTOCOL_UNDEFINED.What is the value of dwActiveProtocolafter the SCardConnect()?
If you add a the line pioSendPci.dwProtocol = SCARD_PROTOCOL_T0 before the switch(dwActiveProtocol) the C program should also fail. Do you confirm?
Oh I'm absolutely sure you're right!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
from pyscard.
What is the value of dwActiveProtocol after the SCardConnect()?
You forgot to answer this question.
from pyscard.
I got no answer?
I need to understand the problem in order to fix it correctly.
from pyscard.
On 2016-11-07 20:28, Ludovic Rousseau wrote:
I got no answer?
I need to understand the problem in order to fix it correctly.
sorry, got several NMIs
from pyscard.
Really sorry for the delay!
repr(dwActiveProtocol) == 0L after ScardConnect
from pyscard.
It should be fixed with fa3addb
Please confirm it works for you.
from pyscard.
Can you please confirm the fix works for you?
The idea is to close this issue and release a new version of PySCard.
from pyscard.
Actually it doesn't. I still needed my patch to make it work.
from pyscard.
Your patch should not apply without modifications on the latest version.
- Are you really using the latest PySCard git version?
- If yes can you send me your updated patch for review?
from pyscard.
from pyscard.
OK. You PR can apply cleanly.
But your patch should have NO effect since the case 0 (or SCARD_PROTOCOL_UNDEFINED
) is already managed by the current code.
I also note that your repository at https://github.com/SUNET/pyscard/commits/master is NOT up to date.
from pyscard.
This bug should be fixed upstream.
If your problem is still present then please open a new issue with details and traces.
from pyscard.
Related Issues (20)
- Download artifacts for Windows HOT 2
- Windows EXE and MSI missing for Python 3.10 in collected artifacts HOT 3
- Wheels for macOS (all Python versions) HOT 11
- Consolidate GHA pipeline (cross-platform tests, PyPI releases) HOT 2
- Some missing steps in "Installing on windows from the binary distribution" HOT 4
- Failed to list readers: The Smart Card Resource Manager is not running HOT 7
- OS-dependent behaviour: HOT 4
- I can not read more than 8 cards, I think it is the cache memory of the library HOT 5
- Order of readers in list change arbitrarily HOT 15
- Typo in some method names in documentation HOT 1
- python3 -m pip install pyscard fails on MacOS HOT 2
- drop deprecated use of `imp` HOT 2
- pyscard seems to be not thread save HOT 2
- new release? HOT 1
- 2.0.8: compile time warnings HOT 3
- TypeError: CardRequestTimeoutException.__init__() got an unexpected keyword argument 'hresult' HOT 1
- Unexpected keyword argument 'hresult' for CardRequestTimeoutException HOT 2
- pyscard mutes/hides user created exceptions in `on_insert()` hook. HOT 5
- The Smart Card Resource Manager is not running. (0x8010001D) HOT 13
- Could not build wheels for pyscard HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyscard.