Commit Graph

768 Commits

Author SHA1 Message Date
Frank Morgner d551f9a8e0 avoid registering pkcs11 mechanisms multiple times
fixes #349
2015-09-07 09:53:02 +02:00
Martin Paljak 8da31d271e Fix for #183: export more symbols
- also export C_Initialize and C_Finalize to please vmware-view
- have a single pkcs11.exports file for both pkcs11-spy and opensc-pkcs11
2015-08-30 18:58:00 +03:00
Frank Morgner d7d64ee8d4 Merge pull request #494 from frankmorgner/fork
After a fork do not release resources shared with parent
2015-08-04 10:32:01 +02:00
Frank Morgner b3dc5ea32a fixed segfault for uninitialized IsoApplet
fixes #400
2015-07-27 18:43:51 +02:00
Frank Morgner 6cfd71c387 avoid double detecting card on uninitialized reader
initialize_reader already calls detect_card
2015-07-27 16:15:33 +02:00
Frank Morgner 7cec500e54 added flags to sc_context_t
- is initialized in sc_context_create with parm->flags
- removes members paranoid_memory and enable_default_driver
2015-07-22 17:30:21 +02:00
Frank Morgner edc839e072 restrict access to card handles after fork
fixes #333
closes #493
2015-07-22 16:46:04 +02:00
Doug Engert b48fa70308 sc_pkcs11_card improvements
This is name change only fix.

    The variable name "card" was being used to refer to a struct sc_card or a struct sc_pkcs11_card
    in some files including sc_pkcs11.h. In other files the variable name "p11card" is used for struct sc_pkcs11_card.
    This creates hard to read code, such as: slot->card->card.

    All definitations of sc_pkcs11_card *card now use p11card as the variable name.

Fix #471
2015-05-24 11:41:29 +02:00
Philip Wendland 78e434da93 register EC mechanisms with flags independent of RSA flags
Prior to this commit, all hashes registered for RSA or other key types were
registered for ECDSA as well.

register ECDH mechanism only when supported by card

ECDH should only be registered if the card driver sets the
SC_ALGORITHM_ECDH_CDH_RAW flag.

register software PKCS#1 (1.5) padding only when RAW RSA is supported by card

If OpenSC supports PSS/OAEP padding or other padding mechanisms in
future, and there would be a card that enforces hardware PSS/OAEP
padding, the PKCS#1 v1.5 padding mechanism should not be registered.
2015-05-08 20:45:27 +02:00
Frank Morgner ef4edb74ba fixed invalid free
We duplicate mechanisms based on OpenSSL so that they can be freed along
all the card's algorithms created via sc_pkcs11_new_fw_mechanism. Fixes
regression from eaf548aa3dab80a9bbf51da8291e7db978e3a2ad
2015-05-08 09:11:55 +02:00
Frank Morgner e338b7c1ab framework-pkcs15: fixed memory leak when encoding pubkey 2015-05-08 09:11:55 +02:00
Frank Morgner e84951a5bf fix resource leaks in while registering PKCS#11 mechanisms
introduces a free_mech_data for sc_pkcs11_mechanism_type_t to clear the
mechanisms private memory
2015-05-08 09:11:55 +02:00
Frank Morgner ecc9b9dac9 openssl: fixed resource leak 2015-05-08 09:11:55 +02:00
Andreas Schwier ed588d2443 pkcs11: fixed broken C_Decrypt
Fixed broken C_Decrypt from 643080baf9

fix #449
2015-04-30 15:57:44 +02:00
Frank Morgner 9f318b829f remove slots of removed readers 2015-04-21 02:00:06 +02:00
Frank Morgner 54f285d57a correctly handle readers that have been removed 2015-04-21 01:04:18 +02:00
Frank Morgner c45c90a337 sc_pkcs11_close_all_sessions: close all sessions even if closing one fails 2015-04-20 16:18:11 +02:00
Frank Morgner 643080baf9 honour key capabilities for decryption/verification
fixes #419
2015-04-12 11:28:25 +02:00
vletoux 8ea328ff7f Minor code quality improvements.
Basically checks that the memory allocation succeed.

The ctbcs.c change improve the readability
because count = 0 and len > 254 does not add any value.

VTA: added few coding style changes
2015-04-05 13:15:57 +02:00
Frank Morgner c019a62309 pkcs11: parameter checking for 'get_mechanism_list'
fixes #409
2015-03-29 12:11:08 +02:00
Viktor Tarasov 6f6286de99 pkcs11: generate EC key: use allocated EC params
For internal use allocate and copy the EC params data from the caller's template,
rather then use them directly as a pointer in internal public key data.
2015-03-04 19:47:13 +01:00
Frank Morgner 16ea926d29 fixed indentation 2015-02-20 19:54:40 +01:00
Viktor Tarasov fa923831f8 introduce EC curve OID into algorithm info data
needed to store information about EC curve supported by card.
Primary usage is when importing/generating key to get know if particular curve is supported by card.
2015-02-20 13:49:18 +01:00
Thomas Calderon 22fb49b554 PKCS#11: Improve compliance for public keys.
* Key usage required when calling C_CreateObject for public key are not used.
    This adds the logic to convert from PKCS#11 attributes to PKCS#15 in the
    structure that is sent to underlying _store_pubkey functions.
2015-02-07 20:17:12 +01:00
Viktor Tarasov 96265e6d08 pkcs15init: superpluous 'ec-params' in init data
Pkcs15init data, used to import/generate key objects, includes twice the same EC parameters data:
 - explicit 'params' data
 - part of sc_pkcs15_pubkey/sc_pkcs15_prkey
Explicit 'ec-params' data is removed.
2015-02-07 20:00:41 +01:00
Viktor Tarasov 08eb700b97 revert or partially revert some of recent commits
b94c163 - invalid, non-tested
11881a6 -- src/libopensc/card-iasecc.c -- return from select has to be ignored,
3a92bf7 -- src/pkcs11/slot.c -- SEGFAULT issue #373
3a92bf7 -- src/tools/piv-tool.c -- confirmed by author
6759c04 -- src/pkcs15init/pkcs15-lib.c -- file instantiation error has to be ignored
2015-02-07 19:31:17 +01:00
Frank Morgner 3a92bf7af5 fixed resource leaks 2015-02-05 01:38:41 +01:00
Frank Morgner 11881a61b8 removed/fixed dead code 2015-02-05 01:38:41 +01:00
Frank Morgner 6759c04b26 don't ignore errors 2015-01-28 04:45:08 +01:00
Frank Morgner ac0424e947 fixed pkcs11spy's version number 2015-01-28 07:09:02 +01:00
Frank Morgner 77752f442d fixed unused value 2015-01-28 05:47:20 +01:00
Frank Morgner 7a34c204c1 fixed dereference before null check
silence warnings reported by coverity-scan
2015-01-22 20:29:33 +01:00
Mathias Brossard 762d466b23 Add display of Elliptic Curve flags 2015-01-20 23:15:41 -08:00
Mathias Brossard 7a455f64c7 Support of additional type, mechanisms and attributes 2015-01-20 23:15:31 -08:00
Mathias Brossard 3dadd3fba1 Add some missing PKCS#11 values 2015-01-20 23:15:22 -08:00
Mathias Brossard 17c1cffb3d Fix typo on CKF_EC_UNCOMPRESS 2015-01-20 23:14:50 -08:00
Mathias Brossard c3a0bbc715 Update email and year 2015-01-20 23:14:36 -08:00
Thomas Calderon ed87ea38b9 PKCS#11: Fetch real value of CKA_LOCAL for pubkey
* Fetch value from pub_info structure for CKA_LOCAL attribute.
2015-01-14 17:38:08 +01:00
Thomas Calderon d727acb47a PKCS#11: Remove inconsistent attributes
* Improve compliance related to PKCS#11 attribute fetching.
2015-01-14 17:22:43 +01:00
Thomas Calderon 4915eaa56b Improve PKCS#11 compliance. Issue #335
* This simple patch allows for values of PKCS#11 attributes to be fetched
  from the underlying card.
2015-01-05 14:00:22 +01:00
Doug Engert cd01a73caf C_Digest does not check if buffer too small before update. Issue #327
C_Digest will now query for the buffer size using sc_pkcs15_md_final
before calling sc_pkcs15_md_update. This avoids doing a double update
when the user passes in a buffer to small, then gets the buffer and calls
C_Digest again.
2014-12-02 11:15:24 +01:00
Frank Morgner 8672291a73 Merge pull request #312 from frankmorgner/fix-p15
fixed type of pkcs15init_initialize
2014-11-05 10:38:42 +01:00
Doug Engert fd22098e19 Public certs and pubkeys with an auth_id are treated as private (See #291)
Code to test for an auth_id for certs and pubkeys was removed.
See: PKCS#15 section 4.1.3 Access methods

This is conseritive change and all objects could be treaded the same.
2014-11-01 14:02:39 -05:00
Frank Morgner d3c8fbcf1d fixed type of pkcs15init_initialize
regression from 95b6b4cc
2014-10-27 23:22:40 +01:00
Doug Engert 189e998486 PKCS#11 hashes for cards without RAW (see #241)
The framework-pkcs15.c did not add hashes correctly if the card did not support RSA RAW.
    This change fixes that and only adds hashes if the card did not specify a list of hashes.
    It also will not add hashes done in software if ENABLE_OPENSSL is not specified.
    Some error conditions are also tested for EC mechanisms.

    See bug report #241 for more information.
2014-10-13 10:29:27 -05:00
Andreas Schwier be200ab3c8 Merge pull request #282 from CardContact/fix-deleted-related-public-key
framework-pkcs15: Duplicate public key related to private key rather than referencing the framework object

Referencing the related public key is required to return PKCS#11 attributes for a private key only available
in the public key object (i.e. CKA_MODULUS). This patch adds a copy of the public key to the private key object rather than
referencing the public key object in the framework. This prevents SEGV when the public key framework object
is deleted with C_DestroyObject, but the reference from the public key remains intact.

The bug leads to all kind of stability problems when keys are created and deleted in the same session.

The patch is in particular important if OpenSC is used with EJBCA or any other application using the
SUN PKCS#11 provider: When generating key pairs, then the public key object is eventually garbage collected
which removes the related object in the PKCS#11 module. Because there is no fixed time for this operation,
corruption occurs at random.

In a next step, the remaining related_xxx fields in sc_pkcs11_object should be revised and possibly removed.

framework: Added more error checking
2014-09-07 23:47:24 +02:00
Andreas Schwier e6505b3d9c pkcs11: Fixed wrong reference to PIN object in C_SetPIN() for SO-PIN 2014-09-07 22:11:39 +02:00
Frank Morgner 5d6c4b391d Merge pull request #253 from github-frankmorgner/remove-deadcode
card-asepcos: removed dead code
card-authentic: removed dead code
card-belpic: removed dead code
card-epass2003: removed dead code
card-flex: removed dead code
card-gpk: removed dead code
card-oberthur: removed dead code
card-piv: removed dead code
card-setcos: removed dead code
ctbcs: removed dead code
cwa14890: removed dead code
muscle: removed dead code
pkcs15-atrust-acos: removed dead code
pkcs15-gemsafeV1: removed dead code
pkcs15-skey: removed dead code
reader-ctapi: removed dead code
framework-pkcs15: removed dead code
pkcs11-object: removed dead code
pkcs15-asepcos: removed dead code
pkcs15-cardos: removed dead code
pkcs15-jcop: removed dead code
pkcs15-lib: removed dead code
pkcs15-oberthur: removed dead code
parse: removed dead code
sclex: removed dead code
sm-card-authentic: removed dead code
sm-card-iasecc: removed dead code
sm-cwa14890: removed dead code
sm-global-platform: removed dead code
sc-test: removed dead code
pkcs11-tool: removed dead code
pkcs15-tool: removed dead code
2014-09-07 21:22:43 +02:00
Emanuele Pucciarelli ee0566af09 pkcs11: pr-239: PKCS15 pubkey release fix 2014-06-01 18:55:56 +02:00
Raul Metsma 77c71be833 Don't depend configuration default value 2014-05-31 21:15:19 +02:00