Commit Graph

386 Commits

Author SHA1 Message Date
Raul Metsma 91a1dd9af4 Option to delete object by index
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-17 14:38:40 +02:00
Raul Metsma 3935d501bf Implement Secret Key write object
Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-04-17 14:37:49 +02:00
Frank Morgner fe95520e3e explicitly import libpkcs11.h 2019-04-08 11:16:13 +02:00
Jakub Jelen fc4d600634 pkcs11-tool: Allow to set CKA_ALLOWED_MECHANISMS when creating an objects
Also list them in the attributes listing
2019-04-08 11:15:19 +02:00
alegon01 f631b5f733 Fix in encrypt_decrypt(), check for (in_len <= sizeof orig_data) 2019-04-05 10:39:52 +02:00
alegon01 4913feadb8 Fix in encrypt_decrypt(), check for (in_len <= sizeof orig_data) 2019-04-05 10:38:12 +02:00
alegon01 31831c300b Remove the call to OPENSSL_init_crypto() which is not needed. I have a segmentation fault when the process exits. 2019-03-12 08:52:06 +01:00
alegon01 728d099a53 FIX typo OpenSSL vs OpenSsl. 2019-03-06 11:35:11 +01:00
alegon01 b327b76134 FIX use pseudo_randomize() for a proper initialization of orig_data in encrypt_decrypt(). 2019-03-06 10:26:05 +01:00
Frank Morgner ba185954c5 fixed 333709 Unchecked return value 2019-03-06 00:42:38 +01:00
alegon01 7271fe610b Add support for the OpenSsl signature format for the signature verification. 2019-02-18 16:03:41 +01:00
alegon01 9ae507c5f8 Fix indentation. 2019-02-12 14:09:26 +01:00
alegon01 b63a868e68 Fix build when EVP_PKEY_CTX_set_rsa_oaep_md is not defined. 2019-02-12 10:42:39 +01:00
alegon01 973625773b Fix encrypt_decrypt() for CKM_RSA_PKCS_OAEP. It is working fine now with OpenSsl 1.1.1a. 2019-02-07 10:42:48 +01:00
alegon01 084624f340 Fix CKM_RSA_PKCS in encrypt_decrypt(). 2019-02-05 12:03:51 +01:00
alegon01 9aa413bd7e Fix CKM_RSA_X_509 encrypt_decrypt(). Improve the code for CKM_RSA_PKCS and CKM_RSA_PKCS_OAEP. For these alogs, only CKM_SHA_1 is supported. 2019-02-05 11:35:42 +01:00
alegon01 d25fbe3cec Remove 2 useless comments in encrypt_decrypt(). 2019-02-05 11:24:33 +01:00
alegon01 3d09823df0 Fix build when OPENSSL_NO_RIPEMD and OPENSSL_NO_CAST are defined. Fix formatting. 2019-02-04 14:26:02 +01:00
alegon01 f030aa2c25 Add support for CKM_RSA_X_509 in encrypt_decrypt() and decrypt_data(). 2019-02-04 14:23:13 +01:00
alegon01 9b7605ff3c Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). Only set the OAEP params for CKM_RSA_PKCS_OAEP, I had an issue with a variable not initialized. 2019-02-01 15:27:55 +01:00
alegon01 cf617da4bd Before calling encrypt_decrypt() make sure that the mechanism is for RSA and supports decryption, otherwise skip it. 2019-02-01 11:37:47 +01:00
alegon01 2be799f739 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). fix mechanism value in call to util_fatal(). fix formatting. 2019-02-01 11:35:25 +01:00
alegon01 16ca73ae40 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). fix mechanism value in call to util_fatal(). 2019-02-01 11:19:33 +01:00
alegon01 968bfa8444 Add support for CKM_RSA_PKCS_OAEP in encrypt_decrypt(). 2019-02-01 09:16:59 +01:00
alegon01 ff3448fb18 Fix build when OPENSSL_NO_RIPEMD and OPENSSL_NO_CAST are defined. 2019-02-01 09:13:21 +01:00
alegon01 f412995811 Bug fix in verify_signature() when the buffer to verify is larger than 1025 bytes. In this case, the signature length given to C_VerifyFinal() was incorrect. 2019-02-01 09:10:02 +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 993f6f5cc6 Use opensc-pkcs11.so for static build of pkcs11-tool
Statically link opensc-pkcs11 into pkcs11-tool with --disable-shared
2019-01-30 21:57:59 +01:00
Frank Morgner 4b30858092 pkcs11-tool: fixed argument type
reported by lgtm
2019-01-20 23:02:21 +01:00
Martin Paljak c3a9837b10 Add mechanisms used by SoftHSM2
/Library/OpenSC/bin/pkcs11-tool --module /usr/local/lib/softhsm/libsofthsm2.so -M

will not show any more numeric mechanisms.

Source: https://www.cryptsoft.com/pkcs11doc/STANDARD/include/v240e01/pkcs11t.h
2019-01-15 13:07:58 +02:00
Mat e19fe680c4 Add object type "secrkey" to help of --type switch in pkcs11-tool (#1575)
* Add object type "secrkey" to help of --type switch in pkcs11-tool

Reading an object with pkcs11-tool requires the `--type` switch. The help for that switch is currently incomplete as it is missing the (not very friendly named" *secrkey* option used to read out a secret key object.

I have added this information to the help description.

* Update man page

Describe secrkey option of pkcs11-tool's --type switch in man page
2019-01-15 07:32:41 +01:00
Hannu Honkanen 9e5a324903 Edited according to PR review: CKA_ALWAYS_AUTHENTICATE only associated with private keys. Defined a custom attribute to achieve same functionality with secret keys. Updated man pages. 2018-12-05 12:10:42 +01:00
Hannu Honkanen ee8c80af4f Implemented handling of CKA_ALWAYS_AUTHENTICATE attribute when importing and generating keys, mapping it to pkcs#15 userConsent field. Added command line options to pkcs11-tool and pkcs15-init tool to use the feature. 2018-12-05 12:10:42 +01:00
Jakub Jelen f1f98f829c pkcs11-tool: Unbreak signature and verification in pkcs11-tool 2018-11-25 22:07:33 +01:00
Jakub Jelen b9e33a3c64 Coverity warnings
card-piv.c
	make sure the string is null terminated before passing it
	to hex_to_bin routine, which expects it
pkcs15-cac.c
	free cn_name on failure
pkcs11-tool.c
	make sure the string is null terminated before passing it to
	parse_certificate(), which expects it
2018-10-01 23:07:34 +02:00
Jakub Jelen 9a853176b8 pkcs11-tool: Support for signature verification
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-30 21:23:27 +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
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
Frank Morgner b3e3ab61c0 avoid integer underflow 2018-06-29 17:14:55 +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
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
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
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
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
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
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
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
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 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
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
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
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
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
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 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 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
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
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
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
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
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 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