Commit Graph

407 Commits

Author SHA1 Message Date
Peter Marschall 16c889cf7d spelling fixes
Fix various spelling errors, mostly in comments but also in texts displayed.

Errors found & interactively fixed using 'codespell', with additional manual
checks after the fixes.
2020-08-30 10:35:14 +02:00
Jakub Jelen 97ec23a2d9 pkcs11: Propagate ignore_user_consent
If user consent is ignored through configuration, do not present
ALWAYS_AUTHENTICATE=TRUE attribute in PKCS#11

Fixes #2039
2020-07-03 17:55:24 +02:00
Frank Morgner 1bb2547abc respect PKCS#11 allowed return values 2020-06-08 14:18:23 +02:00
Frank Morgner 6a6b3e4b62 prevent memory leak 2020-06-08 14:18:23 +02:00
Frank Morgner 58b03b68dd check for unbound cards
closes https://github.com/OpenSC/OpenSC/pull/2045
2020-06-08 14:18:23 +02:00
Jakub Jelen 16456922e2 pkcs11: Return CKR_TOKEN_NOT_RECOGNIZED for not recognized cards
Fixes #2030
2020-05-30 16:00:04 +02:00
Jakub Jelen 27a819baa7 framework-pkcs15: Do not leak memory (CID 139147) 2020-05-13 21:54:16 +02:00
Jakub Jelen 84ee2be122 framework-pkcs15: Copy pubkey to avoid double free 2020-05-07 02:32:46 +02:00
Lars Silvén 8257e0186d The PKCS#11 specifies that the PIN parameter(s) in C_Login and C_SetPIN
always should be used, even if a PIN pad reader is used. PIN must only
be fetched from the PIN pad reader if the corresponding parameter is
null.
Before this commit PIN was always fetch from the reader if the PIN could
be fetched from the reader.
The 'pkcs11-tool has also been updated. Before parameters was never
taken from the command line if a PID pad reader was used. Now PINs from
the command line is always used but if not existing the PIN is fetched
from the reader if a reader with a PIN pad is used, otherwise the user
is prompted for PIN(s) from the CLI.
2020-04-08 09:54:07 +02:00
Lars Silvén a771450ab2 From the PKCS#11 specification chapter C_SetPIN:
C_SetPIN modifies the PIN of the user that is currently logged in, or
the CKU_USER PIN if the session is not logged in. ....

This was not true for "if the session is not logged in" before this fix.
2020-04-08 09:54:07 +02:00
Frank Morgner 8d4af9eb0b pkcs11: fixed right padding of token label with ' '
fixes https://github.com/OpenSC/OpenSC/issues/1922
2020-02-01 22:20:48 +01:00
Jakub Jelen 3a3a465e6b Add basic support for OEAP decryption in OpenSC internals 2020-01-07 13:30:28 +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
Frank Morgner 72f474f09f use consistent parameters
- in sc_pkcs15_wrap()
- and sc_pkcs15_derive()
2019-07-26 15:23:02 +02:00
Jakub Jelen 272e380898 Set correctly flags for ECDH derive operations 2019-06-17 12:49:11 +02:00
Frank Morgner b7b501d0a5 fixed issues reported by clang-analyzer 2019-05-21 19:34:46 +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 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 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
Frank Morgner aed95b2f2b pkcs11: check inputs
prevents NULL pointer dereference
2019-01-30 21:57:59 +01: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
Hannu Honkanen c051ef64dd Convert sequences of four spaces to tabs to fix indentation problems. 2018-11-20 11:52:54 +01:00
Frank Morgner 2cb6f9c94f fixed compilation without OpenSSL
closes https://github.com/OpenSC/OpenSC/pull/1518
2018-11-13 15:50:17 +01:00
Frank Morgner c032b2f15d CID 320271 (#1 of 1): Dereference before null check (REVERSE_INULL) 2018-11-06 15:53:17 +01:00
Frank Morgner 54c9d65a48 CID 325861 (#1 of 1): Dereference before null check (REVERSE_INULL) 2018-11-06 15:53:17 +01:00
Frank Morgner 22c8204a2f Merge remote-tracking branch 'upstream/pr/1393'
closes https://github.com/OpenSC/OpenSC/pull/1393
2018-11-06 10:51:24 +01:00
Jakub Jelen 0f5d73d816 framework-pkcs15.c: Add SHA224 mechanism for PKCS#1.5 2018-11-05 09:15:20 +01:00
Jakub Jelen d2671ee05b framework-pkcs15.c: Add PKCS#1 mechanisms also if SC_ALGORITHM_RSA_HASH_NONE is defined 2018-11-05 09:15:20 +01:00
Jakub Jelen 7e0ef7c16c framework-pkcs15.c: Reformat
* Reasonable line lengths
 * Correct indentation
 * Add missing SHA224 mechanism
2018-11-05 09:15:20 +01:00
Hannu Honkanen 351e0d2bd6 Merge remote-tracking branch 'upstream/master' into wrapping-rebased and resolve conflicts 2018-11-02 13:42:41 +02:00
Hannu Honkanen b35fb19ec4 Resolved conflict in pkcs15_create_secret_key 2018-11-02 13:28:51 +02:00
Frank Morgner 54cb1099a0 fixed warnings about precision loss 2018-11-01 00:17:22 +01:00
Hannu Honkanen 7bb53423a1 Code cleanup and minor corrections according to review. pkcs15-lib: Extractable keys are now marked as native. Check return value of check_key_compatibility in more explicit way to avoid misunderstandings. 2018-10-31 10:36:41 +02:00
Hannu Honkanen 90ec7123ba Corrections and code cleanup as requested in review. Changed value to void* in sc_sec_env_param_t, because param_type defines type of the value. Fixed handling of secret key length in framework-pkcs15 and pkcs15-lib: CKA_VALUE_LEN from PKCS#11 is in bytes, PKCS#15 objects need key length in bits. Rebased on top of upstream/master and resolved merge conflicts. 2018-10-31 10:27:03 +02:00
Lars Silvén 84317f4e9d Fixing missing call to sc_unlock. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 8ebb43d440 Removed #ifdef USE_PKCS15_INIT around __pkcs15_create_secret_key_object. This function is now used also when reading and parsing a card, not only when creating new objects. 2018-10-31 10:27:03 +02:00
Hannu Honkanen 287a63c704 Fixes to key wrapping and unwrapping code: Set IV correctly in symmetric unwrap. Correctly distinguish symmetric and asymmetric operation when building APDUs. Check CKA_TOKEN from the pkcs15 object in framework_pkcs15. Updated some comments. 2018-10-31 10:27:03 +02:00