web-eid / libpcsc-cpp Goto Github PK
View Code? Open in Web Editor NEWC++ library for accessing smart cards using the PC/SC API
License: MIT License
C++ library for accessing smart cards using the PC/SC API
License: MIT License
Lines 133 to 142 in 0483f24
In the source code there is comment about digging up the reason why the +4 is included in the computation. I have found out it is most probably included because of the first 4 bytes the code uses to actually read the length.
In the next step the program usually uses this length to read whole certificate from the card, so the first 4 bytes need to be included, otherwise it would be 4 bytes shorter.
This is not really an issue, but I have been in contact with @mrts who told me to make a comment about it here. Maybe in the future it might confuse people.
I originally envisioned that libpcsc-cpp
could be used in embedded environments where every byte counts and so didn't want to have a copy of the ATR both in Reader
and SmartCard
, so I used std::move
to move it from Reader
. Now I think this was an inadequate premature optimization, and SmartCard
takes all data that it uses by copy.
I took a second look and I actually think the best way to have only a single copy of the ATR is to add a reference to Reader
to SmartCard
so that SmartCard::atr()
just does return reader.atr
. The trick, though, is to assure that the Reader
object remains alive, it was originally meant to live on the stack and possibly have shorter lifetime than SmartCard
.
Originally posted by @mrts in #8 (comment)
Currently, when the status word from the card is 6CXX, an exception is thrown:
Lines 218 to 220 in 8c6bfdc
When receiving 6CXX, one is supposed to resend the command APDU with Le=XX. However, since an exception is thrown, the ResponseApdu object is not returned to the caller, and as a result the SW2 value cannot be accessed to determine the correct Le.
I think this can be solved by simply removing the code that throws the exception, and let the caller handle it.
What do you think?
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.