Commit Graph

14299 Commits

Author SHA1 Message Date
Andreas Steffen 63d370387d vici: Certification Authority support added.
CDP and OCSP URIs for a one or multiple certification authorities
can be added via the VICI interface. swanctl allows to read
definitions from a new authorities section.
2015-07-21 13:02:30 +02:00
Andreas Steffen e194349148 vici: Compute rekey_bytes and rekey_packets if life_bytes and life_packets are defined 2015-07-20 21:34:09 +02:00
Tobias Brunner 170e8d141c testing: Do not attempt to start the test environment if hosts are still running 2015-07-15 16:53:37 +02:00
Tobias Brunner 390ae7a2c2 ike-sa-manager: Safely access the RNG instance with an rwlock
Threads might still be allocating SPIs (e.g. triggered by an acquire or
an inbound message) while the main thread calls flush().  If there is a
context switch right after such a thread successfully checked this->rng
in get_spi() and the main thread destroys the RNG instance right then,
that worker thread will cause a segmentation fault when it continues and
attempts to call get_bytes().

Fixes #1014.
2015-07-14 15:25:23 +02:00
Martin Willi 856ea64129 vici: Asynchronize debug logging
The vici logger uses the listener_t.log() callback to raise vici events.

When doing so, it holds the bus lock as reader while acquiring the vici socket
mutex (1). If at the same time the vici socket enables a writer, that thread
tries to lock the watcher mutex (2). The watcher thread uses debugging while
holding the lock, i.e. acquires the bus read lock (3).

(1) bus.rlock -> vici.lock!
(2) vici.lock -> watcher.lock!
(3) watcher.lock -> bus.rlock!

This all actually would resolve just fine, as we have a shared read lock on the
bus. However, under Windows we seem to have a strict writer preference when
acquiring the rwlock (4). This results in blocking read locks until any pending
write lock can be fulfilled, and makes the constellation deadlock. The relevant
threads are:

Thread (1)
6  0x71313d25 in wait_ at threading/windows/mutex.c:137
7  0x7054c8a2 in find_entry at vici_socket.c:201
8  0x7054d690 in send_ at vici_socket.c:624
9  0x7054f6c1 in send_op at vici_dispatcher.c:119
10 0x705502c1 in raise_event at vici_dispatcher.c:469
12 0x704c3878 in log_cb at bus/bus.c:332
13 0x712c7c3a in invoke_function at collections/linked_list.c:414
14 0x704c3a63 in vlog at bus/bus.c:400
15 0x704c3b36 in log_ at bus/bus.c:430
18 0x70508f1f in process_response at sa/ikev2/task_manager_v2.c:664
20 0x704f5430 in process_message at sa/ike_sa.c:1369
21 0x704e3823 in execute at processing/jobs/process_message_job.c:74
22 0x712e629f in process_job at processing/processor.c:235

Thread (2)
4  0x71313b61 in lock at threading/windows/mutex.c:66
5  0x712e81fd in add at processing/watcher.c:441
6  0x712e1ab9 in add_watcher at networking/streams/stream.c:213
7  0x712e1b4d in on_write at networking/streams/stream.c:237
8  0x7054d606 in _cb_enable_writer at vici_socket.c:609
9  0x712e5e34 in execute at processing/jobs/callback_job.c:77
10 0x712e629f in process_job at processing/processor.c:235

Thread (3)
3  0x71313f38 in read_lock at threading/windows/rwlock.c:74
4  0x704c3971 in vlog at bus/bus.c:373
5  0x704cc156 in dbg_bus at daemon.c:126
6  0x712e7bf9 in watch at processing/watcher.c:316
7  0x712e5e34 in execute at processing/jobs/callback_job.c:77
8  0x712e629f in process_job at processing/processor.c:235

Thread (4)
3  0x71313f70 in write_lock at threading/windows/rwlock.c:82
4  0x704c378b in remove_logger at bus/bus.c:290
5  0x704cb284 in listener_unregister at control/controller.c:166
6  0x713136cd in thread_cleanup_pop at threading/windows/thread.c:558
8  0x704cb94e in initiate at control/controller.c:435
9  0x70553996 in _cb_initiate at vici_control.c:187
12 0x7054d200 in _cb_process_queue at vici_socket.c:508
13 0x712e5e34 in execute at processing/jobs/callback_job.c:77
14 0x712e629f in process_job at processing/processor.c:235

To avoid such a situation, we dissolve the (1) lock sequence. It's actually
never good practice to acquire shared locks during bus hooks, as it is
problematic if we raise bus events while holding the lock. We do so by
raising vici events for log message asynchronously, but of curse must keep
log order as is using a synchronized queue.
2015-07-12 13:57:48 +02:00
Martin Willi 3232c0e64e Merge branch 'chapoly'
Add ChaCha20/Poly1305 AEAD support in IKEv2 and libipsec ESP through the
chapoly plugin, and in kernel ESP SAs starting with Linux 4.2.
2015-07-12 13:55:08 +02:00
Martin Willi 396607987a NEWS: Add ChaCha20/Poly1305 news 2015-07-12 13:54:08 +02:00
Martin Willi 918dfce551 testing: Enable AESNI/PCLMULQD in moon/sun guests, if supported 2015-07-12 13:54:08 +02:00
Martin Willi 2a75c6e487 testing: Do not overwrite kernel configuration if it already exists
This allows us to do changes to the kernel configuration using menuconfig
and friends, and update the kernel with make-testing.
2015-07-12 13:54:08 +02:00
Martin Willi a4a13d0be2 testing: Extract and patch each kernel version only once
This allows us to do modifications to the kernel tree and rebuild that kernel
using make-testing. We can even have a git kernel tree in a directory to
do kernel development.
2015-07-12 13:54:08 +02:00
Martin Willi 6f913def3c testing: Build with --enable-chapoly 2015-07-12 13:54:08 +02:00
Martin Willi c6d60f4808 libipsec: Add a unit-test for ESP encryption using ChaCha20Poly1305 2015-07-12 13:54:08 +02:00
Martin Willi 29e3544f1f libipsec: Add a unit-test test runner 2015-07-12 13:54:08 +02:00
Martin Willi 98aa6aa344 unit-tests: Add a IKEv2 message encryption test case
It uses the ChaCha20Poly1305 test vectors from
draft-ietf-ipsecme-chacha20-poly1305-06.
2015-07-12 13:54:03 +02:00
Martin Willi 80d7f44198 unit-tests: Increase failure message buffer to hold larger hex dumps 2015-07-12 13:25:50 +02:00
Martin Willi ee9f691915 unit-tests: Forward variable argument list in TEST_SUITE_DEPEND
For some plugin features, such as crypters or AEADs, we have some additional
feature arguments, such as the key size.
2015-07-12 13:25:50 +02:00
Martin Willi 88d90c7b4b unit-tests: Load libstrongswan plugins in libcharon tests 2015-07-12 13:25: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 42459b41f0 configure: Check if building against a x86/x64 architecture
This allows us to include compiler flags specific for them, such as MMX/SSE.
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
Martin Willi 405c5dcd82 kernel-netlink: Add ChaCha20-Poly1305 AEAD support 2015-06-29 17:32:14 +02:00
Martin Willi 19e0a71c73 libipsec: Create AEAD with four byte salt for ChaCha20-Poly1305 2015-06-29 17:32:13 +02:00
Martin Willi 6ffaa8626e ikev2: Derive additional 4 byte CHILD_SA nonce keymat for ChaCha20-Poly1305 2015-06-29 17:32:13 +02:00
Martin Willi bbcb76e260 ikev2: Use four byte salt for ChaCha20-Poly1305 AEAD 2015-06-29 17:32:13 +02:00
Martin Willi b211f283b7 proposal: Add a chacha20poly1305 proposal keyword 2015-06-29 17:32:13 +02:00
Martin Willi 9e110cc54c crypter: Define a ChaCha20/Poly1305 AEAD algorithm identifier 2015-06-29 17:32:03 +02:00
Tobias Brunner b01b331afe capabilities: Handle ERANGE in user and group lookups
As it turns out, getpwnam_r, getgrnam_r, and friends will return
ERANGE if _any_ user or group on the system is larger than will fit
into the scratch buffer you pass to them.

This reworks the resolve_uid and resolve_gid methods plus
init_supplementary_groups to use a variable-size buffer that is grown
until the results fit.

Based on a patch by Evan Broder.

Closes strongswan/strongswan#12.
2015-06-23 10:03:38 +02:00
Martin Willi 5fbc709224 osx: Version bump to 5.3.2-1 2015-06-18 10:37:21 +02:00
Martin Willi 88b60c3349 osx: Use CodeSignOnCopy for privileged helper, as suggested by XCode 2015-06-18 10:36:05 +02:00
Martin Willi 0f1d6b34b3 charon-xpc: Use DNS non-append/replace mode in osx-attr plugin 2015-06-18 10:36:04 +02:00
Martin Willi 61d6cdb926 osx-attr: Optionally replace existing DNS server instead of appending them 2015-06-18 10:36:04 +02:00
Tobias Brunner d13c8f8f7f Remove accidentally added stamp-h1
Was added in bc47488323 ("Add a return value to prf_t.get_bytes()").
2015-06-15 14:17:28 +02:00
Tobias Brunner f146104736 settings: Fix out-of-tree build
The header file was created in the source directory before, where it
wasn't found by the generated C files in the build directory.
2015-06-11 12:34:55 +02:00
Tobias Brunner 2d5b3d34ec stroke: Add missing include for UINT16_MAX
Fixes the build on FreeBSD.

Fixes #988.
2015-06-09 10:25:33 +02:00
Andreas Steffen 3ea5d437fb Version bump to 5.3.2 2015-06-08 09:56:34 +02:00
Tobias Brunner 2b19e51707 NEWS: Add info about CVE-2015-4171 2015-06-05 13:44:43 +02:00
Martin Willi 0020b25a45 ikev2: Enforce remote authentication config before proceeding with own authentication
Previously the constraints in the authentication configuration of an
initiator were enforced only after all authentication rounds were
complete.  This posed a problem if an initiator used EAP or PSK
authentication while the responder was authenticated with a certificate
and if a rogue server was able to authenticate itself with a valid
certificate issued by any CA the initiator trusted.

Because any constraints for the responder's identity (rightid) or other
aspects of the authentication (e.g. rightca) the initiator had were not
enforced until the initiator itself finished its authentication such a rogue
responder was able to acquire usernames and password hashes from the client.
And if a client supported EAP-GTC it was even possible to trick it into
sending plaintext passwords.

This patch enforces the configured constraints right after the responder's
authentication successfully finished for each round and before the initiator
starts with its own authentication.

Fixes CVE-2015-4171.
2015-06-05 13:44:42 +02:00
Martin Willi a49393954f child-sa: Use any fixed reqid configured on the CHILD_SA config
Global reqid allocation (94eb09ac) broke fixed reqid allocation. Resupport them
by bypassing allocation in the kernel if a fixed reqid has been configured.

Fixes #976.
2015-06-05 13:44:42 +02:00
Tobias Brunner 523ea82ed5 unit-tests: Add tests for iv_gen_seq_t 2015-06-05 13:44:42 +02:00
Martin Willi b756eea4f4 ivgen: Allow reusing the same message ID twice in sequential IV gen
We use the message ID and fragment number as IV generator. As IKEv2 uses
distinct message ID counters for actively and passively initiated exchanges,
each IV would be used twice. As we explicitly reject such message IDs since
d0ed1079, original-responder initiated exchanges fail with counter mode ciphers.

This commit separates IV space in two halves for sequential IVs, and
automatically assigns once reused sequence numbers to the second half.

Fixes #980.
2015-06-05 13:44:42 +02:00
Andreas Steffen 9bb7307825 Fix timeattack script compilation under ARM 2015-06-05 12:09:38 +02:00
Andreas Steffen bd60bcc3c2 Updated SWID attribute list 2015-06-02 06:51:41 +02:00
Andreas Steffen f284c17890 Version bump to 5.3.1 2015-06-01 09:50:48 +02:00
Tobias Brunner 099260d8fd NEWS: Add info about CVE-2015-3991 2015-06-01 09:42:11 +02:00
Tobias Brunner 541543dbfe message: Log message if unknown/disallowed payload received 2015-06-01 09:42:11 +02:00
Tobias Brunner e67161fe9e message: Log original message type of unknown payloads 2015-06-01 09:42:11 +02:00