Commit Graph

112 Commits

Author SHA1 Message Date
andre 2eca7061b4 iso7816.c: Fixes #301.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4945 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-14 01:09:44 +00:00
martin 5d9c02b197 ISO 7816: if decrypting with 2048 keys, non-extended APDU cards require command chaining (Lc would be 257, which is 2 bytes over 255 limit)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4895 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-29 14:22:15 +00:00
viktor.tarasov 58c1c88efa libopensc: homogenise line ending in the debug messages
continuating r4759


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4774 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-25 20:35:59 +00:00
martin 39311cb881 libopensc: check for unset max_recv/send_size in all places.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4721 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-15 11:09:28 +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
ep fbf1d621cb Remove unused give_random operation
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4677 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-02 22:58:34 +00:00
ep 5990d26f80 If a FCI features tag 84h, then the file is a DF
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4639 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-21 20:12:53 +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
ep 71cdef0ed2 New card driver: Italian CNS/CIE (eID)
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4627 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-16 00:56:27 +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
viktor.tarasov 5e805ecf2d libopensc: in iso7816 process_fci() decode Life Cycle Status byte (ISO 7816-4 2005, 5.3.3, tag '8A')
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3961 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-29 10:54:51 +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 612d66655d Introduce SC_ERROR_NOT_ENOUGH_MEMORY <=> CKR_DEVICE_MEMORY.
When trying to import a too large keyfile as a data object, TrueCrypt received a CKR_GENERAL_ERROR before this.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3926 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-23 19:12:52 +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 3cf4707b1a Aktiv Co. / Aleksey Samsonov:
Remove dead code.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3704 c6295689-39f2-0310-b995-f0e70906c6a9
2009-06-28 07:23:16 +00:00
aj 2a0b63e0ad Aktiv Co. / Aleksey Samsonov:
Add assert() calls to check constant buffer size.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3703 c6295689-39f2-0310-b995-f0e70906c6a9
2009-06-28 07:22:24 +00:00
aj 25ab286fed Aktiv Co. / Aleksey Samsonov:
Check buffer length (*outlen)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3702 c6295689-39f2-0310-b995-f0e70906c6a9
2009-06-28 07:20:37 +00:00
aj 7d282a9e0e Aktiv Co. / Aleksey Samsonov:
Fix for the case when "apdu.resplen < 2" and checked buffer length.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3701 c6295689-39f2-0310-b995-f0e70906c6a9
2009-06-28 07:19:38 +00:00
aj 265eb5923b Aktiv Co. / Aleksey Samsonov: fix case depending on length.
also no need to null resplen or le (done by sc_format_apdu).


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3700 c6295689-39f2-0310-b995-f0e70906c6a9
2009-06-28 07:17:19 +00:00
ludovic.rousseau c44b7cbbeb iso7816_set_security_env(): correctly set P1 parameter in case of
SC_SEC_OPERATION_DECIPHER

Thanks to Aleksey Samsonov for the patch
http://www.opensc-project.org/pipermail/opensc-devel/2009-June/012263.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3698 c6295689-39f2-0310-b995-f0e70906c6a9
2009-06-25 08:45:05 +00:00
martin 1e41d4d267 * Fix issues with pkcs11-tool testing of C_GenerateRandom/C_SeedRandom and OpenSC PKCS#11 implementation of those functions.
Thanks goes to Rickard Bondesson who noticed the issues.

http://www.opensc-project.org/pipermail/opensc-devel/2008-November/011436.html



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3595 c6295689-39f2-0310-b995-f0e70906c6a9
2008-11-24 22:06:27 +00:00
vtarasov 0d0048e5ad introduce SC_PATH_TYPE_FROM_CURRENT and SC_PATH_TYPE_PARENT path types
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3094 c6295689-39f2-0310-b995-f0e70906c6a9
2007-01-02 10:04:35 +00:00
aj b3ad2f9dd2 convert to utf-8.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3084 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-19 21:31:17 +00:00
nils 0199dfa29b use net size if available
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3076 c6295689-39f2-0310-b995-f0e70906c6a9
2006-12-18 11:22:22 +00:00
nils 9be468b3a8 try to read at most max_recv_size bytes in GET RESPONSE
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3060 c6295689-39f2-0310-b995-f0e70906c6a9
2006-11-21 22:10:11 +00:00
nils 28c6c1ebc1 git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3057 c6295689-39f2-0310-b995-f0e70906c6a9 2006-11-12 21:01:01 +00:00
nils 651d2c554d remove useless code
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3055 c6295689-39f2-0310-b995-f0e70906c6a9
2006-11-11 11:46:36 +00:00
vtarasov 2d4bd463b0 Use do {...} while(0) construction for SC_TEST_RET, SC_FUNC_RETURN and SC_FUNC_CALLED defines
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3050 c6295689-39f2-0310-b995-f0e70906c6a9
2006-11-06 11:15:09 +00:00
nils 7c823d89ca fix warning
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3034 c6295689-39f2-0310-b995-f0e70906c6a9
2006-10-01 20:39:53 +00:00
ludovic.rousseau 45fc350513 iso7816_process_fci(): dump the filename in Hex + ASCII instead of just
ASCII in the debug log


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3031 c6295689-39f2-0310-b995-f0e70906c6a9
2006-09-27 12:01:31 +00:00
nils 88bae5c923 remove iso logout function, remove dummy logout functions and remove logout call from sc_unlock()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2971 c6295689-39f2-0310-b995-f0e70906c6a9
2006-06-17 12:24:04 +00:00
nils 83c7dc9045 return an error if offset is too large
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2881 c6295689-39f2-0310-b995-f0e70906c6a9
2006-04-03 10:42:00 +00:00
nils fe3e93b625 summary: -complete rewrite of the APDU/transmission handling
code (should now support extended APDUs and is
          hopefully better documented. Note: support for
          the T0 ENVELOPE command is still missing due to
          a lack of test cards).
         -add new APDU case constants SC_APDU_CASE_2 etc.
          which let OpenSC decides, based on the card
          capabilities, whether to use short or extended
          APDUs.
         -add new capability SC_CARD_CAP_RSA_2048 for
          cards supporting 2048 bit RSA operations (note:
          this is more a preliminary hack)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2795 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-28 20:01:43 +00:00
martin e1d7384e8a If there's less data ina file/record than requested do not fail but return as much data as was available. This behaviour is similar to read(2).
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2792 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-27 14:11:35 +00:00
aj d7b6abaef5 add proper free to error path.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2712 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-05 21:37:34 +00:00
nils f74eaee690 fix GET RESPONSE handling
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2678 c6295689-39f2-0310-b995-f0e70906c6a9
2005-10-31 18:44:18 +00:00
nils 43f0118740 summary: - improve support for extended APDUs
- add experimental support for command chaining
         - simplify get_response prototype


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2673 c6295689-39f2-0310-b995-f0e70906c6a9
2005-10-30 20:37:03 +00:00
nils 6abeaf1f1c add a new function
void sc_mem_clear(void *ptr, size_t len);
to clear a memory buffer. If OpenSSL is used this function
is a wrapper for OPENSSL_cleanse, otherwise memset is currenlty used.

Use this function to clear memory buffers with sensitive content.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2601 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-17 10:44:45 +00:00
nils 142d18378b don't use static buffer in iso7816_build_pin_apdu
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2598 c6295689-39f2-0310-b995-f0e70906c6a9
2005-09-17 08:20:13 +00:00
nils 2fb54dd374 use compile time initialization for the iso_ops structure
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2501 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-20 13:39:18 +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 94d899931e cleanup
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2455 c6295689-39f2-0310-b995-f0e70906c6a9
2005-08-02 21:13:06 +00:00
nils eddd1e3ab6 fix file descriptor byte and ef_structure type; patch supplied by richard.musil@bigfoot.com
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2396 c6295689-39f2-0310-b995-f0e70906c6a9
2005-07-11 21:28:55 +00:00
sth 6102459d13 Allow an empty path in iso7816_delete_file(), to indicate that the current DF should be deleted.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2281 c6295689-39f2-0310-b995-f0e70906c6a9
2005-03-26 19:47:13 +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