Commit Graph

14 Commits

Author SHA1 Message Date
Vincent JARDIN fd83e885f7 IASECC/CPX: parse EF.ATR from ASN1 2F01 object
2F01 is:
./opensc-explorer -r 0
OpenSC [3F00]> cat 2F01
00000000: 80 43 01 B8 46 04 04 B0 EC C1 47 03 94 01 80 4F .C..F.....G....O
00000010: 08 80 25 00 00 01 FF 01 00 E0 10 02 02 01 04 02 ..%.............
00000020: 02 01 04 02 02 01 00 02 02 01 00 78 08 06 06 2B ...........x...+
00000030: 81 22 F8 78 02 82 02 90 00                      .".x.....

so the ASN1 decoder gets confused because it assumes that two bytes are
needed before getting the first tag 43/ISO7816_TAG_II_CARD_SERVICE.
In order to avoid such confusion, whenever the content of the EF.ATR/2F01 starts
with ISO7816_II_CATEGORY_TLV, we skip the first byte in order to parse
the ASN1 payload.

Fix: issue #2220
2021-03-17 10:58:20 +01:00
Frank Morgner d5ecafc334 fixed memory leak
fixes https://oss-fuzz.com/testcase-detail/5084702283399168
2020-03-20 17:12:18 +01:00
Jakub Jelen a623226a87 Avoid memory leaks from sc_parse_ef_attr()
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20710
2020-03-04 21:27:56 +01:00
Maciej S. Szmigiero 62cbda6cd9 Fix log messages format and parameter issues flagged by GCC
Since "Add GCC format checking attributes to log functions" commit GCC
warns us about problems with format strings and their arguments provided
to OpenSC message logging functions.

This commit fixes all cases where GCC warned about incorrect format on
64-bit Linux, 32-bit and 64-bit mingw builds (with SM and OpenSSL enabled).
Well, almost all since on mingw GCC does not recognize "ll" size specifier
(present at least since Visual Studio 2005, also in mingw own CRT) so these
(few) warnings about it remain.

In most cases format size specifier for size_t type was missing (usually
size was left at default int level, with is different on 64-bit x86).
Some formats had too few / too many arguments.
In some cases pointers were printed as integers.
Some long variables were missing "l" prefix (especially with regard to %x
format).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 11:05:16 +02:00
Frank Morgner 2909ba28a9 parse Extended Length Information in EF.ATR/INFO 2016-07-19 14:30:38 +02:00
Frank Morgner 9a325fc1db EF.ATR: removed IAS/ECC workaround
- IAS/ECC has the category indicator byte in EF.ATR, which is a
  violation of ISO 7816-4, where it is only allowed in the historical
  bytes of ATR. Removing the IAS/ECC specific modification of EF.ATR
  allows reading ISO complient EF.ATR again.
- IAS/ECC parsing should still be successfull. We now always try to
  check for ISO7816_TAG_II_STATUS_SW ignoring the category indicator
  byte
2016-07-19 14:30:31 +02:00
Frank Morgner 3d0064e983 don't expect the card to specify the file length in generic tools
if sc_file_t.size == 0 we try to read 1024 bytes by default.
2013-09-29 18:52:48 +02:00
Viktor Tarasov 58b4304957 libopensc: 'init', 'format', 'compare', 'is-valid' OID procedures
In a reason of number of bugs(*) that concern the OID management,
the general usage OID procedures 'init', 'format', 'compare', 'is-valid' are introduced.
These procedures should be used by all actors: libopensc, pkcs15, pkcs11, tools, ....

(*)
This bug reported by Andreas Schwier :
8e75d971cb (commitcomment-1792477)

In pkcs15-algo sc_asn1_get_algorithm_info() can return the OID without ending '-1's:
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L452
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L459
2012-09-06 10:47:29 +02:00
ludovic.rousseau 46946f285f Remove dead code
ef-atr.c:41:16: warning: Value stored to 'category' during its initialization is
      never read
        unsigned char category = *buf;
                      ^          ~~~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5156 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 21:04:28 +00:00
vtarasov 6ce28a6adb libopensc: initialize 'sc_ef_atr' type variable
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5114 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-19 14:22:57 +00:00
vtarasov 772ab4cefb libopensc: parse EF.ATR: redefine 'STATUS' macros ...
thanks to Andre Zepezauer for his precious remarks


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5083 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-11 10:29:23 +00:00
vtarasov 8f5f0b684a libopensc: remove non-ISO7816 members from the EF.ATR data, thanks to Andre Zepezauer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5079 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-10 14:15:37 +00:00
vtarasov 8f2c96863a libopensc: do not return 'SUCCESS' if EF.ATR do not exist ...
debug messages


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5065 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-09 08:51:55 +00:00
vtarasov bf4aa793af libopensc: parse content of the EF(ATR) file
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5059 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-07 15:49:10 +00:00