Commit Graph

14082 Commits

Author SHA1 Message Date
Martin Willi aa9b74931f Merge branch 'const-memeq'
Introduce constant time memory comparing functions for cryptographic purposes,
and a tool to test such functions or crypto transforms relying on them.
2015-04-14 12:02:51 +02:00
Martin Willi 161a015782 utils: Use chunk_equals_const() for all cryptographic purposes 2015-04-14 12:02:51 +02:00
Martin Willi 9d6e952201 utils: Add a constant time chunk_equals() variant for cryptographic purposes 2015-04-14 12:02:48 +02:00
Martin Willi 71afe0a556 utils: Use memeq_const() for all cryptographic purposes 2015-04-14 11:53:31 +02:00
Martin Willi b833963270 utils: Add a constant time memeq() variant for cryptographic purposes 2015-04-14 11:51:54 +02:00
Martin Willi 39e1ddec2e scripts: Add a tool that tries to guess MAC/ICV values using validation times
This tool shows that it is trivial to re-construct the value memcmp() compares
against by just measuring the time the non-time-constant memcmp() requires to
fail.

It also shows that even when running without any network latencies it gets
very difficult to reconstruct MAC/ICV values, as the time variances due to the
crypto routines are large enough that it gets difficult to measure the time
that memcmp() actually requires after computing the MAC.

However, the faster/time constant an algorithm is, the more likely is a
successful attack. When using AES-NI, it is possible to reconstruct (parts of)
a valid MAC with this tool, for example with AES-GCM.

While this is all theoretical, and way more difficult to exploit with network
jitter, it nonetheless shows that we should replace any use of memcmp/memeq()
with a constant-time alternative in all sensitive places.
2015-04-14 11:51:54 +02:00
Martin Willi b17f0beda8 Merge branch 'cpu-features'
Centralize all uses of CPUID to a cpu_feature class, which in theory can support
optional features of non-x86/x64 as well using architecture specific code.
2015-04-13 15:31:59 +02:00
Martin Willi 6a84a4049d sqlite: Use our locking mechanism also when sqlite3_threadsafe() returns 0
We previously checked for older library versions without locking support at
all. But newer libraries can be built in single-threading mode as well, where
we have to care about the locking.
2015-04-13 15:31:58 +02:00
Martin Willi 63d1e5b930 rdrand: Reuse CPU feature detection to check for RDRAND instructions 2015-04-13 15:31:58 +02:00
Martin Willi 4e621ada96 sqlite: Show SQLite library version and thread safety flag during startup 2015-04-13 15:31:58 +02:00
Martin Willi 137079b56f padlock: Reuse common CPU feature detection to check for Padlock features 2015-04-13 15:31:58 +02:00
Martin Willi 793851856b cpu-feature: Support Via Padlock security features 2015-04-13 15:31:58 +02:00
Martin Willi f155880eda cpu-feature: Add a common class to query available CPU features
Currently supported is x86/x64 via cpuid() for some common features.
2015-04-13 15:31:58 +02:00
Martin Willi d20be3fa28 vici: Defer read/write error reporting after connection entry has been released
If a vici client registered for (control-)log events, but a vici read/write
operation fails, this may result in a deadlock. The attempt to write to the
bus results in a vici log message, which in turn tries to acquire the lock
for the entry currently held.

While a recursive lock could help as well for a single thread, there is still
a risk of inter-thread races if there is more than one thread listening for
events and/or having read/write errors.

We instead log to a local buffer, and write to the bus not before the connection
entry has been released. Additionally, we mark the connection entry as unusable
to avoid writing to the failed socket again, potentially triggering an error
loop.
2015-04-13 15:08:10 +02:00
Martin Willi 3c81cb6fc3 aead: Create AEAD using traditional transforms with an explicit IV generator
Real AEADs directly provide a suitable IV generator, but traditional crypters
do not. For some (stream) ciphers, we should use sequential IVs, for which
we pass an appropriate generator to the AEAD wrapper.
2015-04-13 15:06:15 +02:00
Martin Willi a4549e5525 iv-gen: Add a generic constructor to create an IV gen from an algorithm 2015-04-13 15:06:15 +02:00
Martin Willi c2906c8f21 openssl: Don't pre-initialize OpenSSL HMAC with an empty key
With OpenSSL commit 929b0d70c19f60227f89fac63f22a21f21950823 setting an empty
key fails if no previous key has been set on that HMAC.

In 9138f49e we explicitly added the check we remove now, as HMAC_Update()
might crash if HMAC_Init_ex() has not been called yet. To avoid that, we
set and check a flag locally to let any get_mac() call fail if set_key() has
not yet been called.
2015-04-13 14:52:30 +02:00
Martin Willi 7394ad92ae thread: Remove unneeded thread startup synchronization
sem_init() is deprecated on OS X, and it actually fails with ENOSYS. Using our
wrapped semaphore object is not an option, as it relies on the thread cleanup
that we can't rely on at this stage.

It is unclear why startup synchronization is required, as we can allocate the
thread ID just before creating the pthread. There is a chance that we allocate
a thread ID for a thread that fails to create, but the risk and consequences
are negligible.
2015-04-13 14:50:45 +02:00
Martin Willi 101d67440f libsimaka: Link against Winsock2 on Windows
The library makes use of htons/ntohs().
2015-04-13 09:31:28 +02:00
Martin Willi 280f752c56 fips-prf: Remove superfluous <arpa/inet.h> include
As we make no use of htonl() and friends, this is unneeded, but actually
prevents a Windows build.
2015-04-13 09:31:28 +02:00
Martin Willi dad99b5eea kernel-netlink: Fix GCC error about uninitialized variable use
get_replay_state() always returns a replay_state_len when returning a
replay state, but GCC doesn't know about that.
2015-04-08 11:13:04 +02:00
Martin Willi 12def59617 asn1: Undefine TIME_UTC, which is used by C11
When building with C11 support, TIME_UTC is used for timespec_get() and
defined in <time.h>. Undefine TIME_UTC for our own internal use in asn1.c.
2015-04-08 08:47:31 +02:00
Andreas Steffen ff96400d13 Wipe auxiliary key store 2015-03-28 10:44:23 +01:00
Martin Willi 9310d4250a crypto-tester: Explicitly exclude FIPS-PRF from append mode tests
This was implicitly done by the seed length check before 58dda5d6, but we
now require an explicit check to avoid that unsupported use.
2015-03-28 08:38:52 +01:00
Martin Willi b234fdfce8 fips-prf: Fail when trying to use append mode on FIPS-PRF
Append mode hardly makes sense for the special stateful FIPS-PRF, which is
different to other PRFs.
2015-03-28 08:36:35 +01:00
Andreas Steffen b07fb365ef Added PB-TNC test options to strongswan.conf man page 2015-03-27 21:05:00 +01:00
Andreas Steffen 883c11caa0 Added tnc/tnccs-20-fail-init and tnc/tnccs-20-fail-resp scenarios 2015-03-27 20:56:44 +01:00
Andreas Steffen ef5f96366e Version bump to 5.3.0 2015-03-27 20:56:44 +01:00
Andreas Steffen 619e0b4235 Fixed PB-TNC error handling 2015-03-27 20:56:44 +01:00
Andreas Steffen 193e057509 Added configurations for 3.18 and 3.19 KMV guest kernels 2015-03-27 20:56:44 +01:00
Andreas Steffen 8b36323b8c Fixed strongswan.conf man page entry of imc-attestation 2015-03-27 20:56:44 +01:00
Andreas Steffen 85aa509e84 Added tnc/tnccs-20-pt-tls scenario 2015-03-27 20:56:43 +01:00
Martin Willi bc1876bc9a cmac: Reset state before doing set_key() 2015-03-27 16:07:53 +01:00
Martin Willi 4075e9d7a4 af-alg: Reset hmac/xcbc state before doing set_key() 2015-03-27 16:06:21 +01:00
Martin Willi eedd92b53b xcbc: Reset XCBC state in set_key()
If some partial data has been appended, a truncated key gets invalid if it
is calculated from the pending state.
2015-03-27 15:53:52 +01:00
Martin Willi bfb029c82a hmac: Reset the underlying hasher before doing set_key() with longer keys
The user might have done a non-complete append, having some state in the
hasher.

Fixes #909.
2015-03-27 15:53:50 +01:00
Martin Willi 58dda5d6ab crypto-tester: Test set_key() after a doing a partial append on prf/signers
While that use is uncommon in real-world use, nonetheless should HMAC set a
correct key and reset any underlying hasher.
2015-03-27 15:53:47 +01:00
Tobias Brunner c063b9cfe9 stroke: Properly parse bliss key strength in public key constraint 2015-03-25 13:27:15 +01:00
Tobias Brunner 328db935bb eap-tnc: Free eap-tnc object if IKE_SA not found to get IPs 2015-03-25 13:24:37 +01:00
Tobias Brunner 97c7dc6d14 tnccs-20: Fix error handling in build() 2015-03-25 13:23:14 +01:00
Tobias Brunner f4c37166f9 android: Add messages/ita directory to tnccs-20 plugin 2015-03-25 12:00:20 +01:00
Tobias Brunner 48bae7b2ba android: Sync libstrongswan Makefile.am and Android.mk 2015-03-25 12:00:20 +01:00
Tobias Brunner 4a5d958bc5 libtnccs: Set apidoc category to libtnccs and move plugins 2015-03-25 12:00:20 +01:00
Tobias Brunner 48087e0944 libtnccs: Fix apidoc category for split IF-TNCCS 2.0 header files
Fixes 80322d2cee ("Split IF-TNCCS 2.0 protocol processing into
separate TNC client and server handlers").
2015-03-25 12:00:20 +01:00
Tobias Brunner a2ec3b0546 Fixed some typos, courtesy of codespell 2015-03-25 12:00:20 +01:00
Tobias Brunner a3c2edb19c kernel-netlink: Copy current usage stats to new SA in update_sa()
This is needed to fix usage stats sent via RADIUS Accounting if clients
use MOBIKE or e.g. the kernel notifies us about a changed NAT mapping.
The upper layers won't expect the stats to get reset if only the IPs have
changed (and some kernel interface might actually allow such updates
without reset).

It also fixes traffic based lifetimes in such situations.

Fixes #799.
2015-03-25 12:00:20 +01:00
Tobias Brunner 70728eb1b6 child-sa: Add a new state to track rekeyed IKEv1 CHILD_SAs
This is needed to handle DELETEs properly, which was previously done via
CHILD_REKEYING, which we don't use anymore since 5c6a62ceb6 as it prevents
reauthentication.
2015-03-25 12:00:20 +01:00
Martin Willi 66147ef670 ikev1: Inverse check when applying received KE value during Quick Mode
Fixes Quick Mode negotiation when PFS is in use.
2015-03-24 09:37:38 +01:00
Andreas Steffen cf9befcba4 Version bump to 5.3.0rc1 2015-03-23 23:15:31 +01:00
Andreas Steffen be04f90815 testing: added tnc/tnccs-20-mutual scenario 2015-03-23 23:01:13 +01:00