Commit Graph

76 Commits

Author SHA1 Message Date
Doug Engert f1bc07dec1 Fix piv-tool on wondows
fopen needs "rb" for fopen in two places

fixes #2338

 On branch piv-tool-windows
 Changes to be committed:
	modified:   piv-tool.c
2021-05-20 10:37:31 +02:00
Ludovic Rousseau 7fc00a1178 Fix spelling error
Thanks to Debian lintian:
I: opensc: spelling-error-in-binary usr/bin/netkey-tool conatin contain
I: opensc: spelling-error-in-binary usr/bin/piv-tool conatin contain
2020-08-29 23:17:02 +02:00
Peter Marschall 04f4f589a1 piv-tool: cleanup
- remove command line option '--card-driver';
- instead force driver 'PIV-II' and fail if card is not a PIV card
- overhaul option parsing
  - remove unused variable 'long_optind'
  - make work option '--reader' ( "r:" was missing in the optstring!!!)
  - bail out with usage message on all unknown/unhandled args
  - correctly terminate option parsing (no infinite loop)
2020-01-12 09:40:53 +01:00
Peter Marschall 30fdc7de4a piv-tool: make '--card-driver ?' list all available drivers
Extend piv-tool the same way opensc-explorer was extended. I.e.
treat the question mark given as argument to option '--card-driver'
special: list all available drivers instead of stupidly bailing out.

In contrast to opensc-tool and opensc-explorer, which are card-agnostic,
I am not sure whether the option '--card-driver' makes sense on this
card-specific tool.
2020-01-12 09:36:49 +01:00
Priit Laes 0b4b7fbaf0 openssl: Drop all compatibility checks for <=openssl-1.0.0 2020-01-06 15:47:07 +01:00
Frank Morgner 070370895f fixed 333707 Dereference before null check 2019-03-06 00:42:38 +01:00
Frank Morgner c858d4b3d1 fixed argument checking 2019-02-14 09:22:23 +01:00
Frank Morgner 32e1995300 fixed dead assignment 2019-02-14 09:22:23 +01:00
opensignature 84f0a88edb Remove postecert and infocamere support because no longer issued (#1584)
* Remove postecert and infocamere support because no longer issued

* Remove wrong changes

* reset NEWS

* EC_POINT_set_affine_coordinates_GFp and EC_POINT_get_affine_coordinates_GFp are
deprecated, use EC_POINT_set_affine_coordinates and EC_POINT_get_affine_coordinates

* If OPENSSL API version is < 3 use old functions EC_POINT_[sg]et_affine_coordinates_GFp

* Move the OpenSSL compatibility stuff to src/libopensc/sc-ossl-compat.h
2019-01-30 22:01:24 +01:00
Frank Morgner fbb4d1f843 tools: use consistent behavior of -v
-v switches to debug output to stderr in OpenSC tools regardless of the opensc.conf setting
2019-01-15 07:30:46 +01:00
Jakub Jelen a5daaaff0c piv-tool: Error checking 2018-10-01 23:07:34 +02:00
Jakub Jelen 16c5a352a4 piv-tool: Avoid memory leaks on realloc failure 2018-10-01 23:07:34 +02:00
Priit Laes 1f06a76b1a openssl: Bump openssl requirement to 0.9.8 2018-09-14 08:21:40 +02:00
Frank Morgner 1798bbe692 manuals: added missing "Authors" section 2018-05-16 13:43:25 +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 04a7075290 fixed compiler warnings 2017-11-09 12:42:29 +01:00
Doug Engert c7ed71c76f piv-tool loops when using OpenSSL-1.1
Add code to support OpenSSL initialization correctly when using OpenSSL-1.1

Tested with OpenSSL-1.1.0c and OpenSSL-1.1.0e.

 Changes to be committed:
	modified:   src/tools/piv-tool.c
2017-05-22 13:38:34 +02:00
Frank Morgner 6bfb39454b Fix missing error handling of memory allocation (#1020)
* libopensc: handle allocation errors
* handle more faults during memory allocation

fixes several situations that cause segmentation fault
2017-04-20 21:08:49 +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
Peter Marschall 6498721076 piv: fix typos in usage & man page 2015-10-15 12:51:19 +02:00
Frank Morgner c399bc94ec piv-tool: fixed resource leak 2015-09-17 22:32:07 +02:00
Doug Engert 572218c59c Fall through comment before break 2015-02-16 10:11:24 -06:00
Doug Engert 981a0fbbaf Fix-up changes caused by Coverity scan
piv-tool.c add  /* fall through */ to avoif false warning
card-piv.c - clean up if sc_lock fails.
2015-02-11 13:39:59 -06:00
Viktor Tarasov 08eb700b97 revert or partially revert some of recent commits
b94c163 - invalid, non-tested
11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored,
3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue #373
3a92bf7 -- src/tools/piv-tool.c -- confirmed by author
6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
2015-02-07 19:31:17 +01:00
Frank Morgner 3a92bf7af5 fixed resource leaks 2015-02-05 01:38:41 +01:00
Frank Morgner a3fc62f79f fixed NULL dereference (or warning thereof) 2015-02-05 01:38:40 +01:00
Frank Morgner 6759c04b26 don't ignore errors 2015-01-28 04:45:08 +01:00
Frank Morgner 7a34c204c1 fixed dereference before null check
silence warnings reported by coverity-scan
2015-01-22 20:29:33 +01:00
Charles Bancroft 865900e210 Updated load_cert to use the proper key identifier 2013-08-10 22:30:59 +02:00
Charles Bancroft 62dbdfff3a Fixed gen_key to expect the proper PIV Key references.
0x9B is defined as the Card Management Key, and probably shouldn't be
regenerated.  0x9E is the Card Authentication key which is what you
should be generating keys for.  This also brings piv-tool in line with
the documentation that states 0x9A, 0x9C, 0x9D and 0x9E are the proper
keyIds to use.
2013-05-10 09:14:20 -04:00
Doug Engert 58a4821689 piv-tool -s not sending APDU - missing code
The code to send the APDU to the piv card when using
piv-tool -s xx:xx:xx... was inadvertently removed
on 2011-04-26 02:29:53 by: 1cdb3fa971
APDU parsing: switch to Frank Morgner's implementation

The missing code is replaced.

The -s option is infrequently used, so the problem
was not spotted earlier.
2012-07-29 11:29:14 +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 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
andre 79db564732 piv-tool.c: Leftover from r5412.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5426 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-04 17:17:28 +00:00
vtarasov 08c9328e62 piv-tool: remove the Oberthur's specific features of the PIV card
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5412 c6295689-39f2-0310-b995-f0e70906c6a9
2011-05-01 18:44:53 +00:00
martin 1cdb3fa971 APDU parsing: switch to Frank Morgner's implementation
Patch by Frank Morgner, proposed in
http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016419.html and
http://www.opensc-project.org/pipermail/opensc-devel/2011-April/016420.html:

* replace partly incorrect extended APU parsing implementation
  with one factored-out in function sc_bytes2apdu() in apdu.c
* re-factor APDU parsing functions in
  - opensc-explorer
  - opensc-tool
  - piv-tool
  to make use of sc_bytes2apdu()

Thanks to Peter Marschall and Frank Morgner
This fixes #260 and #351.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5394 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-26 07:29:53 +00:00
martin 8f0ba374f3 Add reminders to bytes2apdu style code blocks.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5370 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-19 10:51:27 +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
vtarasov 99fac2685a piv-tool: increase receive buffer for the 'send-apdu' command
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5340 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-15 16:33:18 +00:00
vtarasov d611dcc9ed piv-tool: add containers discovery
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5334 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-12 17:51:08 +00:00
vtarasov b85e1a798f piv-tool: new action to print the key slots properties
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5324 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-11 12:02:47 +00:00
vtarasov eb7bc552b1 piv: no 'usepin' authentication mode in PIV tools
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5323 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-11 11:55:00 +00:00
vtarasov f1dec64630 piv-tool: in 'send-apdu' command increase size of response buffer ...
'GET DATA' apdu can return the code 'data still available'


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5320 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-10 20:08:09 +00:00
vtarasov cfffb7f5dd piv-tool: 'admin' and 'genkey' options need an argument ...
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5311 c6295689-39f2-0310-b995-f0e70906c6a9
2011-04-08 12:28:59 +00:00
dengert 0180a969db Remove dependency on sc_establish_context, and provide appname
via sc_ctx_create_context and ctx_param.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5191 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-09 14:45:51 +00:00
dengert 98aa4cb571 Fix uninitialized variables and warning messages.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5188 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-07 16:23:54 +00:00
martin b5f329ba7c tools: EC(DSA) requires OpenSSL >= 0.9.8.
This fixes building for OS X 10.5.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4918 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-06 14:41:15 +00:00
dengert 3cfcb5cdc6 Minor corrections to r4906
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4907 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-03 15:44:29 +00:00
dengert b7f4537031 Test for OPENSSL_NO_EC as some systems build OPENSSL without EC.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4906 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-03 15:15:29 +00:00
dengert c2fe4609a9 Modifications to support EC and ECDSA for
emulated cards. True PKCS#15 cards with EC 
will need additional changes. 

Main changes are in framework-pkcs15.c, mechanism.c,
padding.c, pkcs15-algo.c and pkcs15-sec.c 
where switch statements for key type, and testing
of flags was modified to make it easier to add 
additional key types in the future. 

The code was tested using RSA and ECDSA using a PIV card 
from pkcs11-tool, OpenSSL and Thunderbird with 
modifications to NSS-3.12.7 to get ECDSA to sign e-mail. 

Only named curves are supported for ECDSA, ECDH is still 
needed. pkcs11-tool has only minimal changes need to work 
with the -O option to list EC keys. 

One additional line was added to pkcs15-sec.c which 
should get GOSTR sign to work. 

libp11 and engine do not yet have EC support. 

 --This line, and those below, will be ignored--

M    src/tools/piv-tool.c
M    src/tools/pkcs11-tool.c
M    src/pkcs11/framework-pkcs15.c
M    src/pkcs11/mechanism.c
M    src/pkcs11/pkcs11-object.c
M    src/libopensc/pkcs15-prkey.c
M    src/libopensc/card-piv.c
M    src/libopensc/padding.c
M    src/libopensc/cardctl.h
M    src/libopensc/pkcs15-algo.c
M    src/libopensc/libopensc.exports
M    src/libopensc/pkcs15-piv.c
M    src/libopensc/pkcs15-sec.c


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4904 c6295689-39f2-0310-b995-f0e70906c6a9
2010-12-01 20:08:42 +00:00