Commit Graph

45 Commits

Author SHA1 Message Date
Jakub Jelen fd96d2c960 Do not use deprecated ERR_load_ERR_strings() with OpenSSL 3.0 2021-05-24 11:25:53 +02:00
Frank Morgner 8b6ba40a8e fixed 341853 Resource leak 2019-11-05 21:49:30 +01:00
Rosen Penev 7159400086 treewide: Fix compilation without deprecated OpenSSL APIs 2019-07-26 08:49:18 +02:00
Frank Morgner 32e1995300 fixed dead assignment 2019-02-14 09:22:23 +01:00
Frank Morgner fdb0e6d581 Fixed Potential leak of memory 2019-02-14 09:22:23 +01:00
Frank Morgner 7f7bcbff52 fixed misuse of realloc
calling it with size 0 leads to a free, which eventually may lead to a
double free corruption.
2019-01-30 21:57:59 +01:00
Frank Morgner 3fe198f21e treat records with size_t 2019-01-20 23:02:21 +01:00
Frank Morgner a899a46b09 replaced SC_TEST_RET with LOG_TEST_RET 2018-12-06 09:26:42 +01:00
Frank Morgner e3dda8894e log errors in verbose 2018-12-06 09:26:42 +01:00
Frank Morgner 00a150f74c replaced SC_FUNC_RETURN with LOG_FUNC_RETURN 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 cf55cdc637 replace SC_FUNC_CALLED with LOG_FUNC_CALLED 2018-12-06 09:26:42 +01:00
Jakub Jelen a1dfdbbdbc pkcs15-oberthur-awp: Do not confuse cppcheck 2018-10-01 23:07:34 +02:00
Frank Morgner 6819759946 fixed memory leak 2018-06-29 17:14:55 +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
Frank Morgner 17132b04c7 fixed possible bad memory access 2017-11-09 12:42:29 +01:00
Frank Morgner 4251a362b5 fixed potential memory leak 2017-11-09 12:42:29 +01: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
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
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
Frank Morgner fd904fbcb8 pkcs15-oberthur-awp.c: fixed potential resource leak 2015-10-30 12:15:06 +01:00
Viktor Tarasov d636338eaf pkcs15-oberthur: fix memory leakage 2015-05-08 09:11:54 +02:00
Frank Morgner ed9572422f check return values 2015-02-05 01:37:53 +01:00
Frank Morgner 5e3d54186a removed useless check for non-null array 2015-02-05 01:37:53 +01:00
Frank Morgner 2e04fa99c1 fixed pointless array comparisons 2015-01-28 07:39:35 +01:00
Frank Morgner 7a34c204c1 fixed dereference before null check
silence warnings reported by coverity-scan
2015-01-22 20:29:33 +01:00
Frank Morgner a64326e768 fixed compiler warnings (partially submitted)
Signed-off-by: Frank Morgner <morgner@informatik.hu-berlin.de>

PR-222: commit 0b567dbaa8
partially submitted by Viktor Tarasov
2014-05-03 21:47:15 +02: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
Viktor Tarasov e57d443e86 pkcd15init: remove trailing whitespaces
inspired by
http://www.opensc-project.org/pipermail/opensc-devel/2012-March/017883.html

Change-Id: I817f903e67965942d9cc0c30931dbaea0c5f736e
2012-04-02 23:40:05 +02:00
Stef Walter 6ed52a06b8 libopensc: Don't fail to allocate memory when mlock fails
* Print out warning when mlock fails, and continue.
 * The warning required a ctx to be passed in, so that means
   changing a few function signatures.

https://www.opensc-project.org/opensc/ticket/389
2012-02-17 10:02:55 +01:00
vtarasov 9ac55871fb pkcs15init: oberthur: cleanup compiler warnings
http://www.opensc-project.org/pipermail/opensc-devel/2011-May/016724.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5532 c6295689-39f2-0310-b995-f0e70906c6a9
2011-06-01 17:15:31 +00:00
vtarasov ee4f346b07 pkcs15init oberthur: avoid warnings 'signed/unsigned mismatch'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5512 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-28 22:47:05 +00:00
martin 7ab9b7f10d Fix a typo reported by lintian
I: libopensc3: spelling-error-in-binary ./usr/lib/libopensc.so.3.0.0 extention extension

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5238 c6295689-39f2-0310-b995-f0e70906c6a9
2011-03-20 12:18:55 +00:00
ludovic.rousseau 28bf3bf02e Remove dead code
pkcs15-oberthur-awp.c:143:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP container list";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:138:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP private object list";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:133:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP public object list";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:128:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP token info";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:122:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP private data object info";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:117:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP data object info";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:112:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP public key info";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:106:3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP private key info";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c💯3: warning: Value stored to 'desc' is never read
                desc = "Oberthur AWP certificate info";
                ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pkcs15-oberthur-awp.c:338:2: warning: Value stored to 'rec_offs' is never read
        rec_offs = 0;
        ^          ~
pkcs15-oberthur-awp.c:1369:2: warning: Value stored to 'offs' is never read
        offs += len;
        ^       ~~~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5150 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 20:53:08 +00:00
vtarasov 84b93e4099 Oberthur: replace 'SC_ERROR_MEMORY_FAILURE' return code by the 'SC_ERROR_OUT_OF_MEMORY'
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5034 c6295689-39f2-0310-b995-f0e70906c6a9
2011-01-03 09:55:14 +00:00
viktor.tarasov dc3b1d008b pkcs15init: homogenise line ending of debug messages
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4759 c6295689-39f2-0310-b995-f0e70906c6a9
2010-09-22 12:17:53 +00:00
viktor.tarasov 0004461734 oberthur: add in emulator and create in pkcs15init the private data object
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4253 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-18 14:51:44 +00:00
ludovic.rousseau 2820f78e09 Fix
pkcs15-oberthur-awp.c: In function ‘awp_encode_data_info’:
pkcs15-oberthur-awp.c:1211: warning: implicit declaration of function ‘sc_asn1_encode_object_id’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4205 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-02 12:23:21 +00:00
ludovic.rousseau d4b143830a Rename variable rand in rand_buf
pkcs15-oberthur-awp.c: In function ‘awp_new_container_entry’:
pkcs15-oberthur-awp.c:241: warning: declaration of ‘rand’ shadows a global declaration
/usr/include/stdlib.h:176: warning: shadowed declaration is here


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4204 c6295689-39f2-0310-b995-f0e70906c6a9
2010-04-02 12:21:48 +00:00
ludovic.rousseau 2e4610e3be Use a "const char *" to store a const C-string ptr. Fix
pkcs15-oberthur-awp.c:97: warning: assignment discards qualifiers from pointer target type
pkcs15-oberthur-awp.c:98: warning: assignment discards qualifiers from pointer target type
pkcs15-oberthur-awp.c:99: warning: assignment discards qualifiers from pointer target type
[etc...]


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4161 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 11:53:44 +00:00
ludovic.rousseau 6973403675 Fix pkcs15-oberthur-awp.c:729: warning: no previous prototype for
‘awp_update_object_list’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4151 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 09:44:22 +00:00
ludovic.rousseau 1eb944e256 Fix pkcs15-oberthur-awp.c:1246: warning: no previous prototype for
‘awp_set_data_info’


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4150 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-28 09:43:20 +00:00
viktor.tarasov 7106674d41 oberthur pkcs15init: support for creation of the 'public' DATA objects
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4143 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-22 14:17:27 +00:00
viktor.tarasov 0608713b07 oberthur pkcs15init: use macro for debug level
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4139 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-18 17:51:06 +00:00
viktor.tarasov 0f82c7c1d4 oberthur: pkcs15init emulator
Now the native Oberthur card format is supported for emulation of pkcs15 and pkcs15init.

It means that card personalized with OpenSC and the obejcts created with OpenSC 
will be usable with the native Oberthur's middleware 
and vice-versa.





git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4137 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-18 12:30:39 +00:00