Commit Graph

236 Commits

Author SHA1 Message Date
Priit Laes 1f06a76b1a openssl: Bump openssl requirement to 0.9.8 2018-09-14 08:21:40 +02:00
Frank Morgner 99eed0aa82 pkcs15-init: documented remaining commandline switches
fixes https://github.com/OpenSC/OpenSC/issues/1267
2018-05-04 23:38:24 +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
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
Timo Teräs e23190d0b5 pkcs15-init: support secret key upload and generation 2017-06-13 10:40:36 +02:00
Timo Teräs 7e99cf7411 pkcs15-init: include secret keys in generic object handling code
Type user visible type string is 'secrkey' in harmony with pkcs11-tool.
2017-06-13 10:40:36 +02:00
Frank Morgner c5e40127d0 Coverity fixes (#1012)
card-cac.c
 * CLANG_WARNING: The left operand of '<' is a garbage value
card-coolkey.c
 * CLANG_WARNING: overwriting variable
 * CPPCHECK_WARNING: memory leak / overwrite variable
 * CLANG_WARNING: null pointer dereference
 * UNUSED_VALUE: unused return value
card-gids.c
 * CLANG_WARNING: Branch condition evaluates to a garbage value
 * SIZEOF_MISMATCH: suspicious_sizeof
card-myeid.c
 * RESOURCE_LEAK: Variable "buf" going out of scope leaks the storage it points to.
 * CLANG_WARNING: overwriting variable
 * (rewrite not to confuse coverity)
pkcs15-cac.c
 * RESOURCE_LEAK: Variable "cert_out" going out of scope leaks the storage it points to.
pkcs15-coolkey.c
 * UNUSED_VALUE: unused return value
pkcs15-piv.c
 * RESOURCE_LEAK: Variable "cert_out" going out of scope leaks the storage it points to.
pkcs15-sc-hsm.c
 * DEADCODE
pkcs11/framework-pkcs15.c
 * RESOURCE_LEAK: Variable "p15_cert" going out of scope leaks the storage it points to.
pkcs15init/pkcs15-lib.c
 * CLANG_WARNING: Assigned value is garbage or undefined
pkcs15init/pkcs15-myeid.c
 * UNREACHABLE: Probably wrong placement of code block
tests/p15dump.c
 * IDENTICAL_BRANCHES
pkcs15-init.c
 * CLANG_WARNING: Potential leak of memory pointed to by 'args.der_encoded.value'
pkcs15-tool.c
 * RESOURCE_LEAK: Variable "cert" going out of scope leaks the storage it points to.
 * MISSING_BREAK: The above case falls through to this one.
sc-hsm-tool.c
 * CLANG_WARNING: Potential leak of memory pointed to by 'sp'
westcos-tool.c
 * FORWARD_NULL: Passing null pointer "pin" to "unlock_pin", which dereferences it.
 * (rewrite not to confuse coverity)
card-cac.c
* Avoid malloc with 0 argument
gids-tool.c
* FORWARD_NULL -- copy&paste error
scconf.c
* CLANG_WARNING: Call to 'malloc' has an allocation size of 0 bytes

closes #982
2017-04-03 13:43:30 +02:00
Nuno Goncalves 68f8f0bfa7 pkcs15-init,pkcs15-tool: reword --no-prompt to --use-pinpad (close #944) (#957)
* pkcs15-init,pkcs15-tool: reword --no-prompt to --use-pinpad (close #944)

Wording was confusing for a novice user. Old option is mantained as an alias,
but will print to stderr a deprecation warning.

Deprecation related code is all marked with deprecated word to easy future removal.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

* pkcs15-init,pkcs15-tool: document --use-pinpad

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-03 17:01:52 +01:00
Frank Morgner 5a9d7e1c42 pkcs15-init: Fixed segfault
regression introduced in de7aaa4197

fixes https://github.com/OpenSC/OpenSC/issues/934
closes https://github.com/OpenSC/OpenSC/pull/935
2017-01-10 12:57:53 +01:00
Frank Morgner de7aaa4197 pkcs15init: explicitly lock the card
Fixes https://github.com/OpenSC/OpenSC/issues/703
2016-10-31 12:35:22 +01:00
Jakuje 12f4026160 Fix Coverity remarks (#876) 2016-10-10 22:21:46 +02:00
Doug Engert c6dba96f55 Add support for LibreSSL compatability as well as OpenSSL-1.1.0
This commit is based on input from https://github.com/lbschenkel
LibreSSL is based on OpenSSL 1.0.1. API.

 Changes to be committed:
	modified:   libopensc/sc-ossl-compat.h
	modified:   tools/pkcs11-tool.c
	modified:   tools/pkcs15-init.c
	modified:   tools/sc-hsm-tool.c
2016-10-08 06:17:44 -05: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
Viktor Tarasov 5c0a37c53d pkcs15init: use aux-data to set MD container GUID 2016-04-08 11:02:53 +02:00
Viktor Tarasov 4b51d70969 tools: print OpenSC package version 2016-03-28 20:41:19 +02:00
LE TOUX Vincent 56275c6993 remove visual studio compilation error
quote:
avoid error C4703: potentially uninitialized local pointer variable 'obj' used line 1414
2015-12-31 18:09:45 +01:00
Frank Morgner 851e0a24ff Merge pull request #571 from frankmorgner/label
Fixes accessing fixed size arrays
2015-10-14 18:56:29 +02:00
Olaf Kirch f42a1c2563 Replace outdated address okir@lst.de -> okir@suse.de
Signed-off-by: Olaf Kirch <okir@suse.de>
2015-10-05 14:07:28 +02:00
Frank Morgner 137afb10b7 Check for NUL in label to test its presence 2015-10-05 08:30:47 +02:00
Frank Morgner 35f028a57c pkcs15-init.c: fixed accessing label in sc_pkcs15_object_t 2015-10-04 17:33:14 +02:00
Viktor Tarasov e0aec3764a pkcs15init: 'store-or-update' certificate option 2015-05-10 14:35:41 +02:00
Frank Morgner 1f16f24052 pkcs15-init: fixed resource leak 2015-05-08 09:11:54 +02:00
Viktor Tarasov 96265e6d08 pkcs15init: superpluous 'ec-params' in init data
Pkcs15init data, used to import/generate key objects, includes twice the same EC parameters data:
 - explicit 'params' data
 - part of sc_pkcs15_pubkey/sc_pkcs15_prkey
Explicit 'ec-params' data is removed.
2015-02-07 20:00:41 +01:00
Frank Morgner 3a92bf7af5 fixed resource leaks 2015-02-05 01:38:41 +01:00
Frank Morgner 2e04fa99c1 fixed pointless array comparisons 2015-01-28 07:39:35 +01:00
Frank Morgner 8df9896204 pass big parameter by reference
reported by coverity scan
2015-01-24 19:25:11 +01:00
Frank Morgner 7a34c204c1 fixed dereference before null check
silence warnings reported by coverity-scan
2015-01-22 20:29:33 +01:00
Philip Wendland aa7886f36d
pkcs15-init: fix memory corruption 2014-12-19 16:52:14 +01:00
Frank Morgner 73715e37d9 fixed compiler warnings
fixed warnings introduced with b18c86e646

fixes memory leaks in pkcs15-init and pkcs15-tool
2014-12-12 21:45:53 +01:00
Frank Morgner 4459e146c4 use util_get_pin in tools 2014-11-04 22:07:07 +01:00
Viktor Tarasov c1b6575204 pkcs15init tool: throw error when invalid appliaction-id supplied
fix action labels
2013-03-11 18:25:05 +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
Viktor Tarasov 58b4304957 libopensc: 'init', 'format', 'compare', 'is-valid' OID procedures
In a reason of number of bugs(*) that concern the OID management,
the general usage OID procedures 'init', 'format', 'compare', 'is-valid' are introduced.
These procedures should be used by all actors: libopensc, pkcs15, pkcs11, tools, ....

(*)
This bug reported by Andreas Schwier :
8e75d971cb (commitcomment-1792477)

In pkcs15-algo sc_asn1_get_algorithm_info() can return the OID without ending '-1's:
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L452
https://github.com/OpenSC/OpenSC/blob/staging/src/libopensc/pkcs15-algo.c#L459
2012-09-06 10:47:29 +02:00
Nguyễn Hồng Quân affb38304e pkcs15-init tool: Change the order of action.
DELETE_OBJECT will be done before STORE_XXX.
2012-07-29 13:09:08 +02:00
Viktor Tarasov d3dbe444e1 pkcs15-init: coverity scan warning NEGATIVE-RETURNS
CID 402540: Argument cannot be negative (NEGATIVE_RETURNS)
2012-06-11 21:28:37 +02:00
Viktor Tarasov 12dcf13236 pkcs15-init: coverity scan warning RESOURCE-LEAK
CID 402619: Resource leak (RESOURCE_LEAK)
2012-06-11 20:10:42 +02:00
Viktor Tarasov 525f61af73 pkcs15-init: 'erase-application', 'update-lastUpdate', ...
New operations:
- 'erase-application' -- erase on-card application indicated by it's AID;
- 'update-lastupdate' -- parse tokenInfo, set 'lastUpdate' value to the current date and write back tokenInfo content;
- 'ignore-ca-certificates' -- when importing PKCS#12 ignore all CA certificates;
2012-06-01 16:58:47 +02:00
Peter Marschall 367ebd94d4 tools: allow arguments to be printed in usage message
Extend util_print_usage_and_die() by a string argument that describes
further arguments to the program.

1st user: opensc-explorer
2012-05-30 09:39:12 +02:00
Viktor Tarasov 10e1ad001d pkcs15init: change sc_pkcs15init_bind() prototype
Add new argument 'application-info',
that will allow to select the on-card application to by binded with.

pkcs11: use sc_pkcs15init_bind with 'AID' argument

Prototype of sc_pkcs15init_bind() has been changed to add argument with
AID of the on-card application to be binded with.
2012-05-26 09:36:25 +02:00
Viktor Tarasov cb13633634 remove trailing whitespaces
inspired by
http://www.opensc-project.org/pipermail/opensc-devel/2012-March/017883.html

Change-Id: If170e830d8d9587a31742feffb6fff54cfdf75b4
2012-04-03 00:00:56 +02:00
Ludovic Rousseau 594427e516 Merge pull request #26 from viktorTarasov/staging
merge 'master' into 'staging'
2012-02-22 09:38:37 -08:00
Viktor Tarasov 2b63213e0a pkcs15-init tool: fix for pin auth_type comparison
partial merge of pull request
https://github.com/OpenSC/OpenSC/pull/8

Thanks to 'joelhockey'.
2012-02-22 09:42:30 +01:00
Robbert Müller 3248a6b122 Adding default accessflags to the do_store_private_key function in the same way do_generate_key has those accessflags
This seems the right thing to do, when you look at the initial commit which added the flags in do_generate_key and the ticket
http://www.opensc-project.org/opensc/ticket/198

Currently when storing a key, the accessflags are not set
2012-01-10 16:47:27 +01:00
Robbert Müller d97f239468 Setting usage flags for the public key when storing a private key 2012-01-08 13:50:46 +01: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
vtarasov 71b1f55f7c pkcs15-init: use general function to reverse memory buffer
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5517 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-29 17:49:00 +00:00
martin 215c133ba0 libopensc: remove more traces of software token/non-native private key related code.
pkcs15-wrap.c can be removed. Clarified/changed the meaning of "insecure" flag to pkcs15-init tool,
which will be needed to explicitly enforce the creation of a key which does not require a PIN.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5510 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-28 22:14:07 +00:00
vtarasov 78d90c4765 EC support: introduce data type dedicated to EC parameters ...
EC parameters can be presented in a three forms: namedCurve, OID and implicit data.
This new data type will facilitate manipulation of ec-parameters in the OpenSC tools and library.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5386 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-22 13:08:45 +00:00
martin e5a133d00c Fix a crash on Windows, where pkcs15-tool -E would always crash in sc_pkcs15_free_card()
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5366 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-19 10:51:06 +00:00
martin 007d27feeb Introduce sc_ctx_log_to_file to set the debug file of libopensc.
On Windows every DLL has their own file descriptor table, thus specifying
-v from any of the OpenSC tools resulted in a crash when the tool tried to override
ctx->debug_file with stderr.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5359 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-18 10:01:27 +00:00