Commit Graph

13236 Commits

Author SHA1 Message Date
Tobias Brunner 1350ee1ec7 android: Use capped exponential backoff for automatic retries 2018-07-03 11:31:39 +02:00
Tobias Brunner 2ec6ad71d3 android: Show countdown and retry button in notification 2018-07-03 11:31:39 +02:00
Tobias Brunner 0d9dd4b150 android: Avoid IllegalStateException in state fragments
This happened if the state service got connected while such a fragment was
not visible (anymore or at all).
2018-07-03 11:31:38 +02:00
Tobias Brunner bc52868173 android: Don't hide the notification if we are connecting to a profile
In particular, if we are reconnecting after an error.
2018-07-03 11:31:38 +02:00
Tobias Brunner 68afdd3464 android: Add an automatic reconnect on errors
This way the connection will be attempted to be kept up even on "fatal"
errors like authentication failures.
2018-07-03 11:31:38 +02:00
Tobias Brunner 89a88d7c56 ike-sa-manager: Fix races when changing initiator SPI of an IKE_SA
Removing and readding the entry to a potentially different row/segment,
while driving out waiting and new threads, could prevent threads from
acquiring the SA even if they were waiting to check it out by unique
ID (which doesn't change), or if they were just trying to enumerate it.
With this change the row and segment doesn't change anymore and waiting
threads may acquire the SA. However, those looking for an IKE_SA by SPIs
might get one back that has a different SPI (but that's probably not
something that happens very often this early).

This was noticed because we check out SAs by unique ID in the Android
app to terminate them after failed retransmits if we are not reestablishing
the SA (otherwise we continue), and this sometimes failed.

Fixes: eaedcf8c00 ("ike-sa-manager: Add method to change the initiator SPI of an IKE_SA")
2018-07-03 11:31:38 +02:00
Tobias Brunner f23b107857 android: Show a retry button in the error banner
The button to view the log is now below the status info.  And since the
IMC results are just below that we don't need a special handling for
that anymore.
2018-07-03 11:31:38 +02:00
Tobias Brunner 063230c27b android: Add function to quickly reconnect the current profile 2018-07-03 11:31:37 +02:00
Tobias Brunner a5f565646a android: Use Java 8 features 2018-07-03 11:31:37 +02:00
Tobias Brunner ab5dbbc4ab android: Show an error if client certificate is unavailable
This can happen on systems (e.g. Android 7.x) where Always-on VPNs are
triggered right after booting before the KeyChain is unlocked by the user.
Retrieving the certificate chain or private key then fails with
"KeyChainException: IllegalStateException: keystore is LOCKED" until the
user unlocks the screen once.

The built-in client actually also fails in this situation (e.g. with XAuth
RSA), it tries three times then stops and shows an error notification.
2018-07-03 11:31:37 +02:00
Tobias Brunner f0b3e303c4 android: Show an error if a profile without a password is initiated
This could happen if an incomplete profile is used with Always-on VPN.
2018-07-03 11:31:37 +02:00
Tobias Brunner e145a5e66d android: Use modern shortcuts on Android 8+ 2018-07-03 11:31:37 +02:00
Tobias Brunner 5b6a0a3f9e android: Add an adaptive launcher icon
Using <inset> in a mipmap folder apparently is not fully valid, at least
Android Studio complains about it (it seems to work fine, though).
2018-07-03 11:31:36 +02:00
Tobias Brunner a7d679ff1b android: Show the actual error description in the notification 2018-07-03 11:31:36 +02:00
Tobias Brunner c353734f47 android: Change format for error strings
Place the dot in the main message not the descriptions of the individual
errors.
2018-07-03 11:31:36 +02:00
Tobias Brunner 4dbe7ffa3e android: Collapse Quick Settings drawer if password entry is required 2018-07-03 11:31:36 +02:00
Tobias Brunner 56f599560c android: Initiate configured default profile when triggered as Always-on VPN
With Android 8.1 this isn't triggered after a reboot until the device
has been unlocked once (solving the issue with the key store) and traffic
may optionally be blocked by the user until the VPN is established.

There are still some issues (e.g. password prompts and fatal errors), and we
might need some workaround for older Android releases.
2018-07-03 11:31:36 +02:00
Tobias Brunner d56f1bf832 android: Just reconnect if the tile is clicked even if there was an error
A long press click on the tile (or a click on the notification) will open
the main activity if more information about the error are necessary.
2018-07-03 11:31:35 +02:00
Tobias Brunner be89310784 android: Allow reconnecting without confirmation in case of an error 2018-07-03 11:31:35 +02:00
Tobias Brunner 6987ddb313 android: Show connection errors as banner, not as modal dialog 2018-07-03 11:31:35 +02:00
Tobias Brunner 64b7a6d622 android: Add Quick Settings tile to toggle VPN state
Only if there is no currently active (or previously active) profile does
this currently operate on the configured (or stored most recently used)
profile.  This way it's possible to use a different connection and
quickly disable and re-enable it again.  When unlocked the profile name
is shown, when locked a generic text is used (this detection doesn't seem
to work 100% reliably).  To disconnect, the user is forced to unlock the
device, connecting is possible without, if the credentials are available
and no fatal error occurs (it even works with the system credential store,
at least on Android 8.1).

Note that the tile is not available right after a reboot.  It seems that
the system has to be unlocked once to activate third-party tiles (will
be interesting to see how this works together with Always-on VPN).
2018-07-03 11:31:35 +02:00
Tobias Brunner 08c79d5112 android: Store the ID of the most recently used profile as preference 2018-07-03 11:31:35 +02:00
Tobias Brunner acdac14818 android: Add settings activity and default profile selection
The default profile can then be used for a Quick Settings tile or the
Always-on VPN feature.
2018-07-03 11:31:34 +02:00
Tobias Brunner 6e73a939a9 android: Reset error state after user confirmed it
This allows other listeners to change their display.
2018-07-03 11:31:34 +02:00
Tobias Brunner 52aaffdeb4 android: Use specific icon when connecting to the VPN 2018-07-03 11:31:34 +02:00
Tobias Brunner 70d6a0cf33 android: Use a handler to show/remove notification from main UI thread
This avoids races that were previously seen (e.g. when disconnecting
while connecting, which sometimes showed a "Disconnecting..."
notification).
2018-07-03 11:31:34 +02:00
Tobias Brunner 58d139dad3 android: Use separate activity to control VPN connections
This way we don't have to open the main window, but only show a dialog
if necessary (or nothing in many cases).
2018-07-03 11:31:34 +02:00
Tobias Brunner 1d336cc2ae android: Migrate onAttach() from deprecated version 2018-07-03 11:31:33 +02:00
Tobias Brunner 4671f023c3 android: Make certificate import activity properly transparent 2018-07-03 11:31:33 +02:00
Tobias Brunner d390d97da4 android: Remove deprecated progress indicator in MainActivity
Support for this was already removed with API level 21. On modern
devices loading CA certs should be quick enough anyway.
2018-07-03 11:31:33 +02:00
Tobias Brunner ed9d5a314c android: Replace deprecated ProgressDialog during profile import 2018-07-03 11:31:33 +02:00
Tobias Brunner 6ca0b46c20 android: Add notification channel for API level 26+
Unfortunately, setLockscreenVisibility() doesn't seem to have any
effect. So the full notification is shown unless the user manually
configures the notification settings.
2018-07-03 11:31:33 +02:00
Tobias Brunner 56dec924ec android: Set compile-/targetSdkVersion to 26
This allows us to add tiles to Quick Settings and enabling the Always-on
VPN feature in the VPN settings (both require API level 24, but 26 will
be required as targetSdkVersion later this year).
2018-07-03 11:31:33 +02:00
Tobias Brunner 71f4a20aa1 android: Show profile ID at bottom of advanced settings
Can be selected and copied to the clipboard to use in automation
software that doesn't support the shortcut.
2018-07-03 11:31:32 +02:00
Tobias Brunner 93033728a9 android: Accept a profile's UUID when initiating 2018-07-03 11:31:32 +02:00
Tobias Brunner 581f4326d5 android: Add additional Intent filter for import Activity with MIME type mask
Chrome creates such an Intent when opening downloaded files (not when
directly opening them), a MIME type is set, but apparently not ours.
2018-07-03 11:31:32 +02:00
Tobias Brunner 93489acc0d android: UUID is now mandatory
Unless there are profiles created with old versions of the app (< 1.8.0)
that were never updated since, all profiles should already have a UUID
assigned.  If not, we do that now with a DB migration.
2018-07-03 11:31:32 +02:00
Tobias Brunner 0917caa195 android: Show an error dialog if we can't get permission for VPNs
This is either because a third-party VPN app has the always-on feature
enabled, or because the user denied the permission in the system's confirmation
dialog.

If the always-on feature is enabled for a connection of the built-in VPN
client we get an IllegalStateException, for which we show an updated and
clearer error message.
2018-07-03 11:31:32 +02:00
Tobias Brunner 08601c58e9 android: Suppress self-assign warnings with clang
These are triggered by the little endian functions in byteorder.h.
2018-07-03 11:31:31 +02:00
Tobias Brunner 2afdb92dd0 atomics: Use type of destination in CAS implementation
The type of the value was incorrect (void**) if NULL was passed to cas_ptr()
as expected value, which caused a compiler warning with Clang because
__atomic_compare_exchange_n() expects the types of the first two arguments
to be the same.
2018-07-03 11:31:31 +02:00
Tobias Brunner 942599b623 atomics: Define HAVE_GCC_ATOMIC_OPERATIONS when building with clang
We should probably check for stdatomic.h and use the c11 functions if
available.
2018-07-03 11:31:31 +02:00
Tobias Brunner 929badfefd android: Build native libraries for all non-deprecated ABIs
armeabi has been superseded by armeabi-v7a and the MIPS ABIs were removed
with the latest NDK (r17), after being marked deprecated for a while.
By not specifying APP_ABI we build for all non-deprecated ABIs.
2018-07-03 11:31:31 +02:00
Tobias Brunner 4bb0a589ff android: Update Gradle plugin and wrapper 2018-07-03 11:31:31 +02:00
Tobias Brunner b68a0adace ike: Include length of reassembled IKE message in log message
Also simplify wording a bit when fragmenting.
2018-07-02 12:19:00 +02:00
Tobias Brunner 707b70725a dhcp: Only use DHCP server port if explicitly configured
If a DHCP server is running on the same host it isn't necessary to
bind the server port and might even cause conflicts.
2018-07-02 11:39:22 +02:00
Tobias Brunner 50c4c1bb40 kernel-pfkey: Avoid updating policies if nothing significant changed
The FreeBSD kernel doesn't update policies atomically, causing
unnecessary traffic loss during simple rekeyings.

Fixes #2677.
2018-07-02 10:17:04 +02:00
Tobias Brunner daa0a0cc1b settings: Fix compilation with newer versions of Clang
Depending on the actual va_list definition it's not valid to compare it
directly or assign NULL.
2018-06-29 11:47:26 +02:00
Tobias Brunner 187a01cc9f backend-manager: Change how IKE/peer config matches are logged
Instead of logging the search parameters for IKE configs (which were already
before starting the lookup) we log the configured settings.

The peer config lookup is also changed slightly by doing the IKE config
match first and skipping some checks if that or the local peer identity
doesn't match.
2018-06-28 18:46:42 +02:00
Tobias Brunner 2ad1df9571 Replace 'inacceptable' with the more common 'unacceptable' 2018-06-28 18:46:42 +02:00
Tobias Brunner 84cdfbc9bc child-cfg: Allow suppressing log messages when selecting traffic selectors
Although being already logged on level 2, these messages are usually just
confusing if they pop up randomly in the log when e.g. querying the configs
or installing traps.  So after this the log messages will only be logged when
actually proposing or selecting traffic selectors during IKE.
2018-06-28 18:46:42 +02:00
Tobias Brunner 054ee5e7c0 ike-init: Switch to an alternative config if proposals don't match
This way we don't rely on the order of equally matching configs as
heavily anymore (which is actually tricky in vici) and this also doesn't
require repeating weak algorithms in all configs that might potentially be
selected if there are some clients that require them.

There is currently no ordering, so an explicitly configured exactly matching
proposal isn't a better match than e.g. the default proposal that also
contains the proposed algorithms.
2018-06-28 18:46:42 +02:00
Tobias Brunner da288a07aa ike-auth: Consider negotiated IKE proposal when selecting peer configs
In some scenarios we might find multiple usable peer configs with different
IKE proposals.  This is a problem if we use a config with non-matching
proposals that later causes IKE rekeying to fail.  It might even be a problem
already when creating the CHILD_SA if the proposals of IKE and CHILD_SA
are consistent.
2018-06-28 18:46:41 +02:00
Tobias Brunner 29e7fe63c3 ike-cfg: Add method to check if config contains matching proposal
This way we can check whether the config should be considered or not if
we have a selected proposal.
2018-06-28 18:46:41 +02:00
Tobias Brunner f72aa13a29 proposal: Add method to check if two proposals match
Similar to select() but does not return a proposal and does not log
anything.
2018-06-28 18:46:41 +02:00
Tobias Brunner 90f5fe1ca9 child-cfg: Log the selected proposal on level 1 2018-06-28 16:53:35 +02:00
Tobias Brunner 4d338b9acf ike-cfg: Log the selected proposal on level 1 2018-06-28 16:53:35 +02:00
Tobias Brunner aa4f0c44ee backend-manager: Add enumerator over all matching IKE configs 2018-06-28 16:53:35 +02:00
Tobias Brunner 82e237c04e backend-manager: Simplify sorting peer configs 2018-06-28 16:53:35 +02:00
Tobias Brunner b9745618cd daemon: Allow configuration of logfile path as value
Some characters are not allowed in section names, this way they can
still be used in paths of log files.
2018-06-27 14:19:35 +02:00
Tobias Brunner 61c3870bef conf: Document reference syntax 2018-06-27 14:19:35 +02:00
Tobias Brunner 089d5f9765 settings: Properly lock when extending sections or adding fallbacks
There was a potential chance for a race condition if the ensured section
was purged for some reason before using it later.

This also changes the behavior for NULL/empty strings via load_string*
with merge == FALSE, which now purges the config/section.
2018-06-27 14:19:35 +02:00
Tobias Brunner 35ca6a7b2f settings: Add reference feature
Similar to the `also` keyword in ipsec.conf, the new syntax allows adding
one or more references to other sections, which means all the settings and
subsections defined there are inherited (values may be overridden, even
with an empty value to clear it).

It's important to note that all subsections are inherited, so if this is
used to reference a connection in swanctl.conf all auth rounds and
children are inherited.  There is currently no syntax to limit the
inclusion level or clear inherited sections (but as mentioned, settings
in those inherited sections may be overridden).

Another property is that inherited settings or sections always follow
explicitly defined entries in the current section when they are enumerated.
This is relevant if the order is important (e.g. for auth rounds if `round`
is not specified).

References are evaluated dynamically at runtime, so referring to
sections later in the config file or included via other files is no
problem.

The colon used as separator to reference other sections may be used in
section names by writing :: (e.g. for Windows log file paths).

This is based on a patch originally written in 2016.
2018-06-27 14:19:35 +02:00
Tobias Brunner 0ca0fa71c0 charon-systemd: Register journal logger as custom logger
This way we get early log messages during plugin loading (including
integrity check results).

Instead of the fallback we could also remove the `customlog` namespace,
which was added to avoid conflicts with other settings/sections.
2018-06-26 15:24:42 +02:00
Tobias Brunner 2c02b02589 linked-list: Order of insert_before/remove_at calls doesn't matter anymore
This was quite confusing previously:  While calling insert_before()
and then remove_at() properly replaced the current item, calling them the
other way around inserted the new item before the previous item because
remove_at() changed the enumerator's position to the previous item.

The behavior in corner cases (calling the methods before or after
enumeration) is also changed slightly.
2018-06-26 15:11:02 +02:00
Tobias Brunner 91640baf6d vici: Maintain connection order when replacing one 2018-06-26 15:10:40 +02:00
Andreas Steffen ef4a63524f vici: list cert_policy parameter 2018-06-22 10:39:40 +02:00
Tobias Brunner 3a05566d0e ike-mobike: Always use this task for DPDs even if not behind a NAT
This allows switching to probing mode if the client is on a public IP
and this is the active task and connectivity gets restored.  We only add
NAT-D payloads if we are currently behind a NAT (to detect changed NAT
mappings), a MOBIKE update that might follow will add them in case we
move behind a NAT.
2018-06-22 09:20:30 +02:00
Tobias Brunner 35e49ffd2f unit-tests: Add mock implementation of kernel_net_t
This is required for DPDs via ike-mobike task to work (it does a source
address lookup).
2018-06-22 09:20:30 +02:00
Andreas Steffen daf8ed210a vici: Fixed crash when parsing cert_policy parameter 2018-06-22 08:52:09 +02:00
Andreas Steffen 782344e5e5 libimcv: Prevent integer overflow in time conversion 2018-06-18 11:04:53 +02:00
Andreas Steffen 97688e8567 libtpmtss: Query maximum TPM data transmission size 2018-06-14 15:47:27 +02:00
Andreas Steffen 2a26566ed3 libimcv: Implementation of RFC 8412 SWIMA 2018-06-12 21:47:40 +02:00
Andreas Steffen 27ec213d0b libimcv: Added reserved field in SWIMA Inventory encoding 2018-06-12 21:47:40 +02:00
Andreas Steffen cd6e45817e libimcv: Fixed processing of PTS Request File Metadata 2018-06-12 21:47:39 +02:00
Andreas Steffen 0a3c89a053 libimcv: Removed whitespace 2018-06-12 21:47:39 +02:00
Andreas Steffen 66b9287cd5 libimcv: Fixed processing of PTS Simple Component Evidence 2018-06-12 21:47:39 +02:00
Andreas Steffen e1833a90ba bio_reader: Fix read_uint24 2018-06-12 21:47:39 +02:00
Andreas Steffen a31f9b7691 libimcv: Removed TCG SWID IMC/IMV support 2018-06-12 21:47:39 +02:00
Andreas Steffen eccd2b6e09 libimcv: SWIMA SW locator must be file URI 2018-06-12 17:53:06 +02:00
Andreas Steffen 0b445a5c54 libimcv: Updated IANA numbers assigned to SWIMA 2018-06-12 17:53:06 +02:00
Micah Morton 4f1d2f2b09 Allow charon to change group on files before dropping caps
Allow charon to start as a non-root user without CAP_CHOWN and still be
able to change the group on files that need to be accessed by charon
after capabilities have been dropped. This requires the user charon starts
as to have access to socket/pidfile directory as well as belong to the
group that charon will run as after dropping capabilities.

Closes strongswan/strongswan#105.
2018-06-12 10:25:30 +02:00
Markus Sattler 1331010aa4 starter: Reset action before handling it
Stater will lose update/reload commands when there is a second signal
coming in when the previous is still processed. This can happen more
easily with big configurations.

Closes strongswan/strongswan#101.
2018-06-05 10:13:22 +02:00
Andreas Steffen 6d087b33de libstrongswan: xmppaddr prefix designates an xmppAddr otherName ID type 2018-05-30 17:25:28 +02:00
Tobias Brunner 6d8a57342b ikev2: Initialize variable in case set_key() or allocate_bytes() fails
In case the PRF's set_key() or allocate_bytes() method failed, skeyseed
was not initialized and the chunk_clear() call later caused a crash.

This could have happened with OpenSSL in FIPS mode when MD5 was
negotiated (and test vectors were not checked, in which case the PRF
couldn't be instantiated as the test vectors would have failed).
MD5 is not included in the default proposal anymore since 5.6.1, so
with recent versions this could only happen with configs that are not
valid in FIPS mode anyway.

Fixes: CVE-2018-10811
2018-05-24 15:45:08 +02:00
Tobias Brunner 2c7a4b0704 swanctl: Document new HW offload options/behavior 2018-05-24 10:49:19 +02:00
Tobias Brunner 887885f33b sw-collector: Proper cleanup if DB query fails in check operation 2018-05-23 20:25:50 +02:00
Tobias Brunner d837d0b339 kernel-netlink: Use strncpy to copy interface name when configuring HW offload 2018-05-23 20:25:49 +02:00
Tobias Brunner 89bd016ef4 Fixed some typos, courtesy of codespell 2018-05-23 16:33:02 +02:00
Tobias Brunner 1b67166921 Unify format of HSR copyright statements 2018-05-23 16:32:53 +02:00
Tobias Brunner 740133b12d settings: Parse assigned values in a different context
This allows us to accept characters like = or { without having to use
quoted strings.  And we can also properly warn about unexpected quoted
strings.
2018-05-23 12:01:50 +02:00
Tobias Brunner f8c20fb1c2 settings: Support CRLF in settings parser 2018-05-23 12:01:45 +02:00
Tobias Brunner c057cd26fa swanctl: Add option to force IKE_SA termination 2018-05-22 10:06:07 +02:00
Tobias Brunner 0bcfed1aa2 vici: Optionally terminate IKE_SA immediately 2018-05-22 10:06:07 +02:00
Tobias Brunner 7b72909774 controller: Add option to force destruction of an IKE_SA
It's optionally possible to wait for a timeout to destroy the SA.
2018-05-22 10:06:07 +02:00
Tobias Brunner a79d510354 ike-sa: Add option to force the destruction of an IKE_SA after initiating a delete 2018-05-22 10:06:07 +02:00
Martin Willi c58434aeff proposal: Add a compat alg for ChaCha20Poly1305 with explicit key length
The keylength fix for ChaCha20Poly1305 (5a7b0be2) removes the keylength
attribute from the AEAD transform. This breaks compatibility between
versions with the patch and those without. The ChaCha20Poly1305 AEAD
won't match in proposals between such versions, and if no other algorithm
is available, negotiating SAs fails.

As a migration strategy, this patch introduces a new string identifier for a
ChaCha20Poly1305 proposal keyword which uses the explicit keylength, exactly
as it was used before the mentioned patch. Administrators that care about
the use of that AEAD with old clients can temporarily add this keyword to
the list of proposals, until all clients have been upgraded.

The used approach is the least invasive, as it just adds an additional
keyword that can't do any harm if not explicitly configured. Nontheless
allows it the administrator to smoothly keep ChaCha20Poly1305 working,
even if upgrading all peers simultaneously is not an option. It requires
manual configuration edits, though, but we assume that ChaCha20Poly1305
is not that widely used, and not as the only transform in proposals.

Removing the compat keyword in a future version is an option; it might
be helpful for other implementations, though, that falsely use an
explicit key length in ChaCha20Poly1305 AEAD transforms.
2018-05-22 10:05:22 +02:00
Tobias Brunner 10b8acb554 kernel-netlink: Change how routes are un-/installed
We now check if there are other routes tracked for the same destination
and replace the installed route instead of just removing it.  Same during
installation, where we previously didn't replace existing routes due to
NLM_F_EXCL.  Routes with virtual IPs as source address are preferred over
routes without.

This should allow using trap policies with virtual IPs on Linux.

Fixes #85, #2162.
2018-05-22 10:04:24 +02:00
Tobias Brunner 0cf3549675 revocation: Fix memory leak if fetching CRL/OCSP fails
We might get a 404 error page back.
2018-05-22 09:50:47 +02:00
Tobias Brunner cae43b890a revocation: Set defaults if CRL/OCSP checking is disabled in config 2018-05-22 09:50:47 +02:00
Tobias Brunner b00d3adbd1 revocation: Also store validation results for intermediate CA certificates
If the certificate is revoked, we immediately returned and the chain was
invalid, however, if we couldn't fetch the CRL that result was not stored
for intermediate CAs and we weren't able to enforce a strict CRL policy
later.
2018-05-22 09:50:47 +02:00
Tobias Brunner 13f76a241c revocation: Ignore CRLs that are not yet valid
Using such CRLs can be a problem if the clock on the host doing the
revocation check is trailing behind that of the host issuing CRLs in
scenarios where expired certificates are removed from CRLs.  As revoked
certificates that expired will then not be part of new CRLs a host with
trailing clock might still accept such a certificate if it is still
valid according to its system clock but is not contained anymore in the
not yet valid CRL.
2018-05-22 09:50:47 +02:00
Tobias Brunner 9c6b102ee0 openssl: Fail CRL validity check if thisUpdate is in the future 2018-05-22 09:50:47 +02:00
Tobias Brunner a0902d1ae0 x509: Fail CRL validity check if thisUpdate is in the future 2018-05-22 09:50:47 +02:00
Tobias Brunner 6143f926ef ike: Reject certificates that are not compliant with RFC 4945 2018-05-22 09:50:47 +02:00
Tobias Brunner 504e12326d openssl: Set IKE compliance flag depending on keyUsage 2018-05-22 09:50:47 +02:00
Tobias Brunner 920366e688 x509: Set IKE compliance flag depending on keyUsage 2018-05-22 09:50:47 +02:00
Tobias Brunner 9fcf4fdda1 x509: Add flag that marks compliance with RFC 4945
According to RFC 4945, section 5.1.3.2, a certificate for IKE must
either not contain the keyUsage extension, or, if it does, have at least
one of the digitalSignature or nonReputiation bits set.
2018-05-22 09:50:47 +02:00
Tobias Brunner 7b660944b6 dhcp: Only send client identifier if identity_lease is enabled
The client identifier serves as unique identifier just like a unique MAC
address would, so even with identity_leases disabled some DHCP servers
might assign unique leases per identity.
2018-05-18 18:04:01 +02:00
Tobias Brunner 0e5b94d038 dhcp: Increase maximum size of client identification option
This increases the chances that subject DNs that might have been cut
off with the arbitrary previous limit of 64 bytes might now be sent
successfully.

The REQUEST message has the most static overhead in terms of other
options (17 bytes) as compared to DISCOVER (5) and RELEASE (7).
Added to that are 3 bytes for the DHCP message type, which means we have
288 bytes left for the two options based on the client identity (host
name and client identification).  Since both contain the same value, a
FQDN identity, which causes a host name option to get added, may be
142 bytes long, other identities like subject DNs may be 255 bytes
long (the maximum for a DHCP option).
2018-05-18 18:04:01 +02:00
Tobias Brunner 30e886fe3b dhcp: Increase buffer size for options in DHCP messages
According to RFC 2131, the minimum size of the 'options' field is 312
bytes, including the 4 byte magic cookie.  There also does not seem to
be any restriction regarding the message length, previously the length
was rounded to a multiple of 64 bytes.  The latter might have been
because in BOOTP the options field (or rather vendor-specific area as it
was called back then) had a fixed length of 64 bytes (so max(optlen+4, 64)
might actually have been what was intended), but for DHCP the field is
explicitly variable length, so I don't think it's necessary to pad it.
2018-05-18 18:04:01 +02:00
Tobias Brunner 13edecdc20 dhcp: Reduce receive buffer size on send socket
Since we won't read from the socket reducing the receive buffer saves
some memory and it should also minimize the impact on other processes that
bind the same port (Linux distributes packets to the sockets round-robin).
2018-05-18 18:04:01 +02:00
Tobias Brunner becf027cd9 dhcp: Bind server port when a specific server address is specified
DHCP servers will respond to port 67 if giaddr is non-zero, which we set
if we are not broadcasting.  While such messages are received fine via
RAW socket the kernel will respond with an ICMP port unreachable if no
socket is bound to that port.  Instead of opening a dummy socket on port
67 just to avoid the ICMPs we can also just operate with a single
socket, bind it to port 67 and send our requests from that port.

Since SO_REUSEADDR behaves on Linux like SO_REUSEPORT does on other
systems we can bind that port even if a DHCP server is running on the
same host as the daemon (this might have to be adapted to make this work
on other systems, but due to the raw socket the plugin is not that portable
anyway).
2018-05-18 18:04:01 +02:00
Tobias Brunner e8b5c7b94e dhcp: Fix destination port check in packet filter
The previous code compared the port in the packet to the client port and, if
successful, checked it also against the server port, which, therefore, never
matched, but due to incorrect offsets did skip the BPF_JA.  If the client port
didn't match the code also skipped to the instruction after the BPF_JA.
However, the latter was incorrect also and processing would have continued at
the next instruction anyway.  Basically, DHCP packets to any port were accepted.

What's not fixed with this is that the kernel returns an ICMP Port
unreachable for packets sent to the server port (67) because we don't
have a socket bound to it.

Fixes: f0212e8837 ("Accept DHCP replies on bootps port, as we act as a relay agent if server address configured")
2018-05-18 18:04:01 +02:00
Matt Selsky 646a492538 dhcp: Fix typos in comments 2018-05-18 18:04:01 +02:00
Tobias Brunner 3594663166 eap-aka-3gpp: Add test vectors from 3GPP TS 35.207 14.0.0 2018-05-18 17:37:39 +02:00
Tobias Brunner 943f3929f4 pki: --verify command optionally takes directories for CAs and CRLs 2018-05-18 17:29:00 +02:00
Tobias Brunner 667e74d60a bliss: Fix compilation with non-GNU C libraries
Not even the glibc man page mentions that type.

Fixes #2638.
2018-05-14 15:51:42 +02:00
Micah Morton b9fcc61991 Allow strongSwan to be spawned as non-root user
This patch allows for giving strongSwan only the runtime capabilities it
needs, rather than full root privileges.

Adds preprocessor directives which allow strongSwan to be configured to
 1) start up as a non-root user
 2) avoid modprobe()'ing IPsec kernel modules into the kernel, which
    would normally require root or CAP_SYS_MODULE

Additionally, some small mods to charon/libstrongswan ensure that charon
fully supports starting as a non-root user.

Tested with strongSwan 5.5.3.
2018-05-14 15:50:01 +02:00
Tobias Brunner 0d2e18a189 nm: Update NEWS 2018-05-07 12:13:23 +02:00
Tobias Brunner 6e5c00b7c7 nm: Don't hardcode install path for .name file 2018-05-07 12:09:32 +02:00
Tobias Brunner 9c4e4b5e8e nm: Don't rely on NetworkManager.pc for paths when building without libnm-glib
Also make the paths configurable, in case the defaults don't work out on
a certain platform.
2018-05-07 12:09:32 +02:00
Andreas Steffen 43a1839cbc libimcv: Added inactive field to device database table 2018-04-27 12:42:29 +02:00
Andreas Steffen 234ec9225d sw-collector: Added --check option 2018-04-27 11:42:34 +02:00
Tobias Brunner 8929c700ef ikev1: Ignore roam events for IKEv1
We don't have MOBIKE and the fallback to reauthentication does also not
make much sense as that doesn't affect the CHILD_SAs for IKEv1.  So
instead of complicating the code we just ignore roam events for IKEv1
for now.

Closes strongswan/strongswan#100.
2018-04-27 11:13:17 +02:00
Tobias Brunner 4af1fd59dd thread: Properly clean up meta data of thread if pthread_create() fails 2018-04-19 18:22:15 +02:00
Tobias Brunner a747ad738c ike: Ignore rekeyed and deleted CHILD_SAs when reestablishing IKE_SAs 2018-04-12 16:32:47 +02:00
Tobias Brunner a1620c16ec ike: Remove special handling for routed CHILD_SAs during reauth/reestablish
These are managed in the trap manager, no trap policies will ever be
attached to an IKE_SA (might have been the case in very early releases).
2018-04-12 16:30:28 +02:00
Tobias Brunner 485952ff83 controller: Remove special handling for routed CHILD_SAs when terminating
In very early versions routed CHILD_SAs were attached to IKE_SAs, since
that's not the case anymore (they are handled via trap manager), we can
remove this special handling.
2018-04-12 16:30:28 +02:00
Tobias Brunner 5a7b0be294 proposal: Don't specify key length for ChaCha20/Poly1305
This algorithm uses a fixed-length key and we MUST NOT send a key length
attribute when proposing such algorithms.

While we could accept transforms with key length this would only work as
responder, as original initiator it wouldn't because we won't know if a
peer requires the key length.  And as exchange initiator (e.g. for
rekeyings), while being original responder, we'd have to go to great
lengths to store the condition and modify the sent proposal to patch in
the key length.  This doesn't seem worth it for only a partial fix.
This means, however, that ChaCha20/Poly1305 can't be used with previous
releases (5.3.3 an newer) that don't contain this fix.

Fixes #2614.

Fixes: 3232c0e64e ("Merge branch 'chapoly'")
2018-04-12 16:07:13 +02:00
Tobias Brunner b2163409cc ikev2: Reuse marks and reqid of CHILD_SAs during MBB reauthentication
Since these are installed overlapping (like during a rekeying) we have to use
the same (unique) marks (and possibly reqid) that were used previously,
otherwise, the policy installation will fail.

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

Fixes #2608.
2018-04-12 15:45:24 +02:00
Tobias Brunner 85bfab621d ike: Float to port 4500 if either port is 500
If the responder is behind a NAT that remaps the response from the
statically forwarded port 500 to a new external port (as Azure seems to be
doing) we should still switch to port 4500 if we used port 500 so far as
it would not have been possible to send any messages to it if it wasn't
really port 500 (we only add a non-ESP marker if neither port is 500).
2018-04-12 15:25:21 +02:00
Tobias Brunner 40ec7f998a _updown: Remove printf calls for identities
This was apparently for compatibility with pluto, which escaped some
characters as octal values.
2018-04-12 15:17:24 +02:00
Tobias Brunner eb82210620 ikev1: Trigger down events for CHILD_SAs if reauthentication failed due to retransmits 2018-04-12 15:17:24 +02:00
Tobias Brunner ebc6defa05 ikev1: Reestablish SAs if reauthentication failed due to retransmits 2018-04-12 15:17:24 +02:00
Tobias Brunner a36d8097ed traffic-selector: Always print protocol if either protocol or port is set
This helps to distinguish between port and protocol if only one of them
is set.  If no protocol is set it's printed as 0, if the traffic
selector covers any port (0-65535) the slash that separates the two values
and the port is omitted.
2018-04-11 12:31:31 +02:00
Tobias Brunner 3a3136ef33 bus: Don't trigger child_updown for deleted CHILD_SAs
These were rekeyed but have not been destroyed yet.
2018-04-09 17:13:41 +02:00
Tobias Brunner 16898026a5 child-sa: Add new state to track deleted but not yet destroyed CHILD_SAs
This allows us to easily identify SAs we keep around after a rekeying to
process delayed packets.
2018-04-09 17:13:41 +02:00
Afschin Hormozdiary e873544080 ikev1: Unify child_updown calls when having duplicate QMs
If a Quick mode is initiated for a CHILD_SA that is already installed
we can identify this situation and rekey the already installed CHILD_SA.

Otherwise we end up with several CHILD_SAs in state INSTALLED which
means multiple calls of child_updown are done. Unfortunately,
the deduplication code later does not call child_updown() (so up and down
were not even).

Closes strongswan/strongswan#95.
2018-04-09 15:06:48 +02:00
Andreas Steffen 55cce124bf libtpmtss: Properly initialize tabrmd tcti_context 2018-04-09 11:07:20 +02:00
robinleander 826b4232d3 pkcs11: Use unused return value of C_GetMechanismList
Closes strongswan/strongswan#96.
2018-03-29 17:18:27 +02:00
Tobias Brunner e811659323 kernel-pfkey: Add option to install routes via internal interface
On FreeBSD, enabling this selects the correct source IP when sending
packets from the gateway itself.
2018-03-21 10:37:49 +01:00
Adi Nissim 8ced1570ab child-cfg: Make HW offload auto mode configurable
Until now the configuration available to user for HW offload were:
hw_offload = no
hw_offload = yes

With this commit users will be able to configure auto mode using:
hw_offload = auto

Signed-off-by: Adi Nissim <adin@mellanox.com>
Reviewed-by: Aviv Heller <avivh@mellanox.com>
2018-03-21 10:32:02 +01:00
Tobias Brunner ee26f7156f kernel-netlink: Cleanup and fix some HW offload code issues
Besides some style issues there were some incorrect allocations
for ethtool requests.
2018-03-21 10:29:57 +01:00
Adi Nissim 338cc5812e kernel-netlink: Add new automatic hw_offload mode
Until now there were 2 hw_offload modes: no/yes
* hw_offload = no  : Configure the SA without HW offload.
* hw_offload = yes : Configure the SA with HW offload.
                     In this case, if the device does not support
                     offloading, SA creation will fail.

This commit introduces a new mode: hw_offload = auto
----------------------------------------------------
If the device and kernel support HW offload, configure
the SA with HW offload, but do not fail SA creation otherwise.

Signed-off-by: Adi Nissim <adin@mellanox.com>
Reviewed-by: Aviv Heller <avivh@mellanox.com>
2018-03-21 10:28:44 +01:00
Adi Nissim aad9bd3613 ipsec-types: Create new enum hw_offload_t
Add the new enum in order to add HW offload auto mode.

Signed-off-by: Adi Nissim <adin@mellanox.com>
Reviewed-by: Aviv Heller <avivh@mellanox.com>
2018-03-21 10:27:38 +01:00
Martin Willi 3b29590b70 starter: Ignore an existing PID file if it references ourself 2018-03-21 10:25:49 +01:00
Martin Willi 83187f3883 charon-tkm: Ignore an existing PID file if it references ourself 2018-03-21 10:25:49 +01:00
Martin Willi 9655a3ffbc charon: Ignore an existing PID file if it references ourself
If a daemon PID file references the process that does the check, it is safe
to ignore it; no running process can have the same PID. While this is rather
unlikely to get restarted with the same PID under normal conditions, it is
quite common when running inside PID namespaced containers: If a container
gets stopped and restarted with a PID file remaining, it is very likely that
the PID namespace assigns the same PID to our service, as they are assigned
sequentially starting from 1.
2018-03-21 10:25:49 +01:00
Tobias Brunner a7005e435b diffie-hellman: Remove unused exponent length initialization in get_params()
This isn't used anymore since 46184b07c1 ("diffie-hellman: Explicitly
initialize DH exponent sizes during initialization").
2018-03-21 10:21:32 +01:00
Tobias Brunner 8b6f615741 diffie-hellman: Don't set exponent length for DH groups with prime order subgroups
According to RFC 5114 the exponent length for these groups should always equal
the size of their prime order subgroup.
This was handled correctly before the initialization was done during
library initialization.

Fixes: 46184b07c1 ("diffie-hellman: Explicitly initialize DH exponent sizes during initialization")
2018-03-21 10:21:32 +01:00
Tobias Brunner ee019ab321 proposal: Make sure non-AEAD IKE proposals contain integrity algorithms 2018-03-21 10:15:18 +01:00
Tobias Brunner 42a6b187f7 proposal: Compress arrays after removing transforms 2018-03-21 10:15:18 +01:00
Tobias Brunner a48f3d8939 ikev2: Use correct type to check for selected signature scheme
The previous code was obviously incorrect and caused strange side effects
depending on the compiler and its optimization flags (infinite looping seen
with GCC 4.8.4, segfault when destroying the private key in build() seen
with clang 4.0.0 on FreeBSD).

Fixes #2579.
2018-03-21 10:12:59 +01:00
Tobias Brunner 70d99d67d6 vici: Make sure to read all requested data from socket in Perl binding
Closes strongswan/strongswan#91.
2018-03-21 10:10:35 +01:00
Tobias Brunner d3b9db688a libimcv: Add Debian 8.10 to IMV database
References #2582.
2018-03-20 09:20:17 +01:00
Tobias Brunner 0acd1ab4d0 stroke: Ensure a minimum message length 2018-03-19 18:06:00 +01:00
Matus Fabian 04ede658c8 libipsec: Fix ip_packet_create_from_data() version field in IPv6 header
Closes strongswan/strongswan#92.

Signed-off-by: Matus Fabian <matfabia@cisco.com>
2018-03-19 11:01:10 +01:00
Tobias Brunner 53827a5fde load-tester: Start numbering IDs from 1 again
ref_get() increments the number before returning it.

Fixes: 2cbaa63295 ("load-tester: Fix race condition issuing same identity")
2018-03-07 15:41:56 +01:00
Tobias Brunner 954f73ea6e charon-nm: Parse any type of private key not only RSA 2018-03-07 15:23:03 +01:00
Tobias Brunner 5808467ed1 pkcs5: Parse PRF algorithms if given in PBKDF2-params as defined in RFC 8018
We can't use ASN1_DEF, which would technically be more correct, as the
ASN.1 parser currently can't handle that.  For algorithm identifiers we
often use ASN1_EOC as type (with ASN1_RAW), however, that doesn't work with
ASN1_DEF because the element is assumed missing if the type doesn't match.
On the other hand, we can't set the type to ASN1_SEQUENCE because then the
parser skips the following rule if the element is missing (it does so for
all constructed types, but I guess is mainly intended for context tags),
which in this case overruns the parser rules array.
2018-03-07 15:23:03 +01:00
Tobias Brunner e5c5792ff8 prf: Add helper function to convert OIDs to algorithm identifiers 2018-03-07 15:23:03 +01:00
Tobias Brunner ba16a95454 asn1: Add OIDs for HMAC-based PRFs as defined in RFC 8018 2018-03-07 15:23:03 +01:00
Tobias Brunner 6b8749ab18 proposal: Compare algorithms of all transform types for equality 2018-03-05 12:25:19 +01:00
Tobias Brunner 76c7c951e1 proposal: Make sure to consider all transform types when selecting proposals
This way there will be a mismatch if one of the proposals contains
transform types not contained in the other (the fix list of transform
types used previously resulted in a match if unknown transform types
were contained in one of the proposals).  Merging the sets of types
makes comparing proposals with optional transform types easier (e.g.
DH for ESP with MODP_NONE).
2018-03-05 12:23:59 +01:00
Tobias Brunner 5eb094df11 proposal: Print all algorithms even those with currently unknown transform types 2018-03-05 12:05:36 +01:00
Tobias Brunner cc55461c8d proposal: Keep track of contained transform types 2018-03-05 12:05:36 +01:00
Tobias Brunner ec1ebb2377 transform: Move internal identifiers out of private range
Avoid any conflicts if implementations use transform types in the
private range.
Also removed the unused UNKNOWN_TRANSFORM_TYPE identifier.
2018-03-05 12:05:36 +01:00
Tobias Brunner 0d06cbd66e unit-tests: Ignore binaries of renamed test runners
Fixes: 9cc61baaf5 ("unit-tests: Rename targets for libstrongswan and kernel-netlink")
2018-03-02 17:11:27 +01:00
Tobias Brunner cdfa0ba4d1 libimcv: Fix typo in PTS hash algorithm mapping for 512-bit SHA-3
Fixes: 40f2589abf ("gmp: Support of SHA-3 RSA signatures")
2018-03-02 08:30:13 +01:00
Tobias Brunner 2f5d6be5a0 kernel-netlink: Ignore local routes in any table
Such routes seem to show up in tables other than local with recent kernels.

Fixes #2555.
2018-02-28 15:32:41 +01:00
Tobias Brunner 9189aec666 kernel-netlink: Ignore routes with next hop during local subnet enumeration
These are not locally attached and we do the same already in kernel-pfroute.

Fixes #2554.
2018-02-28 15:32:30 +01:00
Tobias Brunner d9400f44d8 kernel-netlink: Simplify rt_entry_t initialization 2018-02-28 15:32:25 +01:00
Tobias Brunner 958a0545e5 nm: Version bump to 1.4.4 2018-02-28 15:30:42 +01:00
Tobias Brunner 07f6cfe910 nm: Update German translation 2018-02-28 15:29:39 +01:00
Tobias Brunner 5bb197d880 nm: Fix tooltips for proposal text fields
There is no ! syntax as the default proposal is only used if no custom
proposal is configured.
2018-02-28 15:22:41 +01:00
Tobias Brunner 574f74d232 child-rekey: Don't destroy IKE_SA if initiating CHILD_SA rekeying failed
This could happen if the peer e.g. selects an invalid DH group or
responds multiple time with an INVALID_KE_PAYLAOD notify.
2018-02-23 09:25:46 +01:00
Tobias Brunner 4f1bf89ed9 child-create: Fail if we already retried with a requested DH group
With faulty peers that always return the same unusable DH group in
INVALID_KE_PAYLOADs we'd otherwise get stuck in a loop.
2018-02-23 09:25:46 +01:00
Tobias Brunner 7754c714c1 child-create: Make sure we actually propose the requested DH group
If we receive an INVALID_KE_PAYLOAD notify we should not just retry
with the requested DH group without checking first if we actually propose
the group (or any at all).
2018-02-23 09:25:46 +01:00
Tobias Brunner ecbcfbdaa1 child-create: Make sure the returned KE payload uses the proposed DH group 2018-02-23 09:25:46 +01:00
Tobias Brunner 529ffc2fe3 child-sa: Don't update outbound policies if they are not installed
After a rekeying we keep the inbound SA and policies installed for a
while, but the outbound SA and policies are already removed.  Attempting
to update them could get the refcount in the kernel interface out of sync
as the additional policy won't be removed when the CHILD_SA object is
eventually destroyed.
2018-02-22 11:38:43 +01:00
Tobias Brunner ca79bd54ff child-sa: Don't try to update outbound SA if it is not installed anymore 2018-02-22 11:38:38 +01:00
Tobias Brunner a541cf05c1 trap-manager: Remove unused find_reqid() method
It might actually have returned an incorrect result if there were child
configs for different peer configs sharing the same name.
2018-02-22 11:31:05 +01:00
Tobias Brunner c9998e5fea child-sa: No need to find reqid of existing trap policy
When initiating a trap policy we explicitly pass the reqid along.  I guess
the lookup was useful to get the same reqid if a trapped CHILD_SA is manually
initiated.  However, we now get the same reqid anyway if there is no
narrowing.  And if the traffic selectors do get narrowed the reqid will be
different but that shouldn't be a problem as that doesn't cause an issue with
any temporary SAs in the kernel (this is why we pass the reqid to the
triggered CHILD_SA, otherwise, no new acquire would get triggered for
traffic that doesn't match the wider trap policy).
2018-02-22 11:31:05 +01:00
Tobias Brunner 24fa1bb02a trap-manager: Remove reqid parameter from install() and change return type
Reqids for the same traffic selectors are now stable so we don't have to
pass reqids of previously installed CHILD_SAs.  Likewise, we don't need
to know the reqid of the newly installed trap policy as we now uninstall
by name.
2018-02-22 11:31:05 +01:00
Tobias Brunner f42dd430d8 trap-manager: Compare peer config name during installation 2018-02-22 11:31:05 +01:00
Tobias Brunner ca213e1907 trap-manager: Uninstall trap policies by name and not reqid
If a trap policy is concurrently uninstalled and reinstalled under a
different name the reqid will be the same so the wrong trap might be
removed.
2018-02-22 11:31:05 +01:00
Tobias Brunner 6f569263a0 vici: Remove external enumeration to uninstall shunt policies 2018-02-22 11:31:05 +01:00
Tobias Brunner 9d69d8a399 stroke: Remove external enumeration to unroute shunt policies 2018-02-22 11:31:05 +01:00
Tobias Brunner 57ea3f73bb shunt-manager: Remove first match if no namespace given during uninstall
Also makes namespace mandatory.
2018-02-22 11:31:05 +01:00
Tobias Brunner c1c63a400e appveyor: Allow events to trigger early in threading unit tests
The timed wait functions tested in the threading unit tests often but
randomly trigger a bit early on AppVeyor Windows containers.  We allow this
if it is not earlier than 5ms.
2018-02-22 09:19:14 +01:00
Tobias Brunner ee8c25516a charon-nm: Fix building list of DNS/MDNS servers with libnm
g_variant_builder_add() creates a new GVariant using g_variant_new() and
then adds it to the builder.  Passing a GVariant probably adds the
pointer to the array, not the value.  I think an alternative fix would
be to use "@u" as type string for the g_variant_builder_add() call, then
the already allocated GVariant is adopted.

Fixes: 9a71b7219c ("charon-nm: Port to libnm")
2018-02-22 09:05:48 +01:00
Tobias Brunner 9ba01ce380 x509: Fix leak if a CRL contains multiple authorityKeyIdentifiers 2018-02-21 11:13:42 +01:00
Tobias Brunner 29b983309f nm: Version bump to 1.4.3 2018-02-19 14:45:15 +01:00
Tobias Brunner 40da179f28 signature-params: Properly handle MGF1 algorithm identifier without parameters
Credit to OSS-Fuzz.

Fixes: CVE-2018-6459
2018-02-19 10:29:32 +01:00
Tobias Brunner fb545dd34d vici: Also return close action 2018-02-16 09:55:22 +01:00
Tobias Brunner bac71410f3 save-keys: Add warning message to log if keys are being saved 2018-02-15 23:03:29 +01:00
Tobias Brunner 1da1ba01c4 save-keys: Add options to enable saving IKE and/or ESP keys 2018-02-15 23:03:29 +01:00
Codrut Cristian Grosu 88e151d10d save-keys: Store derived CHILD_SA keys in Wireshark format 2018-02-15 23:03:29 +01:00
Codrut Cristian Grosu 4be7db5f60 save-keys: Store derived IKE_SA keys in Wireshark format
The path has to be set first, otherwise, nothing is done.
2018-02-15 23:03:29 +01:00
Codrut Cristian Grosu 345cd4684c save-keys: Add save-keys plugin
This plugin will export IKE_SA and CHILD_SA secret keys in the format used
by Wireshark.

It has to be loaded explicitly.
2018-02-15 23:03:29 +01:00
Andreas Steffen 4eaf08c35b vici: list-conn reports DPD settings and swanctl displays them 2018-02-15 16:28:06 +01:00
Tobias Brunner ac140220c4 proposal: Add modp6144 to the default proposal
We always had modp4096 and modp8192 included, not sure why this wasn't.
2018-02-14 14:54:32 +01:00
Tobias Brunner ce048c30ff ha: Double receive buffer size for HA messages and make it configurable
With IKEv1 we transmit both public DH factors (used to derive the initial
IV) besides the shared secret.  So these messages could get significantly
larger than 1024 bytes, depending on the DH group (modp2048 just about
fits into it).  The new default of 2048 bytes should be fine up to modp4096
and for larger groups the buffer size may be increased (an error is
logged should this happen).
2018-02-14 14:52:18 +01:00
Tobias Brunner 2db6d5b8b3 Fixed some typos, courtesy of codespell 2018-02-13 12:19:54 +01:00
Tobias Brunner 044b0f048b ike-mobike: Don't trigger update for NAT mapping change detected during an address update
This is really only needed for other exchanges like DPDs not when we
just updated the addresses. The NAT-D payloads are only used here to
detect whether UDP encapsulation has to be enabled/disabled.
2018-02-09 15:53:30 +01:00
Tobias Brunner 35ef1b032d child-sa: Install drop policies while updating IPsec SAs and policies
If we have to remove and reinstall SAs for address updates (as with the
Linux kernel) there is a short time where there is no SA installed.  If
we keep the policies installed they (or any traps) might cause acquires
and temporary kernel states that could prevent the updated SA from
getting installed again.

This replaces the previous workaround to avoid plaintext traffic leaks
during policy updates, which used low-priority drop policies.
2018-02-09 15:53:30 +01:00
Tobias Brunner 4664992f7d kernel-netlink: Optionally trigger roam events on routing rule changes
This can be useful if routing rules (instead of e.g. route metrics) are used
to switch from one to another interface (i.e. from one to another
routing table).  Since we currently don't evaluate routing rules when
doing the route lookup this is only useful if the kernel-based route
lookup is used.

Resolves strongswan/strongswan#88.
2018-02-09 15:51:28 +01:00
Tobias Brunner 80ae474863 ike-sa: Remove unused counter for pending MOBIKE updates 2018-02-09 11:21:02 +01:00
Tobias Brunner 9f0497818c ike-mobike: Only ignore MOBIKE responses if an actual update is queued
The counter does not tell us what task is actually queued, so we might
ignore the response to an update (with NAT-D payloads) if only an address
update is queued.
2018-02-09 11:21:02 +01:00
Tobias Brunner 2d27c350f8 ikev2: Update currently queued MOBIKE task
Instead of destroying the new task and keeping the existing one we
update any already queued task, so we don't loose any work (e.g. if a
DPD task is active and address update is queued and we'd actually like
to queue a roam task).
2018-02-09 11:21:02 +01:00
Tobias Brunner 43bbe07036 ike-mobike: Don't reset address update flag if set previously
If we update a queued job we don't want to reset previously set task
properties.
2018-02-09 11:21:02 +01:00
Tobias Brunner f90561155b ike: Add log message if host moves out of NAT 2018-02-09 11:21:02 +01:00
Tobias Brunner 626e8a31d0 ikev1: Properly handle fragmented Quick Mode messages 2018-02-09 10:46:00 +01:00
Tobias Brunner 73cbce6013 libradius: Pad received MSK to at least 64 bytes
According to RFC 3748 MSKs must be at least 64 bytes, however, that's
not the case for the MSK derived via EAP-MSCHAPv2.  The two key parts
received are only 16 bytes each (derived according to RFC 3079,
section 3.3), so we end up with an MSK of only 32 bytes. The eap-mschapv2
plugin, on the other hand, pads these two parts with 32 zeros.

Interestingly, this is not a problem in many cases as the SHA1/2 based
PRFs used later use a block size that's >= 64 bytes, so the shorter MSK
is just padded with zeros then.  However, with AES-XCBC-PRF-128, for
instance, which uses a block size of 16 bytes, the different MSKs are an
issue as XCBC is applied to both to shorten them, with different results.
This eventually causes the authentication to fail if the client uses a
zero-padded MSK produced by the eap-mschapv2 plugin and the server the 32
byte MSK received via RADIUS.
2018-02-09 10:44:52 +01:00
Tobias Brunner e698bdea24 man: Fix documentation of pubkey constraints
Hash algorithms have to be repeated for multiple key types.

References #2514.
2018-02-09 10:42:13 +01:00
Tobias Brunner 5a259ade4e child-create: Promote selected DH group, demote proposals that don't contain it 2018-02-09 10:20:05 +01:00
Tobias Brunner ff79020cd2 ike-init: Promote selected DH group and demote proposals that don't contain it 2018-02-09 10:20:05 +01:00
Tobias Brunner d9c9b7b832 proposal: Add method to move a given DH group to the front
This way a responder (like strongSwan) selecting a proposal first and
then checking if the KE payload matches sees the peer's preferred group
first.
2018-02-09 10:20:05 +01:00
Tobias Brunner 97ad041e6e unit-tests: Make sure we reuse the DH group during CHILD_SA rekeying 2018-02-09 10:20:05 +01:00
Tobias Brunner 576d9b907c ike-init: Make DH group reuse optional to test INVALID_KE_PAYLOAD handling
This is currently not an issue for CHILD_SA rekeying tests as these only
check rekeyings of the CHILD_SA created with the IKE_SA, i.e. there is
no previous DH group to reuse.
2018-02-09 10:20:05 +01:00
Tobias Brunner 27b0bd91d4 child-rekey: Use previously negotiated DH group when rekeying CHILD_SAs
For the CHILD_SA created with the IKE_SA the group won't be set in the
proposal, so we will use the first one configure just as if the SA was
created new with a CREATE_CHILD_SA exchange.  I guess we could
theoretically try to use the DH group negotiated for IKE but then this
would get a lot more complicated as we'd have to check if that group is
actually contained in any of the CHILD_SA's configured proposals.
2018-02-09 10:20:05 +01:00
Tobias Brunner f8e53003aa child-create: Add an option to set the DH group to be used 2018-02-09 10:20:05 +01:00
Tobias Brunner 727615ee05 ike-init: Reuse the DH group of the previous IKE_SA when rekeying 2018-02-09 10:20:05 +01:00
Tobias Brunner 18242f62c2 ike-init: Move creation of DH instance after INVALID_KE_PAYLOAD to build_i()
This way we get proper error handling if the DH group the peer requested
is not actually supported for some reason (otherwise we'd just retry to
initiate with the configured group and get back another notify).
2018-02-09 10:20:05 +01:00
Tobias Brunner d058fd3c32 child-cfg: Strip DH groups from both compared proposals
This fixes two issues, one is a bug if a DH group is configured for the
local ESP proposals and charon.prefer_configured_proposals is disabled.
This would cause the DH groups to get stripped not from the configured but
from the supplied proposal, which usually already has them stripped.  So
the proposals wouldn't match.  We'd have to always strip them from the local
proposal.  Since there are apparently implementations that, incorrectly, don't
remove the DH groups in the IKE_AUTH exchange (e.g. WatchGuard XTM25
appliances) we just strip them from both proposals.  It's a bit more lenient
that way and we don't have to complicate the code to only clone and strip the
local proposal, which would depend on a flag.

References #2503.
2018-02-09 10:18:59 +01:00
Tobias Brunner 007a2701bb ike: Don't handle roam events if no IKE config is available
IKE_SAs newly created via HA_IKE_ADD message don't have any IKE or peer
config assigned yet (this happens later with an HA_IKE_UPDATE message).
And because the state is initially set to IKE_CONNECTING the roam() method
does not immediately return, as it later would for passive HA SAs. This
might cause the check for explicitly configured local addresses to crash
the daemon with a segmentation fault.

Fixes #2500.
2018-02-09 10:10:07 +01:00
Adrian-Ken Rueegsegger fcff3808b4 charon-tkm: Update to latest Anet version 2018-02-08 17:01:38 +01:00
Tobias Brunner c6a402d4fa android: New release after changing cert sending policy 2018-02-08 12:26:11 +01:00
Tobias Brunner 6bafa2d346 android: Always send the client certificate
In scenarios where the server accepts client certificates from dozens or
even hundreds of CAs it might be necessary to omit certificate request
payloads from the IKE_SA_INIT response to avoid fragmentation.

As it is rarely the case in road-warrior scenarios that the server
already has the client certificate installed it should not be a problem
to always send it.
2018-02-08 12:15:36 +01:00
Tobias Brunner c7263577b3 auth-cfg: Classify key strengths as multi value rules
If that's not the case only the last value added would be considered
not all the keys of a trust chain.

Fixes #2515.
2018-02-08 10:15:53 +01:00
Tobias Brunner 268a1bfa34 charon-nm: Remove unused variable 2018-02-05 15:11:03 +01:00
Tobias Brunner 4a84fb07ca gmp: Fix compatibility with older libgmp releases
Older releases don't have mpz_powm_sec() and mpz_inits() yet.

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

Fixes #2509.
2018-01-31 10:50:41 +01:00
Reinhard Pfau a8e940ade2 eap: Reset errno before calling strtoul() to parse EAP type
Reset errno to 0 before calling strtoul() since it sets errno only on
error cases. So the following test fails even on correct conversions if
errno had a value != 0.

Fixes #2506.
2018-01-23 10:09:14 +01:00
Andreas Steffen 3232cf68b9 libtpmtss: Return after failure 2018-01-09 16:12:40 +01:00
Tobias Brunner 419ae9a20a ikev1: Default remote identity to %any for PSK lookup if not configured
Otherwise, the remote identity is ignored when matching owner identities
of PSKs and this way matching PSKs that explicitly have %any assigned is
improved.

Fixes #2497.
2017-12-22 10:37:32 +01:00
Tobias Brunner a9f3016ef3 stroke: Don't ignore %any as owner of shared secrets
If users want to associate secrets with any identity, let 'em. This is
also possible with vici and might help if e.g. the remote identity is
actually %any as that would match a PSK with local IP and %any better
than one with local and different remote IP.

Fixes #2497.
2017-12-22 10:33:27 +01:00
Tobias Brunner 3c36c95539 kernel-netlink: Fix compilation on old kernels not defining IFA_F_NODAD
Fixes #2490.
2017-12-22 10:28:05 +01:00
Tobias Brunner 381f6d982c kernel-pfkey: Fix extended replay configuration on FreeBSD 11.1
Fixes: 88a8fba1c7 ("kernel-pfkey: Support anti-replay windows > 2k")
Fixes #2501.
2017-12-22 10:19:49 +01:00
Tobias Brunner 6d98bb926e swanctl: Allow dots in authority/shared secret/pool names
Use argument evaluation provided by settings_t instead of using strings
to enumerate key/values.

If section names contain dots the latter causes the names to get split
and interpreted as non-existing sections and subsections.

This currently doesn't work for connections and their subsections due to
the recursion.
2017-12-22 10:11:21 +01:00
Tobias Brunner a7f613ca2e vici: Document NTLM secrets in README.md
Fixes #2481.
2017-12-22 10:09:26 +01:00
Tobias Brunner 859d645c44 vici: Accept XAUTH as shared key type too
Fixes #2481.
2017-12-22 10:09:22 +01:00
Lubomir Rintel 9a71b7219c charon-nm: Port to libnm
libnm-glib is deprecated for several years and reaching the end of its
life. Let's switch to the more up-to-date library.

Closes strongswan/strongswan#85.
2017-12-22 10:05:10 +01:00
Andreas Steffen 0fb293fc91 tpm_extendpcr: Extend digests into a TPM PCR 2017-12-13 07:10:28 +01:00
Andreas Steffen ee402a22a3 asn1: Added tlsfeature OID 2017-12-10 19:56:14 +01:00
Andreas Steffen 3e7a19bfa9 pki: Extend pki --print with --keyid parameter 2017-12-10 19:31:10 +01:00
Andreas Steffen acfd590ab6 imc-os: Derive device ID from private key bound to smartcard or TPM 2017-12-10 11:51:50 +01:00
Eyal Birger 2389168388 ipsec-types: Don't mask the mark value if it is one of the 'unique' values
Support for mark=%unique/%unique-dir is implemented by using designated
magic mark values.

Use of masks is orthogonal to the 'unique' feature, as it is useful to be
able to designate portions of the packet mark for other purposes, while
still using different marks for different connections.

When these magic values are masked, their magic meaning is lost.

Perform masking only on explicit mark values.

Closes strongswan/strongswan#87.
2017-12-07 09:36:53 +01:00
Lubomir Rintel ee22e8080f nm: Allow disabling libnm-glib
The distros are eventually going to drop it, allow omitting it.

Closes strongswan/strongswan#86.
2017-12-06 11:13:03 +01:00