Commit Graph

36 Commits

Author SHA1 Message Date
Feitian Technologies 45e1732bb5 card-epass2003: Fixed plaintext communication and ATR mask (#967)
The old code only support encrypted communication for ePass2003 USB PKI
Token, now add plaintext communication support, the code now can using
ePass2003 USB PKI Token and ePass2003 PKI applet with java card.

The last mask code has issue, cannot show the OEM ID and SN, not modify
it. the rule made by Feitian only.
2017-03-06 12:40:00 +01: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
Feitian Technologies 426f266dfa Solve #871 #731 #730
1. Solved multiple epss2003
2. check expats point to prevent memory leak
3. Add new ATR for entersafe PKI card
4. declare all variables at the beginning of block
5. Solved Incorrect PIN raise wrong CKR error, no token flags change

Closes https://github.com/OpenSC/OpenSC/pull/879
2016-10-10 22:41:01 +02:00
Doug Engert 5fb4db6373 Use OpenSSL versions OpenSSL-0.9.7 to 1.1.0a for OpenSC
OpenSSL-1.1.0 was released 8/25/2016
OpenSSL-1.1.0a was released 9/22/2016

  https://www.openssl.org/news/openssl-1.1.0-notes.html

Changes to allow the OpenSC code base to work with OpenSSL versions from
0.9.7 to 1.1.0 with few changes.

This is an update and rebased version of my prep-openssl-1.1.0-pre6 branch.

No attempt was made to back port any OpenSSL features. These changes
just allow an updated OpenSC code base to use what is in the various OpenSSL
releases.

A new header libopensc/sc-ossl-compat.h contains extra defines
to reduce the need for so many #if OPENSSL_VERSION_NUMBER statements
in the source code.

The OpenSC source can now use the OpenSSL 1.1 API. The libopensc/sc-ossl-compat.h
has defines for the new API for use with older versions of OpenSSL.

sc-ossl-compat.h is included by libopensc/internal.h so all OpenSC
library routines can take advantage of it. For the tools, which do not use
libopensc/internal.h, libopensc/sc-ossl-compat.h is included by the tools.

The OpenSC source has been modified to use OpenSSL functions to access
hidden structures, such X509, BIGNUM, EVP_CIPHER_CTX, and use XXX_new
functions to allocate structures which must use pointer such as
BIGNUM and EVP_CIPHER_CTX.

For backward compatability sc-ossl-compat.h now defines inline routines
to emulate the RSA and DSA  access routines in OpenSSL-1.1.0. Thus
the same OpenSC source code can be used with openSSL versions from
0.9.7 to 1.1.0.

Inline routines were chosen, because using macros does not work on all platforms.
Having OpenSC versions of these routines in libopensc would be a posibility,
but they are only used for older version of OpenSSL, and could be removed in
the future.
 Changes to be committed:
	modified:   src/libopensc/card-entersafe.c
	modified:   src/libopensc/card-epass2003.c
	modified:   src/libopensc/card-gids.c
	modified:   src/libopensc/card-gpk.c
	modified:   src/libopensc/card-oberthur.c
	modified:   src/libopensc/card-piv.c
	modified:   src/libopensc/card-westcos.c
	modified:   src/libopensc/cwa-dnie.c
	modified:   src/libopensc/cwa14890.c
	modified:   src/libopensc/internal.h
	modified:   src/libopensc/p15card-helper.c
	modified:   src/libopensc/pkcs15-itacns.c
	modified:   src/libopensc/pkcs15-prkey.c
	modified:   src/libopensc/pkcs15-pubkey.c
	new file:   src/libopensc/sc-ossl-compat.h
	modified:   src/pkcs11/openssl.c
	modified:   src/pkcs15init/pkcs15-lib.c
	modified:   src/pkcs15init/pkcs15-oberthur-awp.c
	modified:   src/pkcs15init/pkcs15-oberthur.c
	modified:   src/pkcs15init/pkcs15-oberthur.h
	modified:   src/pkcs15init/pkcs15-westcos.c
	modified:   src/tools/cryptoflex-tool.c
	modified:   src/tools/gids-tool.c
	modified:   src/tools/netkey-tool.c
	modified:   src/tools/piv-tool.c
	modified:   src/tools/pkcs11-tool.c
	modified:   src/tools/pkcs15-init.c
	modified:   src/tools/sc-hsm-tool.c
	modified:   src/tools/westcos-tool.c
2016-10-08 06:15:06 -05:00
Maciej S. Szmigiero 80f5c8b835 Code files don't need execute permission
Some .c files had execute permission bit set needlessly.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-08-30 23:30:43 +02:00
Ian Young f64c71da28 Don't free file if pointer is null (#858)
Protect against segmentation

closes #854.
2016-08-27 23:14:04 +02:00
Feitian Technologies e2c21d7c25 Add new Feitian PKI Card ATR into OpenSC
Add new PKI Card ATR into OpenSC support, all of these ATR using same
PKI Applet. and the ATR/JAVA CARD is provided by Feitian.

More information, please check www.javacardos.com

Fixes a memory leak in `entersafe_select_fid`

Closes https://github.com/OpenSC/OpenSC/pull/625
2016-02-04 12:23:46 +01:00
Frank Morgner bcf9b2bc84 added error checking 2015-10-14 23:14:47 +02:00
Frank Morgner bcb5fc15e5 honour HAVE_CONFIG_H 2015-04-22 23:55:33 +02:00
Frank Morgner 11881a61b8 removed/fixed dead code 2015-02-05 01:38:41 +01:00
entersafe c02f30a2da Fix a bug when writing public key 2013-07-29 10:13:39 +02: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 2804395cf4 libopensc: revert erroneous commit
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5003 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-30 13:10:28 +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 eb5871645b entersafe: don't list supported exponents in the dirver.
Native keys are generated with exponent 65537, imported keys can now have any (?) exponent.
Tested with openssl genrsa -3/-f4 keys.

Improves r4910 and closes #297

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4915 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-06 12:52:27 +00:00
ludovic.rousseau 5a736c0ac6 entersafe_init(): add support of RSA exponent 35
Closes: Ticket #297


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4910 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-06 09:37:23 +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
martin a1c77b96ab Entersafe: cache the presented PIN on personalization, simplify the code a bit.
See http://www.opensc-project.org/pipermail/opensc-devel/2010-June/014312.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4408 c6295689-39f2-0310-b995-f0e70906c6a9
2010-06-09 13:53:11 +00:00
viktor.tarasov 9396297f21 libopensc for win32: to be compiled
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4241 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-14 11:41:16 +00:00
ludovic.rousseau f8fa636311 Do not use a type of possibly different size.
Would fail on PowerPC in 64-bits for example.

Fix
card-entersafe.c: In function ‘entersafe_cipher_apdu’:
card-entersafe.c:197: warning: passing argument 3 of ‘EVP_EncryptUpdate’ from incompatible pointer type
card-entersafe.c: In function ‘entersafe_mac_apdu’:
card-entersafe.c:270: warning: passing argument 3 of ‘EVP_EncryptUpdate’ from incompatible pointer type
card-entersafe.c:278: warning: passing argument 3 of ‘EVP_EncryptUpdate’ from incompatible pointer type
card-entersafe.c:286: warning: passing argument 3 of ‘EVP_EncryptUpdate’ from incompatible pointer type


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4212 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-02 13:57:30 +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 d7dfa2104a entersafe: fix import key RSA 2048 bits
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4046 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-20 10:09:06 +00:00
martin 26f1750cd7 entersafe: don't mix hexadecimal and decimal in code and comments
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4044 c6295689-39f2-0310-b995-f0e70906c6a9
2010-02-20 08:31:19 +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
aj 4942760d06 Xiaoshuo Wu:
removes the assert line and some unused code, solves a problem with ePass3000.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3906 c6295689-39f2-0310-b995-f0e70906c6a9
2010-01-13 12:27:05 +00:00
martin 56fb57603b Merge [3758:3783/trunk]
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3785 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-22 09:18:16 +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 9da39d8462 Merged r3719:3749 from trunk
git-svn-id: https://www.opensc-project.org/svnp/opensc/branches/martin/0.12@3750 c6295689-39f2-0310-b995-f0e70906c6a9
2009-10-03 07:48:28 +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 4670238556 Entersafe changes by Weitao Sun:
1.Card type FTCOS/PK-01C added. (new)
2.Limit pin length in range [4,16). (bug fix)
3.Can not unblock PIN. (bug fix)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3674 c6295689-39f2-0310-b995-f0e70906c6a9
2009-04-02 10:32:02 +00:00
martin 36112bf6e0 typos
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3594 c6295689-39f2-0310-b995-f0e70906c6a9
2008-11-24 21:55:28 +00:00
alonbl ff4d6dd101 Fix for two apparent C code bugs
By Stanislav Brabec

entersafe_init_pin_info() was declared as int, but defined and used as
void, resulting in a function returning an unused pseudo-random value.

card-gemsafeV1.c uses comparison 'type == "DF"', which is always false,
as it compares pointer to a string with pointer to the string "DF" in
the code.



git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3563 c6295689-39f2-0310-b995-f0e70906c6a9
2008-09-10 12:44:40 +00:00
aj 27d00f9265 Add new entersafe driver for ePass 3000 tokens.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@3556 c6295689-39f2-0310-b995-f0e70906c6a9
2008-08-20 05:41:20 +00:00