wookey-project / libiso7816 Goto Github PK
View Code? Open in Web Editor NEWSoC-independent part of the iso7816 stack
License: GNU Lesser General Public License v2.1
SoC-independent part of the iso7816 stack
License: GNU Lesser General Public License v2.1
Hi, I've been using libiso7816
with my smartcard application at T=1 configuration. Short commands (<255 byte length) seem to work well, but as soon as an extended length command is sent, errors are shown:
SC_fsm_early_init(SC_MAP_AUTO);
SC_fsm_init(&card, 0 /* do_negotiate_pts */, 0 /* do_change_baudrate */, 2 /* do_force_protocol T=1 */, 0 /* do_force_etu */);
apdu.cla = 0x00; apdu.ins = requestType; apdu.p1 = apdu.p2 = 0x00;
apdu.le = 0xFF; apdu.send_le = 1;
SC_send_APDU(&apdu, &res, &card);
This is using the default init (though with T=1 forced as it is a T=1 card), and with a smartcard applet that is known to work with extended length commands in other programs.
Returns the following error:
[Smartcard T=1] Unexpected case: received other block than expected IBLOCK, or bad sequence number ...
and seems to fail here: https://github.com/wookey-project/libiso7816/blob/master/smartcard_iso7816.c#L1952
I can see that a RBLOCK is received at that point while the last block (out of 2 blocks) is being sent and therefore an IBLOCK is expected.
Not sure whats going on, but this seems to be a bug in the handling logic?
In libiso7816, calculate wi = atr->tc[1] & 0x0f, but in SPEC 7816 it says TC2 encodes the waiting time integer WI over the eight bits, except the value '00' reserved for future use.
So should it be if (atr->tc[1] != 0) wi = atr->tc[1] ?
And another question, in SC_push_pull_APDU_T0( ) comments we send a 0 as P3 in a case 1 APDU, but code is send le byte, it could be a mistake?
Hi, I didn't find lib process "Case 2S.3 -- Process aborted; Ne not accepted, Na indicated", it mapped 6C XX to the Response APDU directly. I think lib should add hadling of this case.
Another question, I find some T0 card (some credit card, like PBOC, EMV card), can not work well if I do not add delay (here I used 16etus), between the leading edages of the start bits of the last character received and the first character sent in the opposite direction. Although I find this principle in EMV book1 SPEC( EMV 4.2 book1 9.2.2.1 For the ICC or terminal, the minimum interval between the leading edges of thestart bits of the last character received and the first character sent in theopposite direction shall be 16 etus.), but I did not find in ISO7816 SPEC.
Hi, I am trying to use libiso7816 project, but found missing define of SC_ATR, SETUP_LENGTH, SC_APDU_cmd, SC_APDU_resp, can you fix it?
Thanks a lot.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.