-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
T0/T1 marshaling confusion #31
Comments
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:
|
Why don't you use the value returned by |
You are using |
Sure but the case statement in _Transmit in scard.i makes that impossible |
Yes but I use SCARD_SHARE_DIRECT in the pyscard code too - I just left that out for brevity |
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 |
Here is a patch that "fixes" this. Review pls...
|
I guess your C code works because you go in the default case and What is the value of If you add a the line |
Skickat från min iPhone
Oh I'm absolutely sure you're right!
|
You forgot to answer this question. |
I got no answer? |
On 2016-11-07 20:28, Ludovic Rousseau wrote:
sorry, got several NMIs |
Really sorry for the delay! repr(dwActiveProtocol) == 0L after ScardConnect |
If the connection to the card/reader was done using SCARD_SHARE_DIRECT then the card protocol has not been negociated and is undefined. This is not an error and _Transmit should not fail in this case. For example this is used to read/write memory cards. Thanks to Leif Johansson for the bug report. "T0/T1 marshaling confusion" #31
It should be fixed with fa3addb Please confirm it works for you. |
Can you please confirm the fix works for you? |
Actually it doesn't. I still needed my patch to make it work. |
Your patch should not apply without modifications on the latest version.
|
Skickat från min iPhone
5 jan. 2017 kl. 16:09 skrev Ludovic Rousseau ***@***.***>:
Your patch should not apply without modifications on the latest version.
Are you really using the latest PySCard git version?
Yeah I'm pretty sure
If yes can you send me your updated patch for review?
Exactly the same one the one in my PR
… —
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
OK. You PR can apply cleanly. I also note that your repository at https://github.com/SUNET/pyscard/commits/master is NOT up to date. |
This bug should be fixed upstream. |
I've been tracking a strange issue that I believe is due to a problem in the swig code for scard. I'm talking to a SLE5542 using an ACR39U reader and I've got a piece of C code for reading memory off of that card that works but the corresponding python code using the scard interface does not. All of this was done using fresh clones of pcsc-lite and pyscard from github.
The C code is in https://gist.github.com/leifj/140f9c79d99af078c5167f587cd81b69
This code works as expected and it depends on using the T0 protocol which triggers the correct processing of "pseudo" APDUs in the driver. So far so good. However ...
Using scard I expect code like this to work:
Using this code I get a protocol mismatch (between the card protocol and requested protocol) and when I step through pcscd with gdb while running this python code, I find that the message string received by ContextThread in winscard_svc.c has a '1' in the pioSendPciProtocol field instead of the expected 0. A sample gdb snippet:
Continuing to step through this I confirm that the subsequent call to SCardTransmit is attempted using the T1 protocol which of course results in a protocol mismatch later on.
There seems to be a marshalling error somewhere in pyscard.
The text was updated successfully, but these errors were encountered: