Commit Graph

141 Commits

Author SHA1 Message Date
Tobias Brunner 1b67166921 Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
robinleander 826b4232d3 pkcs11: Use unused return value of C_GetMechanismList
Closes strongswan/strongswan#96.
2018-03-29 17:18:27 +02:00
Tobias Brunner de280c2e03 private-key: Add optional parameters argument to sign() method 2017-11-08 16:48:10 +01:00
Tobias Brunner a413571f3b public-key: Add optional parameters argument to verify() method 2017-11-08 16:48:10 +01:00
Tobias Brunner 6ce7ae24a4 pkcs11: Call C_Finalize() to cancel jobs waiting in C_WaitForSlotEvent()
This is not ideal as the call to C_Finalize() should be the last one via
the PKCS#11 API.  Since the order in which jobs are canceled is undefined
we can't be sure there is no other thread still using the library (it could
even be the canceled job that still handles a previous slot event).
According to PKCS#11 the behavior of C_Finalize() is undefined while other
threads still make calls over the API.

However, canceling the thread, as done previously, could also be problematic
as PKCS#11 libraries could hold locks while in the C_WaitForSlotEvent() call,
which might not get released properly when the thread is just canceled,
and which then might cause later calls to other API functions to block.

Fixes #2437.
2017-11-02 10:15:32 +01:00
Tobias Brunner 46a62f0126 Define MODP_CUSTOM constructors as variadic functions
They now match the dh_constructor_t signature.  This is a follow up for
the changes merged with b668bf3f9e and should fix use of MODP_CUSTOM on
Apple's ARM64 platform.
2017-09-18 12:07:26 +02:00
Tobias Brunner 525cc46cab Change interface for enumerator_create_filter() callback
This avoids the unportable 5 pointer hack, but requires enumerating in
the callback.
2017-05-26 13:56:44 +02:00
Tobias Brunner 95a63bf281 Migrate all enumerators to venumerate() interface change 2017-05-26 13:56:44 +02:00
Raphael Geissert 9a7049635e pkcs11: Look for the CKA_ID of the cert if it doesn't match the subjectKeyId
charon-nm fails to find the private key when its CKA_ID doesn't match the
subjectKeyIdentifier of the X.509 certificate.  In such cases, the private
key builder now falls back to enumerating all the certificates, looking for
one that matches the supplied subjectKeyIdentifier.  It then uses the CKA_ID
of that certificate to find the corresponding private key.

It effectively means that PKCS#11 tokens where the only identifier to relate
the certificate, the public key, and the private key is the CKA_ID are now
supported by charon-nm.

Fixes #490.
2016-10-04 12:09:04 +02:00
Andreas Steffen 40f2589abf gmp: Support of SHA-3 RSA signatures 2016-09-22 17:34:31 +02:00
Tobias Brunner 7316a13bd1 pkcs11: Skip zero-padding of r and s when preparing EC signature
They are zero padded to fill the buffer.

Fixes #1377.
2016-04-05 16:17:10 +02:00
Andreas Steffen b12c53ce77 Use standard unsigned integer types 2016-03-24 18:52:48 +01:00
Tobias Brunner b2efc61818 pkcs11: Fix encoding of RSA keys if unnecessarily zero prefixed
Some tokens/libraries seem to prefix all numbers with zero bytes even
if not necessary (e.g. the default exponent 0x010001).  If we don't fix
that, the fingerprints calculated based on the retrieved values will be
incorrect.

Even if the pkcs1 plugin can properly handle numbers that are not in
two's complement since a81bd670b0 ("Added PUBKEY_RSA_MODULUS
encoding type") we prefix them with zero if necessary as other encoders
might expect them in two's complement.

Fixes #1012.
2015-08-06 17:15:25 +02:00
Martin Willi 0356089d0f diffie-hellman: Verify public DH values in backends 2015-03-23 17:54:03 +01:00
Martin Willi a777155ffe diffie-hellman: Add a bool return value to set_other_public_value() 2015-03-23 17:54:03 +01:00
Martin Willi 42431690e0 diffie-hellman: Add a bool return value to get_my_public_value() 2015-03-23 17:54:03 +01:00
Martin Willi bace1d6479 diffie-hellman: Use bool instead of status_t as get_shared_secret() return value
While such a change is not unproblematic, keeping status_t makes the API
inconsistent once we introduce return values for the public value operations.
2015-03-23 17:54:02 +01:00
Tobias Brunner e5009fbb66 pkcs11: Convert RFC 3279 ECDSA signatures when verifying
References #873.
2015-03-09 15:37:07 +01:00
Tobias Brunner b258ed0192 pkcs11: Properly encode RFC 3279 ECDSA signatures
Fixes #873.
2015-03-09 15:37:07 +01:00
Tobias Brunner 8c9a0b5fb5 pkcs11: Properly encode EC_POINTs created on a token
Some tokens might not fail when creating EC public keys in the incorrect
format, but they will later not be able to use them to verify signatures.

References #872.
2015-03-09 15:37:01 +01:00
Tobias Brunner 4aab3153a4 pkcs11: Properly handle EC_POINTs returned as ASN.1 octet string
This is the correct encoding but we internally only use unwrapped keys
and some tokens return them unwrapped.

Fixes #872.
2015-03-09 15:36:07 +01:00
Tobias Brunner e13ef5c434 crypto: Define MODP_CUSTOM outside of IKE DH range
Before this fix it was possible to crash charon with an IKE_SA_INIT
message containing a KE payload with DH group MODP_CUSTOM(1025).
Defining MODP_CUSTOM outside of the two byte IKE DH identifier range
prevents it from getting negotiated.

Fixes CVE-2014-9221.
2014-12-23 15:40:01 +01:00
Martin Willi 4163421f91 plugins: Don't link with -rdynamic on Windows 2014-06-04 15:53:02 +02:00
Martin Willi 9ee8b3b41f enum: Don't directly include enum.h
To allow enum.h to depend on utils.h definitions, avoid its direct inclusion.
Instead include utils.h, which includes enum.h as well.
2014-05-16 15:42:07 +02:00
Tobias Brunner 8dc6e71632 lib: All settings use configured namespace 2014-02-12 14:34:32 +01:00
Martin Willi 19cb07b890 automake: replace INCLUDES by AM_CPPFLAGS
INCLUDES are now deprecated and throw warnings when using automake 1.13.
We now also differentiate AM_CPPFLAGS and AM_CFLAGS, where includes and
defines are passed to AM_CPPFLAGS only.
2013-07-18 14:59:19 +02:00
Tobias Brunner 7756c0383e pkcs11: Use plugin_features_add() in get_features() 2013-06-11 11:18:18 +02:00
Tobias Brunner f05b427265 Moved debug.[ch] to utils folder 2012-10-24 16:00:51 +02:00
Tobias Brunner d5c143e5be Moved enum_name_t to utils folder 2012-10-24 16:00:50 +02:00
Tobias Brunner 125b37af6d Moved chunk_t to utils folder 2012-10-24 16:00:50 +02:00
Tobias Brunner 12642a6831 Moved data structures to new collections subfolder 2012-10-24 16:00:49 +02:00
Martin Willi 712e81306f PKCS#11 library search using keyid uses a fallback to look for certificates 2012-10-24 13:07:54 +02:00
Martin Willi 434902b302 Add a strongswan.conf option to disable loading of all certificates from a pkcs11 module 2012-10-24 13:07:53 +02:00
Martin Willi 36e47a409b Explicit pkcs11 certificate loading can enforce a module and a slot 2012-10-24 13:07:53 +02:00
Martin Willi 5d4c27d077 Be less verbose if loading PKCS#11 certificate fails 2012-10-24 13:07:53 +02:00
Martin Willi fbd3863571 Add a builder to load specific pkcs11 certificates by keyid 2012-10-24 13:07:52 +02:00
Martin Willi ffe42fa405 If no pkcs11 public key for a private key found, search for a certificate 2012-10-24 13:07:52 +02:00
Martin Willi 44fdc62f82 Move pkcs11 public key lookup function declaration to header file 2012-10-24 13:07:52 +02:00
Tobias Brunner 3c4d383443 Added an option to reload certificates from PKCS#11 tokens on SIGHUP 2012-10-18 14:42:09 +02:00
Tobias Brunner ca1c2ee281 Copy the name of pkcs11_library_t objects
Strings returned by settings_t.create_section_enumerator will be freed
when the config is reloaded.
2012-10-18 14:42:09 +02:00
Tobias Brunner a05f3b2021 Make sure first argument is an int when using %.*s to print e.g. chunks 2012-09-28 18:01:49 +02:00
Martin Willi e3b2e900e6 Add a return value to hasher_t.reset() 2012-07-16 14:55:06 +02:00
Martin Willi 87dd205b61 Add a return value to hasher_t.allocate_hash() 2012-07-16 14:55:06 +02:00
Martin Willi 8bd6a30af1 Add a return value to hasher_t.get_hash() 2012-07-16 14:55:06 +02:00
Tobias Brunner 39e807728e RNGs' get_bytes and allocate_bytes return boolean 2012-07-16 14:53:34 +02:00
Tobias Brunner 26d77eb3e6 Centralized thread cancellation in processor_t
This ensures that no threads are active when plugins and the rest of the
daemon are unloaded.

callback_job_t was simplified a lot in the process as its main
functionality is now contained in processor_t.  The parent-child
relationships were abandoned as these were only needed to simplify job
cancellation.
2012-06-25 17:38:59 +02:00
Tobias Brunner a190ec0ac5 Compiler warnings fixed. 2012-02-14 16:09:44 +01:00
Tobias Brunner 4de8f280e1 pkcs11: Fixed a bug when creating public keys. 2011-11-09 17:39:24 +01:00
Tobias Brunner f3eef176f4 Common spelling errors fixed. 2011-11-03 19:30:17 +01:00
Tobias Brunner 1bdd255ed3 pkcs11: Make public key operations on tokens optional. 2011-11-03 17:56:40 +01:00