Commit Graph

65 Commits

Author SHA1 Message Date
Frank Morgner b232c9b675 card-starcos: use transceive length from EF.ATR
fixes https://github.com/OpenSC/OpenSC/issues/765
2016-07-19 14:30:45 +02:00
Frank Morgner e95707362f Merge pull request #357 from fancycode/startcos34_dtrust
Added initial support for STARCOS 3.4 (German D-Trust cards).
2015-07-31 15:40:30 +02:00
Frank Morgner bcb5fc15e5 honour HAVE_CONFIG_H 2015-04-22 23:55:33 +02:00
Joachim Bauch 9543cdb121 Handle case where input data is already padded. 2015-01-20 16:52:30 +01:00
Joachim Bauch 87cc05c03f Receive signature to temporary buffer, will be copied to output buffer later. 2015-01-20 16:49:11 +01:00
Joachim Bauch 19bbfc76f5 Added initial support for STARCOS 3.4 (German D-Trust cards).
Code inspired by experimental STARCOS 3 driver by Martin Vogt:
http://article.gmane.org/gmane.comp.encryption.opensc.devel/9846

Supports `opensc-explorer`, `pkcs15-tool` and `pkcs15-crypt` (signing with PKCS#1 padding).

Cards available from `https://www.bundesdruckerei.de/en/768-d-trust-signature-cards`.
2015-01-19 18:04:12 +01:00
martin 7406d84415 Fix a typo reported by lintian
I: libopensc3: spelling-error-in-binary ./usr/lib/libopensc.so.3.0.0 enviroment environment

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5239 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-20 12:19:01 +00:00
andre 8ff3d5d647 Fixing misuse of SC_CARD_FLAG_RNG. From opensc.h :
[http://www.opensc-project.org/opensc/browser/trunk/src/libopensc/opensc.h?rev=5190#L88 #define SC_ALGORITHM_RSA_PAD_PKCS1      0x00000002]
[http://www.opensc-project.org/opensc/browser/trunk/src/libopensc/opensc.h?rev=5190#L413 #define SC_CARD_FLAG_RNG                0x00000002]

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5218 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-04 16:23:07 +00:00
ludovic.rousseau 28b6b60870 Remove dead code
card-starcos.c:657:5: warning: Value stored to 'p' is never read
                        *p++ = file->record_length & 0xff;
                         ^~~
card-starcos.c:652:5: warning: Value stored to 'p' is never read
                        *p++ = file->record_length & 0xff;
                         ^~~
card-starcos.c:647:5: warning: Value stored to 'p' is never read
                        *p++ = file->size & 0xff;
                         ^~~
card-starcos.c:609:4: warning: Value stored to 'p' is never read
                *p++ = tmp;     /* SM ISF */
                 ^~~
card-starcos.c:572:4: warning: Value stored to 'p' is never read
                *p++ = tmp;
                 ^~~
card-starcos.c:1024:2: warning: Value stored to 'keyID' is never read
        keyID = env->key_ref[0];
        ^       ~~~~~~~~~~~~~~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5166 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 21:44:14 +00:00
vtarasov 3efe35d246 libopensc: avoid the using of not completely initialized 'sc_path' variables
to be continued...


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5103 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-17 19:00:52 +00:00
vtarasov 92c3e59e16 libopensc: Now 'cache-valid' flag is a member of 'sc_card_cache' ...
add 'current_ef' and 'current_df' member to 'sc_card_cache'.
The main purpose of this is to reduce number of APDU transactions.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5002 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-30 13:04:55 +00:00
andre 50567141f0 Rename of SC_NO_ERROR to SC_SUCCESS.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4954 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-16 05:04:37 +00:00
martin 9fe86d16fe libopensc: protect for possible buffer overflows from rogue cards.
Reported by Rafael Dominguez Vega

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4913 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-06 12:52:14 +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
ludovic.rousseau f47416d60e Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety

malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in

int *ptr = (int*)malloc(10 * sizeof (int));

When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.

The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.

The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "

See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +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
martin 64f9578202 apdu.sensitive is not in use since [2868]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3751 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-03 09:31:07 +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 ad79822134 convert to utf-8.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3085 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-19 21:32:31 +00:00
nils bf389495a8 add starcos spk 2.4 ATR
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3022 c6295689-39f2-0310-b995-f0e70906c6a9
2006-09-22 14:34:51 +00:00
nils eb3b27709c bugfix
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3021 c6295689-39f2-0310-b995-f0e70906c6a9
2006-09-22 14:18:22 +00:00
nils 9e5ed96912 use correct ef attribute in switch statement; thanks to Chaskiel M Grundman <cg2v@andrew.cmu.edu>
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2937 c6295689-39f2-0310-b995-f0e70906c6a9
2006-05-03 07:16:38 +00:00
nils de4b5c280f - implement thread-safe path printing function sc_path_print() and use
it src/libopensc/ and src/pkcs15init/
- use size_t for the certlen parameter of sc_pkcs15init_update_certificate()


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2811 c6295689-39f2-0310-b995-f0e70906c6a9
2006-01-11 23:41:17 +00:00
nils 1376a07cfa fix APDU case
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2764 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-12 20:38:19 +00:00
nils 0a23e307af remove senseless and inconsistent checks + cleanup
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2688 c6295689-39f2-0310-b995-f0e70906c6a9
2005-11-26 10:03:38 +00:00
nils 3a803dfe3b remove disabled code, request FCI only if a file object has been specified
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2685 c6295689-39f2-0310-b995-f0e70906c6a9
2005-11-20 21:53:34 +00:00
nils 47ee84e72d add functions
void sc_ctx_suppress_errors_on(sc_context_t *ctx);
	void sc_ctx_suppress_errors_off(sc_context_t *ctx);
to turn on/off error suppression (to avoid accessing
sc_context_t directly) and use it.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2671 c6295689-39f2-0310-b995-f0e70906c6a9
2005-10-30 19:08:06 +00:00
nils f6c95792fe let src/libopensc/ compile with -Wall -W -Wno-unused-parameter -Werror
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2546 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-07 08:33:55 +00:00
nils 45a9d05830 cleanup, mostly signed/unsigned issues
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2469 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-08 10:22:14 +00:00
nils 69ffd496b2 the apdu error codes are unsigned => change sc_check_sw and the card ops check_sw
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2467 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-05 17:18:10 +00:00
nils a1261369e2 only copy resp if the operation was successful
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2437 c6295689-39f2-0310-b995-f0e70906c6a9
2005-07-18 21:30:30 +00:00
nils 817e26a362 starcos has a GET CHALLENGE command ... useless flag
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2427 c6295689-39f2-0310-b995-f0e70906c6a9
2005-07-18 07:26:41 +00:00
bert 2d97002824 API fixup: use defined type instead of struct for exposed structs
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2232 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-08 20:59:35 +00:00
aet 32b417cbf3 - First stab towards standardized card types
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2172 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-10 10:07:13 +00:00
aet 73aa989875 - Unify a bit the output of commands like opensc-tool -D
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2166 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-09 14:47:46 +00:00
aet ece96aff98 - Add atrmask to sc_atr_table
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2160 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-09 11:33:37 +00:00
aet 69d2e9014d - Optimize a few cpu cycles from _sc_match_atr_hex
- Replace struct sc_atr_table / _sc_match_atr with
  recently introduced _hex variants
- Rewrote _add_atr
- Introduce int type variable to sc_card_t, so that
  every other card driver won't have to glue around
  with this
- Card driver cleanups, optimize the number of
  sc_match_atr called per card driver. Also
  always try direct match with _sc_match_atr
  first, before relying on eg. historical bytes
  information on some card drivers
- Fixed a memory leak from the miocos driver


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2145 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-06 19:40:40 +00:00
nils f2cf81ba19 cleanup
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2135 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-04 22:11:08 +00:00
aet bd0f86f69c - Unify all card drivers ATR matching code to use _sc_match_atr_hex,
untested as of yet.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2134 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-04 20:29:35 +00:00
nils 6e05b6bfbc add debugging output
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2121 c6295689-39f2-0310-b995-f0e70906c6a9
2005-02-01 19:03:39 +00:00
nils 5e552bddc1 starcos: use iso decipher, iso7816: set le to 256 == 0x00
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2072 c6295689-39f2-0310-b995-f0e70906c6a9
2005-01-13 20:28:57 +00:00
aet 55e170e0ac - Build / warning fixes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2014 c6295689-39f2-0310-b995-f0e70906c6a9
2004-12-15 13:53:36 +00:00
nils 1249c9c2ab fix starcos spk 2.3 "onepin" profile support
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1908 c6295689-39f2-0310-b995-f0e70906c6a9
2004-09-28 20:06:04 +00:00
nils 5ebccf1842 rename "StarCOS" -> "STARCOS SPK 2.3"
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1900 c6295689-39f2-0310-b995-f0e70906c6a9
2004-09-17 19:13:30 +00:00
nils f8c603f559 update starcos spk 2.3 pkcs15-init support
change summary:
- some bug fixes
- support for global so-pins
- use so-pin (if present) to protect key creation etc.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1891 c6295689-39f2-0310-b995-f0e70906c6a9
2004-08-21 10:53:09 +00:00
nils 8d9ace2d7f experimental support for card serial numbers
(at first only for starcos spk 2.3 and cardos m4)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1841 c6295689-39f2-0310-b995-f0e70906c6a9
2004-07-19 16:51:41 +00:00
nils ac5fea091a update starcos spk 2.3 support (add create file + key gen)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1762 c6295689-39f2-0310-b995-f0e70906c6a9
2004-04-17 09:05:54 +00:00
okir 5dda541b7e - made apdu_masquerade functionality available to all readers, not just pcsc
- added new parameters max_send_size and max_recv_size, roughly corresponding
  to the old max_le (SC_APDU_CHOP_SIZE) parameter. You can now set this
  chop limit per driver class (pcsc, openct, ctapi), which sets
  driver->max_{send,recv}_size. This value is copied to
  card->max_{send,recv}_size in sc_connect_card, and can be overridden
  by the card driver.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1683 c6295689-39f2-0310-b995-f0e70906c6a9
2003-12-18 16:35:28 +00:00
aet c69ef430ee C++ warning fixes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1438 c6295689-39f2-0310-b995-f0e70906c6a9
2003-09-10 22:20:26 +00:00