Commit Graph

954 Commits

Author SHA1 Message Date
Priit Laes 0b4b7fbaf0 openssl: Drop all compatibility checks for <=openssl-1.0.0 2020-01-06 15:47:07 +01:00
Jakub Jelen 8ab39bdec7 pkcs11-session: Explicitly reset login_user and release lock 2019-12-04 12:00:07 +01:00
Jakub Jelen 4bd8cda966 pkcs11-session: When we notice logout in lower layers, while pkcs11 thinks we are logged in, invalidate all sessions in given slot 2019-11-28 11:18:25 +01:00
Jakub Jelen e0e1f10bd3 pkcs11/slot: Fix indentation 2019-11-28 11:18:25 +01:00
Oskar Wiksten 79a51e0d18 pkcs11: Support for RSA PSS padding in verify
* Explicitly copies the mechanism parameters during a PKCS#11 `C_VerifyInit`
  and `C_DecryptInit` operation.
* Resolves issues where the calling application deallocates the `pParameter`
  pointer in the `CK_MECHANISM` struct between calls to `C_VerifyInit` and
  `C_Verify`, or between `C_DecryptInit` and `C_Decrypt`.
* These mech parameters are used in RSASSA-PSS and RSAES-OAEP, for example.
* This commit copies the same fix that was applied to `sc_pkcs11_sign_init` in
  commit e5707b545e for supporting RSASSA-PSS.
2019-11-28 11:17:12 +01:00
Jakub Jelen 0ea11523a3 Improve logging of exit codes 2019-11-01 15:50:34 +01:00
Frank Morgner e2491a7d7f
pkcs11-tool: fixed displaying secret key attributes (#1807)
fixes https://github.com/OpenSC/OpenSC/issues/1805
2019-10-01 11:51:55 +02:00
Ludovic Rousseau 2bfd022180 pkcs11-spy: add support of CKM_*_PSS in C_VerifyInit()
In bdb1961dee the same code was added to
C_SignInit(). Now it is also used in C_VerifyInit().
2019-08-27 14:52:10 +02:00
Ludovic Rousseau 2240abcef1 spy: display -1 instead of 18446744073709551615
buf_len is a CK_ULONG (unsigned long). But if the attribute is sensitive
or is not extractable or is invalid for the object then the library set
the buffer length value to (CK_LONG)-1.

It is more friendly to see "-1" instead of "18446744073709551615" (on
64-bits CPU)
2019-08-26 10:53:09 +02:00
Ludovic Rousseau 43a8f870e5 pkcs11-spy: add support of CKA_OTP_* values 2019-08-26 10:18:04 +02:00
Ludovic Rousseau e35a7e7395 Add definition of CKA_OTP_* constants 2019-08-26 10:17:05 +02:00
Frank Morgner 72f474f09f use consistent parameters
- in sc_pkcs15_wrap()
- and sc_pkcs15_derive()
2019-07-26 15:23:02 +02:00
Raul Metsma d14cf97d7a Allow to create temporary objects with readonly sessions and readonly cards
Fixes #1719

Signed-off-by: Raul Metsma <raul@metsma.ee>
2019-07-22 13:34:59 +02:00
Frank Morgner 7fb72ccf7b pkcs11: fixed slotIDs when a new slot list is requested
fixes https://github.com/OpenSC/OpenSC/issues/1706

regression of 24b7507a69
2019-06-30 10:24:11 +02:00
Jakub Jelen df0bbc110e pkcs11-spy: Dump EC Derive parameters 2019-06-17 12:49:11 +02:00
Jakub Jelen 272e380898 Set correctly flags for ECDH derive operations 2019-06-17 12:49:11 +02:00
Frank Morgner 94388f9538 fixed more clang-tidy warnings 2019-06-05 13:48:51 +02:00
Ludovic Rousseau cc189585c8 pkcs11-spy: display CK_GCM_PARAMS.ulIvBits field 2019-05-29 15:17:15 +02:00
Ludovic Rousseau 0fbd2663e6 Add missing ulIvBits to CK_GCM_PARAMS
The PKCS#11 specification text does not document the ulIvBits field.
But the header file defining CK_GCM_PARAMS uses it.
Since the header file is the normative version we need to add it.

See also https://github.com/Pkcs11Interop/Pkcs11Interop/issues/126o
and https://lists.oasis-open.org/archives/pkcs11-comment/201602/msg00001.html
and https://www.oasis-open.org/committees/document.php?document_id=58032&wg_abbrev=pkcs11
2019-05-29 15:17:15 +02:00
Frank Morgner b7b501d0a5 fixed issues reported by clang-analyzer 2019-05-21 19:34:46 +02:00
Frank Morgner 7449b00768 pkcs11: avoid double initialization of notify 2019-04-26 23:51:37 +02:00
Ludovic Rousseau ffaaf1c0d3 pkcs11-spy: parse CKM_AES_GCM for C_EncryptInit() 2019-04-25 14:52:20 +02:00
Ludovic Rousseau 69727c79ad pkcs11.h: add CK_GCM_PARAMS structure 2019-04-25 14:52:20 +02:00
Ludovic Rousseau 98ec27e768 pkcs11-spy: log pParameter buffer for C_EncryptInit & C_DecryptInit 2019-04-25 14:52:20 +02:00
Dmitriy Fortinskiy 0e12b1dc71 pkcs11-tool: Generate GOSTR3410-2012 keys 2019-04-17 16:42:12 +02:00
Frank Morgner fe95520e3e explicitly import libpkcs11.h 2019-04-08 11:16:13 +02:00
Frank Morgner 0abe9d11c7 pkcs11: (de-) initialize notifications on load
fixes https://github.com/OpenSC/OpenSC/issues/1507
fixes https://github.com/OpenSC/pkcs11-helper/issues/16
2019-04-04 11:04:50 +02:00
Frank Morgner 2e87e4cfed fixed issues from review 2019-03-13 21:22:19 +01:00
Frank Morgner b7ec7f95b1 pkcs11: fixed token label 2019-03-13 21:22:19 +01:00
Frank Morgner 0079d836f3 pkcs11: truncate oversized labels with '...' 2019-03-13 21:22:19 +01:00
Frank Morgner 19c5ab315d fixed uninitialized use of variable 2019-03-06 08:53:47 +01:00
Frank Morgner 8fbd0b3ee1 fixed 333708 Dereference after null check 2019-03-06 00:42:38 +01:00
Frank Morgner 53954e9ff1 fixed OpenSSL handling in PKCS#11 mapping
prevents NULL pointer dereference
2019-02-14 09:22:23 +01:00
Frank Morgner 85485eb9b0 fixed unused assignments 2019-02-14 09:22:23 +01:00
Frank Morgner fdb0e6d581 Fixed Potential leak of memory 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 f486486413 removed unused defines 2019-01-30 21:57:59 +01:00
Frank Morgner aed95b2f2b pkcs11: check inputs
prevents NULL pointer dereference
2019-01-30 21:57:59 +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
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
Doug Engert 08a02ed5d2 Fix PKCS#11 Object Restrictions
Framework-pkcs15.c silently ignores adding objects if MAX_OBJECTS
is exceeded while creating the fw_data objects. This simple fix
is to change the MAX_OBJECTS from 64 to 128. A better fix would
be to realloc the objects arrays as needed.

__pkcs15_create_data_object and __pkcs15_create_secret_key_object
now return rv like the other  __pkcs15_create_*_object routines.

pkcs15_dobj_get_value now calls sc_pkcs15_read_data_object just like
the other pkcs15_*_get_value routines. The problem was introduced
in 0c3412bb 2018-04-09 which added:
 `return sc_to_cryptoki_error(SC_SUCCESS, "C_GetAttributeValue");`
before trying to read the data object.

The MAX_OBJECT problem was discovered while trying to use a new PIV
card with 24 standard cert objects and 10 other objects for a total
of 106 objects. Each cert object corresponds to a cert, pubkey,
private key, and the cert object itself for a possible 112 data objects.

The pkcs15_dobj_get_value was found while running:
running pkcs11-tool -r -y data --application-id 2.16.840.1.101.3.7.2.1.1
using git bisect to locate the bad commit.  The pkcs11 data objects are
created last from the pkcs15 objects which are a linked list with no limits.

 On branch fix-object-restrictions
	modified:   src/pkcs11/framework-pkcs15.c
2019-01-15 07:31:39 +01:00
Frank Morgner 5c50dc58da fixed 320270 Dereference after null check 2019-01-04 00:44:45 +01:00
Peter Marschall 01287e393e framework-pkcs15: fix warning
* fix -Werror=format-truncation= warning in pkcs15_init_slot()
* do not only remove blanks from the end, but all spaces
2018-12-09 23:44:00 +01:00
Frank Morgner f2145eca79 don't debug pointers 2018-12-06 09:26:42 +01:00
Luka Logar ba77042911 Fix token label formatting
PKCS#15 token label may be padded with spaces, trim it when making a PKCS#11 token label in order not to loose closing parenthesis.
I would actually prefer for the token label to be "myCard (User PIN)" instead of current "User PIN (myCard)"

before:
$ pkcs11-tool --list-slots
Available slots:
Slot 0 (0x0): OMNIKEY AG CardMan 3121 00 00
  token label        : User PIN (myCard
...

after:
$ pkcs11-tool --list-slots
Available slots:
Slot 0 (0x0): OMNIKEY AG CardMan 3121 00 00
  token label        : User PIN (myCard)
...
2018-12-05 12:42:30 +01:00
Luka Logar 2552fde05f Fix some pinpad reader related issues (#1540)
1. Show pinpad reader capabilities even for uninitialised tokens. This way pinpad can be used during initialisation.
2. Make possible to create so-pin object during initialisation even if no so-pin was provided (on the command line) but pinpad reader is used and card profile contains so-pin data.
2018-12-05 12:41:58 +01:00
Hannu Honkanen 7d640e62c1 Fixed incorrect conversion fron int to CK_BBOOL when converting PKCS#15 user consent to a PKCS#11 attribute 2018-12-05 12:10:42 +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
Hannu Honkanen aa8f666f46 Removed unnecessary spaces from framework-pkc15.c as requested.
pkcs15: added explicit comparison when checking return value of sc_compare_oid() to make the logic more obvious.
2018-11-20 11:52:54 +01:00