Commit Graph

40 Commits

Author SHA1 Message Date
Frank Morgner 3ebfb01a3c itacns: fixed length checking
fixes https://oss-fuzz.com/testcase-detail/5116660103774208
2020-09-29 08:53:16 +02:00
Jakub Jelen 595926471b itacns: Really do not read behind the buffer bounds
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25885
2020-09-24 08:59:47 +02:00
Jakub Jelen 8dd136ac24 pkcs15-itacns: Do not access behind the allocated buffer boundary
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25473
2020-09-15 12:41:37 +02:00
Jakub Jelen 752c088e10 pkcs15-itacns: Free allocated memory
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25475
2020-09-15 12:41:37 +02:00
Jakub Jelen a626c63d91 itacns: Do not leaek memory if file is empty
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25475
2020-09-15 12:41:37 +02:00
Jakub Jelen f49162af04 Avoid memory leaks when initializing tokeninfo in various drivers
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=22578
2020-06-09 13:02:27 +02:00
Nuno Goncalves 3ac47fbea9 replace SC_FUNC_CALLED(...,1) with SC_FUNC_CALLED(..., SC_LOG_DEBUG_NORMAL) (close #1698)
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-10-28 09:51:28 +01:00
Nuno Goncalves 60581ecc82 remove trailing whitespace
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2019-10-28 09:51:28 +01:00
Frank Morgner 94388f9538 fixed more clang-tidy warnings 2019-06-05 13:48:51 +02:00
Raul Metsma 63fd71c245 Remove unused sc_pkcs15emu_opt_t structure
Only usage was removed SC_PKCS15EMU_FLAGS_NO_CHECK flag

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-05-02 10:08:46 +02:00
Raul Metsma bbec50bfdb Remove unused SC_PKCS15EMU_FLAGS_NO_CHECK flag
Fixes #1634

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-25 14:53:25 +02:00
Frank Morgner 01d515a026 fixed use of garbage value 2019-02-14 09:22:23 +01:00
Frank Morgner a899a46b09 replaced SC_TEST_RET with LOG_TEST_RET 2018-12-06 09:26:42 +01:00
Frank Morgner 24b50a4277 replace sc_debug with sc_log 2018-12-06 09:26:42 +01:00
Frank Morgner 8fe377e93b fixed out of bounds reads
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting and suggesting security fixes.
2018-08-14 15:50:13 +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
Vadim Penzin e1d6f0869b Add missing initialisation of variables to pacify Clang.
1. src/libopensc/card-openpgp.c:pgp_store_key().
2. src/libopensc/cwa14890.c:cwa_verify_icc_certificates().
3. src/libopensc/cwa14890.c:cwa_prepare_external_auth().
4. src/libopensc/pkcs15-itacns.c:itacns_check_and_add_keyset().

(Discovered by Clang 4.0.0 on OpenBSD 6.2.)
2018-03-19 09:48:21 +01:00
Jakub Jelen 09af8714ad Avoid GCC 7 warnings with -Werror (#1196)
* Avoid GCC 7 warnings with -Werror

-Werror=implicit-fallthrough=
	libopensc/card-incrypto34.c
		not sure if this is a bug or intention
	libopensc/card-rutoken.c
		most probably intention
	libopensc/card-westcos.c
		remove bogus if so the compile is not confused
		I will fill a separate bug to gcc probably
	pkcs15init/pkcs15-iasecc.c
		Simplify the log and avoid compiler confusion
	sm/sm-common.c
		explicit fallthrough
	tools/pkcs11-tool.c
		use explicit fallthrough comment
	tools/pkcs15-init.c
		The fallthrough is obvious here

-Werror=format-truncation=
	libopensc/pkcs15-itacns.c
		use explicit string lengths
	pkcs11/framework-pkcs15.c
		calculate the truncation
	tests/pintest.c
		avoid sprintf
	tools/pkcs15-crypt.c
		avoid sprintf
	tools/pkcs15-init.c
		calculate the truncation
2017-11-17 10:47:53 +01: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 d84ee6c96a Initialize PIN logged_in field for cards that do not support PIN info
Commit 2f10de4f5c ("use sc_pkcs15_get_pin_info in C_GetTokenInfo")
introduced dependency of logged in state returned for session
by C_GetTokenInfo() on logged_in field of that session slot PIN.

This field is updated by sending pin_cmd of type SC_PIN_CMD_GET_INFO to
card.
However, not all cards support such pin_cmd type (in fact, majority of
them don't). In this case logged_in field is usually left zero-initialized
which means SC_PIN_STATE_LOGGED_OUT.

With such logged_in field value C_GetTokenInfo() always returns
CKS_R{O,W}_PUBLIC_SESSION, instead of CKS_R{O,W}_USER_FUNCTIONS when
logged in.

At least Firefox (and probably other NSS-based software, too) is confused
by such value and keeps repeating PIN prompts a few times until it
ultimately considers that logging in to this slot has failed.

Fix this by initializing PIN logged_in field to SC_PIN_STATE_UNKNOWN for
cards that do not support SC_PIN_CMD_GET_INFO pin_cmd.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2016-09-01 02:03:42 +02:00
Viktor Tarasov 9ac4120594 pkcs15: 'aid' argument for emulator init
Allows to PKCS#15 emulator to bind more then one application
2016-04-08 10:48:58 +02:00
Frank Morgner be073396be Fixes warnings about unused variables/functions 2015-09-17 22:24:33 +02:00
Frank Morgner 77752f442d fixed unused value 2015-01-28 05:47:20 +01:00
Thomas Calderon 91ddcfb514 PKCS15: remove redundant code for access_flags.
* With commit facaf59, access_flags were set for most cards. A closer look
    revealed that this is already done in `sc_pkcs15emu_add_rsa_prkey`.
    Therefore, this removes the duplicated code for cards calling this function.
2015-01-16 10:03:13 +01:00
Viktor Tarasov df9a4d0b2c pkcs15: for 'sc_pkcs15_cer's data use the 'der' object type
To hold the raw certificate blob in 'sc_pkcs15_cert' data use the 'sc_pkcs15_der' data type.
also:
; in 'pkcs15-cert.c' use short call of the debug messages;
; in 'destroy-object' pkcs15 framework handler take into account the multi-application cards:
-- when binding card use the application info;
-- when finalizing profile use the application ID.
2012-09-30 22:54:52 +02:00
vtarasov d888b3fd55 pkcs15: use general 'AuthenticationObject' instead of 'PinObject'
now the attributes of the previous 'pin-info' data type are included
as the sub-type attributes of the general 'auth-info' data .
It will allow to include support of the 'biometricTemplate' and 'authKey' authentication types.

http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016655.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5550 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-05 15:46:25 +00:00
ludovic.rousseau b435f6007a Fix compiler warning
pkcs15-itacns.c: In function 'itacns_add_data_files':
pkcs15-itacns.c:478: warning: declaration of 'list_size' shadows a global declaration
../../src/common/simclist.h:497: warning: shadowed declaration is here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5267 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-23 16:05:24 +00:00
ep 1ed93af035 Amend and update register of IC manufacturers for itacns
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5122 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-27 08:43:32 +00:00
ep ab40e70e04 Wrong structure size calculation in pkcs15-itacns.c; thanks to Matteo Nastasi for the heads-up.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4978 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-19 11:18:43 +00:00
ludovic.rousseau 2e9c72ec5e Use 'const char *' instead of 'char *' for static strings and avoids a
lot of "discards qualifiers from pointer target type" warnings


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4870 c6295689-39f2-0310-b995-f0e70906c6a9
2010-11-06 18:07:04 +00:00
martin f5a21e417b pkcs15: don't play with TokenInfo.version. 0 means PKCS#15 v1.1. The flag is not used by OpenSC.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4789 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 16:02:57 +00:00
martin 50f99a20f8 libopensc: move TokenInfo fields from sc_pkcs15_card_t to a separate structure.
Thanks to Andre Zepezauer for the patch.

See http://www.opensc-project.org/pipermail/opensc-devel/2010-September/015076.html

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4788 c6295689-39f2-0310-b995-f0e70906c6a9
2010-10-05 15:44:58 +00:00
dengert 3bb5c9f530 allow pkcs15-itacns.c compile without OpenSSL
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4763 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-22 20:57:07 +00:00
ep ffdad69bca Avoid mixed declarations and code in ItaCNS files, per C90
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4702 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-08 21:23:49 +00:00
ep 223d5e1bb3 Fix signedness issues in pkcs15-itacns.c
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4681 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-02 22:58:47 +00:00
ep 31e6602835 Remove unused variables and constants from pkcs15-itacns.c
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4680 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-02 22:58:45 +00:00
martin 2d32947de4 Style: // -> /**/
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4673 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-02 13:39:01 +00:00
ep d37dd91b63 Use strlcpy(3), strlcat(3) in pkcs15-itacns.c
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4635 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 13:42:30 +00:00
ep acd062e0dd Avert potential buffer overflows in pkcs15-itacns.c
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4632 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 13:42:16 +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