Commit Graph

51 Commits

Author SHA1 Message Date
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 8de544653c dump data with sc_debug_hex and sc_log_hex 2017-11-17 10:03:54 +01:00
Frank Morgner 251a5f9fef reader-pcsc: use sc_apdu2bytes for PIN APDU 2017-11-09 12:42:29 +01:00
Frank Morgner d757db2ca8 Avoid dnie_transmit_apdu in the dnie driver (#970) (#1013)
closes #975 
closes #972
2017-04-03 18:00:41 +02:00
Frank Morgner 752e5afd49 log exit of sc_single_transmit in case of SM 2017-03-28 14:24:13 +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
Viktor Tarasov 91a28c613c libopensc: few debug messages more 2016-04-28 10:51:49 +02:00
Frank Morgner ef40021417 use sc_debug_hex for hexdump 2016-03-07 10:39:42 +01:00
German Blanco e9f94d7818 Align end of the loop with comment in previous line (exit when 90 00 or length completed). 2015-12-15 10:43:48 +01:00
Frank Morgner 2d9802308f reactivate handling of `0` for max_recv/send_size
The special value still needs to be handled for commands that are issued
during card initialization. This especially concerns T=0 cards that need
to use iso_get_response.

fixes #533
regression of 85b79a3332
2015-08-26 02:55:35 +02:00
Frank Morgner 85b79a3332 don't always overwrite max_send_size/max_recv_size
If the reader announces extended length support, but the card driver
leaves max_send_size/max_recv_size at `0`, max_send_size/max_recv_size
previously would have been overwritten with the reader's size though the
card might not have set SC_CARD_CAP_APDU_EXT. This commit fixes this
behavior.

Additionally card->max_send_size/max_recv_size is always initialized to
a value different from 0 after the card initialization. This removes the
need to check for this special value in all subsequent calls.
2015-08-11 23:08:41 +02:00
Frank Morgner bcb5fc15e5 honour HAVE_CONFIG_H 2015-04-22 23:55:33 +02:00
Frank Morgner b6a935a261 fixed memory leak 2015-01-24 23:12:47 +01:00
Viktor Tarasov 8d7c773561 SM: move SM APDU procedures to dedicated source file
new SM errors: 'session-already-opened' and 'invalid-checksum'
declare typed data for DH SM session
2013-01-06 16:40:17 +01:00
Viktor Tarasov 49e7f529b2 sm: misplaced check of the 'get-sm-apdus' return code 2012-07-29 21:38:39 +02:00
Frank Morgner 31bdbd6b6a use error code if no SM was applied 2012-07-05 10:12:34 +02:00
Viktor Tarasov 0914b1eca7 libopensc: SM: not all the APDUs need to be wrapped
For some cards some APDUs are always transmitted in a plain mode,
even if SM session is opened.
For these APDUs the 'get_sm_apdu' card's handler returns SUCCESS without wrapped APDU version.
In such cases 'transmit' is called for the plain APDU.
2012-06-19 18:04:37 +02:00
Viktor Tarasov cfd5aaba7d SM: initial implementation of secure messaging framework 2012-06-08 20:17:35 +02:00
andre a28bacf02c libopensc: Reveal another Belpic hack introduced in r2117.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5561 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-08 07:35:03 +00:00
martin 1cdb3fa971 APDU parsing: switch to Frank Morgner's implementation
Patch by Frank Morgner, proposed in
http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016419.html and
http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016420.html:

* replace partly incorrect extended APU parsing implementation
  with one factored-out in function sc_bytes2apdu() in apdu.c
* re-factor APDU parsing functions in
  - opensc-explorer
  - opensc-tool
  - piv-tool
  to make use of sc_bytes2apdu()

Thanks to Peter Marschall and Frank Morgner
This fixes #260 and #351.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5394 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-26 07:29:53 +00:00
ludovic.rousseau f76600b901 Remove dead code
apdu.c:166:5: warning: Value stored to 'p' is never read
                        *p++ = (u8)apdu->le;
                         ^~~
apdu.c:156:4: warning: Value stored to 'p' is never read
                        p += apdu->lc & 0xff;
                        ^    ~~~~~~~~~~~~~~~
apdu.c:147:5: warning: Value stored to 'p' is never read
                        *p++ = (u8)apdu->le;
                         ^~~
apdu.c:139:3: warning: Value stored to 'p' is never read
                p += apdu->lc;
                ^    ~~~~~~~~
apdu.c:118:3: warning: Value stored to 'p' is never read
                p += apdu->lc;
                ^    ~~~~~~~~
apdu.c:112:5: warning: Value stored to 'p' is never read
                        *p++ = (u8)apdu->le;
                         ^~~
apdu.c:107:5: warning: Value stored to 'p' is never read
                        *p++ = (u8)apdu->le;
                         ^~~
apdu.c:102:4: warning: Value stored to 'p' is never read
                *p++ = (u8)apdu->le;
                 ^~~
apdu.c:99:5: warning: Value stored to 'p' is never read
                        *p++ = (u8)0x00;
                         ^~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5157 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 21:09:15 +00:00
dengert f194c873d0 Fix 253 third fix for same problem. The first fix
r4761 added a test in the wrong place. Second fix
r4804 added the test in the correct place. This fix
removes one of the tests added by r4761


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4806 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-14 14:59:51 +00:00
dengert 6b4cb93c84 Fix #253 - Allow caller to read a partial object
by returning all that was read. Related to #257
which fixed a different path in apdu.c


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4804 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-08 14:53:29 +00:00
dengert 10a5d1be3a Fix #257 Reading partial objects differs for T=0 vs T=1
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4761 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-22 14:55:03 +00:00
viktor.tarasov 239de7b6e3 libopensc: remove 'max_xx_size' from debug message
after the 'max_xx_size' stuff has been reverted


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4757 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-22 11:51:52 +00:00
martin a5ca648afd Revert r4668. Change the way limitations on max send and receive sizes are set.
See http://www.opensc-project.org/pipermail/opensc-devel/2010-September/014836.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4706 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-09 18:58:44 +00:00
viktor.tarasov 0fe106e53a libopensc: in a supplement to r4668
Use 'max_recv_size' when building APDU for 'select file'


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4682 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-04 20:08:52 +00:00
martin 241d3b5d86 libopensc: improve max_send/recv_size related code comments.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4670 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 11:50:39 +00:00
martin 07ab2a2871 Ticket #226: Initial changes as noted by reporter
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4668 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-01 11:50:24 +00:00
viktor.tarasov d10effd58c libopensc: fix #209
In APDU consider Le=0 as Le=256

Thanks to FrankMpunkt, Martin, ludovic.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4244 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-16 19:34:47 +00:00
aj 6545b42c02 cleanup of the debug code:
* reduce to a few, supported functions.
* change all functions to take the debug level as parameter.
* use symbolic names for the debug levels.
* fix tools to pass "verbose"/"opt_debug" as ctx->debug.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4118 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-15 12:17:13 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00
aj 119c7751c7 Improved chaining for large APDU commands,
by Mats Andersson and Douglas E. Engert.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3997 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-05 06:14:19 +00:00
martin d006b1845e libopensc:
- Remove slot abstraction from internal API and all reader drivers. CT-API (from where it all comes from) readers with multiple slots (if still found) can be presented as separate readers, OpenCT should remove the slot abstraction, PC/SC never knew about it. None of the tools knew how to use slots.
 - Add sc_cancel (translates to SCardCancel)
 - Re-implement sc_wait_for_event; support a blocking call.
 - Replace the "int reader" API with "* sc_reader_t" style; add "Get reader by name" functionality.
 - Remove "action" parameter from sc_disconnect_card() (was not used)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3931 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 15:25:08 +00:00
martin cd9e666926 SC_ERROR_MEMORY_FAILURE signals EEPROM failures on card. Failures to allocate memory on host result in SC_ERROR_OUT_OF_MEMORY.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3927 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-24 12:38:34 +00:00
martin 615b181471 Revert [3752]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3773 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-12 09:26:05 +00:00
martin 99e84ae82a Fix spelling
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3753 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-03 10:07:55 +00:00
martin ab2ed07b78 Fix APDU sanity check.
By Emanuele Pucciarelli,  http://itacns.corp.it/hg/itacns/file/adc0b2ceec86/patches/010-apdu.patch


git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3752 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-03 10:06:53 +00:00
martin d672fde449 Remove sc_error and sc_ctx_suppress_errors_* in favor of sc_debug/fprintf
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3721 c6295689-39f2-0310-b995-f0e70906c6a9
2009-09-14 08:46:59 +00:00
aj 43b7391a94 fix typo, found by Gürer Özen.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3260 c6295689-39f2-0310-b995-f0e70906c6a9
2007-08-28 20:35:06 +00:00
aj f9b30e48c4 fix typos, patch by Gürer Özen
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3257 c6295689-39f2-0310-b995-f0e70906c6a9
2007-08-22 18:38:02 +00:00
nils 8135be4166 bugfix: avoid recursion
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3167 c6295689-39f2-0310-b995-f0e70906c6a9
2007-05-13 09:30:53 +00:00
nils 0ccd6daf8d improve get_response logic: try to read at least as much bytes
as indicated in the 0x61xx response.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3109 c6295689-39f2-0310-b995-f0e70906c6a9
2007-01-09 19:41:05 +00:00
aj dad82e19d7 only the first apdu (command) tells us how many bytes we need to get.
we need to keep this value and call get_response as often as needed
to get them part by part.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3093 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-29 09:44:13 +00:00
aj 8fe04d5a86 revert bogus change.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2926 c6295689-39f2-0310-b995-f0e70906c6a9
2006-05-01 10:10:35 +00:00
aj ab0066b0d7 fix printf size_t problem with "%lu" and (unsigned long) cast.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2923 c6295689-39f2-0310-b995-f0e70906c6a9
2006-05-01 10:02:50 +00:00
aj 2327835416 fix a memory leak.
don't access buffer beyond length.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2912 c6295689-39f2-0310-b995-f0e70906c6a9
2006-04-26 10:07:20 +00:00
nils 383602b6fe - move logging to the reader driver
- log APDUs only if DEBUG is defined (sensitive APDUs should
  never be logged and we cannot know whether a APDU is sensitive
  or not => enable APDU logging only in a non-production debug
  build)
- remove OPENSC_DONT_LOG_SENSITIVE configure option as it's 
  needed anymore 


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2868 c6295689-39f2-0310-b995-f0e70906c6a9
2006-03-03 22:56:41 +00:00
nils ca2a5e11fd - move APDU encoding to the reader layer
- remove APDU masquerading code, it shouldn't be necessary
  anymore


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2831 c6295689-39f2-0310-b995-f0e70906c6a9
2006-02-05 19:00:01 +00:00
nils 85aaa4466d fix typo
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2830 c6295689-39f2-0310-b995-f0e70906c6a9
2006-02-03 21:24:11 +00:00