Commit Graph

54 Commits

Author SHA1 Message Date
Jakub Jelen b6e08e008e Move the Global Platform related commands to separate file and port existing code to that 2018-05-18 23:52:01 +02:00
Frank Morgner 439a95f2d2
If card initialization fails, return SC_ERROR_INVALID_CARD (#1251)
fixes https://github.com/OpenSC/OpenSC/issues/946
2018-05-18 23:49:29 +02:00
Peter Marschall 5abe99d228 fix typos
Mass-typo fixing, almost exclusively in comments and text strings.

While at it also fixed a few (very few) grammar errors.
2018-04-15 09:34:45 +02:00
Frank Morgner fc64c87c5c with keep_alive, use cache only within the transaction
fixes https://github.com/OpenSC/OpenSC/issues/1159
2018-04-06 12:20:32 +02:00
Frank Morgner f24b55db4a IAS/ECC: fixed applet selection
fixes https://github.com/OpenSC/OpenSC/issues/1240
2018-01-24 10:45:16 +01:00
Frank Morgner 8de544653c dump data with sc_debug_hex and sc_log_hex 2017-11-17 10:03:54 +01:00
Arnaud Fontaine 2765b7b1a0 Support for new MinInt agent card (#1092)
* Support for new MinInt agent card

This card uses the same ATR as the existing card, but the applet installed
does not have the same AID. This card actually works exactly as the
IASECC_SAGEM.

Unify iasecc_init for AMOS/SAGEM and MI cards
2017-08-22 01:13:18 +02: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
Michał Trojnara 645780e6d4 NULL parameter check moved to sc_file_free()
This fixes numerous issues where the check is *not* performed,
and also simplifies the code.
2017-01-10 12:46:44 +01:00
Frank Morgner 2f10de4f5c use sc_pkcs15_get_pin_info in C_GetTokenInfo
introduced paramter to signal back the login state
- used for the pin command SC_PIN_CMD_GET_INFO
- implemented in accordance to ISO 7816-4; all other implementations
  are currently set to an unknown login state

implemented and exporeted sc_pkcs15_get_pin_info

use sc_pkcs15_get_pin_info in C_GetTokenInfo

C_GetSessionInfo: Check whether a logout was done

Closes https://github.com/OpenSC/OpenSC/pull/624

rebased by @viktorTarasov
2016-07-17 14:07:43 +02:00
Ludovic Rousseau ae67f16e9b card-iasecc.c: fix 1 compiler warning
card-iasecc.c:3206:3: error: variable 'rv' is used uninitialized whenever 'if'
      condition is false [-Werror,-Wsometimes-uninitialized]
  ...LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Need RSA_HASH_SHA1 or RSA_HASH_SHA256 algorithm");
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/libopensc/log.h:90:36: note: expanded from macro 'LOG_TEST_RET'
  ...r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/libopensc/log.h:84:6: note: expanded from macro 'SC_TEST_RET'
        if (_ret < 0) { \
            ^~~~~~~~
card-iasecc.c:3207:20: note: uninitialized use occurs here
        LOG_TEST_RET(ctx, rv, "Cannot get QSign data");
                          ^~
../../src/libopensc/log.h:90:77: note: expanded from macro 'LOG_TEST_RET'
  ...r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
                                                       ^
../../src/libopensc/log.h:83:14: note: expanded from macro 'SC_TEST_RET'
        int _ret = (r); \
                    ^
card-iasecc.c:3206:3: note: remove the 'if' if its condition is always true
                LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Need RSA_...
                ^
../../src/libopensc/log.h:90:36: note: expanded from macro 'LOG_TEST_RET'
                                   ^
../../src/libopensc/log.h:84:2: note: expanded from macro 'SC_TEST_RET'
        if (_ret < 0) { \
        ^
card-iasecc.c:3185:8: note: initialize the variable 'rv' to silence this warning
        int rv;
              ^
               = 0
2016-03-02 15:01:19 +01:00
Ludovic Rousseau d86ada1c64 card-iasecc.c: fix 1 compiler warning
card-iasecc.c:2322:58: error: address of 'data->pin2.data' will always evaluate
      to 'true' [-Werror,-Wpointer-bool-conversion]
  ...if (!data->pin1.data && !data->pin1.len && &data->pin2.data && !data->pi...
                                             ~~  ~~~~~~~~~~~^~~~
2016-03-02 14:59:27 +01:00
Frank Morgner c9420046c5 Removed unused parameter 2015-10-14 22:08:14 +02:00
Frank Morgner f851197129 Merge pull request #565 from frankmorgner/sm-openssl
Build a lightweight version of OpenSC
2015-10-02 15:12:41 +02:00
Frank Morgner ffd85adae7 Decouples SM from OpenSSL 2015-09-24 14:46:30 +02:00
Frank Morgner fe31aceacb Fixes signature of iasecc_read_public_key 2015-09-17 22:24:33 +02:00
Frank Morgner 8a225eb42b Avoids potential NULL pointer deref 2015-09-17 22:24:33 +02:00
Viktor Tarasov 475ce71453 iasecc: fixed resource leak
pkcs15-iasecc: fix memory leakage
iasecc: fix memory leakage
2015-05-08 09:11:20 +02:00
Frank Morgner cbc43eeb88 fixed compiler warning 2015-04-21 01:04:18 +02:00
Viktor Tarasov 3e2d51e0ba iasecc: use PIN PAD with variable PIN length 2015-04-11 16:47:13 +02:00
Viktor Tarasov 95ad11a253 iasecc: special case for 'Gemalto GemPC Pinpad'
issue 424
VTA: this pinpad, the only available, do not accept different values
for min and max PIN lengths in P10 block.
2015-04-04 21:41:28 +02:00
Thomas Calderon 4a4d750e73 iasecc: Fix log output is always displayed
* iasecc_read_public_key function uses SC_SUCCESS instead of log level
  value, hence the log output is always displayed. This uses
  SC_LOG_DEBUG_NORMAL instead.

VTA: updated to use short form of LOG macro
2015-03-31 18:47:11 +02:00
Thomas Calderon 435291f216 iasecc: initial support for Morpho IAS Agent Card
* This commit adds initial support for Morpho French Agent card which is an
    IAS card. Signature operations are working. Since my test card was
    read-only, I was unable to test object management functions.

  * Add missing copy of AID in structure
2015-03-29 12:10:55 +02:00
Viktor Tarasov 08eb700b97 revert or partially revert some of recent commits
b94c163 - invalid, non-tested
11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored,
3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue #373
3a92bf7 -- src/tools/piv-tool.c -- confirmed by author
6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
2015-02-07 19:31:17 +01:00
Frank Morgner 11881a61b8 removed/fixed dead code 2015-02-05 01:38:41 +01:00
Frank Morgner a3fc62f79f fixed NULL dereference (or warning thereof) 2015-02-05 01:38:40 +01:00
Frank Morgner ac4da89d0d use memmove for overlapping memory 2015-02-05 01:37:53 +01:00
Frank Morgner 6759c04b26 don't ignore errors 2015-01-28 04:45:08 +01:00
Frank Morgner 7a34c204c1 fixed dereference before null check
silence warnings reported by coverity-scan
2015-01-22 20:29:33 +01:00
Thomas Calderon 32d8173b4c IAS-ECC: Improve detection Gemalto cards(Issue #343)
* Improve IAS-ECC card detection using the ATRMask.
    Previous commit was revert since work was not done in topic branch.
2014-12-29 16:09:06 +01:00
Frank Morgner e137396d56 workaround for compiler warnings 2014-12-12 21:45:53 +01:00
Frank Morgner e3649fb7de fixed even more compiler warnings 2013-08-02 15:43:25 +02:00
Viktor Tarasov 60b7e52e06 pkcs15: mandatory 'publicKeyCoefficients' in encode/decode public key procedures
http://www.opensc-project.org/pipermail/opensc-devel/2012-November/018586.html
2012-11-20 22:58:37 +01:00
Viktor Tarasov 7fbca94698 opensc: new card operation 'read-public-key'
In PukDF of PKCS#15 the public key value can be presented by 'direct value', by path or by path and reference.
For the different cards the public key can be stored in EF, internal EF or in card specific SDO (security data objects).
A new card handle allows to read out the public key from the card specific SDOs.
2012-11-09 14:36:14 +01:00
Viktor Tarasov ceef4c0be3 iasecc: remove ostentatious TODO messages 2012-09-24 11:50:56 +02:00
Viktor Tarasov ea5a19e27e iasecc: SM add related procedures 2012-06-08 20:17:35 +02:00
vtarasov f026db6f84 compile warnings: resolve 'comparison between signed and unsigned' compiler warnings
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5534 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-02 16:59:39 +00:00
vtarasov a44ec385bd iasecc: no support for SHA256 in the OpenSSL previous to v0.9.8
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5444 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-13 16:11:06 +00:00
vtarasov cbecf23395 iasecc: when getting data for qualified signature, take the last SHAxx block from the input data ...
... and not from the SHAxx-CTX, to avoid big/little endian uncertainty


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5435 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-10 08:24:27 +00:00
vtarasov 1e025a0ded iasecc: support the digital signature with RSA scheme PKCS#1 SHA-256 ...
in this mode the final digest (SHA-256) step has to be performed by card.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5433 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-09 15:31:02 +00:00
vtarasov c70e0ae982 iasecc: use atr mask to accept the Gemalto's IAS/ECC card without MF
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5411 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-30 17:51:43 +00:00
vtarasov ad478eb9cc iasecc: write 'compulsorily use' data for the new key slot ...
Once written the 'compulsorily use' data cannot be changed. 
Write this data immediately after a new key slot has been created.
It helps to avoid further confusion between 'use new key slot' and 'reuse existing slot'.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5402 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-27 14:06:58 +00:00
vtarasov 6c3b43f636 iasecc: when signing short data sequence with PSO_DST ...
... 'last-hash-step' APDU do not includes the 'pre-hash' and 'counter' data -- only the 'last-data-block'.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5401 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-27 13:56:31 +00:00
vtarasov c9bf9bc22c iasecc: 'DELETE SDO' card ctl ...
to be used by Obertbur's IAS/ECC card.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5398 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-26 17:29:08 +00:00
vtarasov 346490b953 iasecc: 'CREATE SDO' card ctl ...
; static function dedicated to emulate FCP data of application DF when it's not returned by card



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5397 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-26 16:42:48 +00:00
vtarasov 27cd40629e iasecc: Oberthur's card strictly follows specification in 'IO buffer size' ...
Most of the card producers interpret 'send' values in 'IO buffer size' data as "maximum APDU data size" .
The last Oberthur's card strictly follows specification and interpret these values as "maximum APDU command size".


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5392 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-24 17:57:49 +00:00
andre b21eeb46b9 libopensc: Removes unused flag SC_CARD_CAP_RSA_2048.
Relates to [http://www.opensc-project.org/opensc/ticket/296#comment:1 #296].

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5308 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-07 18:16:40 +00:00
ludovic.rousseau 8c0dbf4b02 Fix compiler warning
card-iasecc.c: In function 'iasecc_get_serialnr':
card-iasecc.c:2218: warning: declaration of 'ii' shadows a previous local
card-iasecc.c:2165: warning: shadowed declaration is here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5266 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-23 16:02:42 +00:00
ludovic.rousseau 0e6b87b135 Fix compiler warning
card-iasecc.c: In function 'iasecc_select_file':
card-iasecc.c:647: warning: declaration of 'rv' shadows a previous local
card-iasecc.c:635: warning: shadowed declaration is here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5265 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-23 16:01:45 +00:00
ludovic.rousseau 161678d8a6 Fix compiler warning
card-iasecc.c:1529: warning: declaration of 'ffs' shadows a global declaration
/usr/include/string.h:121: warning: shadowed declaration is here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5264 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-23 16:00:56 +00:00