Commit Graph

13958 Commits

Author SHA1 Message Date
Tobias Brunner 44cda40d58 tls-peer: Simply ignore certificate request context
This SHALL be zero length for server authentication anyway.
2021-02-12 11:45:44 +01:00
Tobias Brunner bfa3178836 tls-peer: Use existing code to verify certificate and signature 2021-02-12 11:45:44 +01:00
Tobias Brunner c78b2bee5d tls-peer: Refactor parsing of TLS extensions
Also adds proper error handling.
2021-02-12 11:45:44 +01:00
Tobias Brunner f0ed5f9125 tls-peer: Fix parsing of encrypted extensions 2021-02-12 11:45:44 +01:00
Tobias Brunner 4c40a3d3f0 tls-peer: Fix parsing of intermediate CA certificates 2021-02-12 11:45:44 +01:00
Tobias Brunner 2e1c0a2776 tls-crypto: Rename methods to calculate finished message
Instead of the version number use "legacy" for the one for earlier TLS
versions.
2021-02-12 11:45:44 +01:00
Tobias Brunner f116a4823f tls-crypto: Use internal PRF of tls-hkdf to generate finished message
Also adds additional checks.
2021-02-12 11:45:44 +01:00
Tobias Brunner a9f661f52a tls-hkdf: Add helper method to allocate data from the internal PRF 2021-02-12 11:45:44 +01:00
Tobias Brunner 6a0ee0c23c tls-hkdf: Cleanups and refactorings
The main refactoring is how secrets (PSK/DH) are handled.
2021-02-12 11:45:44 +01:00
Tobias Brunner de983a3cb9 tls-crypto: Simplify signature creation/verification 2021-02-12 11:45:44 +01:00
Tobias Brunner 2921f43705 tls-crypto: Simplify handshake/application key derivation and rename methods
Also consistently change the ciphers outside of tls_crypto_t and
simplify key derivation in tls_peer_t and fix a memory leak.
2021-02-12 11:45:44 +01:00
Tobias Brunner fff1974012 tls-hkdf: Make labels enum a proper type 2021-02-12 11:45:44 +01:00
Tobias Brunner 8495138d4a tls-peer: Support x25519/448 for TLS 1.2
These DH groups don't use the point format prefix (RFC 8422 deprecated
any other format anyway).  Since they are enumerated now, they can also
be used by servers for TLS 1.2.
2021-02-12 11:45:44 +01:00
Tobias Brunner 3101120c75 tls-crypto: Enumerate x25519/448 and rename constant for consistency 2021-02-12 11:45:44 +01:00
Tobias Brunner 53ba0801ac tls-crypto: Simplify hash algorithm handling 2021-02-12 11:45:44 +01:00
Tobias Brunner 43c8f950a7 tls-crypto: Delay instantiation of cipher suites
This way we can take into account the version set via setter on tls_t.
2021-02-12 11:45:44 +01:00
Tobias Brunner 281766c5e6 tls-crypto: Filter TLS cipher suites by min/max version
There is no point proposing legacy (or future) cipher suites depending on
the proposed TLS versions. It was actually possible to negotiate and use
cipher suites only defined for TLS 1.2 with earlier TLS versions.
2021-02-12 11:45:44 +01:00
Tobias Brunner 436571b2f0 tls-crypto: Correctly filter cipher suites based on PRF algorithms
The previous check operated on the first array element.
2021-02-12 11:45:44 +01:00
Tobias Brunner b7ea969b32 tls-crypto: Use correct key length for ChaCha20/Poly1305 2021-02-12 11:45:44 +01:00
Tobias Brunner ba3c90ded1 libtls: Some code style fixes 2021-02-12 11:45:44 +01:00
bytinbit 7a2b02667c libtls: Implement TLS 1.3 handshake on client-side
The code is a minimal handshake with the HelloRetryRequest message
implementation missing.
Can be tested with an OpenSSL server running TLS 1.3. The server must
be at least version 1.1.1 (September 2018).

Co-authored-by: ryru <pascal.knecht@hsr.ch>
2021-02-12 11:45:44 +01:00
Pascal K 02d7405512 libtls: Implement HKDF for TLS 1.3
TLS 1.3 uses HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
as defined in RFC 5869 to compute traffic secrets.

Co-authored-by: bytinbit <meline.sieber@hsr.ch>
2021-02-12 11:45:44 +01:00
Tobias Brunner 3d83d348f4 libtls: Add support to run unit tests with a custom plugin list 2021-02-12 11:45:44 +01:00
Tobias Brunner 818dc86568 libtls: Add TLS 1.3 implementation of tls_aead_t
The key material, in particular the nonce/IV, is derived differently and
the IV is also generated in a different way.  Additionally, the actual
content type is encrypted and there may be optional padding to mask the
actual size of the encrypted data.
2021-02-12 11:45:44 +01:00
Tobias Brunner ba2bcdd882 libtls: Allow tls_aead_t to change the content type
The actual content type is encrypted with TLS 1.3, the type in the record
header is always Application Data.
2021-02-12 11:45:44 +01:00
Tobias Brunner 781ad0b93b openssl: Allocate our own buffer for i2d_* wrapper macro
If we pass a pointer to NULL, the memory allocated by OpenSSL has to be
freed with OPENSSL_free().  Otherwise, this can lead to random
crashes/freezes for Windows builds as seen on AppVeyor.  To not
complicate things for callers of this macro, we allocate our own memory,
which we already do for other i2d_* calls.
2021-02-11 16:40:58 +01:00
Tobias Brunner 6a440f83ab openssl: Reset HMAC key if chunk_empty is passed
If no valid key is configured (e.g. because it's inadvertently uninitialized),
we should not just reuse the previous key.

The `key_set` flag is not necessary anymore because a non-NULL key is set
during initialization since 6b347d5232 ("openssl: Ensure underlying hash
algorithm is available during HMAC init").
2021-02-11 16:40:58 +01:00
Tobias Brunner cd10ae2ff0 android: Explicitly apply DNS servers to the TUN device
If the peer deletes the CHILD_SA, we recreate it due to the close
action.  However, if we create a new TUN device, we do so with a new
VpnService.Builder object and on that the DNS servers were never applied.
The latter happened only on the fly in the attribute handler when an
IKE_SA was established.  Now we do this explicitly when creating the TUN
device, like the virtual IPs and routes.  While we could avoid the
recreation of the TUN device if the CHILD_SA is recreated, there is the
theoretical possibility that the remote traffic selectors change.  This
way we also avoid adding stuff to the builder in different places.

Fixes #3637.
2021-02-04 16:52:15 +01:00
Tobias Brunner 4dc9edfa55 swanctl: Don't print status message if nothing was loaded to stderr
This is not an error (as reflected by the returned status code) so we
should not print to stderr as output there might still be considered an
error (or at least an audit-worthy event) by some scripts.
2021-02-04 16:50:36 +01:00
Thomas Egerer 2566eb2194 plugin-loader: Add optional filter for plugin features
In some cases, the algorithms that have been compiled into a plugin have
to be disabled at runtime. Based on the array returned by the get_features()
function the optionally provided function can strip algorithms or even
callbacks or registrations from a plugin, giving us a handy and powerful way
for runtime feature configuration aside from the plugin list.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2021-02-04 16:39:27 +01:00
Tobias Brunner e6a6fc33b6 path: Also accept / as directory separator on Windows
This adds helper functions to determine the first or last directory separator
in a string and to check if a given character is a separator.

Paths starting with a separator are now also considered absolute on
Windows as these are rooted at the current drive.

Note that it's fine to use DIRECTORY_SEPARATOR when combining strings as
Windows API calls accept both forward and backward slashes as separators.

Co-authored-by: Michał Skalski <mskalski@enigma.com.pl>

References #3684.
2021-02-03 17:27:57 +01:00
Tobias Brunner 3de65f8d67 enumerator: Implement globbing enumerator on Windows
We don't have glob() available there.  This replacement should work
similarly for simple cases like `include conf.d/*.conf`.

Fixes #3684.
2021-02-03 17:27:31 +01:00
Tobias Brunner 4525233b1e vici: Fix refcount for CA certificates when reloading authority sections
Fixes: 3c5e7eaa88 ("vici: Keep track of all CA certificates in vici_authority_t")
2021-01-27 16:50:17 +01:00
Tobias Brunner 6c26267b07 openssl: Fix potential crash with ECDH on Windows
Apparently, we should use OPENSSL_free() to release memory allocated by
OpenSSL.  While it generally maps to free() that's apparently not the
case on Windows, where the ECP test vectors caused `ACCESS_VIOLATION
exception` crashes (not always the same vector).

Fixes: 74e02ff5e6 ("openssl: Mainly use EVP interface for ECDH")
2021-01-27 16:37:45 +01:00
Tobias Brunner 55df5e9797 openssl: Avoid conflicts with wincrypt.h on Windows
There are several conflicts with newer versions of OpenSSL (> 1.0).
2021-01-27 16:32:43 +01:00
Michał Skalski f30187d422 pkcs11: Fix build on Windows
Windows provides CreateMutexA/W with an alias called CreateMutex that
selects one of the other two based on the UNICODE constant.
2021-01-25 15:16:12 +01:00
Dan James 95a0d800c9 farp: Add support for macOS and FreeBSD
Co-authored-by: Tobias Brunner <tobias@strongswan.org>

Closes strongswan/strongswan#189.
References #3498.
2021-01-22 10:44:05 +01:00
Tobias Brunner 74e02ff5e6 openssl: Mainly use EVP interface for ECDH
Functions like ECDH_compute_key() will be removed with OpenSSL 3 (which
will require additional changes as other functions will be deprecated or
removed too).
2021-01-20 17:53:35 +01:00
Tobias Brunner 5fdc979770 openssl: Extract helper function to derive a shared DH secret 2021-01-20 17:53:35 +01:00
Tobias Brunner 86fb24c2c5 Remove the ecp_x_coordinate_only option
This was for compatibility with very old releases and only complicates
things unnecessarily nowadays.
2021-01-20 17:53:35 +01:00
Mahantesh Salimath 7733ff7d4e openssl: Use ECDH_compute_key() for 'x-coordinate only' setting
ECDH_compute_key() was not used because it only gives x-coordinate of
the result. However, the default setting, as per the errata mentioned,
is to use x-coordinate only.
Use ECDH_compute_key() for this setting as it additionally allows HW
offload of the computation using dynamic engine feature in OpenSSL.
EC_POINT_mul() doesn't allow HW offload.

Signed-off-by: Mahantesh Salimath <mahantesh@nvidia.com>
2021-01-20 17:53:35 +01:00
Tobias Brunner aa3d5bf791 Revert "nm: Remove dummy TUN device"
This reverts commit a28c6269a4.

We add a dummy TUN device again because systemd-resolved insists on
managing DNS servers per interface.

Fixes #3615.
2021-01-19 14:49:48 +01:00
Tobias Brunner bd9b50dcd3 load-tester: Correctly encode serial of generated client certificates
The previous approach would lead to additional zero prefixes in the
encoding of the serial (which is a positive integer, not an arbitrary
blob).

Fixes #3667.
2021-01-18 17:44:59 +01:00
Коренберг Марк d8e4a2a777 identification: Change abbreviation for surname/serialNumber RDNs
To align with RFC 4519, section 2.31/32, the abbreviation for surname
is changed to "SN" that was previously used for serialNumber, which does
not have an abbreviation.

This mapping had its origins in the X.509 patch for FreeS/WAN that was
started in 2000.  It was aligned with how OpenSSL did this in earlier
versions.  However, there it was changed already in March 2002 (commit
ffbe98b7630d604263cfb1118c67ca2617a8e222) to make it compatible with
RFC 2256 (predecessor of RFC 4519).

Co-authored-by: Tobias Brunner <tobias@strongswan.org>

Closes strongswan/strongswan#179.
2021-01-18 17:41:37 +01:00
Tobias Brunner 2610cd7928 vici: Decode error messages in Python bindings
Otherwise we might end up with b'<errmsg>' in the output.
2021-01-18 17:39:15 +01:00
Tobias Brunner 414f2c3754 mem-pool: Be less strict when reassigning existing online leases
Also assign online leases to a peer connecting from the same endpoint
when it requests any virtual IP.  This is mainly a workaround for
Windows clients that remember the virtual IPv6 address and re-request it
the next time the connection is initiated (even if it is not a
reauthentication) but don't do the same for virtual IPv4 addresses.
This can result in duplicate policies with different reqids because
these are allocated for unique sets of traffic selectors.

Fixes #3541.
2021-01-18 13:58:01 +01:00
Tobias Brunner d79cefc3fc vici: Expose ike-update event 2021-01-18 11:34:40 +01:00
Tobias Brunner 2b255f01af ike-mobike: Use ike_sa_t::update_hosts() to trigger events
We should trigger the ike_update() event for MOBIKE updates and since
update_hosts() updates the children we can reuse that code too.
2021-01-18 11:34:40 +01:00
Tobias Brunner 51c7cf9a04 ike-sa: Add flags to force updating hosts/CHILD_SAs
This allows more fine grained control over what's updated and does not
require multiple calls of the method. Plus we'll be able to use it in
the ike-mobike task.
2021-01-18 11:34:40 +01:00
Tobias Brunner 08a3ee0cce bus: Change ike_update() signature and only call it once
This avoids multiple events when both addresses change (e.g. switching
address families).
2021-01-18 11:34:40 +01:00
Tobias Brunner 16fcdb460a charon-tkm: Don't use starter/stroke with charon-tkm anymore
For the tests, the unused init script that was used before switching to
charon-systemd is repurposed to manage the daemon.
2021-01-11 15:28:01 +01:00
Tobias Brunner b322539ef5 charon-tkm: Deinitialize IKE tkm-rpc client
This is necessary if tkm-rpc supports multiple parallel client requests.
2021-01-08 17:22:37 +01:00
Tobias Brunner e637cf8b4a charon-tkm: Remove -gnat05 option not supported by newer compilers 2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger a0a0571bd1 charon-tkm: Reverse cert chain processing order
Verify certificate chains starting from the root CA certificate and
moving towards the leaf/user certificate.

Also update TKM-RPC and TKM in testing scripts to version supporting the
reworked CC handling.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger f8242127a2 charon-tkm: Add support for multiple CAs
Load CA certificate id mapping from config and pass the correct CA ID to
TKM when checking certificate chains. The mapping of CA certificate to
CA ID is done via SHA-1 hash of the CA certificates subjectPublicKey.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger 73d2a11aee charon-tkm: Register TKM cred encoder before init
Make sure the credential encoder is available early to allow getting
public key fingerprints.
2021-01-08 17:22:36 +01:00
Andreas Steffen 2889133cc0 imc_attestation: Fixed double free of tpm_version_info chunk 2021-01-08 11:00:15 +01:00
Andreas Steffen 08760dd927 tpm: Intel FW TPM always uses locality 0 2021-01-08 11:00:15 +01:00
Andreas Steffen 2ea1dac203 libimcv: Support symlinks introduced by usrmerge
Debian, Ubuntu, Fedora et. al. started to apply usrmerge to their
latest Linux distributions, i.e.  /bin, /sbin, and /lib are now
symbolical links to /usr/bin, /usr/sbin, and /usr/lib, respectively.
Since executables and libraries are contained only once in Linux
packages (e.g. /bin/cp in coreutils but not /usr/bin/cp) this leads
to missing file measurments due to the symlinks when doing remote
attestation.

The new ita_attr_symlinks PA-TNC attribute fixes this problem by
collecting symbolic links pointing to directories on the client
platform.
2021-01-08 11:00:15 +01:00
Andreas Steffen 9b4a2322d6 libimcv: Evaluate IMA SHA-256 measurements 2021-01-08 11:00:15 +01:00
Tobias Brunner ea7945a4f5 wolfssl: Disable ECC curves based on minimum ECC key size
wolfSSL 4.6.0 provides a new option to configure the minimum ECC key
size (--with-eccminsz), which currently defaults to 224 bits.
2021-01-04 16:09:56 +01:00
Tobias Brunner 6e2e359f38 wolfssl: Correctly enable Brainpool curves 2021-01-04 16:09:22 +01:00
Tobias Brunner ec9f986b61 Ignore verbose parser generator output file more generally
Depending on from where bison is called, the file might not end up in
the same directory as the .y file, but the location of the Makefile.
This has been seen on FreeBSD.
2020-12-15 10:42:43 +01:00
Tobias Brunner 192581e785 Replace two deprecated parser generator directives
There is a conflict between Flex's bison-bridge and Bison's api.prefix
options.  Apparently, the former was added without consulting the Bison
devs and requires YYSTYPE, which is not added to the header anymore by
the latter.  Instead, we just provide the proper definition of yyflex()
manually (as recommended by the Bison docs), so the option is not
required anymore.
2020-12-15 10:42:43 +01:00
Tobias Brunner eb4cd8e3b1 imv-scanner: Fix potentially unsafe port filter attribute destruction
DESTROY_IF() checks if the given value is not NULL, before calling
destroy() on it, which does not work for sub-structs.  If
port_filter_attr is NULL, this could crash.
2020-12-03 12:19:06 +01:00
Tobias Brunner 25ec2d04aa child-rekey: Don't migrate child-create task if we already are deleting
If we are already deleting the old/redundant CHILD_SA, we must not
migrate the child-create task as that would destroy the new CHILD_SA we
already moved to the IKE_SA.

Fixes #3644.
2020-12-03 11:06:23 +01:00
Tobias Brunner 7d2d94f3e1 host-resolver: Don't wait for a reply if there are no threads
Without threads handling the resolution, there is no point waiting
for a reply.  If no subsequent resolution successfully starts a
thread (there might not even be one), we'd wait indefinitely.

Fixes #3634.
2020-12-03 08:36:20 +01:00
Tobias Brunner 9248f636b0 kernel-netlink: Make sure we successfully opened a Netlink socket
This is in addition to the fix in the destructor in 991e9e5dc9.
2020-12-03 08:34:18 +01:00
Tobias Brunner e8fae43768 identification: Validate ASN.1 DN in from_data() constructor
The DN is otherwise not parsed until compared/printed.  This avoids
false detections as ASN.1 DN if e.g. an email address starts with "0",
which is 0x30 = ASN.1 sequence tag, and the next character denotes
the exact length of the rest of the string (see the unit tests for an
example).
2020-12-03 08:23:54 +01:00
Tobias Brunner 4c61d7aedc android: New release after avoiding marking VPN connections as metered 2020-12-02 16:09:38 +01:00
Tobias Brunner b32a9be419 android: Don't default to marking VPN connections as metered
For apps targeting Android 10, where a method to change this was added, the
default changed so that all VPN connections are marked as metered.  This means
certain background operations (e.g. syncing data) are not performed anymore
even when connected to a WiFi.  By setting this to false, the metered state
of the VPN connection reflects that of the underlying networks.
2020-12-01 16:00:09 +01:00
Tobias Brunner abb3f67bd1 pem: Make sure we actually parsed some data
This could happen if there is no separating empty line between header
and body.

References #3627.
2020-11-13 16:40:01 +01:00
Tobias Brunner ce433c9b29 kernel-wfp: Declare constants explicitly as extern
Newer compilers otherwise complain that there are multiple definitions
of these (in header and .c file).
2020-11-13 16:38:17 +01:00
Tobias Brunner 4fc6b79b93 libimcv: Avoid compiler warning in segmentation unit test
Newer versions of GCC complain that the variable may be used
uninitialized.
2020-11-13 16:38:17 +01:00
Tobias Brunner eec08b41a8 windows: Don't declare [v]asprintf()
None of our build environments seem to require these declarations.  And
current versions of MinGW-w64 define them as inline functions in stdio.h
so these declarations clashed with that ("static declaration of '...'
follows non-static declaration").
2020-11-13 16:38:17 +01:00
Shmulik Ladkani 1607e538e9 controller: Always return SUCCESS when terminating IKE_SAs without callback
If no callback is specified, terminate_ike_execute() is invoked without the
listener waiting on the IKE state change.

Now, if 'force' is false, then ike_sa->delete() just queues an
IKE_DELETE task, and returns SUCCESS - indicating successful task
manager initiation.

However, terminate_ike_execute() ignored this success and set the
status to FAILED.

This is not ideal, as it will be the overall return code of
terminate_ike(), although no failure did occur. This eventually leads
vici's "terminate" to return "Command failed: terminating SA failed",
as seen in this example:

    In [9]: list(session.terminate({'ike-id': 2960, 'timeout': -1}))
    ---------------------------------------------------------------------------
    CommandException                          Traceback (most recent call last)
    <ipython-input-9-5f95b5cea88f> in <module>()
    ----> 1 list(session.terminate({'ike-id': 2960, 'timeout': -1}))

    vici/session.pyc in streamed_request(self, command, event_stream_type, message)
        136                 raise CommandException(
        137                     "Command failed: {errmsg}".format(
    --> 138                         errmsg=command_response["errmsg"]
        139                     )
        140                 )

    CommandException: Command failed: terminating SA failed

If we consider both queueing the task and actually destroying the IKS_SA
a success, we can just always return SUCCESS if we don't have a
callback. There is also no need to explicitly set the status to FAILED
if a listener is waiting as that's the default anyway.

Co-authored-by: Tobias Brunner <tobias@strongswan.org>

Closes strongswan/strongswan#185.
2020-11-04 19:42:41 +01:00
Tobias Brunner 70b0c730d0 gcrypt: Use a dummy buffer to initialize static allocations
In FIPS mode, libgcrypt uses a DRBG, which behaves differently when the
length passed to gcry_create_nonce() or gcry_randomize() is <= 0.  It
expects a struct and explicitly checks that the passed pointer is not
NULL.
2020-11-04 10:06:46 +01:00
Tobias Brunner a59842eb95 parser-helper: Don't attempt to open anything but regular files
A crash could be provoked e.g. via STRONGSWAN_CONF=. or any other
path to a directory.
2020-11-04 10:06:46 +01:00
Tobias Brunner 991e9e5dc9 kernel-netlink: Only attempt to remove routing rule if we have a socket 2020-11-04 10:06:46 +01:00
Tobias Brunner 19343998bb imv-attestation: Fix typo in default value for hash_algorithm option 2020-11-04 10:06:46 +01:00
Tobias Brunner f0f65b20ae libimcv: Remove empty 'swid' Doxygen group
The corresponding IMC/IMV were already removed with a31f9b7691 ("libimcv:
Removed TCG SWID IMC/IMV support").
2020-11-04 10:06:46 +01:00
Tobias Brunner a6f0e19bf5 Fixed some typos, courtesy of codespell 2020-11-04 10:06:46 +01:00
Tobias Brunner bb87e63ca6 child-sa: Delete inbound SAs even if not installed to remove allocated SPIs
If we can't establish an SA, this should delete the allocated SPI.
2020-10-30 13:08:16 +01:00
Tobias Brunner ef636316d2 vici: Send all queued messages during shutdown
This ensures that e.g. ike/child-updown messages are sent that were
queued but couldn't be sent (even the job to enable to on_write() callback
requires a worker thread that's not around anymore during shutdown).

References #3602.
2020-10-30 09:58:42 +01:00
Tobias Brunner 6586f07162 ikev2: Clear fragments of a retransmitted message if we receive the next one
The message_t object used for defragmentation was only cleared after
all fragments have been received and the message was delivered.  So
if we received only some fragments of a retransmitted message, the
fragments of the next message were not processed (message_t returns
INVALID_ARG if the message ID does not match causing the message to
get ignored).  This rendered the IKE_SA unusable as the client
obviously never retransmitted the fragments of that previous message
after it received our response.
2020-10-29 14:06:19 +01:00
Tobias Brunner 01fee62f46 android: New release after adding IPv6 support and several fixes 2020-10-29 10:57:07 +01:00
Tobias Brunner ec317c29ca android: Throw an exception if UUID can't get parsed
The parser is quite picky and e.g. doesn't accept UUIDs without dashes.
Even without a specific error, this at least points the users into the
right direction.

Fixes #3583.
2020-10-29 10:57:07 +01:00
Tobias Brunner 80337f4f9d android: Prevent illegalStateException when showing power whitelist dialog
If the activity is not active when the service connection is
established and handleIntent() is called, the activity's state is already
saved and any fragment transaction would result in an illegalStateException
due to state loss.  We just ignore this and wait for another initiation
attempt (via onNewIntent()).
2020-10-29 10:22:52 +01:00
Tobias Brunner 264435f626 android: Handle restarts of control activity with power whitelist dialog better
With the flag set, we basically ignore the resent intent, which is not
ideal if we have not yet actually started another activity.  The information
dialog we show first would disappear when closing and reopening the app
or even just rotating it (we hide all dialogs when receiving an intent),
but since the flag was restored, the dialog was not shown again even
when attempting to start other connections.
2020-10-29 10:22:52 +01:00
Tobias Brunner 21476a8d91 android: Make IPv6 transport flag configurable in the GUI 2020-10-29 10:22:52 +01:00
Tobias Brunner 7d10095123 android: Import IPv6 transport flag 2020-10-29 10:22:52 +01:00
Tobias Brunner 3581914387 android: Add flag to enable IPv6 transport addresses 2020-10-29 10:22:51 +01:00
Tobias Brunner 0bc826c2f2 android: IPV6_PKTINFO is supported (i.e. struct in6_pktinfo is available) 2020-10-29 10:22:51 +01:00
Tobias Brunner 294c022fae android: Add ability to lookup IPv6 source addresses 2020-10-29 10:22:51 +01:00
Tobias Brunner 217d8ab81e android: Fix port scanning IMC
Since 9e88bb987d ("Subscribed Scanner IMC/IMV to IETF_FIREWALL PA subtype")
the port filter attribute is requested with a different message type.
2020-10-29 10:22:51 +01:00
Tobias Brunner 1c82e65cbe android: Ignore deprecation warning for legacy code in NetworkManager 2020-10-29 10:22:51 +01:00
Tobias Brunner a7713372d3 android: Replace deprecated getFragmentManager() in TNC-related Fragments 2020-10-29 10:22:51 +01:00
Tobias Brunner e106fce483 android: Consistently use PreferenceManager from AndroidX
android.preference.PreferenceManager has been deprecated.  The one from
AndroidX was already in use in some places.
2020-10-29 10:22:51 +01:00
Tobias Brunner ea303d3f5a android: Update dependencies 2020-10-29 10:22:51 +01:00
Tobias Brunner f71f6f659f android: Set compile-/targetSdkVersion to 29
This will be mandatory for existing apps on Nov 2, 2020.
2020-10-29 10:22:51 +01:00
Tobias Brunner ad2caae301 android: Update Gradle plugin 2020-10-29 10:22:51 +01:00
Tobias Brunner a689e358e5 kernel-netlink: Ignore deprecated candidate source addresses
The currently used address may get deprecated e.g. if an IPv6 prefix changes.
In this case we should switch to another address.

Fixes #3511.
2020-10-29 09:46:14 +01:00
Tobias Brunner 2eb43ca405 kernel-netlink: Update cached address flags
Note that manually adding an IPv6 address without disabling duplicate
address detection (DAD, e.g. via `nodad` when using iproute2) will cause
a roam event due to a flag change after about 1-2 seconds (TENTATIVE is
removed).  If this is a problem, we might have to ignore addresses with
TENTATIVE flag when we receive a RTM_NEWADDR message until that flag is
eventually removed.

Fixes #3511.
2020-10-29 09:46:14 +01:00
Tobias Brunner bce0c5fd74 child-create: Update CHILD_SA IP addresses before installation
We create the child_sa_t object when initiating the CREATE_CHILD_SA
request, however, the IP addresses/ports might have changed once we
eventually receive the response (potentially to a retransmit sent to
a different address).  So update them before installing the SA and
policies.

If the local address changed too and depending on the kernel
implementation, the temporary SA created to allocate the inbound SPI
might remain as it can't be updated.  This could cause issues if e.g.
the address switches back before that SA expired (the updated inbound
SA conflicts with the temporary one), or if that happens close together
and the expire (having to wait for the address update) causes the
updated SA to get deleted.

Fixes #3164.
2020-10-27 16:45:10 +01:00
Tobias Brunner 9118fd39d7 child-sa: Only query/update/delete inbound SA if it was actually installed
We usually can't do any of these things with temporary SAs created while
allocating an SPI.
2020-10-27 16:42:01 +01:00
Tobias Brunner 610745e724 unit-tests: Free allocated SPIs in mock IPsec backend 2020-10-27 16:42:01 +01:00
Tobias Brunner 29b491ed9c child-sa: No need to attempt to update policies if none are configured 2020-10-27 16:42:01 +01:00
Tobias Brunner de69d25596 child-sa: Only reinstall VIPs if any are passed 2020-10-27 16:42:00 +01:00
Tobias Brunner f3f93cade9 load-tester: Also request a virtual IPv6 address
Fixes #3595.
2020-10-27 16:40:38 +01:00
Tobias Brunner 1d232d4954 load-tester: Use appropriate family to request addresses from source IP pools
Looks like this wasn't necessary before 40e9089889 ("Strictly enforce
address family match while acquiring mem_pool IPs").

Fixes #3595.
2020-10-27 16:40:05 +01:00
Tobias Brunner 12a3f3ca52 quick-delete: Properly handle failures to restart CHILD_SA
If DESTROY_ME is returned from initiate(), we must not touch the IKE_SA
anymore.
2020-10-27 16:35:45 +01:00
Tobias Brunner c5baa4cbd6 pkcs7: Order DER encoded attributes
The attributes are encoded as a SET OF, which means that in DER encoding
the encoded attributes have to be ordered lexicographically.

Fixes #3589.
2020-10-27 11:21:09 +01:00
Tobias Brunner 30d47ea4cb swanctl: Support any key type for decrypted keys
The previous code required explicit support for a particular key type,
of which Ed25519 and Ed448 were missing.  While a fallback to `any` would
have been possible (this is already the case for unencrypted keys in the
`private` and `pkcs8` directories, which are not parsed by swanctl), it's
not necessary (as long as swanctl and the daemon are from the same release)
and does not require the daemon to detect the key type again.

Fixes #3586.
2020-10-27 11:17:44 +01:00
Tobias Brunner 6839256773 vici: Support all defined key types
References #3586.
2020-10-27 11:17:21 +01:00
Martin Willi 7efe92130a revocation: Validate OCSP nonce only if response actually contains a nonce
Commit 27756b081c (revocation: Check that nonce in OCSP response matches)
introduced strict nonce validation to prevent replay attacks with OCSP
responses having a longer lifetime. However, many commercial CAs (such as
Digicert) do not support nonces in responses, as they reuse once-issued OCSP
responses for the OCSP lifetime. This can be problematic for replay attack
scenarios, but is nothing we can fix at our end.

With the mentioned commit, such OCSP responses get completely unusable,
requiring the fallback to CRL based revocation. CRLs don't provide any
replay protection either, so there is nothing gained security-wise, but may
require a download of several megabytes CRL data.

To make use of replay protection where available, but fix OCSP verification
where it is not, do nonce verification only if the response actually contains
a nonce. To be safe against replay attacks, one has to fix the OCSP responder
or use a different CA, but this is not something we can enforce.

Fixes #3557.
2020-10-27 10:51:51 +01:00
Tobias Brunner 706a579e96 charon-nm: Terminate if signaled by NetworkManager
This only happens during shutdown, not after terminating a connection.

Fixes #3579.
2020-10-27 10:44:33 +01:00
Tobias Brunner b422f16d10 sys-logger: Optionally log the level of each message
Fixes #3509.
2020-10-27 10:42:49 +01:00
Tobias Brunner a3f5e38b7f file-logger: Optionally log the level of each message
Fixes #3509.
2020-10-27 10:42:39 +01:00
Thomas Egerer e635d3dcbd drbg: Add missing format specifiers to debug output
Fixes: 737375a2d2 ("drbg: Implemented NIST SP-800-90A DRBG")

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2020-10-13 10:05:43 +02:00
Tobias Brunner c810912d2f libimcv: Fix Doxygen comments for some pts_meas_algo_* functions 2020-10-12 13:48:57 +02:00
Andreas Steffen f3d96b7bc9 Version bump to 5.9.1dr1 2020-10-07 16:54:32 +02:00
Andreas Steffen 3e5a528aec tpm: Auto-detection of legacy TPM 2.0 devices 2020-10-07 16:54:32 +02:00
Andreas Steffen 3ef5b23903 pts: Variable size PCR banks 2020-10-07 16:54:32 +02:00
Andreas Steffen 56de4dc596 libtpmtss: Remove aik_blob debug output 2020-10-07 16:54:32 +02:00
Andreas Steffen d647a8f91d pts: Parse TPM 2.0 BIOS/EFI event log 2020-10-07 16:54:32 +02:00
Andreas Steffen da1d7815ef tpm: TPM 2.0 supports SHA3 and CMAC 2020-10-07 16:54:32 +02:00
Tobias Brunner 7f170e4c9c openssl: Accept CRLs issued by non-CA certificates with cRLSign keyUsage flag
The x509 plugin accepted CRL signers since forever, to be precise, since
dffb176f2b ("CRLSign keyUsage or CA basicConstraint are sufficient
for CRL validation")).

References #3529.
2020-10-05 15:39:37 +02:00
Tobias Brunner 040608a48d Simplify handling of terminating signals in all libcharon wrappers
Closes strongswan/strongswan#182.
2020-09-30 12:47:39 +02:00
Noel Kuntze d1d5659ead ike-vendor: Add option to send Cisco FLexVPN vendor ID
A new global option enables sending this vendor ID to prevent Cisco
devices from narrowing the initiator's local traffic selector to the
requested virtual IP, so e.g. 0.0.0.0/0 can be used instead.

This has been tested with a "tunnel mode ipsec ipv4" Cisco template but
should also work for GRE encapsulation.

Closes strongswan/strongswan#180.
2020-09-10 12:01:44 +02:00
Tobias Brunner dc0c20600f libipsec: Enable code coverage
Same as with libtls.
2020-09-09 13:25:30 +02:00
Tobias Brunner ed1ba70894 libtls: Enable code coverage
While the test runner was already correctly set up, the library itself
was not and no coverage was reported for any of its files.
2020-09-09 13:25:30 +02:00
Tobias Brunner d5d6d671fb leak-detective: Whitelist OPENSSL_init_ssl()
These leaks are reported with OpenSSL 1.1.0+ if the mysql plugin is loaded.
2020-09-09 13:25:30 +02:00
Tobias Brunner 1496991078 leak-detective: Whitelist leaks that occur on Debian buster 2020-09-03 15:24:37 +02:00
Tobias Brunner 766017a8d3 libimcv: Add Debian 10.5 to IMV database 2020-09-03 13:34:19 +02:00
Tobias Brunner bdd058e36c imv-scanner: Fix potential buffer overflow
While `pos` was moved to the end, `len` was not adjusted (i.e. set to 0)
so later calls could write beyond the buffer.  However, the last port
written might have been incomplete, so instead we just reset the string.
2020-08-18 14:05:04 +02:00
Tobias Brunner 3f8eb2ebdf aesni: Remove useless algorithm assignments 2020-08-18 13:17:24 +02:00
Tobias Brunner 0ce2e00d94 vici: Don't use pytest-pycodestyle with Python 3.5
This causes problems due to a deprecation error during the Ubuntu Xenial
build on Travis.
2020-08-17 15:22:34 +02:00
Tobias Brunner 61af9a3478 vici: Fix typos in comments 2020-07-23 14:50:17 +02:00
Tobias Brunner edc7752802 unit-tests: Fix cancel_onoff test
If it takes a while to start one of the threads, another thread might already
have passed the usleep() call previously used and re-enabled cancelability
so that the loop that checked for it would never terminate.
2020-07-20 15:49:44 +02:00
Tobias Brunner 8a4e30ccef unit-tests: Print a header for each test function/iteration if verbosity is >= 0 2020-07-20 14:29:28 +02:00
Tobias Brunner 5c43a5bfa7 unit-tests: Add ability to filter test cases and functions 2020-07-20 14:29:12 +02:00
Tobias Brunner f77e8c171c openssl: Use consistent ifdefs to disable x25519/448
When compiling with OPENSSL_NO_ECDH but without OPENSSL_NO_EC the build
failed.
2020-07-20 14:10:05 +02:00
Tobias Brunner 3c5e7eaa88 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.
2020-07-20 14:05:39 +02:00
Tobias Brunner 3d3d5235aa object: Add helper for callbacks with two void pointers 2020-07-20 14:05:39 +02:00
Tobias Brunner d8a2c58229 vici: Make attribute certificates untrusted again
Fixes: 334119b843 ("Share vici_cert_info.c with vici_cred.c")
2020-07-20 14:05:39 +02:00
Tobias Brunner 6fc1b2c3d3 vici: Clear credential cache when unloading an authority section 2020-07-20 14:05:38 +02:00
Tobias Brunner 46ff268885 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.
2020-07-20 14:05:38 +02:00
Tobias Brunner 306c0c9f8e certificate: Extract helper function to filter certificates 2020-07-20 14:05:38 +02:00
Tobias Brunner 93b2c2066f 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.
2020-07-20 13:50:11 +02:00
Tobias Brunner 736fae4e6c 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.
2020-07-20 13:50:11 +02:00
Tobias Brunner 45376040ce 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.
2020-07-20 13:50:11 +02:00
Tobias Brunner d9944102f5 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.
2020-07-20 13:50:11 +02:00
Tobias Brunner 4334f61284 unit-tests: Pass test iteration to fixtures 2020-07-20 13:50:11 +02:00
Tobias Brunner 31e6ca78df hashtable: Optionally collect and report profiling data 2020-07-20 13:50:11 +02:00
Tobias Brunner 87ceaefe2f 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.
2020-07-20 13:50:11 +02:00
Tobias Brunner c66c850fc0 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.
2020-07-20 13:50:11 +02:00
Tobias Brunner 54a2b35f07 unit-tests: Add tests for larger number of items in hashtables 2020-07-20 13:50:11 +02:00
Tobias Brunner 13d302e95a unit-tests: Optionally report the times test cases ran 2020-07-20 13:50:11 +02:00
Tobias Brunner fd94c1301e 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: 9f12b8a61c ("kernel-netlink: Enumerate temporary IPv6 addresses according to config")
2020-07-07 10:01:46 +02:00
Tobias Brunner 10a913685f 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.
2020-07-06 13:47:16 +02:00
Tobias Brunner feda4a3d37 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.
2020-07-01 15:59:41 +02:00
Boris Vanhoof 6870a9b590 eap-radius: Small spelling fix
Closes strongswan/strongswan#174.
2020-06-29 09:44:19 +02:00
Tobias Brunner 33412158f5 ike: Send AEAD ESP default proposal first
We generally prefer AEAD nowadays.

References #3461.
2020-06-12 13:47:13 +02:00
Tobias Brunner c7bef954ee proposal: Add AES-GCM to the ESP default AEAD proposal
References #3461.
2020-06-12 13:45:58 +02:00
Tobias Brunner bc40509057 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.
2020-06-11 13:33:32 +02:00
Tobias Brunner 364d8b2628 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.
2020-06-11 13:29:47 +02:00
Tobias Brunner 59ebdac49b child-create: Don't reset DH group when retrying after INVALID_KE_PAYLOAD
migrate() is called before retrying.

Fixes: 0184a69b7b ("child-create: Properly handle DH group during
migration when reestablishing")
2020-06-05 16:41:23 +02:00
Tobias Brunner 736ac65554 ikev1: Fix PSK lookup for Main Mode initiators
We need the PSK/identity already when deriving the keys in process_i().

Fixes: 1665a4e050 ("ikev1: Use actual local identity as initiator or aggressive mode responder")
2020-06-05 14:26:30 +02:00
Tobias Brunner 62367f2c01 ike: Fix retransmission timeouts if base is <= 1
Fixes: 72b282cf20 ("ike: Properly support high number of retransmission tries")
2020-06-05 13:44:00 +02:00
Tobias Brunner a5e4322348 android: New release after improving connectivity/scheduling 2020-06-02 14:55:58 +02:00
Tobias Brunner eadba6d225 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.
2020-06-02 14:42:48 +02:00
Tobias Brunner 93d6fe3e4a android: Ignore some missing quantity lint errors
Once these strings are translated and the quantities are defined, this
attribute can be removed again.
2020-06-02 14:42:45 +02:00
Tobias Brunner 84924249aa 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: 2ef473be15 ("android: Use helper to parse IP addresses where appropriate")
Fixes #3443.
2020-06-02 14:42:38 +02:00
Tobias Brunner 04f4bef235 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.
2020-06-02 14:07:06 +02:00
Tobias Brunner 5d01aaf91d android: Increase lifetimes a bit
This should avoid clashes of soft and hard lifetimes even if the app is
not whitelisted.
2020-06-02 14:07:06 +02:00
Tobias Brunner a0d32a2d13 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.
2020-06-02 14:07:06 +02:00
Tobias Brunner d67a5b0c4d 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.
2020-06-02 14:07:06 +02:00
Tobias Brunner 1b4c4123c2 android: Use Android-specific scheduler on Android 6 and later 2020-06-02 14:07:06 +02:00
Tobias Brunner b7d66ae2cd 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).
2020-06-02 14:07:06 +02:00
Tobias Brunner aaa908dc0a scheduler: Use timercmp(3) instead of a custom function 2020-06-02 14:07:06 +02:00
Tobias Brunner 2edc73d84e 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.
2020-06-02 14:07:06 +02:00
Tobias Brunner f3695d089b 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).
2020-06-02 14:07:06 +02:00
Tobias Brunner 070cd12dfb 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.
2020-06-02 14:07:06 +02:00
Tobias Brunner 6524bd3cd5 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.
2020-06-02 14:07:06 +02:00
Tobias Brunner 664389ebc4 android: Enable switch from NAT interval to DPDs after 20 seconds 2020-06-02 14:07:06 +02:00
Tobias Brunner 0d4a5f6af6 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.
2020-06-02 14:07:06 +02:00
Tobias Brunner 31298187bf 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.
2020-06-02 13:57:37 +02:00
Tobias Brunner 3e358475bb 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.
2020-06-02 13:57:37 +02:00
Tobias Brunner 8b93510dac mutex: Don't use ...timedwait_monotonic() if clock is set via attribute
This allows using clocks other than CLOCK_MONOTONIC.
2020-06-02 13:57:37 +02:00
Tobias Brunner 6b3bf7cdac ike: Track NAT-keepalives as outbound packets 2020-06-02 13:57:37 +02:00
Tobias Brunner 491cdd59bd 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.
2020-06-02 13:57:37 +02:00
Tobias Brunner 3c8280960c android: Update Gradle plugin 2020-06-02 13:57:37 +02:00
Tobias Brunner 907a31db4c 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 3716af079e ("android: Avoid crash related to
TileService on Huawei devices").
2020-06-02 13:57:37 +02:00
Thomas 04db34a3a7 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.
2020-05-25 11:50:46 +02:00
Tobias Brunner 3a54206c08 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.
2020-05-19 17:33:20 +02:00
Tobias Brunner 3f454f33c0 nm: Version bump to 1.5.2 2020-05-19 16:17:05 +02:00
Tobias Brunner 1ebf63b966 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.
2020-05-19 16:17:24 +02:00
Tobias Brunner 7b15ecf82e 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.
2020-05-19 16:17:05 +02:00
Tobias Brunner 73b60338dc 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
2020-05-11 09:57:37 +02:00
Tobias Brunner ecf187509a nm: Version bump to 1.5.1 2020-05-08 18:12:20 +02:00