Commit Graph

16026 Commits

Author SHA1 Message Date
Tobias Brunner cd0bba90a9 apidoc: Add legacy README so links get properly resolved
Also reorders the input files so the READMEs are listed first in the
navigation menu on the left.
2017-05-26 14:36:25 +02:00
Andreas Steffen 2d5a79bf59 testing: Added swanctl/rw-eap-md5-id-rsa scenario 2017-05-26 14:36:25 +02:00
Andreas Steffen 7272fa0c8d README: Converted to swanctl configuration scheme 2017-05-26 14:36:25 +02:00
Tobias Brunner b668bf3f9e Merge branch 'variadic-enumerators'
This adds several changes to enumerator_t and linked_list_t to improve
portability.  In particular to Apple's ARM64 iOS platform, whose calling
convention for variadic and regular functions are different.  This means
that assigning a non-variadic function to a variadic function pointer,
as we did with our enumerator_t::enumerate() implementations and several
callbacks, will result in crashes as the called function will access the
arguments differently than the caller provided them.

To avoid this issue the enumerator_t interface is now fully variadic.
A new mandatory method is added, venumerate(), that takes a va_list with
the arguments provided while enumerating.  enumerate() is replaced with
a generic implementation that prepares a va_list and calls the
enumerator's venumerate() implementation.  As this allows passing the
arguments of one enumerator to another it avoids the five pointer hack
used by enumerator_create_nested() and enumerator_create_cleaner().
To simplify the implementation of venumerate() a helper macro is provided
that assigns values from a given va_list to local variables.

The signature of the callback passed to enumerator_create_filter() has
also changed significantly.  It's now required to enumerate over the
original enumerator in the callback as this avoids the previous in/out
pointer hack. The arguments to the outer enumerator are provided in a
va_list.

Similar changes to avoid such five pointer hacks affect the signatures
of the callbacks for linked_list_t's invoke_function() and find_first()
methods.  For the latter the return type also changed from status_t to
bool, which is important as SUCCESS is defined as 0, so checks for ==
SUCCESS will now fail.
2017-05-26 14:24:13 +02:00
Tobias Brunner 2e4d110d1e linked-list: Change return value of find_first() and signature of its callback
This avoids the unportable five pointer hack.
2017-05-26 13:56:44 +02:00
Tobias Brunner 8a2e4d4a8b linked-list: Change interface of callback for invoke_function()
This avoids the unportable five pointer hack.
2017-05-26 13:56:44 +02:00
Tobias Brunner 5cafea6edd linked-list: invoke_offset() doesn't take any additional arguments anymore 2017-05-26 13:56:44 +02:00
Tobias Brunner 525cc46cab Change interface for enumerator_create_filter() callback
This avoids the unportable 5 pointer hack, but requires enumerating in
the callback.
2017-05-26 13:56:44 +02:00
Tobias Brunner 95a63bf281 Migrate all enumerators to venumerate() interface change 2017-05-26 13:56:44 +02:00
Tobias Brunner 16bffa8b55 enumerator: Add venumerate() method to enumerator_t that takes a va_list
This will allow us to implement e.g. enumerator_cleaner without having to
use that unportable 5 pointer forwarding or having to define a callback for
each instance.

A generic implementation for enumerate() is provided so only venumerate()
has to be implemented, which may be simplified by using the VA_ARGS_VGET()
macro.
2017-05-26 13:56:44 +02:00
Tobias Brunner 5297c65398 utils: Add helper macros to read variadic arguments into local variables 2017-05-26 13:56:44 +02:00
Tobias Brunner 0da10b73ad testing: Fix ikev2/two-certs scenario
Since 6a8a44be88 the certificate received by the client is verified
first, before checking the cached certificates for any with matching
identities.  So we usually don't have to attempt to verify the signature
with wrong certificates first and can avoid this message.
2017-05-26 13:55:32 +02:00
Tobias Brunner 4366494d72 Merge branch 'sha-256-96'
Adds an option to locally configure 96-bit truncation for HMAC-SHA256
when negotiated using the official algorithm identifier.  This is for
compatibility with peers that incorrectly use this shorter truncation
(like Linux does by default).

Fixes #1353.
2017-05-26 11:23:12 +02:00
Tobias Brunner 0afe0eca67 vici: Make 96-bit truncation for SHA-256 configurable 2017-05-26 11:22:28 +02:00
Tobias Brunner 4270c8fcb0 stroke: Make 96-bit truncation for SHA-256 configurable 2017-05-26 11:22:28 +02:00
Tobias Brunner 7637633bb9 child-cfg: Optionally use 96-bit truncation for HMAC-SHA-256
The correct truncation is 128-bit but some implementations insist on
using 96-bit truncation.  With strongSwan this can be negotiated using
an algorithm identifier from a private range.  But this doesn't work
with third-party implementations.  This adds an option to use 96-bit
truncation even if the official identifier is used.
2017-05-26 11:22:27 +02:00
Tobias Brunner 7b476029e6 android-log: Link against liblog 2017-05-26 09:40:14 +02:00
Tobias Brunner 2cbb2271aa unit-tests: Fix test_chunk_eq() if arguments have side-effects 2017-05-24 09:34:17 +02:00
Tobias Brunner f8eb636e70 Merge branch 'avoid-rekey-loss'
This changes the behavior during IKEv2 CHILD_SA rekeyings to avoid
traffic loss.  When responding to a CREATE_CHILD_SA request to rekey a
CHILD_SA the responder already has everything available to install and
use the new CHILD_SA.  However, this could lead to lost traffic as the
initiator won't be able to process inbound packets until it processed the
CREATE_CHILD_SA response and updated the inbound SA.  To avoid this the
responder now only installs the new inbound SA and delays installing the
outbound SA until it receives the DELETE for the replaced CHILD_SA.  The
messages transporting these DELETEs could reach the peer before packets
sent with the deleted outbound SAs reach the respective peer.  To reduce
the chance of traffic loss due to this the inbound SA of the replaced
CHILD_SA is not removed for a configurable amount of seconds after
the DELETE has been processed.

Fixes #1291.
2017-05-23 18:49:13 +02:00
Tobias Brunner 10c7a66806 unit-tests: Check installed IPsec SAs in child-rekey tests 2017-05-23 18:46:50 +02:00
Tobias Brunner 72655fe411 unit-tests: Add assert to check for installed IPsec SAs 2017-05-23 18:46:50 +02:00
Tobias Brunner 2b581b59f0 unit-tests: Migrate cached IPsec SAs to new IKE_SAs during rekeying 2017-05-23 18:46:49 +02:00
Tobias Brunner d80055baae unit-tests: Keep track of installed IPsec SAs in mock kernel_ipsec_t implementation 2017-05-23 18:46:49 +02:00
Tobias Brunner 44107cb7b7 child-delete: Delay the removal of the inbound SA of rekeyed CHILD_SAs
After deleting a rekeyed CHILD_SA we uninstall the outbound SA but don't
destroy the CHILD_SA (and the inbound SA) immediately.  We delay it
a few seconds or until the SA expires to allow delayed packets to get
processed. The CHILD_SA remains in state CHILD_DELETING until it finally
gets destroyed.
2017-05-23 18:46:49 +02:00
Tobias Brunner ba0796fe75 delete-child-sa-job: Add new constructor that takes the unique ID of a CHILD_SA
This makes sure we delete the right SA in case the addresses got updated
in the mean time.
2017-05-23 18:46:49 +02:00
Tobias Brunner 0cbf75eb94 child-sa: Remove state to track installation of half the SA again 2017-05-23 18:46:49 +02:00
Tobias Brunner d94c122439 unit-tests: Overload helper macro to check for outbound SA state 2017-05-23 18:46:49 +02:00
Tobias Brunner afbea8ce3c child-sa: Expose state of the outbound SA 2017-05-23 18:46:48 +02:00
Tobias Brunner c5fed4cdee child-sa: Add method to remove the outbound SA and policies 2017-05-23 18:46:46 +02:00
Tobias Brunner 4ba07a8652 child-sa: Keep track whether the outbound SA has been installed or not 2017-05-23 18:46:06 +02:00
Tobias Brunner 9a5f7a30f8 child-delete: Track flags per individual CHILD_SA 2017-05-23 18:46:06 +02:00
Tobias Brunner dc3710e987 ikev2: Delay installation of outbound SAs during rekeying on the responder
The responder has all the information needed to install both SAs before
the initiator does.  So if the responder immediately installs the outbound
SA it might send packets using the new SA which the initiator is not yet
able to process.  This can be avoided by delaying the installation of the
outbound SA until the replaced SA is deleted.
2017-05-23 18:46:06 +02:00
Tobias Brunner f84757f2e6 child-sa: Add log message for CHILD_SA state changes 2017-05-23 18:46:06 +02:00
Tobias Brunner cad13450be child-sa: Add method to associate rekeyed CHILD_SAs with their replacement 2017-05-23 18:46:06 +02:00
Tobias Brunner 8a3a389e3d child-sa: Add methods that allow partial installation of CHILD_SA
Using install() for the inbound SA and register_outbound() for the
outbound SA followed by install_policies(), will delay the installation of
the outbound SA as well as the installation of the outbound policies
in the kernel until install_outbound() is called later.
2017-05-23 18:46:03 +02:00
Tobias Brunner 83186d3cf7 child-sa: Add new state to track installation of only the inbound SA 2017-05-23 18:41:31 +02:00
Tobias Brunner 4989aba822 child-sa: Change API used to set/install policies
This way we only have to pass the traffic selectors once.
2017-05-23 18:41:31 +02:00
Tobias Brunner 29ef4cf5f4 child-sa: Split in- and outbound policy de-/installation
Only install outbound fallback policies.
2017-05-23 18:41:30 +02:00
Tobias Brunner b00bcb9add child-create: Trigger NARROW_RESPONDER_POST hook before installing SAs
This makes sure we use the same set of traffic selectors when installing
the SAs and installing the policies.
2017-05-23 18:41:30 +02:00
Tobias Brunner 4cc77142e0 Merge branch 'fuzzing'
Adds support for fuzzing the certificate parser provided by the default
plugins (x509, pem, gmp etc.) on Google's OSS-Fuzz infrastructure (or
generally with libFuzzer). Fixes several issues that were found while
fuzzing these plugins.

When building the libraries monolithically and statically the
plugin constructors are now hard-coded in each library so the plugin
code is not removed by the linker because it thinks none of their symbols
are ever referenced.
2017-05-23 18:38:46 +02:00
Tobias Brunner a9b698f5be tnc-ifmap: Null-terminate buffer to make sscanf()-calls safe 2017-05-23 18:29:13 +02:00
Tobias Brunner c001716642 libimcv: Make sure the first argument to sscanf() is null-terminated 2017-05-23 18:29:13 +02:00
Tobias Brunner 411bda6836 asn1: Make sure the first argument to sscanf() is null-terminated 2017-05-23 18:29:12 +02:00
Tobias Brunner 9c42126297 x509: Fix leak when parsing CDPs if an invalid one follows valid ones 2017-05-23 18:29:12 +02:00
Tobias Brunner b72718f4b8 pem: Ensure a value before checking Proc-Type in PEM header 2017-05-23 18:29:12 +02:00
Tobias Brunner aed77b0961 chunk: Correctly parse Base64 text where four = follow in a row
That's not correct Base64 but invalid data could trigger this. Since
outlen would get reduced four times, but is only ever increased three
times per iteration, this could result in an integer underflow and then
a potential buffer overflow.
2017-05-23 18:29:12 +02:00
Tobias Brunner f5aef3a020 configure: Don't modify CFLAGs if fuzzing is enabled
Just rely on the flags passed by the build process.
2017-05-23 18:29:12 +02:00
Tobias Brunner 3963dbbde5 plugin-loader: Disable some logging output when building fuzz targets
This avoids evaluating %N. An alternative would be to define a printf-hook
for plugin features.
2017-05-23 18:29:12 +02:00
Tobias Brunner 92a10e4645 x509: Manually print CRL/OCSP URIs when fuzzing
This avoids a warning about the custom %Y printf specifier.
2017-05-23 18:29:12 +02:00
Tobias Brunner 83eacc448c processor: Move priority threads assignment to set_threads()
This avoids the evaluation of %N even if the thread pool is never used.
We need to avoid as many custom printf specifiers as possible when
fuzzing our code to avoid excessive log messages.
2017-05-23 18:29:12 +02:00