]> git.ipfire.org Git - thirdparty/strongswan.git/log
thirdparty/strongswan.git
5 years agoopenssl: Use consistent ifdefs to disable x25519/448
Tobias Brunner [Thu, 2 Jul 2020 12:09:32 +0000 (14:09 +0200)] 
openssl: Use consistent ifdefs to disable x25519/448

When compiling with OPENSSL_NO_ECDH but without OPENSSL_NO_EC the build
failed.

5 years agoMerge branch 'vici-ca-certs'
Tobias Brunner [Mon, 20 Jul 2020 12:07:47 +0000 (14:07 +0200)] 
Merge branch 'vici-ca-certs'

These changes store all CA certificates in vici_authority_t, which avoids
issues with unloading authority sections or clearing credentials.

Closes strongswan/strongswan#172.

5 years agovici: Keep track of all CA certificates in vici_authority_t
Tobias Brunner [Wed, 20 May 2020 14:50:11 +0000 (16:50 +0200)] 
vici: Keep track of all CA certificates in vici_authority_t

This way we only have one reference for each CA certificate, whether it
is loaded in an authority section, a connection or via load-certs() command.
It also avoids enumerating CA certificates multiple times if they are
loaded in different ways.

5 years agoobject: Add helper for callbacks with two void pointers
Tobias Brunner [Wed, 20 May 2020 15:34:39 +0000 (17:34 +0200)] 
object: Add helper for callbacks with two void pointers

5 years agovici: Make attribute certificates untrusted again
Tobias Brunner [Wed, 20 May 2020 13:25:51 +0000 (15:25 +0200)] 
vici: Make attribute certificates untrusted again

Fixes: 334119b843d7 ("Share vici_cert_info.c with vici_cred.c")
5 years agovici: Clear credential cache when unloading an authority section
Tobias Brunner [Wed, 20 May 2020 13:05:44 +0000 (15:05 +0200)] 
vici: Clear credential cache when unloading an authority section

5 years agovici: Directly provide CA certificates in authority sections
Tobias Brunner [Wed, 20 May 2020 12:40:51 +0000 (14:40 +0200)] 
vici: Directly provide CA certificates in authority sections

With the previous approach, CA certificates that were not re-loaded via
load-cert() (e.g. from tokens or via absolute paths) would not be available
anymore after the clear-creds() command was used.  This avoids this
issue, but can cause duplicate CA certificates to get stored and enumerated,
so there might be a scaling factor.

5 years agocertificate: Extract helper function to filter certificates
Tobias Brunner [Wed, 20 May 2020 12:25:33 +0000 (14:25 +0200)] 
certificate: Extract helper function to filter certificates

5 years agoMerge branch 'ordered-hashtable'
Tobias Brunner [Mon, 20 Jul 2020 12:01:22 +0000 (14:01 +0200)] 
Merge branch 'ordered-hashtable'

This changes the hashtable implementation to that it maintains insertion
order.  This is then used in the vici plugin to store connections in a
hash table instead of a linked list, which makes managing them quite a
bit faster if there are lots of connections.

The old implementation is extracted into a new class (hashlist_t), which
optionally supports sorting keys and provides the previous get_match()
function.

5 years agohashtable: Use quadratic probing
Tobias Brunner [Fri, 24 Apr 2020 17:11:25 +0000 (19:11 +0200)] 
hashtable: Use quadratic probing

This reduces the clustering problem (primary clustering) but is not
completely free of it (secondary clustering) it still reduces the maximum
and average probing lengths.

5 years agovici: Store configs in a hashtable
Tobias Brunner [Fri, 24 Apr 2020 13:16:26 +0000 (15:16 +0200)] 
vici: Store configs in a hashtable

This makes updates more efficient if many configs are loaded. Configs
still have to be enumerated to select them.

5 years agohashtable: Maintain insertion order when enumerating
Tobias Brunner [Fri, 24 Apr 2020 13:51:17 +0000 (15:51 +0200)] 
hashtable: Maintain insertion order when enumerating

With the previous approach we'd require at least an additional pointer
per item to store them in a list (15-18% increase in the overhead per
item).  Instead we switch from handling collisions with overflow lists to
an open addressing scheme and store the actual table as variable-sized
indices pointing into an array of all inserted items in their original
order.

This can reduce the memory overhead even compared to the previous
implementation (especially for smaller tables), but because the array for
items is preallocated whenever the table is resized, it can be worse for
certain numbers of items.  However, avoiding all the allocations required
by the previous design is actually a big advantage.

Depending on the usage pattern, the performance can improve quite a bit (in
particular when inserting many items).  The raw lookup performance is a bit
slower as probing lengths increase with open addressing, but there are some
caching benefits due to the compact storage.  So for general usage the
performance should be better.  For instance, one test I did was counting the
occurrences of words in a list of 1'000'000 randomly selected words from a
dictionary of ~58'000 words (i.e. using a counter stored under each word as
key).  The new implementation was ~8% faster on average while requiring
10% less memory.

Since we can't remove items from the array (would change the indices of all
items that follow it) we just mark them as removed and remove them once the
hash table is resized/rehashed (the cells in the hash table for these may
be reused).  Due to this the latter may also happen if the number of stored
items does not increase e.g. after a series of remove/put operations (each
insertion requires storage in the array, no matter if items were removed).
So if the capacity is exhausted, the table is resized/rehashed (after lots
of removals the size may even be reduced) and all items marked as removed
are simply skipped.

Compared to the previous implementation the load factor/capacity is
lowered to reduce chances of collisions and to avoid primary clustering to
some degree.  However, the latter in particular, but the open addressing
scheme in general, make this implementation completely unsuited for the
get_match() functionality (purposefully hashing to the same value and,
therefore, increasing the probing length and clustering).  And keeping the
keys optionally sorted would complicate the code significantly.  So we just
keep the existing hashlist_t implementation without adding code to maintain
the overall insertion order (we could add that feature optionally later, but
with the mentioned overhead for one or two pointers).

The maximum size is currently not changed.  With the new implementation
this translates to a hard limit for the maximum number of items that can be
held in the table (=CAPACITY(MAX_SIZE)).  Since this equals 715'827'882
items with the current settings, this shouldn't be a problem in practice,
the table alone would require 20 GiB in memory for that many items.  The
hashlist_t implementation doesn't have that limitation due to the overflow
lists (it can store beyond it's capacity) but it itself would require over
29 GiB of memory to hold that many items.

5 years agohashlist: Move get_match() and sorting into a separate class
Tobias Brunner [Fri, 24 Apr 2020 11:41:53 +0000 (13:41 +0200)] 
hashlist: Move get_match() and sorting into a separate class

The main intention here is that we can change the hashtable_t
implementation without being impeded by the special requirements imposed
by get_match() and sorting the keys/items in buckets.

5 years agounit-tests: Pass test iteration to fixtures
Tobias Brunner [Fri, 24 Apr 2020 12:45:21 +0000 (14:45 +0200)] 
unit-tests: Pass test iteration to fixtures

5 years agohashtable: Optionally collect and report profiling data
Tobias Brunner [Fri, 24 Apr 2020 08:56:50 +0000 (10:56 +0200)] 
hashtable: Optionally collect and report profiling data

5 years agohashtable: Optionally sort keys/items in buckets in a specific way
Tobias Brunner [Fri, 24 Apr 2020 06:50:24 +0000 (08:50 +0200)] 
hashtable: Optionally sort keys/items in buckets in a specific way

This can improve negative lookups, but is mostly intended to be used
with get_match() so keys/items can be matched/enumerated in a specific
order.  It's like storing sorted linked lists under a shared key but
with less memory overhead.

5 years agohashtable: Store items in buckets in insertion order
Tobias Brunner [Fri, 24 Apr 2020 06:30:03 +0000 (08:30 +0200)] 
hashtable: Store items in buckets in insertion order

This is more predictable when using get_match() in particular because
the order does not change anymore when the table is rehashed.

5 years agounit-tests: Add tests for larger number of items in hashtables
Tobias Brunner [Fri, 24 Apr 2020 06:02:59 +0000 (08:02 +0200)] 
unit-tests: Add tests for larger number of items in hashtables

5 years agounit-tests: Optionally report the times test cases ran
Tobias Brunner [Thu, 16 Apr 2020 16:05:37 +0000 (18:05 +0200)] 
unit-tests: Optionally report the times test cases ran

5 years agokernel-netlink: Ignore preference for temporary addresses for IPv6 VIPs
Tobias Brunner [Tue, 7 Jul 2020 08:01:46 +0000 (10:01 +0200)] 
kernel-netlink: Ignore preference for temporary addresses for IPv6 VIPs

They are not marked as temporary addresses so make sure we always return
them whether temporary addresses are preferred as source addresses or not
as we need to enumerate them when searching for addresses in traffic selectors
to install routes.

Fixes: 9f12b8a61c47 ("kernel-netlink: Enumerate temporary IPv6 addresses according to config")
5 years agocharon-nm: Set DPD/close action to restart and enable indefinite keying tries
Tobias Brunner [Mon, 18 May 2020 12:17:24 +0000 (14:17 +0200)] 
charon-nm: Set DPD/close action to restart and enable indefinite keying tries

We don't track CHILD_SA down events anymore and rely on NM's initial timeout
to let the user know if the connection failed initially.  So we also don't
have to explicitly differentiate between initial connection failures and
later ones like we do an Android.  Also, with the default retransmission
settings, there will only be one keying try as NM's timeout is lower than
the combined retransmission timeout of 165s.

There is no visual indicator while the connection is reestablished later.

Fixes #3300.

5 years agovici: With start_action=start, terminate IKE_SA without children on unload
Tobias Brunner [Wed, 1 Jul 2020 11:49:58 +0000 (13:49 +0200)] 
vici: With start_action=start, terminate IKE_SA without children on unload

This includes IKE_SAs in CONNECTING state, which not yet have any
CHILD_SAs.

Closes strongswan/strongswan#175.

5 years agoeap-radius: Small spelling fix
Boris Vanhoof [Sat, 27 Jun 2020 08:32:19 +0000 (10:32 +0200)] 
eap-radius: Small spelling fix

Closes strongswan/strongswan#174.

5 years agotesting: Skip tests with missing files, don't abort the test run
Tobias Brunner [Tue, 23 Jun 2020 14:24:18 +0000 (16:24 +0200)] 
testing: Skip tests with missing files, don't abort the test run

This allows simple test configs in testing/tests/local that are no
actual test cases.

5 years agoVersion bump to 5.9.0dr2 5.9.0dr2
Andreas Steffen [Sun, 14 Jun 2020 10:15:44 +0000 (12:15 +0200)] 
Version bump to 5.9.0dr2

5 years agotesting: Fix SQL scenarios after preferring AEAD for ESP
Tobias Brunner [Fri, 5 Jun 2020 13:54:15 +0000 (15:54 +0200)] 
testing: Fix SQL scenarios after preferring AEAD for ESP

sql/net2net-route|start-pem seem to be the only ones that configure a
proposal via database.

5 years agotesting: Fix ikev2/net2net-fragmentation scenario
Tobias Brunner [Fri, 5 Jun 2020 13:46:49 +0000 (15:46 +0200)] 
testing: Fix ikev2/net2net-fragmentation scenario

The IKE_AUTH message from moon is now larger because of the AEAD proposal.

5 years agoike: Send AEAD ESP default proposal first
Tobias Brunner [Fri, 5 Jun 2020 09:12:06 +0000 (11:12 +0200)] 
ike: Send AEAD ESP default proposal first

We generally prefer AEAD nowadays.

References #3461.

5 years agoproposal: Add AES-GCM to the ESP default AEAD proposal
Tobias Brunner [Fri, 5 Jun 2020 09:01:29 +0000 (11:01 +0200)] 
proposal: Add AES-GCM to the ESP default AEAD proposal

References #3461.

5 years agoikev2: Ensure ALERT_RETRANSMIT_SEND_CLEARED is triggered
Tobias Brunner [Fri, 29 May 2020 12:58:36 +0000 (14:58 +0200)] 
ikev2: Ensure ALERT_RETRANSMIT_SEND_CLEARED is triggered

If a MOBIKE task is deferred, the retransmission counter is reset to 0
when reinitiating.  So if there were retransmits before, this alert would
not be triggered if a response is received now without retransmits.

5 years agotravis: Don't pipe negative lgtm.com result into jq
Tobias Brunner [Thu, 11 Jun 2020 08:29:11 +0000 (10:29 +0200)] 
travis: Don't pipe negative lgtm.com result into jq

The data might not be valid JSON.

5 years agoikev1: Ensure local IP is known as identity fallback during Main Mode
Tobias Brunner [Mon, 8 Jun 2020 15:13:50 +0000 (17:13 +0200)] 
ikev1: Ensure local IP is known as identity fallback during Main Mode

We usually have a local IP already via ike_sa_t::resolve_hosts() before
build_i() is called but if that's not the case, it's more likely we have
one after we processed the first response (it might also have changed).
There is a potential chance we still don't have one if the socket API
doesn't provide us with the destination address of received messages,
but that seems not very likely nowadays.

5 years agoVersion bump to 5.9.0dr1 5.9.0dr1
Andreas Steffen [Sat, 6 Jun 2020 13:02:42 +0000 (15:02 +0200)] 
Version bump to 5.9.0dr1

5 years agochild-create: Don't reset DH group when retrying after INVALID_KE_PAYLOAD
Tobias Brunner [Fri, 5 Jun 2020 14:41:23 +0000 (16:41 +0200)] 
child-create: Don't reset DH group when retrying after INVALID_KE_PAYLOAD

migrate() is called before retrying.

Fixes: 0184a69b7b14 ("child-create: Properly handle DH group during
migration when reestablishing")

5 years agoikev1: Fix PSK lookup for Main Mode initiators
Tobias Brunner [Fri, 5 Jun 2020 12:07:43 +0000 (14:07 +0200)] 
ikev1: Fix PSK lookup for Main Mode initiators

We need the PSK/identity already when deriving the keys in process_i().

Fixes: 1665a4e0504f ("ikev1: Use actual local identity as initiator or aggressive mode responder")
5 years agoike: Fix retransmission timeouts if base is <= 1
Tobias Brunner [Fri, 5 Jun 2020 11:43:11 +0000 (13:43 +0200)] 
ike: Fix retransmission timeouts if base is <= 1

Fixes: 72b282cf202d ("ike: Properly support high number of retransmission tries")
5 years agoandroid: New release after improving connectivity/scheduling
Tobias Brunner [Tue, 2 Jun 2020 12:55:58 +0000 (14:55 +0200)] 
android: New release after improving connectivity/scheduling

5 years agotravis: Add build of the Android app
Tobias Brunner [Thu, 14 May 2020 16:14:59 +0000 (18:14 +0200)] 
travis: Add build of the Android app

5 years agoandroid: Suppress linting error in manifest related to cert import activity
Tobias Brunner [Thu, 14 May 2020 13:55:36 +0000 (15:55 +0200)] 
android: Suppress linting error in manifest related to cert import activity

<data> tags that only specify the mimeType attribute are perfectly fine
according to the docs.

5 years agoandroid: Ignore some missing quantity lint errors
Tobias Brunner [Thu, 14 May 2020 12:47:26 +0000 (14:47 +0200)] 
android: Ignore some missing quantity lint errors

Once these strings are translated and the quantities are defined, this
attribute can be removed again.

5 years agoandroid: Mock parseInetAddress() method to fix unit tests
Tobias Brunner [Wed, 13 May 2020 14:02:08 +0000 (16:02 +0200)] 
android: Mock parseInetAddress() method to fix unit tests

The native parseInetAddressBytes() method called by that method is not
available when running the tests.

Not very pretty and there are some warnings because PowerMock does
reflection in some illegal way but it fixes the unit tests and does
not require any new dependencies like Apache Commons or Guava just to
parse IP addresses without DNS lookup.

Fixes: 2ef473be1532 ("android: Use helper to parse IP addresses where appropriate")
Fixes #3443.

5 years agoMerge branch 'android-scheduler'
Tobias Brunner [Tue, 2 Jun 2020 12:18:42 +0000 (14:18 +0200)] 
Merge branch 'android-scheduler'

Starting with Android 6, the system will aggressively suspend apps when
the device is idle (Doze mode).  With Android 10 on a Pixel 4 this seems
to happen after about 70 minutes.  Then the scheduler thread in our
default scheduler is only woken rarely, combined with our previous use
of the monotonic clock it meant that events were executed with severe
delays and noticing that there was such a delay.  This was particularly
bad in regards to NAT keepalives as it usually meant that the device was
not reachable anymore from the outside.

Some changes here try to improve that situation, e.g. the clock is switched
to CLOCK_REALTIME (Bionic doesn't support CLOCK_BOOTTIME for condvars) so we
can measure the actual difference e.g. since the last outbound message,
other changes try to ensure that connectivity is restored after being asleep
for a while (send DPD instead of keepalive after a long delay, send DPD even
if path to peer stays the same).

However, the most significant change is the replacement of the default
scheduler with one specifically designed for Android.  It schedules
long-term events via AlarmManager, which allows waking up the app even
if the system put it to sleep.  The latter requires adding the app to the
system's battery optimization whitelist, which is requested from the
user automatically if necessary.  With this, NAT keepalives and rekeyings
are now scheduled accurately, with little changes to the battery usage.
If the app is not whitelisted (there is a setting to ignore this), events
are delayed by up to 15 minutes after about 70 minutes, so behind a NAT
the device won't be reachable from the outside afterwards (connectivity
should be restored as soon as the device is woken from deep sleep by the
user).

Fixes #3364.

5 years agoandroid: Add a preference flag to ignore battery optimizations
Tobias Brunner [Mon, 11 May 2020 13:49:22 +0000 (15:49 +0200)] 
android: Add a preference flag to ignore battery optimizations

This allows users to ignore whether the app is on the device's power
whitelist without a warning.  The flag is currently not set
automatically if the user denies the request.

5 years agoandroid: Increase lifetimes a bit
Tobias Brunner [Fri, 8 May 2020 12:33:05 +0000 (14:33 +0200)] 
android: Increase lifetimes a bit

This should avoid clashes of soft and hard lifetimes even if the app is
not whitelisted.

5 years agoandroid: Ask user to add our app to the device's power whitelist
Tobias Brunner [Fri, 8 May 2020 10:17:52 +0000 (12:17 +0200)] 
android: Ask user to add our app to the device's power whitelist

This is necessary so we can actually schedule events accurately in Doze
mode. Otherwise, we'd only get woken in intervals of several minutes (up to
15 according to the docs) after about an hour.

5 years agoandroid: Use the default scheduler for short-term events
Tobias Brunner [Sat, 2 May 2020 07:20:59 +0000 (09:20 +0200)] 
android: Use the default scheduler for short-term events

Using AlarmManager has quite some overhead, so we use our regular
scheduler for events that are to be executed in the near future.

5 years agoandroid: Use Android-specific scheduler on Android 6 and later
Tobias Brunner [Fri, 1 May 2020 09:15:38 +0000 (11:15 +0200)] 
android: Use Android-specific scheduler on Android 6 and later

5 years agoandroid: Add Android-specific implementation of scheduler_t
Tobias Brunner [Thu, 30 Apr 2020 16:55:23 +0000 (18:55 +0200)] 
android: Add Android-specific implementation of scheduler_t

This uses AlarmManager to schedule events in a way that ensures the app
is woken up (requires whitelisting when in Doze mode to be woken up at
the exact time, otherwise there are delays of up to 15 minutes).

5 years agoscheduler: Use timercmp(3) instead of a custom function
Tobias Brunner [Fri, 27 Mar 2020 14:34:32 +0000 (15:34 +0100)] 
scheduler: Use timercmp(3) instead of a custom function

5 years agoike: Only track actually sent retransmits as outbound packets
Tobias Brunner [Thu, 30 Apr 2020 15:42:07 +0000 (17:42 +0200)] 
ike: Only track actually sent retransmits as outbound packets

Retransmission jobs for old requests for which we already received a
response previously left the impression that messages were sent more
recently than was actually the case.

task_manager_t always defined INVALID_STATE as possible return value if
no retransmit was sent, this just was never actually returned.

I guess we could further differentiate between actual invalid states
(e.g. if we already received the response) and when we don't send a
retransmit for other reasons e.g. because the IKE_SA became stale.

5 years agoandroid: Change how initial log handler is registered
Tobias Brunner [Tue, 31 Mar 2020 12:56:38 +0000 (14:56 +0200)] 
android: Change how initial log handler is registered

Previously, if the two utility functions were called while the VPN
connection was established (i.e. charon was initialized) the logger for
libstrongswan would get reset to the initial log handler.  So certain
log messages would not get logged to the log file after the TUN device
was created (one of the helpers is used to convert IPs there).

5 years agoandroid: Check the current path using DPD after a roaming event
Tobias Brunner [Thu, 19 Mar 2020 15:08:07 +0000 (16:08 +0100)] 
android: Check the current path using DPD after a roaming event

A new NAT mapping might be created even if the IP stays the same.  Due to
the DPD fallback with NAT keep-alives this might only be necessary in
corner cases, if at all.

5 years agoike: Optionally use DPD to check if the current path still works
Tobias Brunner [Thu, 19 Mar 2020 15:04:01 +0000 (16:04 +0100)] 
ike: Optionally use DPD to check if the current path still works

We could maybe check the duration of the last stale condition or when
the last packet was sent as filter to avoid unnecessary updates.

5 years agoandroid: Enable switch from NAT interval to DPDs after 20 seconds
Tobias Brunner [Thu, 19 Mar 2020 12:48:31 +0000 (13:48 +0100)] 
android: Enable switch from NAT interval to DPDs after 20 seconds

5 years agoike: Add an option to trigger a DPD instead of a NAT keepalive
Tobias Brunner [Thu, 19 Mar 2020 12:39:48 +0000 (13:39 +0100)] 
ike: Add an option to trigger a DPD instead of a NAT keepalive

This is useful on Android where the app might not be able to send
keep-alives if the device is asleep for a while.  If the NAT mapping
has been deleted in the mean time, the NAT-D payloads allow detecting
this and connectivity can be restored by doing a MOBIKE update or
recreating the SA if the peer already deleted it because the client
wasn't reachable.

5 years agoandroid: Switch to CLOCK_REALTIME on Android
Tobias Brunner [Thu, 19 Mar 2020 13:22:56 +0000 (14:22 +0100)] 
android: Switch to CLOCK_REALTIME on Android

This allows measuring the delay between events more accurately if a
device is often suspended.

While CLOCK_BOOTTIME would be preferable, Android's bionic C library
does not support it for condvars.

5 years agotime: Allow using different clocks
Tobias Brunner [Thu, 19 Mar 2020 13:19:22 +0000 (14:19 +0100)] 
time: Allow using different clocks

On some systems it might be preferable to use e.g. CLOCK_BOOTTIME
instead of CLOCK_MONOTONIC, which is also not affected by time
adjustments but includes times when the system was suspended.

5 years agomutex: Don't use ...timedwait_monotonic() if clock is set via attribute
Tobias Brunner [Wed, 1 Apr 2020 08:17:27 +0000 (10:17 +0200)] 
mutex: Don't use ...timedwait_monotonic() if clock is set via attribute

This allows using clocks other than CLOCK_MONOTONIC.

5 years agoike: Track NAT-keepalives as outbound packets
Tobias Brunner [Thu, 19 Mar 2020 10:25:37 +0000 (11:25 +0100)] 
ike: Track NAT-keepalives as outbound packets

5 years agoandroid: Fix app icon on Android versions < 5.0
Tobias Brunner [Wed, 15 Jan 2020 13:12:07 +0000 (14:12 +0100)] 
android: Fix app icon on Android versions < 5.0

XML resources are apparently not supported there.  Moving the icon to
the mipmap folders should fix that.  Aliases are defined for the icons on
Android < 8.0.

5 years agoandroid: Update Gradle plugin
Tobias Brunner [Wed, 15 Jan 2020 12:58:47 +0000 (13:58 +0100)] 
android: Update Gradle plugin

5 years agoandroid: Again change how data source is handled in TileService
Tobias Brunner [Mon, 21 Oct 2019 13:12:05 +0000 (15:12 +0200)] 
android: Again change how data source is handled in TileService

Evidently, onClick() may be called either before onStartListening() or
after onStopListening() has been called, which causes a crash when
trying to load a VpnProfile via mDataSource.

This partially reverts 3716af079e21 ("android: Avoid crash related to
TileService on Huawei devices").

5 years agotravis: Bump tpm2-tss to 2.4.1
Tobias Brunner [Mon, 25 May 2020 12:29:44 +0000 (14:29 +0200)] 
travis: Bump tpm2-tss to 2.4.1

Manually built dependencies are now built in a separate step after
packages have been installed as they might depend themselves on some
packages (e.g. tpm2-tss, which now requires libjson-c).

5 years agocharon-nm: Allow configurable remote traffic selectors
Thomas [Sun, 24 May 2020 11:54:31 +0000 (13:54 +0200)] 
charon-nm: Allow configurable remote traffic selectors

This change allows to customize the previously hard-coded remote traffic
selectors.

This does not actually write the newly added "remote-ts" configuration option
into NetworkManager's configuration file, but will use an existing value.
Exposing the config setting in the GUI could be done later if this is a
desired change.

Use case:  remote firewall appliance wrongly accepts the `0.0.0.0/0` TS but
does not actually route external traffic, leaving the user with a partially
working internet connection.

Closes strongswan/strongswan#173.

5 years agoikev2: Return to the original host if connection fails after redirection
Tobias Brunner [Tue, 19 May 2020 08:07:18 +0000 (10:07 +0200)] 
ikev2: Return to the original host if connection fails after redirection

If we fail connecting to the host we got redirected to, we should restart
with the original host where we might get redirected to a different host.

We must not reset this when retrying due to INVALID_KE_PAYLOAD or COOKIE
notifies.  Since we keep the initiator SPI in those cases, we use that
flag as indicator.

Since we don't store the original remote_host value, we can't restore
that.  So there is a potential conflict with MIPv6.

Closes strongswan/strongswan#171.

5 years agonm: Version bump to 1.5.2
Tobias Brunner [Tue, 19 May 2020 14:14:49 +0000 (16:14 +0200)] 
nm: Version bump to 1.5.2

5 years agonm: Move server port to options tab and position tabs to the left
Tobias Brunner [Mon, 18 May 2020 14:38:51 +0000 (16:38 +0200)] 
nm: Move server port to options tab and position tabs to the left

Also shortened the title of the proposal tab.  This saves some additional
screen space.

Fixes #3448.

5 years agonm: Use tabs for options/proposals to save screen space
Tobias Brunner [Mon, 18 May 2020 09:26:08 +0000 (11:26 +0200)] 
nm: Use tabs for options/proposals to save screen space

The height of the dialog increased due to the recently added additional
fields for certificate selection and identities.  On some screens the
fields to configure custom proposals were not visible anymore.
Together with less spacing on the top level GtkBox this change reduces
the height by about 80 pixels.

Fixes #3448.

5 years agonm: Migrate appdata to metainfo
Tobias Brunner [Mon, 11 May 2020 07:48:27 +0000 (09:48 +0200)] 
nm: Migrate appdata to metainfo

The path '/usr/share/appdata' is deprecated as is the .appdata.xml
extension, files should be in installed in '/usr/share/metainfo' with
a .metainfo.xml extension.

According to the docs, the metainfo path should be well supported even
by older distros like Ubuntu 16.04.

Reference: 2.1.2. Filesystem locations
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html

5 years agonm: Version bump to 1.5.1
Tobias Brunner [Fri, 8 May 2020 16:09:32 +0000 (18:09 +0200)] 
nm: Version bump to 1.5.1

5 years agocharon-nm: Clear secrets when disconnecting
Tobias Brunner [Fri, 8 May 2020 08:33:55 +0000 (10:33 +0200)] 
charon-nm: Clear secrets when disconnecting

The need_secrets() method is called before connect() (where we clear the
previous secrets too), so e.g. a password-protected private could be
decrypted with the cached password from earlier but if the password was not
stored with the connection, it would later fail as no password was requested
from the user that could be passed to connect().

References #3428.

5 years agonm: Fix password entry for private keys and allow saving it
Tobias Brunner [Tue, 28 Apr 2020 17:09:15 +0000 (19:09 +0200)] 
nm: Fix password entry for private keys and allow saving it

On newer desktops the auth dialog is called with --external-ui-mode and
it seems that the password flag has to be set, otherwise the password is
not stored temporarily in the profile and passed to charon-nm (not sure
how this works exactly as need_secrets() is called multiple times even
after the password was already entered, only before doing so the last
time is the password available in that callback, but only if the flag
was set).  This now also allows storing the password for the private key
with the profile.

Fixes #3428.

5 years agoike: Properly support high number of retransmission tries
Tobias Brunner [Thu, 2 Apr 2020 13:48:31 +0000 (15:48 +0200)] 
ike: Properly support high number of retransmission tries

Due to the exponential backoff a high number of retransmits only
makes sense if retransmit_limit is set.  However, even with that there
was a problem.

We first calculated the timeout for the next retransmit and only then
compared that to the configured limit.  Depending on the configured
base and timeout the calculation overflowed the range of uint32_t after
a relatively low number of retransmits (with the default values after 23)
causing the timeout to first get lower (on a high level) before constantly
resulting in 0 (with the default settings after 60 retransmits).

Since that's obviously lower than any configured limit, all remaining
retransmits were then sent without any delay, causing a lot of concurrent
messages if the number of retransmits was high.

This change determines the maximum number of retransmits until an
overflow occurs based on the configuration and defaults to UINT32_MAX
if that value is exceeded.  Note that since the timeout is in milliseconds
UINT32_MAX equals nearly 50 days.

The calculation in task_manager_total_retransmit_timeout() uses a double
variable and the result is in seconds so the maximum number would be higher
there (with the default settings 1205).  However, we want its result to
be based on the actual IKE retransmission behavior.

5 years agoike-auth: Add option to use EAP-only authentication without notify
Tobias Brunner [Tue, 7 Apr 2020 16:49:00 +0000 (18:49 +0200)] 
ike-auth: Add option to use EAP-only authentication without notify

Some peers apparently don't send the notify and still expect to
authenticate with EAP-only authentication.  This option allows forcing
the configured use of EAP-only authentication in that scenario.

5 years agochild-create: Properly handle DH group during migration when reestablishing
Tobias Brunner [Wed, 1 Apr 2020 07:48:56 +0000 (09:48 +0200)] 
child-create: Properly handle DH group during migration when reestablishing

If such a task was active while reestablishing it will get queued on the
new IKE_SA.  If the DH group is already set, the DH groups won't be
stripped from the proposals and a KE payload will be sent, which is invalid
during IKE_AUTH.  We don't want to reset the group if the task is part of a
child-rekey task.

5 years agoikev1: Use actual local identity as initiator or aggressive mode responder
Tobias Brunner [Thu, 9 Apr 2020 08:14:42 +0000 (10:14 +0200)] 
ikev1: Use actual local identity as initiator or aggressive mode responder

If none is configured, there is a fallback to the IP address, which is
not stored on the static auth config, but is set on the IKE_SA.

Fixes #3394.

5 years agoikev1: Store fallback identity (IP address) on IKE_SA's auth-cfg
Tobias Brunner [Tue, 7 Apr 2020 14:59:28 +0000 (16:59 +0200)] 
ikev1: Store fallback identity (IP address) on IKE_SA's auth-cfg

The other auth-cfg object is shared via peer-cfg, so we must not
modify it.  It's only stored to simplify memory management.

Fixes #3394.

5 years agolookip: Use line buffering for stdout
Tobias Brunner [Wed, 8 Apr 2020 14:39:28 +0000 (16:39 +0200)] 
lookip: Use line buffering for stdout

Otherwise, the output is buffered when e.g. piping the output to another
command (or file).  And it avoids having to call fflush() in the
interactive mode.

Fixes #3404.

5 years agotravis: Bump wolfSSL to 4.4.0
Tobias Brunner [Thu, 23 Apr 2020 06:58:41 +0000 (08:58 +0200)] 
travis: Bump wolfSSL to 4.4.0

SHA-3 is only automatically enabled on x86/x64.  The tests are disabled
because we don't need them and they currently cause a compile warning/error
when built with clang on x64 (sizeof() on a pointer to an array).  If the
examples are enabled, another test suite is built, which includes the
disabled crypto tests.

5 years agowolfssl: Add support for Ed448
Tobias Brunner [Thu, 23 Apr 2020 08:39:55 +0000 (10:39 +0200)] 
wolfssl: Add support for Ed448

5 years agowolfssl: Add support for x448 Diffie-Hellman
Tobias Brunner [Thu, 23 Apr 2020 08:26:33 +0000 (10:26 +0200)] 
wolfssl: Add support for x448 Diffie-Hellman

5 years agofile-logger: Set owner/group of log file
Tobias Brunner [Tue, 14 Apr 2020 08:31:49 +0000 (10:31 +0200)] 
file-logger: Set owner/group of log file

The file is usually opened/created by root, however, if user/group IDs
are configured and the configuration is reloaded, the file will be reopened
as configured user.  Like with UNIX sockets we only attempt to change
the user if we have CAP_CHOWN allowing a start as regular user.

We don't have chown() on Windows, so check for it.

5 years agoxfrmi: Only build if libcharon is built
Tobias Brunner [Tue, 14 Apr 2020 08:44:19 +0000 (10:44 +0200)] 
xfrmi: Only build if libcharon is built

The kernel-netlink plugin is only built if libcharon is.

Closes strongswan/strongswan#167.

5 years agopkcs11: Optionally hash data for PKCS#1 v1.5 RSA signatures in software
Tobias Brunner [Mon, 4 May 2020 07:45:39 +0000 (09:45 +0200)] 
pkcs11: Optionally hash data for PKCS#1 v1.5 RSA signatures in software

If cards/libraries don't support signature mechanisms with hashing, we fall
back to do it ourselves in software and pass the PKCS#1 digestInfo ASN.1
structure to sign via CKM_RSA_PKCS mechanism.

Closes strongswan/strongswan#168.

5 years agoscripts: Initialize libstrongswan in id2sql to fix a crash
Tobias Brunner [Mon, 4 May 2020 14:56:47 +0000 (16:56 +0200)] 
scripts: Initialize libstrongswan in id2sql to fix a crash

Since 770f4ccee12d ("identification: Optionally match RDNs in any order
and accept missing RDNs") the DN parser requires lib->settings.

5 years agovici: Allow maximum vici message size configuration via compile option
Thomas Egerer [Tue, 7 Apr 2020 18:35:57 +0000 (20:35 +0200)] 
vici: Allow maximum vici message size configuration via compile option

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
5 years agoUse Botan 2.14.0 for tests
Tobias Brunner [Tue, 7 Apr 2020 08:07:30 +0000 (10:07 +0200)] 
Use Botan 2.14.0 for tests

Requires at least GCC 5.0 to build with `--amalgamation`, so it's
disabled for our Ubuntu 16.04 build.

5 years agoVersion bump to 5.8.4 5.8.4
Andreas Steffen [Sun, 29 Mar 2020 10:49:13 +0000 (12:49 +0200)] 
Version bump to 5.8.4

5 years agoopenssl: Allow squeezing multiple times from SHAKE128/256 XOFs
Tobias Brunner [Thu, 26 Mar 2020 12:52:47 +0000 (13:52 +0100)] 
openssl: Allow squeezing multiple times from SHAKE128/256 XOFs

OpenSSL currently doesn't support squeezing bytes out of an XOF multiple
times.  Unfortunately, EVP_DigestFinalXOF() completely resets the context
and later calls not simply fail, they cause a null-pointer dereference in
libcrypto.  This fixes the crash at the cost of repeating initializing
the whole state and allocating too much data for subsequent calls.

There is an open issue and PR that might add a function that allows
squeezing more data from an XOF in a future version of OpenSSL.

5 years agocharon-nm: Allow using fixed source ports
Tobias Brunner [Thu, 26 Mar 2020 07:55:36 +0000 (08:55 +0100)] 
charon-nm: Allow using fixed source ports

This could be useful in cases a client behind a NAT has to be made reachable
via port forwarding.

Closes strongswan/strongswan#166.

5 years agosettings: Use strtoul(3) for settings to int conversion
Thomas Egerer [Wed, 25 Mar 2020 17:01:37 +0000 (18:01 +0100)] 
settings: Use strtoul(3) for settings to int conversion

strtol(3) accepts values in the range of [LONG_MIN;LONG_MAX].  Based
on the architecture (32 or 64 bits), these values expand to either
0x8000000000000000/0x7fffffffffffffff for 64-bit builds, or
0x80000000/0x7fffffff for 32-bit builds.

The behavior when retrieving non-default values for charon.spi_min or
charon.spi_max, for example, depends on the architecture of the target
platform.  While 0xC000001/0xCFFFFFFE work fine on a 64-bit build, on a
32-bit build, due to the use of strtol(3), an ERANGE causes get_int()
to return the default values.

By using strtoul(3) the default is only returned if the input value
exceeds 32 or 64 bits, based on the platform.  Negative values are still
parsed correctly.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
5 years agoquick-mode: Make sure we have a proposal before determining lifetimes
Tobias Brunner [Thu, 26 Mar 2020 07:41:00 +0000 (08:41 +0100)] 
quick-mode: Make sure we have a proposal before determining lifetimes

Fixes: e0dd36c9c730 ("ikev1: Get and set the lifetimes of the selected proposal/transform")
5 years agounit-tests: Update expired certificates for TLS tests
Tobias Brunner [Wed, 25 Mar 2020 14:31:07 +0000 (15:31 +0100)] 
unit-tests: Update expired certificates for TLS tests

5 years agonm: Version bump to 1.5.0
Tobias Brunner [Wed, 25 Mar 2020 09:14:46 +0000 (10:14 +0100)] 
nm: Version bump to 1.5.0

5 years agoVersion bump to 5.8.3 5.8.3
Andreas Steffen [Tue, 24 Mar 2020 15:01:04 +0000 (16:01 +0100)] 
Version bump to 5.8.3

5 years agocharon-nm: Correctly set remote auth class for PSK authentication
Tobias Brunner [Fri, 20 Mar 2020 14:53:37 +0000 (15:53 +0100)] 
charon-nm: Correctly set remote auth class for PSK authentication

Fixes: bc3eda99bac0 ("charon-nm: Add support for EAP-TLS")
5 years agoVersion bump to 5.8.3rc1 5.8.3rc1
Andreas Steffen [Thu, 19 Mar 2020 07:43:10 +0000 (08:43 +0100)] 
Version bump to 5.8.3rc1

5 years agoNEWS: Add news for 5.8.3
Tobias Brunner [Thu, 12 Mar 2020 18:32:43 +0000 (19:32 +0100)] 
NEWS: Add news for 5.8.3

5 years agoopenssl: Add support for SHAKE128/256
Tobias Brunner [Tue, 10 Mar 2020 11:16:26 +0000 (12:16 +0100)] 
openssl: Add support for SHAKE128/256

5 years agoopenssl: Add support for SHA-3
Tobias Brunner [Tue, 10 Mar 2020 10:22:12 +0000 (11:22 +0100)] 
openssl: Add support for SHA-3