opensc/src/pkcs11
Doug Engert 1b4e9f1d4a C_Initialize may be called by multiple threads
While trying to setup an OpenSC context, the global_locking
and detect cards, it is possible that multiple threads may
call C_Initialize. The current code tries to prevent this using
"if (context == NULL)"  but this is not a mutex, and
multiple threads may endup overwrite contexts and global locking and
cause additional problems, with pcsc and segfault.

FireFox appears to do this see #2032

The PR adds a mutex or Critical section to make sure only one
thread creates the context sets the global_locking  and does
the initial detect cards, etc.

This allows the global_lock (if requested) to be setup
which is then used for other calls.

All but the first call to C_Initialize will return with CKR_OK,
others will return CKR_CRYPTOKI_ALREADY_INITIALIZED.

 Date:      Mon Jan 11 12:47:12 2021 -0600
 Changes to be committed:
	modified:   src/pkcs11/pkcs11-global.c
2021-01-26 12:50:39 +01:00
..
Makefile.am Ignore non-useful check in clang-tidy as we have ton of memset/memcpy 2021-01-06 14:15:06 +01:00
Makefile.mak win32: don't link static libs into static libs 2017-11-09 12:42:29 +01:00
debug.c removed unused defines 2019-01-30 21:57:59 +01:00
framework-pkcs15.c unused code removed 2021-01-24 23:48:00 +01:00
framework-pkcs15init.c pkcs11: check inputs 2019-01-30 21:57:59 +01:00
mechanism.c Add basic support for OEAP decryption in OpenSC internals 2020-01-07 13:30:28 +01:00
misc.c essentially revert 1bb2547 2021-01-22 13:19:33 +01:00
onepin-opensc-pkcs11.dll.manifest Windows: Added support for notifications 2017-08-02 19:03:16 +02:00
opensc-pkcs11.dll.manifest Windows: Added support for notifications 2017-08-02 19:03:16 +02:00
opensc-pkcs11.pc.in install opensc.pc 2016-09-20 01:47:37 +02:00
openssl.c pkcs11 ECDSA verify need rs converted to sequence 2021-01-24 23:48:00 +01:00
pkcs11-display.c pkcs11: Implement PKCS #11 3.0 Profile object and its handling in tools 2021-01-11 14:49:22 +01:00
pkcs11-display.h pkcs11: Implement PKCS #11 3.0 Profile object and its handling in tools 2021-01-11 14:49:22 +01:00
pkcs11-global.c C_Initialize may be called by multiple threads 2021-01-26 12:50:39 +01:00
pkcs11-object.c pkcs11: Implement PKCS#11 3.0 stubs for required functions 2021-01-11 14:49:22 +01:00
pkcs11-opensc.h 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
pkcs11-session.c Implement C_SessionCancel from PKCS #11 3.0 2021-01-11 14:49:22 +01:00
pkcs11-spy.c pkcs11-spy: Implement new functions and interfaces to intercept PKCS #11 3.0 calls 2021-01-11 14:49:22 +01:00
pkcs11.exports pkcs11: Implement PKCS#11 3.0 stubs for required functions 2021-01-11 14:49:22 +01:00
pkcs11.h pkcs11: Implement PKCS #11 3.0 Profile object and its handling in tools 2021-01-11 14:49:22 +01:00
sc-pkcs11.h spelling fixes 2020-08-30 10:35:14 +02:00
slot.c spelling fixes 2020-08-30 10:35:14 +02:00
versioninfo-pkcs11-spy.rc.in win32: Load notification icons from Windows DLLs 2017-08-03 00:19:26 +02:00
versioninfo-pkcs11.rc.in win32: Load notification icons from Windows DLLs 2017-08-03 00:19:26 +02:00