Commit Graph

10871 Commits

Author SHA1 Message Date
Andreas Steffen 881cffb826 Use bitspender->get_bytes() method in ntru_trits 2014-12-12 12:00:20 +01:00
Andreas Steffen 83447555a6 Use Huffman code in BLISS signature 2014-12-12 12:00:20 +01:00
Andreas Steffen 9394e26426 Include design parameters in generated Huffman code files 2014-12-12 12:00:20 +01:00
Tobias Brunner 700df23886 bliss: Fix monolithic build
This requires moving test files so that the Makefile for the tests can be
included after building libstrongswan, which requires the plugin when
building monolithically.  Due to this a static helper library is required
as directly referring to object files (or source files) is not possible.

It's also necessary to avoid any link-time dependency on libstrongswan in
bliss_huffman, to avoid circular dependencies (bliss_huffman -> libstrongswan
-> bliss -> bliss_huffman).
2014-12-12 12:00:20 +01:00
Tobias Brunner f55a03a2de bliss: Fix compilation warning with certain GCC versions
Theoretically, n could be zero and these variables are then used
uninitialized.  Older GCC versions warn about this and on Travis where we
compile with -Werror this causes the tests to fail.
2014-12-12 12:00:20 +01:00
Martin Willi 108e388580 swanctl: Fail loading a connection if loading a cacert constraint fails 2014-12-12 10:23:59 +01:00
Martin Willi 6855b8b36b vici: Use silent builder destroy function in vici_free_req() 2014-12-12 10:23:59 +01:00
Martin Willi c04ee43af7 vici: Add a destroy method to builder, allowing cancellation without error
When cancelling a builder, finalize throws an error which we might prefer
to avoid.
2014-12-12 10:23:59 +01:00
Martin Willi 971ef077ce eap-radius: Use the single-server legacy server options as fallback 2014-12-12 10:23:59 +01:00
Andreas Steffen 443346f56a Pack private key arrays 2014-12-10 22:45:30 +01:00
Martin Willi 48633b1844 dumm: Fix -Wformat warning in ruby extension
In recent ruby versions, extensions get built with -Wformat. As we use custom
printf specifiers, that does not work for us. As there does not seem to be a
reliable way to override -Wformat, we use a variable for the format string,
which prevents gcc from doing the -Wformat check in that particular situation.
2014-12-10 14:29:19 +01:00
Andreas Steffen df5b2ade59 Automatic generation of optimized Huffman codes 2014-12-09 11:58:18 +01:00
Andreas Steffen 7442d2a208 unit-tests: added bliss_sampler test 2014-12-09 11:58:17 +01:00
Andreas Steffen 03f2a52e9c Expanded bliss_bitpacker to 32 bits 2014-12-09 11:58:17 +01:00
Tobias Brunner 728f529c42 ikev1: Use same map for AH and ESP authentication algorithms
The transform identifier used in AH transforms is not the same as the
authentication algorithm identifier used in the transform attributes in
AH (and ESP) transforms.
2014-12-09 11:08:14 +01:00
Tobias Brunner 4141f01671 ikev1: Accept IPComp proposals with 4 octet long CPI values
While they SHOULD be sent as 16-bit values according to RFC 3173
a responder MUST be able to accept CPI values encoded in four bytes.
2014-12-05 15:48:52 +01:00
Tobias Brunner 42e0a317c6 ike: Only parse payloads valid for the current IKE version 2014-12-05 15:41:47 +01:00
Tobias Brunner fac310a467 ike: Make check for known payloads depend on IKE version 2014-12-05 15:41:46 +01:00
Tobias Brunner 7bd5548538 pkcs5: Add support for PBES2 encryption schemes other than 3DES
This allows using e.g. AES for PKCS#8 and PKCS#12 files.

Some legacy schemes defined in RFC 2898 are not supported (like RC2).

Fixes #740.
2014-12-05 14:35:50 +01:00
Tobias Brunner 5743f6df2f asn1: Add OID for Blowfish CBC
The OID (1.3.6.1.4.1.3029.1.2) is technically not correct, the correct
one is (1.3.6.1.4.1.3029.1.1.2).  Every other library or tool (like OpenSSL)
uses the incorrect one so we do the same.

References #740.
2014-12-05 14:35:41 +01:00
Martin Willi 0a5b60db20 diffie-hellman: Handle dh_exponent_ansi_x9_42 as a boolean setting
While it was always documented as boolean setting, the option is currently
handled as integer value, for which yes/no values do not work. Instead the
default of TRUE is used for a no value.

The option has been moved a lot during the last years, and in some locations
was handled as bool, in some as integer. In the latest codebase it
congruently used integer, which is actually not what is documented and used
in testing.

Fixes #781.
2014-12-05 14:00:36 +01:00
Tobias Brunner 02df52fd2b unity: Only do narrowing of responder's TS if we received 0.0.0.0/0
iOS and Mac OS X clients establish individual IPsec SAs for the traffic
selectors received in Split-Include attributes (might have been different
in earlier releases).  If we return 0.0.0.0/0 as TSr that either results
in a bunch of Quick Mode exchanges (for each TS), or with the latest
client releases an error notify (ATTRIBUTES_NOT_SUPPORTED).
We also can't install the IPsec SA with all configured subnets as that
would cause conflicts if the client later negotiates SAs for other subnets,
which iOS 8 does based on traffic to such subnets.

For Shrew and the Cisco client, which propose 0.0.0.0/0, we still need to
override the narrowed TS with 0.0.0.0/0, as they otherwise won't accept
the Quick Mode response.  Likewise, we also have to narrow the TS before
installing the IPsec SAs and policies.

So we basically have to follow the client's proposal and only modify TSr
if we received 0.0.0.0/0.  Since we don't get the original TS in the
narrow hook we handle the inbound QM messages and make note of IKE_SAs on
which we received a TSr of 0.0.0.0/0.

Fixes #737.
2014-12-05 10:12:46 +01:00
Tobias Brunner bf5d0693ef id-payload: Enable multiple calls to get_ts() for subnet traffic selectors
The second call resulted in a /32 subnet previously.
2014-12-05 09:32:38 +01:00
Tobias Brunner 7459f3a5ac ikev2: Fix handling of more than one hash-and-URL certificate payloads 2014-12-04 11:33:38 +01:00
Martin Willi e1a448314f kernel-wfp: Install outbound ALE connect rules for IPsec
Similar to the inbound rules, the ALE filter processes IP-in-IP packets for
outbound tunnel mode traffic. When using an outbound default-drop policy,
Windows does not allow connection initiation without these explicit rules.
2014-12-04 11:10:48 +01:00
Martin Willi a8142a17cf kernel-wfp: Install inbound ALE IP-in-IP filters
When processing inbound tunnel mode packets, Windows decrypts packets and
filters them as IP-in-IP packets. We therefore require an ALE filter that
calls the FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_ALE_ACCEPT callout to allow them
when using a default-drop policy.

Without these rules, any outbound packet created an ALE state that allows
inbound packets as well. Processing inbound packets without any outbound
traffic fails without these rules.
2014-12-04 11:10:48 +01:00
Martin Willi 070461b70d kernel-wfp: Add missing IPsec sublayer GUIDs 2014-12-04 11:10:48 +01:00
Martin Willi a21338a43e kernel-wfp: Define IPsec related ALE layers and callout GUIDs 2014-12-04 11:10:48 +01:00
Martin Willi 4d48dfd6a3 kernel-wfp: Fix logging of MM/QM/EM NetEvent failures 2014-12-04 11:10:48 +01:00
Martin Willi b164cc8e15 vici: Make sure to send/recv all requested bytes over socket
As the underlying C functions, send/recv on ruby sockets are not guaranteed
to send/recv all requested bytes. Use wrapper functions to make sure we get
all bytes needed.
2014-12-04 10:42:22 +01:00
Martin Willi dcae0a3935 updown: Inverse comment of VPN_LOGGING variable, as it is enabled by default
Fixes #780.
2014-12-02 15:02:41 +01:00
Andreas Steffen b6bb32e658 Implemented full BLISS support for IKEv2 public key authentication and the pki tool 2014-11-29 14:51:18 +01:00
Andreas Steffen 0d8a3f5d01 Applied bit packing to BLISS public key 2014-11-29 14:51:18 +01:00
Andreas Steffen bf749fa1fb Wipe BLISS private key memory 2014-11-29 14:51:17 +01:00
Andreas Steffen b352ee4266 Created bliss_bitpacker class to encode BLISS signatures 2014-11-29 14:51:17 +01:00
Andreas Steffen 7143667bdd Skip the unused bits field of the ASN.1 BIT STRING encoding 2014-11-29 14:51:17 +01:00
Andreas Steffen 5a50e364e6 Store NTT A of BLISS public key a 2014-11-29 14:51:17 +01:00
Andreas Steffen 3e1f6edc5a unit-tests: created bliss_sign test suite 2014-11-29 14:51:17 +01:00
Andreas Steffen e71813e56d Finished BLISS signature generation 2014-11-29 14:51:17 +01:00
Andreas Steffen edd72b6bb9 Implemented Gaussian rejection sampler
The bliss_sampler class uses the mgf1_bitspender as a
pseudo-random source.
2014-11-29 14:51:16 +01:00
Andreas Steffen 72bb7eec9c Implemented get_byte() method for mgf1_bitspender class
The new get_byte() method returns a pseudo-random byte at a time.
Changed the get_bits() interface to the same interface as get_byte().
Updated the mgf1 unit-tests accordingly.
2014-11-29 14:51:16 +01:00
Andreas Steffen 5f7a9ea9c3 Added support for BLISS-III 2014-11-29 14:51:16 +01:00
Andreas Steffen f673966b9f Started implementing BLISS signature generation 2014-11-29 14:51:16 +01:00
Andreas Steffen 56009f2001 Store and parse BLISS private and public keys in DER and PEM format
Additionally generate SHA-1 fingerprints of raw BLISS subjectPublicKey
and subjectPublicKeyInfo objects.

Some basic functions used by the bliss_public_key class are shared
with the bliss_private_key class.
2014-11-29 14:51:16 +01:00
Andreas Steffen 37bfe44358 unit-tests: Created separate mgf1 test suite 2014-11-29 14:51:16 +01:00
Andreas Steffen 8614d1214d Use mgf1_bitspender in ntru_poly_create_from_seed 2014-11-29 14:51:15 +01:00
Andreas Steffen 64a5cacde5 Use mgf1_bitspender to generate random secret key 2014-11-29 14:51:15 +01:00
Andreas Steffen 988d477145 Implemented bitspender based on the MGF1 mask generator function 2014-11-29 14:51:15 +01:00
Andreas Steffen c3664d8ee1 unit-tests: Added bliss_fft test suite 2014-11-29 14:51:15 +01:00
Andreas Steffen 1d3e080877 Moved mgf1 class to libstrongswan/crypto/mgf1 2014-11-29 14:51:15 +01:00
Andreas Steffen 73a327404d Defined BLISS I and IV parameter sets 2014-11-29 14:51:14 +01:00
Andreas Steffen 6d31c7ef74 Added BLISS OIDs in ITA-HSR OID tree 2014-11-29 14:51:14 +01:00
Andreas Steffen 8c751b6119 Implemented Number Theoretic Transform using the FFT algorithm
By pre-multiplying the input arrays with a linear phase the
fast multiplication via FFT and inverse FFT computes a negative
wrapped convolution corresponding to a modulus of x^n+1.
2014-11-29 14:51:14 +01:00
Andreas Steffen 9d5b91d198 Created framework for BLISS post-quantum signature algorithm 2014-11-29 14:51:14 +01:00
Martin Willi 4ef819a379 libtls: Catch POLLHUP/NVAL in TLS socket splicing
If one of the sockets gets disconnected, some systems return POLLHUP. Signal
the socket as ready to let the read/write call fail properly.
2014-11-28 15:53:50 +01:00
Martin Willi 015fb3134d watcher: Proper handle poll() POLLHUP/NVAL signaling
poll() may return POLLHUP or POLLNVAL for given file descriptors. To handle
these properly, we signal them to the EXCEPT watcher state, if registered. If
not, we call the read/write callbacks, so they can properly fail when trying
to read from or write to the file descriptor.
2014-11-28 12:50:34 +01:00
Martin Willi 02fd29acc1 windows: Properly set errno for read/write functions using Winsock 2014-11-28 12:45:58 +01:00
Martin Willi f1773fee43 ikev2: Fix ike_rekey switch statement broken with last commit 2014-11-24 10:03:26 +01:00
Martin Willi 8891ed5478 ikev2: Prevent IKE_SA rekeying if we are currently retrying a CHILD_SA rekey 2014-11-21 12:51:20 +01:00
Martin Willi c39b0c883d controller: Keep following initiate() if the first DH guess was wrong 2014-11-21 12:51:19 +01:00
Martin Willi 013857ad79 child-sa: Introduce a CHILD_RETRYING state to detect DH group retries 2014-11-21 12:51:19 +01:00
Martin Willi 89f19ef876 windows: Move the compatibility header to the compat subfolder 2014-11-21 12:02:08 +01:00
Martin Willi aec3d5fb7f apple: Wrap accept() and recvfrom() with poll(2) instead of select 2014-11-21 12:02:08 +01:00
Martin Willi f65779dd0f apple: Introduce a central compatibility header with all __APPLE__ quirks 2014-11-21 12:02:08 +01:00
Martin Willi 6e1d3f3615 watcher: Use Windows read/write(2) wrappers instead of compile-conditions 2014-11-21 12:02:08 +01:00
Martin Willi a301a9c939 windows: Provide a write(2) wrapper that uses send(2) on sockets 2014-11-21 12:02:08 +01:00
Martin Willi 09624c6cec windows: Provide a read(2) wrapper that uses recv(2) on sockets 2014-11-21 12:02:08 +01:00
Martin Willi f518b52c2d unit-tests: Test cancellability of some cancellation points we rely on 2014-11-21 12:02:07 +01:00
Martin Willi 78725e68c1 thread: Test for pending cancellation requests before poll()ing on OS X
As we are now using poll(2) instead of select(2), we need the work-around from
76dc329e for poll() as well.
2014-11-21 12:02:07 +01:00
Martin Willi eeaa6f9b1a kernel-libipsec: Use poll(2) instead of select 2014-11-21 12:02:07 +01:00
Martin Willi 03bccc240c watcher: Use poll(2) instead of select 2014-11-21 12:02:07 +01:00
Martin Willi 10743ac9d6 libtls: Use poll(2) instead of select() in tls_socket 2014-11-21 12:02:07 +01:00
Martin Willi ed247660e8 socket-default: Use round-robin selection of sockets to read from
If multiple sockets are ready, we previously preferred the IPv4 non-NAT socket
over others. To handle all with equal priority, use a round-robin selection.
2014-11-21 12:02:07 +01:00
Martin Willi ce13ba62cc socket-default: Use poll(2) instead of select
It is not only simpler, but also allows the use of arbitrary high fd numbers,
which silently fails with select().
2014-11-21 12:02:07 +01:00
Martin Willi 946cf367d4 tun-device: Read from tun to buffer on stack to avoid over-allocation of packets
Instead of allocating MTU-sized buffers for each packet, read to a stack buffer
and copy to an allocation of the actual packet size. While it requires an
additional copy on non-Apple platforms, this should make allocation more
efficient for small packets.
2014-11-21 12:02:07 +01:00
Martin Willi eaca7f2143 tun-device: Remove the superfluous use of select() before read() 2014-11-21 11:16:48 +01:00
Martin Willi 1abaff6a3c libradius: Use poll(2) to wait for RADIUS responses 2014-11-21 11:16:48 +01:00
Martin Willi fc829ec9fb windows: Provide a poll(2) wrapper calling WSAPoll() 2014-11-21 11:16:48 +01:00
Martin Willi 50bb81425e kernel-netlink: Optionally ignore errors resulting from response message loss
As some backends over unreliable transport do not cache response messages,
retransmissions due the loss of responses perform the operation again. Add an
option to ignore some errors arising from such duplicate operations.

Note: This approach can't distinguish between real EXIST/NOTFOUND errors
and packet failures, and therefore is a source of race conditions and can't
detect any of these errors actually happening. Therefore that behavior is
disabled by default, and can be enabled with the ignore_retransmit_errors
strongswan.conf option.

To properly distinguish between real and retransmission errors, a Netlink
backend should implement retransmission detection using sequence numbers.
2014-11-21 10:55:45 +01:00
Martin Willi 8925abbec4 kernel-netlink: Add an option to enforce using XFRM_MSG_UPDPOLICY 2014-11-21 10:55:45 +01:00
Martin Willi 3065081c3e kernel-netlink: Fallback to UDP if detecting socket protocol fails
getsockopt(SO_PROTOCOL) is not supported before 2.6.32. Default to UDP if
either the SO_PROTOCOL define is missing or the syscall fails.
2014-11-21 10:55:45 +01:00
Martin Willi 87888f9926 kernel-netlink: Alternatively support global port based IKE bypass policies
The socket based IKE bypass policies are usually superior, but not supported
on all networking stacks. The port based variant uses global policies for the
UDP ports we have IKE sockets for.
2014-11-21 10:55:45 +01:00
Martin Willi 6c58fabe29 kernel-netlink: Add options to enable parallel Netlink queries explicitly
As under vanilla Linux the kernel can't handle parallel dump queries and returns
EBUSY, it makes not much sense to use them. Disable parallel queries by default
to basically restore original behavior, improving performance.
2014-11-21 10:55:45 +01:00
Martin Willi 9b43dddff4 kernel-netlink: Release lock while doing Netlink NEW/DELADDR operations
Besides that it can improve throughput, it avoids a deadlock situation. If
all threads are busy, watcher will invoke the FD notification for NEWADDR
events itself. If the lock is held, it gets locked up. As watcher is not
dispatching anymore, it can't signal Netlink socket send() completion, and
the send() operation does not return and keeps the lock.
2014-11-21 10:55:45 +01:00
Martin Willi 4b41ea956c kernel-netlink: Add non-dumping variants of echo and stress tests 2014-11-21 10:55:45 +01:00
Martin Willi adb930ed4f kernel-netlink: Add test cases for successful and timing out retransmissions 2014-11-21 10:55:45 +01:00
Martin Willi 553be051b7 kernel-netlink: Add a compile-time hook to simulate request message loss 2014-11-21 10:55:45 +01:00
Martin Willi 15dc61757c kernel-netlink: Implement configurable Netlink request retransmission 2014-11-21 10:55:45 +01:00
Martin Willi aa762bed7b kernel-netlink: Add a stress test with several threads doing Netlink exchanges 2014-11-21 10:55:45 +01:00
Martin Willi 84f6853c42 kernel-netlink: Retry netlink query while kernel returns EBUSY
If the kernel can't execute a Netlink query because a different query is already
active, it returns EBUSY. As this can happen now as we support parallel queries,
retry on this error condition.
2014-11-21 10:55:45 +01:00
Martin Willi 3c7193f114 kernel-netlink: Support parallel Netlink queries
Instead of locking the socket exclusively to wait for replies, use watcher
to wait for and read in responses asynchronously. This allows multiple parallel
Netlink queries, which can significantly improve performance if the kernel
Netlink layer has longer latencies and supports parallel queries.

For vanilla Linux, parallel queries don't make much sense, as it usually returns
EBUSY for the relevant dump requests. This requires a retry, and in the end
makes queries more expensive under high load.

Instead of checking the Netlink message sequence number to detect multi-part
messages, this code now relies on the NLM_F_MULTI flag to detect them. This
has previously been avoided (by 1d51abb7). It is unclear if the flag did not
work correctly on very old Linux kernels, or if the flag was not used
appropriately by strongSwan. The flag seems to work just fine back to 2.6.18,
which is a kernel still in use by RedHat/CentOS 5.
2014-11-21 10:55:45 +01:00
Martin Willi 02794456a9 kernel-netlink: Add a simple send message test querying available links 2014-11-21 10:55:44 +01:00
Martin Willi f572b38816 kernel-netlink: Add a stub for a test-runner 2014-11-21 10:55:44 +01:00
Tobias Brunner 8ab1b29da4 mem-pool: Fix potential memory leak and lost leases when reassigning leases
If no offline leases are available for the current client and assigning online
leases is disabled, and if all IPs of the pool have already been assigned to
clients we look for offline leases that previously were assigned to other
clients.

In case the current client has online leases the previous code would
replace the existing mapping entry and besides resulting in a memory leak
the online leases would be lost forever (even if the client later releases
the addresses).  If this happens repeatedly the number of available addresses
would decrease even though the total number of online and offline leases seen
in `ipsec leases` would indicate that there are free addresses available.

Fixes #764.
2014-11-11 19:00:02 +01:00
Tobias Brunner fc02a9d4b9 android: New release based on 5.2.1 and after adding EAP-TLS
Also enables support for IKEv2 fragmentation, provides improved MOBIKE
handling and optionally enables PFS for CHILD_SAs.
2014-11-06 17:16:27 +01:00
Tobias Brunner baa4e774c1 android: Build binaries for MIPS 2014-11-06 17:11:55 +01:00
Tobias Brunner bdc4cea316 android: Increase fragment size
We use the same value we use as MTU on TUN devices.
2014-11-06 17:05:47 +01:00
Tobias Brunner 6fddf2af73 android: Enable IKEv2 fragmentation 2014-11-06 16:56:54 +01:00
Tobias Brunner 0e44999867 android: Use %any as AAA identity, but disable EAP-only authentication
Without verification of the identity we can't prevent a malicious user
with a valid certificate from impersonating the AAA server and thus the
VPN gateway.  So unless we make the AAA identity configurable we have to
prevent EAP-only authentication.
2014-11-06 16:28:40 +01:00
Tobias Brunner 4b39a4117a android: Add support for signature schemes used by EAP-TLS 2014-11-06 16:28:40 +01:00