Commit Graph

31 Commits

Author SHA1 Message Date
Peter Marschall 16c889cf7d spelling fixes
Fix various spelling errors, mostly in comments but also in texts displayed.

Errors found & interactively fixed using 'codespell', with additional manual
checks after the fixes.
2020-08-30 10:35:14 +02:00
Frank Morgner 267aea759c use platform dependant implementation of erasing memory
fixes potentially insecure use of memset in CWA SM implementation

fixes https://github.com/OpenSC/OpenSC/issues/1957
2020-03-06 12:23:16 +01:00
rmartinc 20b1d829b9 Always allocate resp buffer in DNIe. 2018-05-23 14:22:28 +02:00
Frank Morgner 19df418fb6 fixed usage of get_challenge 2018-05-23 14:20:28 +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
Frank Morgner 8de544653c dump data with sc_debug_hex and sc_log_hex 2017-11-17 10:03:54 +01:00
rickyepoderi 741add2588 Use sc_hex_dump instead of cwa_hexdump. 2017-04-20 11:04:02 +02:00
rickyepoderi ac091b7466 Add dnie_free_apdu_buffers into dnie_sm_free_wrapped_apdu. 2017-04-20 11:04:02 +02:00
Frank Morgner d757db2ca8 Avoid dnie_transmit_apdu in the dnie driver (#970) (#1013)
closes #975 
closes #972
2017-04-03 18:00:41 +02:00
Maciej S. Szmigiero 58c4de26a7 Fix cases of log function format strings not being a string literal
Looks like Travis CI build server found a few cases of log function format
string not being a string literal (now that log functions have necessary
attributes to check for such things).
Some instances clearly aren't a real problem, but to be future-proof and to
avoid compiler warnings let's fix all of them (that I was able to find in
code).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 11:05:16 +02: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
rickyepoderi c906c5e375 Use struct sm_cwa_session from sm.h in dnie (#955)
* Use cm_ctx instead of a custom cwa struct. Get rid of sc_reset.


* Use ifd.sn and icc.sn from sm_cwa_session struct too

* Minor typo with sizeof

closes https://github.com/OpenSC/OpenSC/issues/930
2017-02-04 22:32:35 +01:00
ricky 39f619fbb3 Disable dnie if not defined ENABLE_SM (issue #927) 2017-01-08 17:13:13 +01:00
ricky e1b4bf4d2c dnie: lost change in the previous pull request ...
... and disable SM mode too.
2016-12-18 12:21:02 +01:00
ricky 282632f7e6 cwa-14890: little issue in cwa_external_auth
# closes #903
2016-11-20 19:21:03 +01:00
ricky e6dca49169 cwa-14890: force to re-establish the SM when disconnected by another process. 2016-11-20 19:04:29 +01:00
ricky 1d051dba6a dnie: changes to include DNIe 3.0 (PIN channel) 2016-11-20 19:04:18 +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
German Blanco 1dd501a705 DNIe. Removing all memory leaks and using SM wrapping and unwrapping. 2016-02-28 08:13:45 +01:00
German Blanco d1a1830115 Removing all memory leaks in DNIe but one. Refactoring pending. 2015-11-27 11:32:33 +01:00
Frank Morgner 0f9645587a cwa14890.c: fixed potential resource leak 2015-11-01 10:44:23 +01:00
Frank Morgner b96ba14aae added fall through comment 2015-10-30 12:15:06 +01:00
Frank Morgner 1308fd0618 cwa14890: fixed resource leak 2015-09-17 22:32:06 +02:00
German Blanco 76517b7d43 Fixing part of the memory allocation problems in DNIe module. 2015-05-26 21:44:13 +02:00
Hector Sanjuan fd3d07a884 Issue #451: Newer DNIe not working with OpenSC.
This patch fixes 3 issues which consecutively have shown up when debugging the original problem:

1 - Newer DNIe report a byte count for public certificates which is the compressed size,
while older DNIe report the uncompressed size. This resulted in short-reading the x509 certificates,
and in an error parsing. Therefore, during initialization we proceed to set path->count for
public certificates to -1. This ensures that the lenght of the certificates for reading
will be set to file-> length, which has the correct size.

2 - pkcs11-tool -t was broken for DNIe (old and new)as it tried to strip pcks11 padding
from the data to sign and OpenSC tried signatures with non-padded data
(as the card had SC_ALGORITHM_RSA_RAW).
The new algoflags (SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1) and the
removal of the strip-padding call fix the issue.

3 - The new cards won't allow setting the LE bytes when calculating the TLV, when LE equals
256. This caused an wrong SM object error response (0x69 0x88). Therefore,
we don't send the LE bytes anymore in this case.

The patch has been tested to work on the new problematic card and on another old one.

close #451
2015-05-08 09:17:01 +02:00
German Blanco 6caa85f238 Issue 395. Avoiding a couple of memory leaks. 2015-04-12 11:35:09 +02:00
Frank Morgner 3a92bf7af5 fixed resource leaks 2015-02-05 01:38:41 +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 5d6c4b391d Merge pull request #253 from github-frankmorgner/remove-deadcode
card-asepcos: removed dead code
card-authentic: removed dead code
card-belpic: removed dead code
card-epass2003: removed dead code
card-flex: removed dead code
card-gpk: removed dead code
card-oberthur: removed dead code
card-piv: removed dead code
card-setcos: removed dead code
ctbcs: removed dead code
cwa14890: removed dead code
muscle: removed dead code
pkcs15-atrust-acos: removed dead code
pkcs15-gemsafeV1: removed dead code
pkcs15-skey: removed dead code
reader-ctapi: removed dead code
framework-pkcs15: removed dead code
pkcs11-object: removed dead code
pkcs15-asepcos: removed dead code
pkcs15-cardos: removed dead code
pkcs15-jcop: removed dead code
pkcs15-lib: removed dead code
pkcs15-oberthur: removed dead code
parse: removed dead code
sclex: removed dead code
sm-card-authentic: removed dead code
sm-card-iasecc: removed dead code
sm-cwa14890: removed dead code
sm-global-platform: removed dead code
sc-test: removed dead code
pkcs11-tool: removed dead code
pkcs15-tool: removed dead code
2014-09-07 21:22:43 +02:00
German Blanco 63ce563d76 Adding support for DNIe. 2013-06-13 17:31:56 +02:00