Commit Graph

1577 Commits

Author SHA1 Message Date
Tobias Brunner 0cf3549675 revocation: Fix memory leak if fetching CRL/OCSP fails
We might get a 404 error page back.
2018-05-22 09:50:47 +02:00
Tobias Brunner cae43b890a revocation: Set defaults if CRL/OCSP checking is disabled in config 2018-05-22 09:50:47 +02:00
Tobias Brunner b00d3adbd1 revocation: Also store validation results for intermediate CA certificates
If the certificate is revoked, we immediately returned and the chain was
invalid, however, if we couldn't fetch the CRL that result was not stored
for intermediate CAs and we weren't able to enforce a strict CRL policy
later.
2018-05-22 09:50:47 +02:00
Tobias Brunner 13f76a241c revocation: Ignore CRLs that are not yet valid
Using such CRLs can be a problem if the clock on the host doing the
revocation check is trailing behind that of the host issuing CRLs in
scenarios where expired certificates are removed from CRLs.  As revoked
certificates that expired will then not be part of new CRLs a host with
trailing clock might still accept such a certificate if it is still
valid according to its system clock but is not contained anymore in the
not yet valid CRL.
2018-05-22 09:50:47 +02:00
Tobias Brunner 9c6b102ee0 openssl: Fail CRL validity check if thisUpdate is in the future 2018-05-22 09:50:47 +02:00
Tobias Brunner a0902d1ae0 x509: Fail CRL validity check if thisUpdate is in the future 2018-05-22 09:50:47 +02:00
Tobias Brunner 504e12326d openssl: Set IKE compliance flag depending on keyUsage 2018-05-22 09:50:47 +02:00
Tobias Brunner 920366e688 x509: Set IKE compliance flag depending on keyUsage 2018-05-22 09:50:47 +02:00
Tobias Brunner 667e74d60a bliss: Fix compilation with non-GNU C libraries
Not even the glibc man page mentions that type.

Fixes #2638.
2018-05-14 15:51:42 +02:00
Tobias Brunner 21553276a3 revocation: Make sure issuer of fetched CRL matches that of the certificate
Unless there is a cRLIssuer listed in the CDP, the CRL should be issued
by the same issuer as the checked certificate.

Fixes #2608.
2018-04-12 15:45:24 +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 9ba01ce380 x509: Fix leak if a CRL contains multiple authorityKeyIdentifiers 2018-02-21 11:13:42 +01:00
Tobias Brunner 2db6d5b8b3 Fixed some typos, courtesy of codespell 2018-02-13 12:19:54 +01:00
Tobias Brunner 4a84fb07ca gmp: Fix compatibility with older libgmp releases
Older releases don't have mpz_powm_sec() and mpz_inits() yet.

Fixes #2505.
2018-01-31 10:53:55 +01:00
Tobias Brunner 432358cf49 revocation: Skip any zero bytes when comparing serials in CRLs
Depending on the plugins that eventually parse the certificate and CRL,
serials with MSB set (i.e. negative numbers that have a zero byte prefixed
when encoded as ASN.1 INTEGER) might have (x509 plugin) or not have
(openssl plugin) a zero byte prefix when returned by get_serial() or
enumerated from the CRL.  Strip them before doing the comparison or
revocation checking might fail if not both credentials are parsed by the
same plugin (which should be rare and only happen if parsing of either
cert or CRL fails with one of the plugins and there is a fallback to the
implementation provided by the other plugin).

Fixes #2509.
2018-01-31 10:50:41 +01:00
Tobias Brunner 7a659c0f99 x509: Initialize signature params when parsing attribute certificates 2017-11-15 14:41:56 +01:00
Tobias Brunner be79839ea7 pkcs8: Add explicit comment for RSASSA-PSS fall-through 2017-11-15 14:33:05 +01:00
Tobias Brunner 364395d2de Treat RSASSA-PSS keys like rsaEncryption RSA keys
In theory we should treat any parameters and the identifier itself as
restriction to only use the key to create signatures accordingly (e.g.
only use RSA with PSS padding or even use specific hash algorithms).
But that's currently tricky as we'd have to store and pass this information
along with our private keys (i.e. use PKCS#8 to store them and change the
builder calls to pass along the identifier and parameters). That would
require quite some work.
2017-11-08 16:48:10 +01:00
Tobias Brunner fb63012e0c openssl: Add support for signature schemes with parameters 2017-11-08 16:48:10 +01:00
Tobias Brunner bbfe39f597 x509: Add support for signature schemes with parameters
Also adds support for specifying the hash algorithm for attribute
certificate signatures.
2017-11-08 16:48:10 +01:00
Tobias Brunner 024b979522 certificate: Return signature scheme and parameters from issued_by() method
This also required some include restructuring (avoid including library.h
in headers) to avoid unresolvable circular dependencies.
2017-11-08 16:48:10 +01:00
Tobias Brunner 37efb9787b gcrypt: Add support for static salts when signing with RSA-PSS 2017-11-08 16:48:10 +01:00
Tobias Brunner f241a981aa gmp: Add support for static salts when signing with RSA-PSS 2017-11-08 16:48:10 +01:00
Tobias Brunner 90a3bc5075 mgf1: Add support for SHA-224/384 based MGF1 2017-11-08 16:48:10 +01:00
Tobias Brunner 126fd8af09 gmp: Use helper to determine XOF type 2017-11-08 16:48:10 +01:00
Tobias Brunner 3ce8b0556a gcrypt: Add support for RSA-PSS signatures
For salt lengths other than 20 this requires 0bd8137e68c2 ("cipher:
Add option to specify salt length for PSS verification."), which was
included in libgcrypt 1.7.0 (for Ubuntu requires 17.04).  As that makes
it pretty much useless for us (SHA-1 is a MUST NOT), we require that version
to even provide the feature.
2017-11-08 16:48:10 +01:00
Tobias Brunner 89c3987baf gcrypt: Register supported RSA signature/verification schemes 2017-11-08 16:48:10 +01:00
Tobias Brunner 7d6b81648b gmp: Add support for RSASSA-PSS signature verification 2017-11-08 16:48:10 +01:00
Tobias Brunner 154ee7f66a gmp: Add support for RSASSA-PSS signature creation 2017-11-08 16:48:10 +01:00
Tobias Brunner 2f95d7195d openssl: Add support for verifying RSASSA-PSS signatures 2017-11-08 16:48:10 +01:00
Tobias Brunner 51dd2fd2db openssl: Add support for creating RSASSA-PSS signatures 2017-11-08 16:48:10 +01:00
Tobias Brunner 5ae3f5cea8 openssl: Add helper to determine EVP_MD from hash_algorithm_t 2017-11-08 16:48:10 +01:00
Tobias Brunner 183a9108fb gcrypt: Determine missing RSA private key parameters
We only need n, e, and d.  The primes p and q and the coefficient
for the Chinese remainder algorithm can be determined from these.
2017-11-08 16:48:10 +01:00
Tobias Brunner bd4df68a7b gmp: Determine missing RSA private key parameters
We only need n, e, and d.  The parameters for the Chinese remainder
algorithm and even p and q can be determined from these.
2017-11-08 16:48:10 +01:00
Tobias Brunner 03eda5a822 openssl: Add functions to determine missing RSA private key parameters
We only need n, e, and d.  The parameters for the Chinese remainder
algorithm and even p and q can be determined from these.
2017-11-08 16:48:10 +01: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 b2266280ef openssl: Also load EC keys from an ENGINE 2017-11-02 09:42:52 +01:00
Tobias Brunner 78acaba6a1 openssl: Fix call of X509_CRL_get0_signature() with OpenSSL 1.1.0
The order of arguments in X509_CRL_get0_signature() is not the same as that
of X509_get0_signature().

Fixes: 989ba4b6cd ("openssl: Update CRL API to OpenSSL 1.1.0")
2017-10-10 10:09:08 +02:00
Tobias Brunner 7e7800e0a3 bliss: Fix compile error of unit tests due to uninitialized variable 2017-09-18 12:16:54 +02: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 ddfb5dd44a plugin-loader: Correctly read dlopen_use_rtld_now option
Fixes: 305c4aa82c ("plugin-loader: Optionally use RTLD_NOW with dlopen()")
2017-09-18 12:07:26 +02:00
Tobias Brunner 86c10a958f openssl: Add support for delta CRLs 2017-09-18 10:54:31 +02:00
Tobias Brunner 4e7b7db62f certificates: Use shared destructor for x509_cdp_t 2017-09-18 10:54:19 +02:00
Tobias Brunner ed13c60c4f plugin-loader: Move indent variables into !USE_FUZZING block
This avoids compile errors on Travis.
2017-08-15 10:35:20 +02:00
Tobias Brunner ef5c37fcdf gmp: Fix RSA signature verification for m >= n
By definition, m must be <= n-1, we didn't enforce that and because
mpz_export() returns NULL if the passed value is zero a crash could have
been triggered with m == n.

Fixes CVE-2017-11185.
2017-08-14 08:49:33 +02:00
Tobias Brunner 1a75514b76 sha2: Write final hash directly to output buffer
This avoids having the last output in internal memory that's not wiped.

References #2388.
2017-08-07 16:55:33 +02:00
Tobias Brunner 67402ec77b curl: Enable following redirects
The maximum number of redirects can be limited. The functionality can also
be disabled.

Fixes #2366.
2017-07-27 13:15:43 +02:00
Andreas Steffen 49d56e1b39 imv-swima: Implemented SW event processing 2017-07-08 23:19:51 +02:00
Tobias Brunner d7dc677ee5 x509: Correctly encode nonce in OCSP request
The nonce value is encoded as OCTET STRING, however, the extension
values themselves must also be encoded as OCTET STRING.
2017-07-07 08:57:14 +02:00
Tobias Brunner 56ffcdb166 configure: Enable coverage for all plugins via PLUGIN_CFLAGS 2017-06-20 13:52:16 +02:00
Tobias Brunner e793d65acd openssl: Properly handle flags in key usage extension 2017-06-14 10:03:13 +02:00
Andreas Steffen 38a8ecadb7 x509: nameConstraints sequence does not require a loop
Fixes: CVE-2017-9023
2017-05-29 11:05:04 +02:00
Andreas Steffen 407fcca200 asn1-parser: Fix CHOICE parsing
Fixes: CVE-2017-9023
2017-05-29 11:05:04 +02:00
Tobias Brunner 6681d98d18 gmp: Make sure the modulus is odd and the exponent not zero
Unlike mpz_powm() its secure replacement mpz_powm_sec() has the additional
requirement that the exponent must be > 0 and the modulus has to be odd.
Otherwise, it will crash with a floating-point exception.

Fixes: CVE-2017-9022
Fixes: 3e35a6e7a1 ("Use side-channel secured mpz_powm_sec of libgmp 5, if available")
2017-05-29 11:05:04 +02:00
Tobias Brunner 2e4d110d1e linked-list: Change return value of find_first() and signature of its callback
This avoids the unportable five pointer hack.
2017-05-26 13:56:44 +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
Tobias Brunner 9c42126297 x509: Fix leak when parsing CDPs if an invalid one follows valid ones 2017-05-23 18:29:12 +02:00
Tobias Brunner b72718f4b8 pem: Ensure a value before checking Proc-Type in PEM header 2017-05-23 18:29:12 +02:00
Tobias Brunner 3963dbbde5 plugin-loader: Disable some logging output when building fuzz targets
This avoids evaluating %N. An alternative would be to define a printf-hook
for plugin features.
2017-05-23 18:29:12 +02:00
Tobias Brunner 92a10e4645 x509: Manually print CRL/OCSP URIs when fuzzing
This avoids a warning about the custom %Y printf specifier.
2017-05-23 18:29:12 +02:00
Tobias Brunner 8699275ed6 plugin-constructors: Add script to generate constructor registration
Using a Python script so this works in cross-compilation situations.
2017-05-23 18:29:12 +02:00
Tobias Brunner 1a06bf03f9 plugin-loader: Add facility to register plugin constructors
Enabled when building monolithically and statically.

This should allow us to work around the -whole-archive issue with
libtool.  If the libraries register the plugin constructors they provide
they reference the constructors and will therefore prevent the linker from
removing these seemingly unused symbols from the final executable.

For use cases where dlsym() can be used, e.g. because the static libraries
are manually linked with -whole-archive (Linux) or -force-load (Apple),
this can be disabled by passing ss_cv_static_plugin_constructors=no to
the configure script.
2017-05-23 18:29:12 +02:00
Tobias Brunner 30c03a7df9 pem: Don't read beyond line ends 2017-05-23 18:29:11 +02:00
Tobias Brunner 388351609d x509: Fix leak if there is an empty CDP 2017-05-23 18:29:11 +02:00
Tobias Brunner 5e37f7e550 x509: Fix leak if a certificate contains multiple authorityKeyIdentifiers 2017-05-23 18:29:11 +02:00
Baruch Siach 0727c8a533 af-alg: Fix crypt() definition conflict
Rename the crypt() method to avoid conflict with POSIX crypt(). Fixes the
following build failure with musl libc:

In file included from ../../../../src/libstrongswan/utils/utils.h:53:0,
                 from ../../../../src/libstrongswan/library.h:101,
                 from af_alg_ops.h:24,
                 from af_alg_ops.c:16:
af_alg_ops.c:110:22: error: conflicting types for 'crypt'
 METHOD(af_alg_ops_t, crypt, bool,
                      ^
../../../../src/libstrongswan/utils/utils/object.h:99:13: note: in definition of macro 'METHOD'
  static ret name(union {iface *_public; this;} \
             ^
In file included from af_alg_ops.c:18:0:
.../host/usr/x86_64-buildroot-linux-musl/sysroot/usr/include/unistd.h:144:7: note: previous declaration of 'crypt' was here
 char *crypt(const char *, const char *);
       ^

Closes strongswan/strongswan#72.
2017-05-15 16:33:21 +02:00
Andreas Steffen b0dcf33f0f x509: Evaluate return codes of parsing functions 2017-05-08 16:44:25 +02:00
Tobias Brunner 1003cf2330 Fixed some typos, courtesy of codespell 2017-03-23 18:29:18 +01:00
Martin Willi a115f48428 x509: Do not mark generated addrblock extension as critical
While RFC 3779 says we SHOULD mark it is critical, this has severe side effects
in practice. The addrblock extension is not widely used nor implemented, and
only a few applications can handle this extension. By marking it critical,
none of these applications can make use of such certificates where included
addrblocks do not matter, such as TLS/HTTPS.

If an application wants to make use of addrblocks, that is usually an explicit
decision. Then the very same application obviously can handle addrblocks, and
there is no need for the extension to be critical. In other words, for local
policy checks it is a local matter to handle the extension, hence making it
critical is usually not of much help.
2017-02-27 09:36:48 +01:00
Martin Willi 6734d7a51a x509: Support encoding the RFC 3779 addrblock extension 2017-02-27 09:36:48 +01:00
Tobias Brunner ac4942c3c3 plugin-loader: Fix hashing of registered plugin features
This strangely never caused any noticeable issues, but was the reason for
build failures in certain test cases (mostly BLISS) due to missing plugin
features when built with specific options on Travis (was not reproducible
locally).
2017-02-24 18:29:08 +01:00
Tobias Brunner 2de9bb30fe revocation: More accurately describe the flags to disable OCSP/CRL validation
These options disable validation as such, e.g. even from cached CRLs, not
only the fetching.  Also made the plugin's validate() implementation a
no-op if both options are disabled.
2017-02-15 10:41:38 +01:00
Tobias Brunner 1c27cf3bc8 bliss: Increase timeout for sampler unit test
Fixes #2204.
2017-01-16 11:28:10 +01:00
Andreas Steffen e3f63c6469 revocation: OCSP and/or CRL fetching can be disabled 2016-12-30 18:12:53 +01:00
Andreas Steffen 4f19112b1f Moved Ed25519 tests to libstrongswan 2016-12-14 11:57:36 +01:00
Andreas Steffen f2eb367adc Implemented EdDSA for IKEv2 using a pro forma Identity hash function 2016-12-14 11:15:48 +01:00
Andreas Steffen d47ad3d67e Added Ed25519 ref10 implementation from libsodium 2016-12-14 11:15:47 +01:00
Andreas Steffen 35bc60cc68 Added support of EdDSA signatures 2016-12-14 11:15:47 +01:00
Tobias Brunner f20b3f7b2c openssl: BoringSSL doesn't provide curve data for ECC Brainpool curves 2016-12-10 12:27:47 +01:00
Tobias Brunner 5078f87a52 plugin-loader: Strip '!' from critical plugin names when setting paths 2016-11-18 12:21:49 +01:00
Martin Willi bd0aa66e45 curve22519: Add a portable backend implemented in plain C 2016-11-14 16:20:51 +01:00
Martin Willi 7f9bfacd5a curve25519: Add a plugin providing Curve25519 DH using backend drivers 2016-11-14 16:20:51 +01:00
Martin Willi 1c26835a0a test-vectors: Add a Curve25519 DH test vector 2016-11-14 16:20:51 +01:00
Andreas Steffen cb8f436112 added XOF dependencies of bliss and ntru plugins 2016-10-18 16:28:43 +02:00
Tobias Brunner 8564535c23 newhope: Fix Doxygen group name 2016-10-14 18:41:25 +02:00
Tobias Brunner 955ce91652 Fixed some typos, courtesy of codespell 2016-10-14 18:09:09 +02:00
Tobias Brunner d3beae1311 newhope: Properly release allocated arrays if RNG can't be created 2016-10-14 15:24:04 +02:00
Tobias Brunner cee01fc9bf revocation: Cache valid CRL also if certificate is revoked 2016-10-11 17:18:22 +02:00
Tobias Brunner c72c6e9225 openssl: Fix AES-GCM with BoringSSL
BoringSSL only supports a limited list of (hard-coded) algorithms via
EVP_get_cipherbyname(), which does not include AES-GCM.  While BoringSSL
deprecated these functions they are also supported by OpenSSL (in BoringSSL
a completely new interface for AEADs was added, which OpenSSL currently does
not support).
2016-10-11 15:29:14 +02:00
Yannick CANN 5f97b73554 ldap: Fix crash in case of empty LDAP response for CRL fetch
In case of an empty LDAP result during a CRL fetch (for example, due to
a wrong filter attribute in the LDAP URI, or invalid LDAP configuration),
the call to ldap_result2error() with NULL value for "entry" lead to
a crash.

Closes strongswan/strongswan#52.
2016-10-06 18:08:51 +02:00
Tobias Brunner 4a6f97d00b openssl: Add a generic private key loader 2016-10-05 11:32:52 +02:00
Tobias Brunner 437610ace5 pkcs1: Support building of KEY_ANY private keys
We try to detect the type of key by parsing the basic structure of the
passed ASN.1 blob.
2016-10-05 11:32:52 +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
Andreas Steffen c54d1ef12c bliss sampler unit-test: Fixed enumeration type 2016-09-22 10:46:39 +02:00
Andreas Steffen a3a8b4acae bliss: bliss_sampler expects XOF type 2016-09-22 09:23:47 +02:00
Andreas Steffen 188b190a70 mgf1: Refactored MGF1 as an XOF 2016-09-21 06:40:52 +02:00
Tobias Brunner 15cbe526ac unbound: Avoid unnecessary cloning of RR list that caused a memory leak 2016-09-20 15:36:14 +02:00
Tobias Brunner 3a25032c16 unbound: Fix memory leak 2016-09-20 15:36:14 +02:00
Tobias Brunner fe4ed4578f padlock: Use builtin bswap32() to fix compilation on FreeBSD
Fixes #591.
2016-08-31 10:52:55 +02:00
Andreas Steffen 3bca51e430 unit-tests: Removed unused variable 2016-08-11 17:01:33 +02:00
Andreas Steffen 1342bd3386 unit-tests: Created newhope unit-tests 2016-08-10 14:22:00 +02:00
Andreas Steffen 393688aea0 Created newhope plugin implementing the New Hope key exchange algorithm 2016-08-10 14:22:00 +02:00
Andreas Steffen 1fddb0b92e xof: Added ChaCha20 stream as XOF 2016-08-06 12:09:05 +02:00
Andreas Steffen b8070e2c85 integrity-test: Added ntru_param_sets to read-only segment 2016-07-29 12:36:15 +02:00
Andreas Steffen 17e4ca6ac9 integrity-test: Added bliss_param_sets to read-only segment 2016-07-29 12:36:15 +02:00
Andreas Steffen 7256c68da0 integrity-test: check code and ro segments of libnttfft 2016-07-29 12:36:15 +02:00
Andreas Steffen d305f251a5 Created libnttfft
This makes Number Theoretic Transforms (NTT) based on the efficient
Fast-Fourier-Transform (FFT) available to multiple plugins.
2016-07-29 12:36:15 +02:00
Andreas Steffen 65f2ecb86d Share twiddle factors table between 512 and 1024 point FFT 2016-07-29 12:36:14 +02:00
Andreas Steffen 68075fb7a7 Implemented FFT with n = 1024 and q = 11289 using Montgomery arithmetic 2016-07-29 12:36:14 +02:00
Andreas Steffen a7d626118f bliss: Implemented FFT with fast Montgomery arithmetic 2016-07-29 12:36:14 +02:00
Andreas Steffen 5ff88c9622 xof: Implemented SHAKE128 and SHAKE256 Extended Output Functions 2016-07-29 12:36:14 +02:00
Andreas Steffen 04208ac5d4 xof: Defined Extended Output Functions 2016-07-29 12:36:14 +02:00
Andreas Steffen 5ce749bcfc unit-tests: Decreased loop count of FFT speed test to 10'000 2016-07-22 21:27:42 +02:00
Andreas Steffen 10ebb3c914 unit-tests: Added bliss_fft_speed test 2016-07-22 11:58:10 +02:00
Tobias Brunner 1fafc56b95 Fixed some typos, courtesy of codespell 2016-07-04 12:18:51 +02:00
Tobias Brunner 7c81219bb8 plugin-loader: Allow selective modification of the default plugin list
This change allows selectively modifying the default plugin list by setting
the `load` setting of individual plugins (e.g. to disable them or to change
their priority) without enabling charon.load_modular and having to configure
a section and a load statement for every plugin.
2016-06-29 11:16:48 +02:00
Tobias Brunner fedec33f5a openssl: Update GCM/crypter API to OpenSSL 1.1.0 2016-06-29 11:09:38 +02:00
Tobias Brunner 97b1a27f43 openssl: Update HMAC API to OpenSSL 1.1.0 2016-06-29 11:09:38 +02:00
Tobias Brunner cd08eb84cb openssl: Don't use deprecated RAND_pseudo_bytes() 2016-06-29 11:09:38 +02:00
Tobias Brunner 985d7b1c67 openssl: Update PKCS#12 API to OpenSSL 1.1.0 2016-06-29 11:09:37 +02:00
Tobias Brunner a9f388e368 openssl: Update PKCS#7 API to OpenSSL 1.1.0 2016-06-29 11:09:37 +02:00
Tobias Brunner 989ba4b6cd openssl: Update CRL API to OpenSSL 1.1.0
There is currently no way to compare the outer and inner algorithms
encoded in a parsed CRL.  X509_CRL_verify() does not seem to check that
either, though (unlike X509_verify()).
2016-06-29 11:09:37 +02:00
Tobias Brunner 08d7e1f190 openssl: Update x509 API to OpenSSL 1.1.0 2016-06-29 11:09:37 +02:00
Tobias Brunner 6688f7986e openssl: Update ECDSA API to OpenSSL 1.1.0 2016-06-29 11:09:37 +02:00
Tobias Brunner 3fb2c8edb7 openssl: Update RSA API to OpenSSL 1.1.0 2016-06-29 11:09:37 +02:00
Tobias Brunner 375a5ed240 openssl: Make some utilities take const BIGNUM pointers 2016-06-29 11:09:37 +02:00
Tobias Brunner 6d5df086f7 openssl: Add macro to define fallback functions for non-opaque OpenSSL versions 2016-06-29 11:09:37 +02:00
Tobias Brunner 54d629b7ad openssl: Update DH API to OpenSSL 1.1.0 2016-06-29 11:09:37 +02:00
Tobias Brunner 1b36fbedf5 openssl: Update crypter API to OpenSSL 1.1.0
EVP_CIPHER and EVP_CIPHER_CTX are now opaque types, the getters already
existed before.
2016-06-29 11:09:37 +02:00
Tobias Brunner faa904fb0b openssl: Fix mapping from ASN1 to chunk_t with OpenSSL 1.1.0
ASN1_OBJECT is now opaque.
2016-06-29 11:09:37 +02:00
Tobias Brunner e2abe7ae97 openssl: Update initialization and cleanup for OpenSSL 1.1.0
We can't call OPENSSL_cleanup() as that would prevent us from
re-initializing the library again (which we use in the Android app, that
loads/unloads plugins).
2016-06-29 11:09:36 +02:00
Tobias Brunner a6c43a8d8a openssl: OpenSSL 1.1.0 is thread-safe so we don't have to setup callbacks 2016-06-29 11:09:36 +02:00
Tobias Brunner a046f929ce android: Use non-aliased cipher identifiers
Some of these are also understood by BoringSSL.

Fixes #1510.
2016-06-13 10:38:20 +02:00
Tobias Brunner 9aaea4dbfe x509: Properly wrap keyid in authorityKeyIdentifier in attribute certificates
The correct encoding got lost in bdec2e4f52 ("refactored openac and
its attribute certificate factory").

Fixes #1370.
2016-06-06 13:46:11 +02:00
Martin Willi 294ac097d6 af-alg: Silently skip probing algorithms if AF_ALG is not supported
If the af-alg plugin is enabled, but kernel support is missing, we get
an error line during startup for each probed algorithm. This is way too
verbose, so just skip probing if AF_ALG is unsupported.
2016-05-19 11:13:24 +02:00
Tobias Brunner 689bb34958 curl: Add TLS support if libcurl is built against BoringSSL
We don't have to rely on the openssl plugin and its threading
initialization as BoringSSL is thread-safe out of the box.
2016-04-15 10:32:53 +02:00
Tobias Brunner 47a46be597 openssl: BoringSSL does not support configuration
The other initialization functions are still defined but many are
apparently no-ops (this is also true for the threading initialization).
2016-04-15 10:32:53 +02:00
Tobias Brunner c8a219a28d openssl: The member storing the DH exponent length has been renamed in BoringSSL 2016-04-15 10:32:53 +02:00
Tobias Brunner 77df573a95 openssl: Use proper EVP macro to determine size of a hash 2016-04-15 10:32:52 +02:00
Tobias Brunner de9b3491ad curl: Handle LibreSSL like OpenSSL in regards to multi-threading
LibreSSL is API compatible so our openssl plugin does not need any
changes and it works fine with the curl plugin.
2016-04-15 10:31:19 +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 aaa4e478b1 Use u_int32_t legacy type in blowfish header file 2016-03-24 20:58:32 +01:00
Andreas Steffen b12c53ce77 Use standard unsigned integer types 2016-03-24 18:52:48 +01:00
Andreas Steffen 87371460f6 vici: Support of raw public keys 2016-01-09 07:23:29 +01:00
Andreas Steffen a78e1c3b11 128 bit default security strength for IKE and ESP algorithms
The default ESP cipher suite is now
    AES_CBC-128/HMAC_SHA2_256_128
and requires SHA-2 HMAC support in the Linux kernel (correctly implemented
since 2.6.33).

The default IKE cipher suite is now
   AES_CBC-128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/ECP_256
if the openssl plugin is loaded or
   AES_CBC-128/HMAC_SHA2_256_128/PRF_HMAC_SHA2_256/MODP_3072
if ECC is not available.

The use of the SHA-1 hash algorithm and the MODP_2048 DH group has been
deprecated and ENCR_CHACHA20_POLY1305 has been added to the default
IKE AEAD algorithms.
2015-12-17 17:49:48 +01:00
Andreas Steffen 5e2b740a00 128 bit default security strength requires 3072 bit prime DH group 2015-12-14 10:39:40 +01:00
Andreas Steffen ef43df6cbe Allow msSmartcardLogon EKU to be built 2015-12-11 18:26:54 +01:00
Andreas Steffen fd90f0613c Print OCSP single responses 2015-12-11 18:26:53 +01:00
Martin Willi 8fa0c7bc77 byteorder: Add 32-bit unaligned little-endian conversion functions 2015-12-04 10:29:09 +01:00
Tobias Brunner e161238e8e revocation: Allow CRLs to be encoded in PEM format
Since the textual representation for a CRL is now standardized
in RFC 7468 one could argue that we should accept that too, even
though RFC 5280 explicitly demands CRLs fetched via HTTP/FTP to
be in DER format.  But in particular for file URIs enforcing that
seems inconvenient.

Fixes #1203.
2015-11-12 14:40:44 +01:00
Tobias Brunner 15d715dace curl: Be less strict when considering status codes as errors
For file:// URIs the code is 0 on success. We now do the same libcurl
would do with CURLOPT_FAILONERROR enabled.

Fixes #1203.
2015-11-12 14:40:37 +01:00
Tobias Brunner 305c4aa82c plugin-loader: Optionally use RTLD_NOW with dlopen()
This can be useful when writing custom plugins as typos or missing
linker flags that result in unresolved symbols in the shared object
could otherwise cause late crashes.  In particular, if such a symbol
is used in a code path that is rarely executed.  During development
and testing using RTLD_NOW instead of RTLD_LAZY will prevent the
plugin from getting loaded and makes the error visible immediately.
2015-11-09 14:37:08 +01:00
Andreas Steffen a88d958933 Explicitly mention SHA2 algorithm in BLISS OIDs and signature schemes 2015-11-06 14:55:31 +01:00
Andreas Steffen 83c1883d0b Use word-aligned XOR in sha3_absorb() 2015-11-03 21:35:09 +01:00
Andreas Steffen f6fede934b Support BLISS signatures with SHA-3 hash 2015-11-03 21:35:09 +01:00
Andreas Steffen a488584b5f Implemented SHA-3 hash algorithm including test vectors 2015-11-03 21:35:09 +01:00
Tobias Brunner 35dbf8af7a random: Properly handle errors when reading from /dev/[u]random
If -1 was returned on the first call to read() `done` got SIZE_MAX
and the function returned TRUE even though no actual random data had
been allocated.

Fixes #1156.
2015-10-29 16:17:17 +01:00
Tobias Brunner 5f18e2c371 openssl: Explicitly include openssl/bn.h
If OpenSSL is compiled with OPENSSL_NO_DEPRECATED some of the headers
we include don't include openssl/bn.h anymore.  Therefore, we have to
explicitly include it ourselves where we use BN_* functions.

Fixes #1113.
2015-09-16 11:57:52 +02:00
Tobias Brunner 7a1fed284c Fixed some typos, courtesy of codespell 2015-08-27 12:06:31 +02:00
Tobias Brunner c605a96d7f Fix some Doxygen issues 2015-08-27 12:03:11 +02:00
Tobias Brunner d6f70ff689 plugin-feature: Add vendor specific EAP method registration macros
Vendor specific EAP methods may be registered with:

    PLUGIN_CALLBACK(eap_method_register, <constructor>),
        PLUGIN_PROVIDE(EAP_SERVER_VENDOR, <type>, <vendor>),

Same for client implementations via EAP_PEER_VENDOR.

References #969.
2015-08-17 11:28:08 +02:00
Tobias Brunner 6967948241 Initialize variables that some compilers seem to warn about 2015-08-13 15:12:38 +02: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
Andreas Steffen e57190c312 Use MGF1 with SHA-512 as BLISS random oracle 2015-07-27 22:09:08 +02:00
Markku-Juhani Olavi Saarinen 7b7c510eec Generalize c_indices generation using SHA-512 random oracle.
This generalization allows the ring dimension n to be different
from the current n = 512 and allows kappa to be > 56. Also the
hash octets are consumed in a more consistent manner.
2015-07-27 19:51:51 +02:00
Markku-Juhani Olavi Saarinen 68d8a16830 Fixed several bugs in the BLISS signature generation/verification step.
The c_indices derived from the SHA-512 random oracle consist of
nine bits (0..511). The leftmost 8 bits of each index are taken
on an octet-by-octet basis from the 56 leftmost octets of the
SHA-512 hash. The 9th bit needed for the LSB is taken from the
extra_bits 64 bit unsigned integer which consists of the 8 rightmost
octets of the SHA-512 hash (in network order). If more than 56
indices must be derived then additional rounds of the random oracle
are executed until all kappa c_indices have been determined.

The bug fix shifts the extra_bits value by one bit in each loop
iteration so that the LSB of each index is random. Also iterate
through the hash array using the loop variable j not the c_indices
variable i.
2015-07-27 19:51:50 +02:00
Martin Willi fe5d6eaa9f chapoly: Process two Poly1305 blocks in parallel in SSSE3 driver
By using a derived key r^2 we can improve performance, as we can do loop
unrolling and slightly better utilize SIMD instructions.

Overall ChaCha20-Poly1305 performance increases by ~12%.

Converting integers to/from our 5-word representation in SSE does not seem
to pay off, so we work on individual words.
2015-07-12 13:25:50 +02:00
Martin Willi b499777cbf chapoly: Process four ChaCha20 blocks in parallel in SSSE3 driver
As we don't have to shuffle the state in each ChaCha round, overall performance
for ChaCha20-Poly1305 increases by ~40%.
2015-07-12 13:25:36 +02:00
Martin Willi 755dadcfda chapoly: Add an SSSE3 based driver
We always build the driver on x86/x64, but enable it only if SSSE3 support
is detected during runtime.

Poly1305 uses parallel 32-bit multiplication operands yielding a 64-bit result,
for which two can be done in parallel in SSE. This is minimally faster than
multiplication with 64-bit operands, and also works on 32-bit builds not having
a __int128 result type.

On a 32-bit architecture, this is more than twice as fast as the portable
driver, and on 64-bit it is ~30% faster.
2015-06-29 17:32:14 +02:00
Martin Willi bf86fd7ccc chapoly: Add a ChaCha20/Poly1305 driver implemented in portable C 2015-06-29 17:32:14 +02:00
Martin Willi 370fb3feb0 chapoly: Provide a generic ChaCha20/Poly1305 AEAD supporting driver backends 2015-06-29 17:32:14 +02:00
Martin Willi 82f7f5882f test-vectors: Add some initial ChaCha20/Poly1305 AEAD test vector 2015-06-29 17:32:14 +02:00
Tobias Brunner f9342fac8f openssl: Don't refer to EVP_des_ecb() if OpenSSL is built without DES support
While DES-ECB is not registered by the plugin in this case (so the
function will never actually be called), the compiler still warns
about the implicitly declared function.
2015-04-17 17:43:58 +02:00
Martin Willi 7d1ffe013d test-vectors: Define test vector symbols as extern
We don't actually define a vector, but only prototype the test vector
implemented in a different file. GCC uses the correct symbol during testing,
but clang correctly complains about duplicated symbols during linking.
2015-04-16 09:38:14 +02:00
Martin Willi 23947b2a4f aesni: Fix doxygen groups 2015-04-15 17:29:56 +02:00
Martin Willi 13a5a906e9 gcrypt: Explicitly initialize RNG backend to allocate static data
The libgcrypt RNG implementation uses static buffer allocation which it does
not free. There is no symbol we can catch in leak-detective, hence we explicitly
initialize the RNG during the whitelisted gcrypt_plugin_create() function.
2015-04-15 14:38:42 +02:00
Martin Willi 41421b85a9 gcrypt: Support setting private value and testing of DH backend 2015-04-15 14:38:42 +02:00
Martin Willi 0778c027a7 openssl: Support setting ECDH private values 2015-04-15 14:38:42 +02:00
Martin Willi e77ca5c79d openssl: Support setting private Diffie-Hellman values 2015-04-15 14:38:42 +02:00
Martin Willi 1a522d327e gmp: Support setting Diffie-Hellman private values 2015-04-15 14:38:41 +02:00
Martin Willi b8f576a803 test-vectors: Add DH vectors for Brainpool groups 2015-04-15 14:38:41 +02:00
Martin Willi 8b070b1b36 test-vectors: Add DH vectors for ECDH groups 2015-04-15 14:38:41 +02:00
Martin Willi 57f1ef220c test-vectors: Add DH vectors for subgroup MODP groups 2015-04-15 14:38:41 +02:00
Martin Willi e62906524c test-vectors: Add DH vectors for normal MODP groups 2015-04-15 14:38:39 +02:00
Martin Willi 79955b2b99 test-vectors: Support testing DH groups 2015-04-15 14:37:38 +02:00
Martin Willi 37794878cc aesni: Avoid loading AES/GHASH round keys into local variables
The performance impact is not measurable, as the compiler loads these variables
in xmm registers in unrolled loops anyway.

However, we avoid loading these sensitive keys onto the stack. This happens for
larger key schedules, where the register count is insufficient. If that key
material is not on the stack, we can avoid to wipe it explicitly after
crypto operations.
2015-04-15 13:44:40 +02:00
Martin Willi 93f0080265 aesni: Align all class instances to 16 byte boundaries
While the required members are aligned in the struct as required, on 32-bit
platforms the allocator aligns the structures itself to 8 bytes only. This
results in non-aligned struct members, and invalid memory accesses.
2015-04-15 13:44:40 +02:00
Martin Willi edab6c658c aesni: Calculate GHASH for 4 blocks of associated data in parallel
While associated data is usually not that large, in some specific cases
this can bring a significant performance boost.
2015-04-15 11:35:28 +02:00
Martin Willi 0eb593b0bb aesni: Calculate GHASH for 4 blocks of encryption data in parallel
Increases performance by another ~30%.
2015-04-15 11:35:28 +02:00
Martin Willi 58c44cdd00 aesni: Use 4-way parallel en/decryption in GCM
Increases overall performance by ~25%.
2015-04-15 11:35:28 +02:00
Martin Willi 677649cfb5 aesni: Use dedicated key size specific en-/decryption functions in GCM
This gives not much more than ~5% increase in performance, but allows us to
improve further.
2015-04-15 11:35:28 +02:00
Martin Willi 313811b72d aesni: Add a GCM AEAD based on the AES-NI key schedule 2015-04-15 11:35:28 +02:00
Martin Willi 4284660677 aesni: Implement CMAC mode to provide a signer/prf
Compared to the cmac plugin using AESNI-CBC as backend, this improves
performance of AES-CMAC by ~45%.
2015-04-15 11:35:28 +02:00
Martin Willi 9d187f8711 aesni: Implement XCBC mode to provide a signer/prf
Compared to the xcbc plugin using AESNI-CBC as backend, this improves
performance of AES-XCBC by ~45%.
2015-04-15 11:35:28 +02:00
Martin Willi d48642b7eb aesni: Partially use separate code paths for different key sizes in CCM
Due to the serial nature of the CBC mac, this brings only a marginal speedup.
2015-04-15 11:35:28 +02:00
Martin Willi 1ae46dfba2 aesni: Add a CCM AEAD reusing the key schedule 2015-04-15 11:35:27 +02:00