Commit Graph

1470 Commits

Author SHA1 Message Date
Peter Marschall 77297f7965 opensc-explorer: check length of argument to option --mf
* fail when it is too long
* replace a magic numerical constant
2018-09-24 00:03:13 +02:00
Peter Marschall 9d501766b4 opensc-explorer: extend 'random' to allow writing to a file
Accept a file name as a second argument to the 'random' command
to allow storing the generated random bytes to the file given.

Forbid writing binary data to stdout in interactive mode.
2018-09-24 00:03:13 +02:00
Peter Marschall 7a4a9f1951 opensc-explorer: refactor do_put() slightly
Avoid misunderstandings by renaming a variable that refers to an
input file handle from 'outf' to 'inf'.
2018-09-24 00:03:13 +02:00
Peter Marschall 1245b617d1 opensc-explorer: refactor do_apdu() slightly
* limit buffer to SC_MAX_EXT_APDU_BUFFER_SIZE
* fix buffer length calculation to correctly calculate the available space
* add length checks when parsing passed data into buffer
2018-09-24 00:03:13 +02:00
Peter Marschall 58da74bc32 opensc-explorer: refactor do_put_data() slightly
* increase input buffer size
* avoid magic number
* notify caller on error details when parsing fails
2018-09-24 00:03:13 +02:00
Peter Marschall aed4b00145 opensc-explorer: harmonize display of command arguments
* consistently show ellipsis for repeatable arguments as 3 dots
* embrace alternative mandatory arguments with curly braces
* use hyphens instead of spaces within non-literal arguments
  for improved alignment with the manual page
2018-09-24 00:03:13 +02:00
Peter Marschall c69f10c2ab opensc-explorer: add command 'pin_info'
Get information on a PIN or key from the card via sc_pin_cmd()'s
SC_PIN_CMD_GET_INFO functionality.
2018-09-24 00:03:13 +02:00
Priit Laes 1f06a76b1a openssl: Bump openssl requirement to 0.9.8 2018-09-14 08:21:40 +02:00
asc 2b60a0db0f Add support for SmartCard-HSM 4K (V3.0) 2018-08-31 13:42:44 +02:00
Frank Morgner 83f45cda2a Added bounds checking to sc_simpletlv_read_tag()
- Logic is identical to sc_asn1_read_tag()
- Fixes out of bounds access e.g. in cac_parse_CCC
2018-08-14 15:50:13 +02:00
Frank Morgner 360e95d45a fixed out of bounds writes
Thanks to Eric Sesterhenn from X41 D-SEC GmbH
for reporting the problems.
2018-08-14 15:50:13 +02: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
Frank Morgner f66ceab4bb fixed typo
fixes https://github.com/OpenSC/OpenSC/issues/1443
2018-08-09 15:50:51 +02:00
Frank Morgner 0f1fdb7872 opensc-notify: add Exit button to tray icon 2018-08-05 11:35:12 +02:00
Frank Morgner 4a3a3e5df2 opensc-notify: implement win32 message dispatching 2018-08-05 11:35:12 +02:00
Frank Morgner 4de0d06a93 use single quotes for passing define
makes sure that the shell doesn't evaluate parts of the define
2018-07-17 14:49:27 +02:00
Frank Morgner a0b6643fa7 Use hard coded default SM module (path)
- avoids the need to set this default in opensc.conf
- fixes loading of (unknown) local library
- removes some unused defines from config.h
2018-07-17 14:49:27 +02:00
Frank Morgner 16275c2683 fixed memory leak 2018-07-17 13:31:14 +02:00
Jakub Jelen 1eaae6526b pkcs15-tool: Build with current gcc
The argument to strncpy is not the length of the target buffer,
but the source one (excluding the null byte, which will be
copied anyway).
2018-07-11 10:48:10 +02:00
Eugene Bright 332535c544 Workaround subject and issuer fields overflow
Structure `x509cert_info` fields `subject` and `issuer`
are doubled in size up to 512 bytes.

We have to use dynamic memory allocation
to completely overcome the issue.

Relates to OpenSC/OpenSC#1412.
2018-07-11 10:13:14 +02:00
Leif Erik Wagner e2f0e367b1 Implement RSA PSS for GoID / SmartCard-HSM 2018-07-11 10:07:28 +02:00
Peter Marschall 99fa4f4a57 pkcs15-tool: harmonize non-short output for -C, -D,
Make sure to have an empty line between information printed for individual
objects, but not in short mode.
This makes output of -D and -C more consistent.
2018-07-11 10:05:30 +02:00
Frank Morgner 88de66bb13 fixed `make distcheck` 2018-07-04 18:12:58 +02:00
Stanislav Brabec 4db9db7403 Add GenericName to the desktop file
Add optional GenericName to org.opensc.notify.desktop. GenericName is
recently widely used for menu rendering in desktop environments.
2018-07-04 09:50:07 +02:00
Frank Morgner b3e3ab61c0 avoid integer underflow 2018-06-29 17:14:55 +02:00
Frank Morgner 03c5280626 avoid NULL dereference 2018-06-29 17:14:55 +02:00
Frank Morgner ed0d829eab removed unused check 2018-06-29 17:14:55 +02:00
Frank Morgner 5f39d7ab74 use correct length of binary ATR 2018-06-29 17:14:55 +02:00
Alon Bar-Lev 31cbf83738 build: support >=libressl-2.7 2018-06-28 08:58:07 +02:00
Frank Morgner d831076974 opensc-notify: use generic icon
fixes https://github.com/OpenSC/OpenSC/issues/1402
2018-06-22 08:52:49 +02:00
Peter Popovec 5dcea4440e pkcs15-tool: added support for reading NIST ssh keys
'pkcs15-tool --read-ssh-key' is now able to read NIST ECC keys from card.
Only 256, 384 and 521 field lengths are supported (same as allowed in
ssh-keygen -t ecdsa). Issue #803 is partialy fixed by this patch.
Openssh PKCS11 interface patches for ECC are now available, please check
https://bugzilla.mindrot.org/show_bug.cgi?id=2474
2018-06-21 15:26:15 +02:00
Peter Marschall e6ad737430 OpenPGP: add cast forgotten in previous commit 2018-06-08 08:21:11 +02:00
Peter Marschall ba9eebceaf OpenPGP: refactor do_dump_do()
- limit length of data to write even in raw mode to the real length
- cluster variuable definitions
- restrict scope of variables
- introduce a variable length to make the purpose more obious
- start preprocessor directives at column one
- add comments where needed
- harmonize coding style: space after "if" and casts
2018-06-08 08:21:11 +02:00
Peter Marschall 4a1bf9fb21 OpenPGP: limit output of -d in non-raw mode to real length 2018-06-08 08:21:11 +02:00
Peter Marschall 85f4ba6c5f OpenPGP: allow calling -d multiple times
Put the arguments passed to option -d into an array instead of only
storing the latest value.
During output, iterate over the values passed in via the option.
2018-06-08 08:21:11 +02:00
Peter Marschall 1da7da5e99 OpenPGP: make parsing of option -d more robust
* accept flexible option arguguments: 1-4, 101-104, 0101-0104, ...
2018-06-08 08:21:11 +02:00
Peter Marschall 41d89b52fc OpenPGP: treat option --del-key as an action 2018-06-08 08:21:11 +02:00
Peter Marschall da6e30b38b OpenPGP: clarify usage text 2018-06-08 08:21:11 +02:00
asc 6dfeb9959f Fix #1371 introduced by 45ad44e 2018-06-08 08:13:32 +02:00
Laurent Bigonville f2042f2270 Do not display opensc-notify in the application list
opensc-notify doesn't propose a GUI that can be displayed to the users,
so it doesn't make sense to display it in the application list/launcher

Fixes: #1379
2018-06-06 22:48:12 +02:00
Peter Marschall ff9df38665 src/tools: remove HELP2MAN_LOCALE from Makefile.am 2018-06-06 22:43:46 +02:00
Peter Marschall c16903140d src/tools: remove deleted man pages from Makefile.am's EXTRA_DIST 2018-06-06 22:43:46 +02:00
Peter Marschall 008845efb3 src/tools: remove legacy man pages generated using help2man
Now that we have proper DocBook sources for them, they can be safely removed.
2018-06-06 22:43:46 +02:00
Peter Marschall 59412aeee3 src/tools: stop building man pages here (see doc/tools)
They have been moved to doc/tools and are generated there.
2018-06-06 22:43:46 +02:00
Peter Marschall d70c140d7a opensc-notify: fix typo 2018-05-27 23:18:13 +02:00
Peter Marschall 0352f298cc npa-tool: fix typo in option parsing 2018-05-27 23:18:13 +02:00
Frank Morgner 42833b6129 added more missing files
fixes https://github.com/OpenSC/OpenSC/issues/1368
2018-05-24 13:51:12 +02:00
Frank Morgner 410cdf0dcc refactored sc_get_challenge
Let sc_get_challenge() do sc_lock() and loop through the card driver's
get_challenge() until enough bytes were collected. The card driver's
get_challenge() now returns the number of bytes collected (less or equal
than requested) or an error code.

- Allow more code re-use.
- PIV driver now uses ASN.1 parser for reading the random bytes
2018-05-23 14:20:28 +02:00
Frank Morgner 45e4f546c2 regenerated built files (gengetopt/help2man)
includes an explicit locale for help2man to recognize umlauts.

partially fixes https://github.com/OpenSC/OpenSC/issues/1365
2018-05-21 20:57:13 +02:00
Frank Morgner 01f712d5da
Use explicit locking for OpenSC tools (#1344)
* opensc-explorer: use explicit locking

fixed https://github.com/OpenSC/OpenSC/issues/1043

* opensc-tool: use explicit locking

* pkcs15-crypt: use explicit locking
2018-05-18 23:21:14 +02:00
Frank Morgner 1798bbe692 manuals: added missing "Authors" section 2018-05-16 13:43:25 +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
David Ward 2c167a9982 Address compiler warnings when using --disable-optimization (#1325)
* Handle errors as intended in sc_pkcs15emu_openpgp_add_data()

If a data object can be read, but it cannot be added to the PKCS#15
framework, return from this function with an error; do not continue
reading other data objects. Otherwise, do not return an error from
this function when a data object cannot be read or is empty.

Improve existing comments for clarity.

* Address other compiler warnings when using --disable-optimization

Certain variables that are not initialized when they are declared
prevent the build from completing, when --disable-optimization is
passed to ./configure.
2018-04-15 09:37:43 +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 445ae0919b rename opensc-notify goi app id
fixes https://github.com/OpenSC/OpenSC/issues/1309
2018-04-05 21:13:23 +02:00
Jakub Jelen eb646dd370 Do not create getSUBJECT without OpenSSL 2018-04-04 21:43:01 +02:00
Jakub Jelen 0997c33a30 pkcs11-tool: Print also SUBJECT of certificate
List also the names of generated functions for better searchability
2018-04-04 21:43:01 +02:00
Jakub Jelen db2ceff911 Avoid circullar dependency 2018-04-04 21:43:01 +02:00
AnthonyA 74885fb1c1 pkcs11-tool: allow mechanism to be specified in hexadecimal
To support vendor mechanisms, let -m accept hexadecimal strings,
e.g., -m 0x80001234
2018-03-31 21:39:53 +02:00
Frank Morgner 45ad44e311 fixed handling SC_ASN1_TAG_EOC from sc_asn1_read_tag
We can't check for `tag == SC_ASN1_TAG_EOC` directly, because this
would also be true for a tag of 0x80 (with `class ==
SC_ASN1_CLASS_CONSTRUCTED`). So what we do is we check for the output
buffer to be NULL!

fixes https://github.com/OpenSC/OpenSC/issues/1273
2018-03-30 08:28:51 +02:00
AnthonyA ea4baf50d5 pkcs11-tool: make ECPoint behaviour standards compliant by default
Fixes #1286. The behaviour of pkcs11-tool will follow the standard -
send DER. If EC_POINT_NO_ASN1_OCTET_STRING is defined then it will
write plain bytes.
2018-03-19 09:39:10 +01:00
Frank Morgner f862060614 EAC: Clearify naming of functions and data
Use names that are specific to EAC, not the German ID card (nPA),
because Protocol and Commands are defined by BSI TR-03110 and ICAO.
Functions that are nPA specific are moved to card-npa.h.
2018-02-20 22:16:51 +01:00
Frank Morgner fccc42295d OpenPGP: Added basic support for OpenPGP card V3
partially implements https://github.com/OpenSC/OpenSC/issues/1215

Refactored OpenPGP code so that future versions of the card will be
accessed using the logic for OpenPGP V2. We hope that backward
compatibility of the standard will keep the new versions functional.
2018-01-22 15:26:44 +01:00
Frank Morgner 804ac2b7f2 fixed compiler warning 2017-12-04 21:09:26 +01:00
Frank Morgner 6f37229303 opensc-explorer/opensc-tool: Allow extended APDUs 2017-12-04 21:09:26 +01:00
Frank Morgner 654ca69c47 initialize notifications in PKCS#11 and tools
... and don't panic when they are not initialized
2017-11-21 13:01:12 +01:00
Frank Morgner 3f0d5ce336 opensc-notify: register a desktop menu entry
- fixes showing notifications in gnome-shell via gio2
- removes gdbus interface for notifications
- fixes https://github.com/OpenSC/OpenSC/issues/1186
2017-11-21 13:01:12 +01:00
Frank Morgner 4444d24f59 win32: generate PDB files for releases
https://msdn.microsoft.com/fsk896zz.aspx

fixes https://github.com/OpenSC/OpenSC/issues/1191
2017-11-21 10:54:48 +01:00
Frank Morgner ddc9baed25 added missing opensc-asn1.1
fixes https://github.com/OpenSC/OpenSC/issues/1206
2017-11-21 10:42:58 +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
Frank Morgner 8de544653c dump data with sc_debug_hex and sc_log_hex 2017-11-17 10:03:54 +01:00
Frank Morgner 4317df10e6 created opensc-asn1
fixes installation of egk-tool.exe on win32
2017-11-17 10:03:54 +01:00
Frank Morgner 1d03000222 fixed dead assignment 2017-11-09 12:42:29 +01:00
Frank Morgner f4946df4e9 fixed dead assignments 2017-11-09 12:42:29 +01:00
Frank Morgner 04a7075290 fixed compiler warnings 2017-11-09 12:42:29 +01:00
Frank Morgner 60e8db4c22 Added tool for German eGK
Fixes missing opensc-notify.1
2017-10-27 19:48:22 +02:00
Mouse e4c589639d Add support in pkcs11-tool and pkcs11-spy for RSA-OAEP (#1169)
* Add RSA-OAEP documentation
* Add definitions and structures needed for RSA-OAEP
* Add ability to display RSA-OAEP parameters to SPY

Closes https://github.com/OpenSC/OpenSC/issues/1170
2017-10-19 22:12:47 +02:00
Frank Morgner 498aedd165 Merge remote-tracking branch 'upstream/master' into winui 2017-10-16 15:16:34 +02:00
Jakub Jelen bdb1961dee Enable RSA-PSS signatures in pkcs11-tool (#1146)
* Add missing SHA224 RSA algorithms

* Fix wrong replacement in pkcs11-tool manual page

* Add MGF and PSS_PARAMS definitions in PKCS#11 header file

* Inspect PSS signature parameters in pkcs11-spy

* Enable RSA-PSS signatures in pkcs11-tool

* Added short names to RSA-PSS methods

* Reintroduce portable NORETURN indication for functions and use it to avoid compilers complaining
2017-09-21 11:19:22 +02:00
Jakub Jelen 41b55b93d4 Print well formated report from decryption stage and do not fail with OAEP mechanisms 2017-09-17 23:08:20 +02:00
Jakub Jelen 0a8213f3d4 Do not overwrite digestinfo + hash for RSA-PKCS Signature 2017-09-17 23:08:20 +02:00
Pavel Cherezov ecb1656b91 sensitive flag added to generate key with CKA_SENSITIVE flag.
pull request issues fix: replace spaces with tabs and fix description of the argument.
2017-09-15 00:11:49 +02:00
Pavel Cherezov 2cf0a119f4 sensitive flag added to generate key with CKA_SENSITIVE flag 2017-09-15 00:11:49 +02:00
Jakub Jelen 789dd16320 List human-readable version in the cardos-tool 2017-09-02 00:19:35 +02:00
Mouse f0e703be49 Fix bug in pkcs11-tool (did not ASN.1-encode ECDSA-SHA-2 signature) 2017-08-29 12:05:16 +02:00
Mouse 1efc73fa2f Fix typo in ECDSA-SHA384 for pkcs11-tool 2017-08-28 21:17:03 +02:00
Frank Morgner 172f320c9a win32: Dedicated md/pkcs11 installation folders
Don't install non-permanent files (md/pkcs11) to system folder anymore.
2017-08-22 23:41:29 +02:00
Jakub Jelen 41796ff0ed [pkcs11-tool] Add SHA2 HMAC mechanisms 2017-08-17 12:02:28 +03:00
Jakub Jelen d5647fe53d [pkcs11-tool] Properly define RSA-PSS mechanisms 2017-08-17 12:02:28 +03:00
Frank Morgner 7bc070ac67 win32: Load notification icons from Windows DLLs
fixes showing wrong icons when loaded as PKCS#11 module
2017-08-03 00:19:26 +02:00
Frank Morgner dcf9d23009 opensc-notify: fixed heavy load on OS X if no reader
Also, if too many errors are supported, opensc-notify will abort
2017-08-02 19:07:23 +02:00
Frank Morgner dd4e96cb24 quick workarounds for notifications 2017-08-02 19:04:31 +02:00
Frank Morgner ce3f27ff54 opensc-notify: notify for card events
... manually or in daemon mode

fixes compilation in MinGW/Travis CI
2017-08-02 19:04:09 +02:00
Frank Morgner b2cde0f7fb Windows: Added support for notifications 2017-08-02 19:03:16 +02:00
Frank Morgner cd62c6cdf5 Linux: Added support for notifications 2017-08-02 19:02:21 +02:00
Frank Morgner bf828014e5 macOS: Added support for notifications
- adds framework for user defined message strings
- automatically determine the system's language
2017-08-02 19:02:05 +02:00
Frank Morgner 7a39d6d058 build against OpenSSL 1.1.0 on Windows, by default
- build with AppVeyor's OpenSSL 1.1.0
- updates AppVeyor version of OpenPACE

Fixes https://github.com/OpenSC/OpenSC/issues/1108
2017-07-24 21:39:01 +02:00
Jakub Jelen e2fe24d56a clang static analyzer reports
tools/pkcs15-tool.c:
	Dead assignment: Value stored to 'c' is never read
tools/pkcs11-tool.c:
	Dead assignment: Value stored to 'n' is never read
	Dead assignment: Value stored to 'rv' is never read
libopensc/card-cac.c:
	Dead assignemnt: Value stored to 'tl_head_len' is never read
	Dead increment: Value stored to 'outp' is never read
common/libpkcs11.c:
	Memory leak in case of C_UnloadModule() fails
libopensc/pkcs15-pubkey.c:
	Potential memory leaks
pkcs11/mechanism.c:
	Potential memory leak
pkcs11/framework-pkcs15.c:
	Potential memory leaks
	Dereference of null pointer
	Dead assignments
tools/sc-hsm-tool.c:
	Function call argument is an uninitialized value
	Dead assignment: Value stored to 'r' is never read
libopensc/card-openpgp.c:
	Dead assignment: ignoring the errors in case of sc_pkcs15_encode_pubkey() failed
libopensc/pkcs15-cac.c:
	Dead assignments: ignoring return values
libopensc/pkcs15-coolkey.c:
	Dead assignments: ignoring return values
libopensc/card-sc-hsm.c:
	Dereference of undefined pointer value: Properly check the file allocation
pkcs11/slot.c:
	Dead assignment
pkcs15init/pkcs15-cflex.c:
	Dereference of null pointer
	Uninitialized argument values
2017-07-18 22:40:20 +02:00
Jakub Jelen 12fe5b5e67 [pkcs11-tool] Do not use modLenBytes before validating 2017-07-11 12:55:38 +02:00
Frank Morgner 206b2cec28 Added npa-tool.1 to distribution
fixes https://github.com/OpenSC/OpenSC/issues/1093
2017-07-11 10:22:14 +02:00
Frank Morgner 828de113e8 pkcs11-tool: respect CKA_ALWAYS_AUTHENTICATE
Quoting from PKCS#11:

The CKA_ALWAYS_AUTHENTICATE attribute can be used to force re-authentication (i.e. force the user to provide a PIN) for each use of a private key. “Use” in this case means a cryptographic operation such as sign or decrypt. This attribute may only be set to CK_TRUE when CKA_PRIVATE is also CK_TRUE.

Re-authentication occurs by calling C_Login with userType set to CKU_CONTEXT_SPECIFIC immediately after a cryptographic operation using the key has been initiated (e.g. after C_SignInit).

Closes https://github.com/OpenSC/OpenSC/pull/1066
2017-06-15 23:43:37 +02:00
Frank Morgner e894bd175b Revert "pkcs11-tool: always authenticate when pinpad is in use"
This reverts commit 423375c6f8.

Fixes https://github.com/OpenSC/OpenSC/issues/1063
2017-06-13 13:06:46 +02: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
Timo Teräs 8f53133ae3 pkcs15-tool: fix secret key dumping 2017-06-13 10:40:36 +02:00
konstantinpersidskiy 083cec8fda pkcs11-tool: add GOSTR3410 keypair generation (#997)
* pkcs11-tool: add GOSTR3410 keypair generation
* Refactor gost3410 generation
2017-06-09 10:30:40 +02:00
Frank Morgner a0e868974d pkcs15-tool: added test for session PIN 2017-05-22 16:25:08 +02:00
Frank Morgner 74ec7b04ff sc-hsm: Add support for SoC
- eac: allow CA without EF.CardSecurity
- sc-hsm: implemented CA based on document PKI
- sc-hsm: adds receive limit for SoC card
- introduces dedicated card type for SoC card
- md: integrate card's PIN pad capabilities
- installer: added SC-HSM SoC card to registry
- pkcs15-tool: Added support for PIN entry on card
- change/unblock PIN: add support for PIN entry on card
- added OpenPACE to macOS build
- travis-ci: install gengetopt/help2man via brew
- sc-hsm: Cache EF.C_DevAut
- sc-hsm: Prevent unnecessary applet selection and state resets
- sc-hsm: added support for session pin
- sc-hsm: avoid multiple AID selection
- sc-hsm: Use the information from match_card for all subsequent selections of the applet
- sc-hsm: cache optional files as empty files (Decoding the files will reveal that they were not existing prior caching. This avoids selecting the file though we have already tried to cache the file before.)
- use dedicated directory for CVC trust anchors
- appveyor: added OpenPACE to windows build
2017-05-22 16:25:08 +02:00
Frank Morgner 77f6e94e6f fixed import of multiple symbols
regression of 45a7ea9737075b5901fe7a5d65ed898733140315:
due to the change in the linkage, the symbols should be found in
opensc.dll instead of the static support libraries.
2017-05-22 16:25:08 +02:00
Doug Engert 0ec89941b2 gids-tool loops when using OpenSSL-1.1
Add code to support OpenSSL initialization as needed for OpenSSL-1.1
2017-05-22 13:38:34 +02: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
Mouse 0cb91fd68c Fix bug in pkcs11-tool.c that prevented it from displaying CKA_DERIVE key usage for EC public keys 2017-04-22 17:12:26 +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
Jakub Jelen c496af17d4 pkcs11-tool: Set CKA_PRIVATE=false for new public keys
Keygen should write public keys with explicit CKA_PRIVATE=false by default (possibility to modify by --private switch)

Related to 4df35b92 discussing writing separate objects years ago.
2017-04-17 01:24:03 +02:00
Jakub Jelen 1ca09b8f10 pkcs11-tool: Do not use unitialized data when C_GetTokenInfo() failed 2017-04-13 15:18:54 +02:00
Frank Morgner c2fa66f1fb pkcs11-tool: fixed RSA-X-509 corner case test
For testing RSA-X-509, we are generating random bytes for signing. It
may happen that the modulus is smaller than the random number
generated, which triggers an error in the card. With this change, we
are setting the most significant byte to 0x00 to assure the random
number is smaller than the modulus.
2017-04-03 21:55:59 +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
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
Maciej S. Szmigiero 1479c4cb3b Add reset operation to opensc-tool
Add "--reset" parameter with optional argument to opensc-tool which
resets a card in reader. Both cold or warm resets are possible
(cold is default).

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 11:05:16 +02:00
Maciej S. Szmigiero 7f778ccff8 Fix most of warnings shown when building on Linux and mingw
This commit fixes most of warnings shown by GCC on 64-bit Linux, 32-bit and
64-bit mingw builds (with SM and OpenSSL enabled).

These warnings were mostly caused by missing casts.

In minidriver there was also a bit of unused variables and dead code.

Remaining warnings on mingw are mostly caused by GCC not recognizing on
this platform "ll" size specifier (present at least since
Visual Studio 2005, also in mingw own CRT) and "z" size specifier (this one
will be fixed in next commits).

There is also a warning about pointer truncation on Win64 when making
PKCS#11 object handle from pointer to this object.
This is a legitimate warning, since it could result in the same handles
being generated from different pointers and so from different objects.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 10:58:26 +02:00
Maciej S. Szmigiero b646a306dc Print size_t variables on properly on Windows
OpenSC used SUSv3 "z" printf length modifier for printing size_t variables,
however this modifier is not available on Windows ("I" must be used
instead), at least for now.

Introduce SC_FORMAT_LEN_SIZE_T define for that purpose and convert existing
code to use it when printing size_t variables.

This define can't go into libopensc/internal.h since tools use it, too.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
2017-03-27 10:57:21 +02:00
Jakub Jelen 2031735fb1 pkcs11-tool: Polish rough edges of --attr-from use case to verify and convert in all cases 2017-03-27 10:53:44 +02:00
Jakub Jelen 74c6494f19 pkcs11-tool: Do not allow to write PEM encoded certificates to cards
Resolves #834
2017-03-27 10:53:44 +02:00
Christoph Müllner c77cb511d9 pkcs11-tool: Add feature to get random data. (#995)
* pkcs11-tool: Add feature to get random data.

Getting random data is an essential part of the PKCS11 API.
This patch provides a new command line parameter to get
random data from the pkcs11-tool.

Tested with a Yubikey (PIV applet) and the following command line:

$ pkcs11-tool --slot=0 --generate-random=128 | hexdump -C
  00000000  0c 35 85 2e 85 68 ab ce  e8 56 b3 f6 f3 33 e6 37  |.5...h...V...3.7|
  00000010  12 10 eb fd 8a 1e 75 b7  3f 4d fa 61 8f ab d8 bf  |......u.?M.a....|
  00000020  f7 2c 7d ba 07 a5 45 6e  a7 85 1c 47 3b 46 01 2c  |.,}...En...G;F.,|
  00000030  79 18 6e 51 4d c4 ae 20  37 37 1d 7b 7e b0 d5 18  |y.nQM.. 77.{~...|
  00000040  ef a4 3c 09 91 68 db dd  2a a8 fc b9 34 06 2a ee  |..<..h..*...4.*.|
  00000050  5a 86 55 54 11 1f ef 4e  07 73 79 27 0a e4 58 cf  |Z.UT...N.sy'..X.|
  00000060  f4 bd bc 2f ad 27 b1 a7  a4 fa c7 1a 7b 31 de a3  |.../.'......{1..|
  00000070  e8 dc 85 28 18 82 00 45  3c f8 eb 48 a4 20 e4 3b  |...(...E<..H. .;|
  00000080

Signed-off-by: Christoph Müllner <christophm30@gmail.com>

* pkcs11-tool: Add documenation for --generate-random.

Signed-off-by: Christoph Müllner <christophm30@gmail.com>
2017-03-27 10:52:38 +02:00
Frank Morgner a4f64d9439 Added (external) card driver for German ID card
(Imported libcardnpa from https://github.com/frankmorgner/vsmartcard)

- Added generic SM implementation of ISO/IEC 7816-8
- Added implementation of extended access control as defined by
  - BSI TR-03110
  - ICAO Doc 9303
  - ISO/IEC 7501
- Added tool for German ID card (and other EAC tokens)
- renamed folder libsm to sm
2017-03-20 21:28:48 +01:00
Martin Paljak 1226462f34 pkcs11-tool: show the PIN lengths from token info 2017-03-03 09:08:52 +01:00
Doug Engert 2a68395d22 Pkcs11-tool.c -t fails to for RSA-X-509 verification
The test_signature routine reuses data array and fails to reset data[0] = 0
when creating a PKCS hash to be pased to OpenSSL.

 Date:	     Mon Feb 13 11:48:00 2017 -0600

 On branch pkcs11-tool-pkcs
 Changes to be committed:
	modified:   tools/pkcs11-tool.c
2017-02-13 20:50:30 +01:00
Nuno Goncalves f1f96a6b40 pkcs15-tool: cast size_t to unsigned long (fix #965) (#966)
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-12 22:47:11 +01:00
Frank Morgner 9d5fe7803d silence warning about not logging in 2017-02-08 22:19:02 +01:00
Nuno Goncalves 9eb706ba29 Fix tools interpretation of util_getpass return value
A negative value means a error and not "No PIN entered".

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01:00
Nuno Goncalves 423375c6f8 pkcs11-tool: always authenticate when pinpad is in use
Authentication might not be required (from pkcs11 side) when
pin cache is used. This can't happen if a pinpad is used.

We were already checking for CKA_ALWAYS_AUTHENTICATE (user_consent),
now also check for CKF_PROTECTED_AUTHENTICATION_PATH (pinpad).

Also encapsulate logic in a function and provide additional checks for
redundant authentication attempts.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01:00
Nuno Goncalves b6cb10f768 pkcs11-tool: make login checks consistent in all test functions
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01:00
Nuno Goncalves 37844fc6c3 Revert "pkcs11-tool: re-login if pincache is disabled or expired"
This reverts commit 1bc09ddafa.

This commit had totally wrong.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-02-04 22:44:26 +01: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
Nuno Goncalves bb905ec1ec pkcs11-tool: small format fix (#950)
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-01-28 00:59:28 +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
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
Nuno Goncalves ebf0a8b9f5 Do not print data to terminal when output file is given.
This brings --read-data-object behavior in line with
--read-certificate, which only print the object to
stdout if no output file is given.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2017-01-08 17:10:33 +01:00
Martin Paljak 27c9daeede opensc-tool: only show the card name if present, to avoid "(null)"
Before:

$ opensc-tool -lv

Nr.  Card  Features  Name
0    No              FujitsuTechnologySolutions GmbH SmartCase KB SCR eSIG [SmartCase Smartcard Reader] 00 00
1    Yes             ACS ACR 38U-CCID 01 00
     3b:6e:00:00:80:31:80:66:b0:84:0c:01:6e:01:83:00:90:00 (null)

After:

$ opensc-tool -lv

Nr.  Card  Features  Name
0    No              FujitsuTechnologySolutions GmbH SmartCase KB SCR eSIG [SmartCase Smartcard Reader] 00 00
1    Yes             ACS ACR 38U-CCID 01 00
     3b:6e:00:00:80:31:80:66:b0:84:0c:01:6e:01:83:00:90:00

Change-Id: Id2cb858897cd845d93609e28019c94736b04fa93

closes #921
2017-01-01 13:40:39 +01:00
Peter Popovec 539c89e581 opensc-explorer: show tag 0x82 for unknown files
For reserved/unknown file type print value of 0x82 tag, instead of "???" string.

closes #918
2016-12-18 12:50:11 +01:00
Frank Morgner dce379b43d pkcs11-tool: fixed missing newline in test output
regression of 4441efa6da
2016-12-14 21:18:58 +01:00
Pieter Naaijkens 13463e2d18 Add missing comma to fix segfault when pkcs11-tool is called without arguments 2016-12-14 19:47:24 +01:00
Frank Morgner 9e6dddb7dd pkcs15-tool: workaround for Apple stupidity
Fixes https://github.com/OpenSC/OpenSC/issues/886
2016-11-29 21:56:52 +01:00
Nuno Goncalves e80a95bc64 Improve format in compact format
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-22 21:27:00 +01:00
Doug Engert 3ff7309520 Pkcs11-tool.c changes to accommodate ECDH operations using SoftHSM. (#901)
PKCS#11 v2.20 in not clear on the format of the public key of the other party
pased during ECDH key derivation. Some implementations (OpenSC) pass just the value
of the public key (RAW), while others (SoftHSM) pass an ASN.1 DER encoded OCTET_STRING.

PKCS$11 v2.40 points out this problem and says implementations must support the
RAW format and may also support the DER format.

To allow pkcs11-tool.c to work with ECDH derivation and using the current libSoftHSM2.so
a new parameter was added to pkcs11-tool, --derive-pass-der.

Also added to teh template fot the new key were:

CKA_SENSITIVE = false
CKA_EXTRACTABLE = true
CKA_VALUE_LEN = size of key to be derived.

OpenSC currently only support derivation of ECDH session keys, (CKA_TOKEN = false)
The derived key must be CK_KEY_TYPE = CKK_GENERIC_SECRET
Additional changes could be made to support AES or DES3 keys.

It is not clear if there is a need to support CKA_TOKEN =  true which says the
derived key must be on the hardware token. For ECDH, these keys are short lived.

 On branch pkcs11-tool-simple-ecdh
 Changes to be committed:
	modified:   src/tools/pkcs11-tool.c
2016-11-20 18:28:42 +01:00
Nuno Goncalves a25a2484f1 pkcs15-tool: add compact output format
Closes https://github.com/OpenSC/OpenSC/pull/900
2016-11-17 09:46:51 +01:00
Nuno Goncalves a16aaed41e pkcs15-tool: add --list-info option
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-17 09:46:44 +01:00
Nuno Goncalves 6cbc57a161 pkcs15-tool: make --list* messages consistent
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-11-17 09:46:39 +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
Frank Morgner 51c27f57a0 hex_to_bin: don't strip leading null-bytes
fixes https://github.com/OpenSC/OpenSC/issues/838

... and hopefully doesn't have any side effects
2016-10-31 12:34:44 +01:00
Doug Engert 0362439563 Move include for internal.h from aux-date.h to aux-data.c (#888)
with #861 internal.h, includes sc-ossl-compat.h  which requires
openssl header files. the tests/Makefile.am did not include the
openssl CFLAGS.
2016-10-16 20:09:00 +02:00
Ludovic Rousseau fad79ac2c3 pkcs15-tool: Fix compiler warning
pkcs15-tool.c:1201:5: warning: no previous prototype for ‘unlink_cb’ [-Wmissing-prototypes]
 int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf)
     ^~~~~~~~~
2016-10-14 17:36:19 +02:00
Ludovic Rousseau 8b761b830b pkcs11-tool.c: fix compiler warning
pkcs11-tool.c:2992:1: warning: control reaches end of non-void function
      [-Wreturn-type]
}
^
2016-10-14 17:36:19 +02: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
Frank Morgner 44694a0cf3 pkcs15-tool: implemented --clear-cache (#873) 2016-10-07 14:19:03 +02:00
Viktor Tarasov 30261ceaec pkcs15-tool: remove overall card unlock
In a complement to c6db68f -- card is not more locked when connected.
2016-10-04 18:26:50 +02:00
Frank Morgner d42aab11ab sc-hsm-tool: hide --print-dkek-share from the user
closes https://github.com/OpenSC/OpenSC/pull/821
2016-09-20 11:25:38 +02:00
Remy a6dff51c6b add dkek share hex print 2016-09-20 11:20:20 +02:00
Frank Morgner c6db68fdee pkcs15-tool: don't unconditionally lock the card 2016-09-19 23:55:41 +02:00
CardContact Systems GmbH 905d78093c Allow tools to enable card lock (#875)
Closes #868
2016-09-19 17:49:34 +02:00
Ian Young 678f2bb1a6 Make pkcs15-tool --dump object formatting consistent (#867)
Properly terminate "Encoded serial" lines so that the blank line after
X.509 certificate blocks isn't consumed doing so.
2016-09-08 22:05:17 +02:00
Jakuje 952fb7cb93 Get rid of misleading indentation warnings (GCC6 -Wmisleading-indentation) (#859) 2016-08-27 23:19:52 +02:00
Sid-Ali TEIR 01c92fe37f pkcs11-tool: fixed --id for C_GenerateKey, DES and DES3 keygen mechanism
fixed --id for C_GenerateKey, added DES and DES3 keygen mechanism and added ability to delete denerated secret key.

This closes #857
2016-08-27 13:11:21 +02:00
Viktor Tarasov 64ba32f2c6 pkcs11-tool: for WIN32 define STDOUT_FILENO
fix bug introduced in 6cd28cfc7c
2016-08-16 10:34:48 +02:00
Hannu Honkanen 6cd28cfc7c myeid: fix to ECDH implementation
fixing #756
rebased by VTA
2016-08-13 20:50:01 +02:00
Nuno Goncalves 6ad229e9f6 pkcs11-tool: Simplify PIN warnings messages logic
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-08-05 10:13:32 +02:00
Nuno Goncalves 1bc09ddafa pkcs11-tool: re-login if pincache is disabled or expired
Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>

closes #839
2016-07-29 17:26:17 +02:00
carblue 1ab99f3756 pkcs11-tool: in 4rd test use other signature keys
also increase signature buffer in framework-pkcs15

closes #814
2016-07-24 19:26:10 +02:00
Frank Morgner 8efca4d6db pkcs15: don't require-L for file caching
File caching is done transparently when the user sets the config option.
2016-07-24 17:19:18 +02:00
Nuno Goncalves 1198197586 pkcs11-tool: use CKF_{SO,USER}_PIN_* flags to provide alerts to the user
rebased by @viktorTarasov
initial version in PR-795
2016-07-17 13:22:55 +02:00
David von Oheimb 4441efa6da pkcs11-tool: various improvements, extensions, fixes, cleanup
========================================
rebased by VTA -- commits are forged to one,
excluding the following chunk
(reason -- if not explicitely indicated, the mechanism has to be found out using the mechanism flags):

@@ -1713,8 +1713,9 @@ static int gen_keypair(CK_SLOT_ID slot, CK_SESSION_HANDLE session,
                        int ii;

                        if (!opt_mechanism_used)
+                               opt_mechanism = CKM_EC_KEY_PAIR_GEN;
                                if (!find_mechanism(slot, CKF_GENERATE_KEY_PAIR, mtypes, mtypes_num, &opt_mechanism))
-                                       util_fatal("Generate EC key mechanism not supported\n");
+                                       util_warn("Generate EC key mechanism not listed as supported");

                        for (ii=0; ec_curve_infos[ii].name; ii++)   {
                                if (!strcmp(ec_curve_infos[ii].name, type + 3))

will close PR #747
2016-06-29 14:18:56 +02:00
Viktor Tarasov 76e0e19460 pkcs11-tool: no error when getting sensitive attr. value
resolves PR #807
2016-06-29 10:34:20 +02:00
Viktor Tarasov 3dbcc0b035 pkcs11-tool: generate secret key
resolve PR #808
2016-06-29 10:32:30 +02:00
Frank Morgner 072ec98301 Merge pull request #772 from vletoux/gids_maintenance
gids bug fixing
2016-06-25 22:32:37 +02:00
vletoux 0ae4b4ac0d gids bux fixing
fix the problem if the serial number is entered in the command line
2016-06-24 21:20:40 +02:00
Frank Morgner 0898d06944 fixed and cleaned up nmake Makefiles 2016-06-23 07:35:53 +02:00
Nuno Goncalves d97ee79333 fix #788 pkcs15-tool --read-ssh-key crash
Don't try to free again pubkey if the parent cert has already been freed.

Signed-off-by: Nuno Goncalves <nunojpg@gmail.com>
2016-06-06 18:29:03 +01:00
Frank Morgner 9066d8f999 simplyfied netkey-tool
fixes conversion from 'long' to 'u8', possible loss of data
2016-06-05 02:28:50 +02:00
Frank Morgner 04825d8d7e avoid using an uninitialized buffer 2016-06-04 01:22:28 +02:00
Viktor Tarasov b8dcf91515 pkcs11-tool: print in hex the code of unknown mechanism 2016-06-03 11:12:03 +02:00
Mouse 2ba87640d2 Fixed bug in derive_key(), where correct execution depended on undefined compiler behavior 2016-05-31 01:59:40 +02:00
Viktor Tarasov a4dfb7b07a tools: fix help message 2016-04-27 20:07:54 +02:00
Viktor Tarasov 89a5b5893b md: use GUID without frame 2016-04-08 11:02:53 +02:00
Viktor Tarasov 5c0a37c53d pkcs15init: use aux-data to set MD container GUID 2016-04-08 11:02:53 +02:00
Viktor Tarasov 56f2319fcc pkcs11-tool: few named curves more 2016-04-01 18:08:00 +02:00
Viktor Tarasov 4b51d70969 tools: print OpenSC package version 2016-03-28 20:41:19 +02:00
Viktor Tarasov 696e4119a5 pkcs15-crypt: allow decipher for key with 'unwrap' usage 2016-03-28 19:59:28 +02:00
Frank Morgner 9985144d45 Merge pull request #702 from viktorTarasov/fix/issue700/invalid-parameter
pkcs11-tool: fix invalid parameter for 'find-mechanism'
2016-03-05 21:37:31 +01:00
Frank Morgner 1c0ab2a2d2 Merge pull request #697 from viktorTarasov/feature/package-revision
tools: print package revision
2016-03-04 17:14:26 +01:00
Viktor Tarasov 36b945aa22 tools: print package revision 2016-03-04 14:16:06 +01:00
Viktor Tarasov 998a1e10c5 pkcs11-tool: fix invalid parameter for 'find-mechanism'
Fixes #700
2016-03-04 11:30:51 +01:00
Ludovic Rousseau cd42fbbc65 openpgp-tool.c: fix compiler warning
penpgp-tool.c:367:9: warning: comparison of integers of different signs: 'int'
      and 'unsigned int' [-Wsign-compare]
                if (r != count) {
                    ~ ^  ~~~~~

Remove 3 casts
Add 1 cast
Fix a format problem
2016-02-29 20:19:42 +01:00
Ludovic Rousseau e7cbc3ba82 opensc-explorer.c: fix compiler warning
opensc-explorer.c:1727:8: warning: comparison of integers of different signs:
      'int' and 'size_t' (aka 'unsigned long') [-Wsign-compare]
                if(r > len) {
                   ~ ^ ~~~
2016-02-29 20:19:42 +01:00
Ludovic Rousseau d929532b63 pkcs11-tool.c: fix 2 compiler warnings
pkcs11-tool.c:2650:25: warning: unused variable 'ecdh_parms' [-Wunused-variable]
        CK_ECDH1_DERIVE_PARAMS ecdh_parms;
                               ^
pkcs11-tool.c:2021:7: warning: unused variable 'is_private' [-Wunused-variable]
                int is_private = opt_object_class == CKO_PRIVATE_KEY;
                    ^
2016-02-29 20:19:42 +01:00
Frank Morgner 50f03bca3f fixed memory leak 2016-02-29 13:08:34 +01:00
Viktor Tarasov dbca85636f pkcs11-tool: use keygen mech. from cmd arguments
There are can be more then one keygen mechanism for a given
key type.
(ex. CKM_RSA_PKCS_KEY_PAIR_GEN and CKM_RSA_X9_31_KEY_PAIR_GEN)
2016-02-19 16:05:55 +01:00
LE TOUX Vincent 6a243449a0 First support for GIDS card
- minidriver included by default in Windows
- GIDS Applet is available here https://github.com/vletoux/GidsApplet
- some informative technical information is available here
  http://www.mysmartlogon.com/knowledge-base/generic-identity-device-specification-gids-kb/

closes https://github.com/OpenSC/OpenSC/pull/651
2016-02-19 00:12:16 +01:00
Frank Morgner 1ca22a22d1 Merge pull request #665 from sfff/pkcs11tool-pubkey-2016
pkcs11-tool: support write of GOST Public Key object
2016-02-16 23:27:56 +01:00