Compare commits

...

680 Commits

Author SHA1 Message Date
Domonkos P. Tomcsanyi cea991aea8 Updated entity name in copyright statements 2022-05-18 17:32:30 +02:00
Tomcsányi, Domonkos 0ed91dc681 simaka_manager: Some more debug logging on success/failure cases 2021-08-26 19:48:11 +02:00
Tomcsányi, Domonkos 65f576bd9c ignore mismatch in received identity.
This is needed, because the standard mandates that the remote entity
must be configured as ims (mimicking the APN setting I think), but on
the other hand the ePDG will identify itself with its FQDN in the end. I
tested this and this is currently the only way to do it with strongswan
I think, because you cannot configure different identities.
2021-08-26 19:47:15 +02:00
Tomcsányi, Domonkos 18b4a240dd permit SHA-1, as some ePDGs require that 2021-08-26 19:46:49 +02:00
Tomcsányi, Domonkos f68dcde6c5 Add support for EAP-AKA against USIM in PC/SC reader 2021-08-26 19:45:59 +02:00
Andreas Steffen 4817d5ed0d Version bump to 5.9.3 2021-07-06 14:00:39 +02:00
Andreas Steffen a09a905e1d vici: Suppress trailing nul character 2021-07-06 12:06:23 +02:00
Tobias Brunner 2cd5314de7 testing: Use specific versions of swidGenerator and strongTNC
This way we get updated versions automatically (referencing "master"
required manually deleting the downloaded archives and the unpacked
directories).  It also allows switching versions when working in different
branches (note that REV can also be set to a commit ID, e.g. to test
changes before tagging them later and merging the branch).
2021-06-30 16:17:39 +02:00
Tobias Brunner 06e11b481b kernel-netlink: Fix theoretical memory leak when parsing routes
This currently can't happen as the kernel always puts RTA_TABLE as first
attribute in RTM_NEWROUTE messages.
2021-06-25 13:51:44 +02:00
Tobias Brunner f6aafb3005 Fixed some typos, courtesy of codespell
Main change is the conversion from the British cancelling/-ed to the
American canceling/-ed.
2021-06-25 11:32:29 +02:00
Andreas Steffen 30fab57124 Version bump to 5.9.3rc1 2021-06-24 09:18:54 +02:00
Tobias Brunner 19611b1d28 testing: Build wolfSSL from the Git repository
Use the same configure options etc. for both builds (no need for the cert
options as we don't use TLS or X.509 parsing) and switch to a Git commit
that includes the SHA-3 OID fix (it's actually the fix itself).
2021-06-22 17:54:15 +02:00
Andreas Steffen 4baca5ca80 testing: Fixed ikev2/farp scenario 2021-06-22 12:32:35 +02:00
Andreas Steffen dbd1534875 Version bump to 5.9.3dr4 2021-06-22 10:33:07 +02:00
Andreas Steffen eba2622587 testing: Migrate ikev2-stroke-bye scenarios to vici 2021-06-22 10:23:06 +02:00
Andreas Steffen 706c58b291 testing: Fixed pretest script of ikev1/rw-psk-aggressive scenario 2021-06-21 12:03:36 +02:00
Tobias Brunner 6d8890767c testing: Migrate ikev2/host2host-transport-nat scenario to vici
This also restores the test as it was before the referenced commit so it
again, as written in the description, demonstrates that venus is unable
to ping sun without IPsec tunnel.

Fixes: f27fb58ae0 ("testing: Update description and test evaluation of host2host-transport-nat")
2021-06-21 12:03:36 +02:00
Tobias Brunner 2b5c743952 testing: Migrate MOBIKE tests to vici
Note that the mobike-nat test has been removed as it basically did the same
as the mobike-virtual-ip-nat test.  Instead, the mobike-nat-mapping scenario
is added, which simulates a NAT router restart.
2021-06-21 12:03:36 +02:00
Tobias Brunner abe51389c5 ike-mobike: Force MOBIKE update after NAT mappings changed
The addresses observed by the client behind the NAT are exactly the same if
the NAT router gets restarted.

Fixes: 2b255f01af ("ike-mobike: Use ike_sa_t::update_hosts() to trigger events")
2021-06-21 12:03:36 +02:00
Tobias Brunner 036ae27645 ike-sa: Log IKE endpoint changes 2021-06-21 12:03:36 +02:00
Tobias Brunner 79b526deba ha: Register the correct IKE_SA with the manager after a rekeying
Fixes: 20dfbcad08 ("ha: Register new IKE_SAs before calling inherit_post()")
Closes strongswan/strongswan#456.
2021-06-21 10:02:26 +02:00
Tobias Brunner 4b9b4dc956 Merge branch 'vici-stuck'
Closes strongswan/strongswan#268.
2021-06-21 09:59:28 +02:00
Tobias Brunner eec3bdb04a vici: Signal waiting threads when skipping disconnected connections
If two threads are waiting in find_entry() and remove_entry(),
respectively, and the former is woken first, the latter remains stuck
as it won't get signaled.
2021-06-21 09:59:15 +02:00
Tobias Brunner b0e2187b6b vici: Signal waiting threads when removing a connection entry
If there are threads waiting in find_entry() and one in remove_entry()
and the latter is woken first by a thread calling put_entry(), the
former threads would remain stuck as they get never signaled.
2021-06-21 09:59:15 +02:00
Tobias Brunner 030e80957d kernel-netlink: Don't wait for VIPs to disappear during de-initialization
This can happen if an IKE_SA is terminated forcefully shortly before
terminating the daemon.  The thread that handles the terminate command
will call checkin_and_destroy(), which unregisters the IKE_SA from the
manager before destroying it.  The main thread that calls flush() on the
IKE_SA manager won't wait for this SA (its entry is already gone), so
the processor and in turn the watcher job/thread might get canceled
before the first thread started deleting the VIP.  It would then wait
indefinitely for a signal that can never be sent.

There is still a small chance the thread hangs in wait() if the state check
happens right before the watcher is canceled and it wasn't yet able to
deliver the event from the kernel, we counter that by rechecking the state
after a while.
2021-06-21 09:59:06 +02:00
Tobias Brunner 0fc8cf0013 NEWS: Add news for 5.9.3 2021-06-18 10:31:31 +02:00
Adrian-Ken Rueegsegger 859dedeab7 testing: Update Anet to version 0.4.2 2021-06-17 09:53:51 +02:00
Stefan Berghofer d7a9e723f3 charon-tkm: Remove useless checks when deriving IKE keys 2021-06-17 09:53:51 +02:00
Stefan Berghofer 22e7900718 charon-tkm: Delegate encryption/decryption of IKE traffic to TKM
Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2021-06-17 09:53:51 +02:00
Tobias Brunner 6537be9c8d pkcs11: Change how unavailable attributes like CKA_TRUSTED are handled
If a PKCS#11 library/token doesn't provide one or more attributes via
C_GetAttributeValue(), we get back CKR_ATTRIBUTE_TYPE_INVALID (similar
for protected attributes where CKR_ATTRIBUTE_SENSITIVE is returned).
This is not an error as the spec demands that all attributes have been
processed with the unavailable attributes having set their length
field to CK_UNAVAILABLE_INFORMATION.

We use this to handle the CKA_TRUSTED attribute, which some tokens
apparently don't support.  We previously used a version check to remove
the attribute from the call but even the latest spec doesn't make the
attribute mandatory (it's just in a list of "common" attributes for
CKO_CERTIFICATE objects, without a default value), so there are current
tokens that don't support it and prevent us from enumerating certificates.
2021-06-14 13:58:48 +02:00
Tobias Brunner a90716cd4d receiver: Avoid division by 0 after system start if CLOCK_MONOTONIC is used
Depending on how CLOCK_MONOTONIC is implemented, time_monotonic() might
return 0 within 1 second after the system is started.  If that's the
case, we just default to 0 for now to avoid a crash (doesn't "hide" the
system time, but it's only the uptime anyway in this case).

Closes strongswan/strongswan#435.
2021-06-14 13:24:08 +02:00
Tobias Brunner 8dbf40d19a charon-nm: Simplify certificate enumeration and allow IDs other than DNs
This allows using SANs as identity instead of having to use the subject DN.

References strongswan/strongswan#437.
2021-06-14 12:13:47 +02:00
Tobias Brunner ae71f8357d dhcp: Move log messages for received packets
This way they are logged in the context of the corresponding IKE_SA.

Closes strongswan/strongswan#417.
2021-06-08 17:03:17 +02:00
Thomas Egerer 4e29d6fac1 bus: Extend and reorder arguments of ike_derived_keys() hook
This now includes all key material derived for IKE_SAs in the order
defined in the RFC:

  {SK_d | SK_ai | SK_ar | SK_ei | SK_er | SK_pi | SK_pr}
               = prf+ (SKEYSEED, Ni | Nr | SPIi | SPIr)

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2021-06-07 17:08:27 +02:00
Andreas Steffen 9c85a52956 Version bump to 5.9.3dr3 2021-06-04 09:28:17 +02:00
Tobias Brunner e166423856 ikev1: Fix flags so NAT Vendor IDs are sent again
Fixes: 6c49ddfbca ("ike: Add additional Vendor IDs for third-party implementations")
2021-06-04 09:20:49 +02:00
Andreas Steffen cc4338267e testing: Added openssl-ikev2/net2net-sha3-rsa-cert scenario 2021-06-03 14:20:06 +02:00
Andreas Steffen 5688e631e3 openssl: Support SHA-3 based RSA_EMSA_PKCS1 signatures 2021-06-03 14:20:06 +02:00
Andreas Steffen de5ca4021a testing: Test wolfssl plugin 2021-06-03 10:22:59 +02:00
Andreas Steffen 8bbd7bbd36 wolfssl: Full support of SHA3 signatures 2021-06-03 10:20:18 +02:00
Andreas Steffen e0044e5f48 credential_factory: Store name of plugin registering a builder 2021-06-01 21:12:46 +02:00
Andreas Steffen 62c5ef035c wolfssl: Set RSA key type 2021-05-30 12:40:08 +02:00
Marius Tomaschewski d654117c66 ccm: Destroy IV generator on crypter creation failure
Closes strongswan/strongswan#343.
2021-05-27 17:43:03 +02:00
Tobias Brunner a82f13e7ce dhcp: Log MAC address when sending DISCOVER message
Closes strongswan/strongswan#239.
2021-05-27 12:06:47 +02:00
Noel Kuntze 6c49ddfbca ike: Add additional Vendor IDs for third-party implementations
For some that are followed by unknown data (e.g. detailed version
information) we only do a prefix match.

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

Closes strongswan/strongswan#393.
2021-05-21 17:50:35 +02:00
Andreas Steffen d415673565 Version bump to 5.9.3dr2 2021-05-21 10:00:41 +02:00
Andreas Steffen 7c5a2974b9 testing: Reorganizing IKEv1 and IKEv2 examples
For documentation purposes the new folders ikev1-algs, ikev2-algs,
ikev1-multi-ca and ikev2-multi-ca have been created. Most of the
test cases have now been converted to the vici interface. The
remaining legacy stroke scenarios yet to be converted have been put
into the ikev2-stroke-bye folder.

For documentation purposes some legacy stroke scenarios will be kept
in the ikev1-stroke, ikev2-stroke and ipv6-stroke folders.
2021-05-21 09:42:50 +02:00
Tobias Brunner db93938297 notify-payload: Update reference for notify types for PPKs
draft-ietf-ipsecme-qr-ikev2 was released as RFC 8784 in June of 2020.
2021-05-11 14:30:05 +02:00
Tobias Brunner c13a1c2829 Don't report current text in parser error messages
The values of `yytext` and `yyleng` might not be properly defined when
the error function is called (in particular if the lexer reached EOF).
While this might just cause non-printable characters in the output, it
could actually lead to a crash depending on where `yytext` points.

Closes strongswan/strongswan#346.
2021-05-11 10:08:58 +02:00
Noel Kuntze cf6a164108 testing: Replace kvm with qemu-system-x86_64
It might not exist on all platforms and according to the man page:

  The kvm wrapper script is used to provide compatibility with old
  qemu-kvm package which has been merged into qemu as of version 1.3.

  The script executes
    qemu-system-x86_64 -enable-kvm
  passing all other command-line arguments to the qemu binary.

Closes strongswan/strongswan#385.
2021-05-10 11:14:00 +02:00
Tobias Brunner 1eb2d149db testing: Use host-passthrough CPU mode for all KVM guests
This should give us the best performance and feature set on modern
hardware (in particular when compared to code2duo, which e.g. does not allow
nested virtualization).

Closes strongswan/strongswan#340.
2021-05-10 10:04:28 +02:00
Tobias Brunner d4c337a42f Use Botan 2.18.0 for tests 2021-05-07 14:48:17 +02:00
Adrian-Ken Rueegsegger f0c25960ed openssl: Consider authorityKeyIdentifier in issued_by()
Prior to verifying the cryptographic signature, check if the
authorityKeyIdentifier matches the key ID of the issuing certificate if
it is available.
2021-05-07 14:29:24 +02:00
Adrian-Ken Rueegsegger 027c5c9dcb x509: Consider authorityKeyIdentifier in issued_by()
Prior to verifying the cryptographic signature, check if the
authorityKeyIdentifier matches the key ID of the issuing certificate if
it is available.
2021-05-07 14:29:24 +02:00
Adrian-Ken Rueegsegger 97c9158378 openssl: Bring CRL issued_by() in line with x509 plugin 2021-05-07 14:29:24 +02:00
Adrian-Ken Rueegsegger 9f468f454a ike: Set DCSP on keepalive packets 2021-05-07 14:29:24 +02:00
Tobias Brunner 546f61d3c8 openssl: Add support for AES in CCM mode
While CCM is available in earlier versions, we only use it with
OpenSSL 1.1.0 and newer because the generic control variables are not
available before and we default to GCM for them.

Closes strongswan/strongswan#353.
2021-05-06 18:29:16 +02:00
Noel Kuntze 5191c2b063 testing: Make sure $SHAREDDIR exists before mounting it
Closes strongswan/strongswan#344.
2021-05-06 17:21:59 +02:00
Tobias Brunner a730873211 github: Fix python build and checks on older Ubuntu releases
On 18.04, setuptools was apparently pulled in by python-pip but is not
by python3-pip and on Ubuntu 16.04 there is an issue with tox when
installed via pip3 (syntax error in one of the dependencies) and with
pip that dependency is not even available.
2021-05-06 15:16:42 +02:00
Tobias Brunner 9535c3f778 wolfssl: Properly handle failure to initialize SHAKE_256 2021-05-06 11:47:38 +02:00
Tobias Brunner 2f650e085b github: Don't fail LGTM test with an error if variables are missing
That's because forks are currently not allowed to be analyzed by LGTM (unlike
with SonarCloud) so this check can't actually be successful for forks even if
variables are defined.

References strongswan/strongswan#328.
2021-05-05 19:11:38 +02:00
Noel Kuntze 260e7b55f6 github: Fail LGTM test if required environment variables aren't set
Closes strongswan/strongswan#328.
2021-05-05 18:12:25 +02:00
Tobias Brunner cd7b80e869 github: Make LGTM project ID configurable via environment variable 2021-05-05 18:09:44 +02:00
Noel Kuntze f830e71457 github: Fail sonarcloud test if required environment variables aren't set
Closes strongswan/strongswan#330.
2021-05-05 18:10:03 +02:00
Tobias Brunner c603704bb3 github: Always upload lint results from Android build 2021-05-05 18:09:44 +02:00
Tobias Brunner 742e0f213c github: Fix build on Ubuntu 20.04 and add a job for 18.04
The nm test can only be done on Ubuntu 18.04 as the required libraries
are not available on newer systems.

Switch to pip3 to install tox (the only Python dependency we use).

Closes strongswan/strongswan#327.
2021-05-05 18:09:44 +02:00
Tobias Brunner eca1b81682 github: Fix installation of Python dependencies 2021-05-05 18:08:20 +02:00
Tobias Brunner 6405653da2 android: Avoid lint errors when determining column indices
The lint version used on our GitHub build hosts reported these errors:

Error: Value must be ≥ 0 [Range]
        db.update(TABLE_VPNPROFILE, values, KEY_ID + " = " + cursor.getLong(cursor.getColumnIndex(KEY_ID)), null);

That's because get*() expect a valid index >= 0 but getColumnIndex()
can return -1 if the column name doesn't exist.
2021-05-05 16:40:14 +02:00
Tobias Brunner f0a20dd2b8 backtrace: The BFD API changed in newer versions 2021-05-05 16:17:54 +02:00
Noel Kuntze 1de13f9037 openssl: Fix OpenSSL version check for EC_POINT_set_affine_coordinates
Fixes: bd323ae6c8 ("openssl: Migrate from deprecated EC_POINT_[set|get]_affine_coordinates_GFp() functions")
Closes strongswan/strongswan#332
2021-05-04 14:51:18 +02:00
Noel Kuntze e9a55abce4 forecast: Restrict strncpy() call
Closes strongswan/strongswan#331.
2021-05-04 14:48:53 +02:00
Tobias Brunner 2b89676157 Merge branch 'doxygen-fixes'
Closes strongswan/strongswan#326.
2021-05-04 14:39:56 +02:00
Noel Kuntze 4886a2c7d8
Doxyfile.in: Remove deprecated variables 2021-04-15 16:13:22 +02:00
Noel Kuntze a11efc5214
doxygen: Fix documentation problems 2021-04-15 00:17:59 +02:00
Andreas Steffen 09df86c033 Version bump to 5.9.3dr1 2021-03-31 09:59:55 +02:00
Andreas Steffen 66ba50b217 testing: Migrated p2pnat/medsrv-psk scenario to vici 2021-03-30 22:12:00 +02:00
Andreas Steffen 03e1272ff2 testing: Migrated p2pnat/behind-same-nat scenario to vici 2021-03-30 22:12:00 +02:00
Andreas Steffen 68154033bb testing: Store mars credentials in the swanctl directory 2021-03-30 22:12:00 +02:00
Andreas Steffen 2cbf7da51a testing: Migrated redirect-active scenario to vici 2021-03-30 22:12:00 +02:00
Andreas Steffen 511b860916 testing: Migrated ha/both-active scenario to vici 2021-03-30 18:57:49 +02:00
Andreas Steffen 5c22e94f0f testing: Migrated ha/active-passive scenario to vici 2021-03-30 18:57:49 +02:00
Andreas Steffen 737f7fce51 testing: Switched PTS measurements to /usr/sbin
Due to Debian 10 linking /bin to /usr/bin which drastically
increased the number of files in /bin, the PTS measurement
was switched to /usr/sbin with a lesser number of files.
2021-03-23 10:54:48 +01:00
Andreas Steffen f412c97648 wolfssl: Support SHAKE_256 2021-03-20 11:19:12 +01:00
Andreas Steffen a91eb3eb96 wolfssl: Support SHA3 2021-03-20 11:15:42 +01:00
Andreas Steffen b57215ba2b wolfssl: Support AES_ECB 2021-03-20 11:15:42 +01:00
Andreas Steffen bd323ae6c8 openssl: Migrate from deprecated EC_POINT_[set|get]_affine_coordinates_GFp() functions 2021-03-19 08:50:27 +01:00
Petr Gotthard c5eac9c390 libcharon: Include libtpmtss in monolithic build 2021-03-17 12:14:47 +01:00
Andreas Steffen 6aef079f59 testing: Bump guest kernel to Linux 5.11 2021-03-07 14:39:44 +01:00
Andreas Steffen 87ba3a424d Version bump to 5.9.2 2021-02-26 11:30:13 +01:00
Tobias Brunner 88c4d8cb22 Merge branch 'sha2-no-trunc'
Closes strongswan/strongswan#215.
2021-02-23 17:30:11 +01:00
Tobias Brunner 875813c055 save-keys: Fix length of AES-GCM with 12-byte ICV 2021-02-23 17:28:46 +01:00
Michał Skalski b6b8880340 save-keys: Add support for full-length HMAC-SHA256 for ESP
Wireshark doesn't really support it, but this way it at least decodes
the ESP packets correctly and the encryption keys are saved and the
packets can be decrypted.  The full-length versions of SHA-384 and
SHA-512 are not supported by Wireshark as 256-bit is the longest ICV
it is able to decode currently.
2021-02-23 17:28:46 +01:00
Michał Skalski c632aa7b31 kernel-netlink: Add support for full-length HMAC-SHA2 algorithms 2021-02-23 17:28:46 +01:00
Michał Skalski aa6da3700a keymat: Add support for full-length HMAC-SHA2 algorithms 2021-02-23 17:23:29 +01:00
Michał Skalski 7a8cd5d6d0 af-alg: Fix typo in algorithm mapping for full-size HMAC-SHA-256 2021-02-23 09:25:44 +01:00
Andreas Steffen 356f87355b Version bump to 5.9.2rc2 2021-02-21 10:40:34 +01:00
Andreas Steffen 20c47af319 testing: Use TLS 1.3 in TNC PT-TLS tests 2021-02-21 09:48:34 +01:00
Andreas Steffen 9f55246018 testing: Added mgf1 plugin to load statement 2021-02-19 17:41:44 +01:00
Andreas Steffen 283b352cee Merge branch 'tls-fixes' 2021-02-18 20:28:33 +01:00
Andreas Steffen d08fa4bd0a Version bump to 5.9.2rc1 2021-02-18 20:16:17 +01:00
Tobias Brunner 48f4f9f667 pt-tls-server: Make TLS client authentication optional as appropriate 2021-02-18 15:41:52 +01:00
Tobias Brunner 82116dba66 tls-test: Add option to make client authentication optional 2021-02-18 15:39:35 +01:00
Tobias Brunner 760f3b730f tls-server: Add flag that makes client authentication optional
This allows clients to send an empty certificate payload if the server
sent a certificate request.  If an identity was set previously, it will
be reset so get_peer_id() may be used to check if the client was
authenticated.
2021-02-18 15:35:46 +01:00
Tobias Brunner 11a4687930 libtls: Add control flags and replace GENERIC_NULLOK purpose with one 2021-02-18 15:10:29 +01:00
Tobias Brunner 602947d48a pt-tls-server: Explicitly request client authentication if necessary
The PT_TLS_AUTH_TLS_OR_SASL case currently can't be implemented properly
as TLS authentication will be enforced if a client identity is configured
on the TLS server socket.
2021-02-18 12:49:54 +01:00
Tobias Brunner 4b7cfb252e tls-server: Use subject DN as peer identity if it was ID_ANY
To request client authentication if we don't know the client's identity,
it's possible to use ID_ANY.  However, if we don't change the identity
get_peer_id() would still report ID_ANY after the authentication.
2021-02-18 12:34:05 +01:00
Tobias Brunner d5606ec350 testing: Adapt some checks as SHA-384 is now preferred for TLS signatures 2021-02-18 12:02:54 +01:00
Tobias Brunner 024120f8ea tls-eap: Only servers conclude EAP method after processing packets
As client with older TLS versions, we have to ack the receipt of the server's
Finished message instead.

Fixes: 083f38259c ("tls-eap: Conclude EAP method also after processing packets")
2021-02-18 12:02:32 +01:00
Stefan Berghofer f7613cb581 ike-sa: Properly set timing info for delete after rekeying
The job is queued properly, yet the timing information is wrong.

Signed-off-by: Stefan Berghofer <stefan.berghofer@secunet.com>

Fixes: ee61471113 ("implemented RFC4478 (repeated authentication)...")
2021-02-18 10:02:55 +01:00
Tobias Brunner d65d4eab73 NEWS: Add news for 5.9.2 2021-02-17 15:24:36 +01:00
Tobias Brunner ff672c785b dhcp: Properly initialize struct when binding to interface 2021-02-16 15:22:18 +01:00
Tobias Brunner fbb70c968b pts: Don't rely on BIOS event buffer to be null terminated 2021-02-16 15:16:25 +01:00
Tobias Brunner 8384527ff5 tls-crypto: Fix potential memory leak
Fixes: d8e42a3d4e ("tls-crypto: Share private key search between client and server")
2021-02-16 14:52:43 +01:00
Tobias Brunner f4258c56f5 ike-sa-manager: Ensure we were able to create a new IKE_SA
This may happen if we are unable to allocate an SPI.
2021-02-16 14:45:51 +01:00
Tobias Brunner cb85967655 github: Bump wolfSSL to 4.7.0 2021-02-16 09:08:12 +01:00
Fedor Korotkov af9d2a8f1e cirrus: Use FreeBSD 12.2
This seems to fix the build with Autotools that recently started to fail
with:

autom4te-2.69: need GNU m4 1.4 or later: /usr/local/bin/gm4
aclocal: error: /usr/local/bin/autom4te-2.69 failed with exit status: 1
autoreconf-2.69: aclocal failed with exit status: 1

Closes strongswan/strongswan#197.
2021-02-16 08:56:43 +01:00
Tobias Brunner 7bd9c0c85e github: Fix emojis in templates 2021-02-15 15:30:03 +01:00
Tobias Brunner 27544f7bd9 github: Add security policy 2021-02-15 09:44:44 +01:00
Tobias Brunner ebf13f4caf github: Add issue templates 2021-02-15 09:44:44 +01:00
René Fischer 4261fcedec botan: Use strongSwan's RNG interface in Botan plugin
This allows using rng_t implementations provided by other plugins to
serve as RNG for Botan.

Closes strongswan/strongswan#192.
2021-02-15 09:27:51 +01:00
Tobias Brunner 5ffc1ec423 botan: Extract helper function to map RNG quality to Botan RNG names 2021-02-15 09:23:57 +01:00
Tobias Brunner eb399fb438 botan: Look for Botan 3 in configure script 2021-02-15 09:23:56 +01:00
Tobias Brunner 97857eaa12 ike-sa: Avoid possible integer underflow when scheduling reauth after rekeying
If the reauthentication is scheduled while rekeying, the difference
might be negative, however, schedule_job() takes an unsigned int,
so the reauth would get scheduled very far in the future.
2021-02-12 15:49:08 +01:00
Tobias Brunner 20dfbcad08 ha: Register new IKE_SAs before calling inherit_post() 2021-02-12 15:49:08 +01:00
Tobias Brunner 1c5cef1b89 ike-rekey: Register new IKE_SA before calling inherit_post()
If rekeying and reauthetication coincided, the reauth job could get
scheduled to run immediately i.e. before checkin() was called.  So the
new IKE_SA would not get reauthenticated, however, the further delayed
delete job would later find the new IKE_SA and delete it.
2021-02-12 15:49:08 +01:00
Tobias Brunner 5d97af5894 ike-sa-manager: Add a method to register/check out new IKE_SAs
This way, jobs for new IKE_SAs (created via create_new()) may be
scheduled/queued before checkin() is called.  If they run before
that happens, they will now correctly block in checkout() instead of
doing nothing because the IKE_SA was not found.
2021-02-12 15:49:08 +01:00
Tobias Brunner bde5bd47bd ike-sa-manager: Rename checkout_new() to create_new()
We don't actually check that SA out (i.e. it's not registered with the
manager).  That was originally different but had to be changed with
86993d6b90 to avoid that SAs created for rekeying don't block other
threads on the manager.
2021-02-12 15:49:08 +01:00
Tobias Brunner 7f6386afd9 Remove redundant calls to set peer config after checking out IKE_SAs by config 2021-02-12 15:49:08 +01:00
Tobias Brunner c46c40ef24 ike-sa-manager: Make checkout_by_config() atomic
These changes should ensure that concurrent calls to checkout_by_config()
result in a single IKE_SA.  For instance, when acquires for different
children of the same connection are triggered concurrently.

There are two major changes to the interface:

 1) The peer config object is now always set on the returned IKE_SA.
    That was previously only the case if an existing IKE_SA was
    returned.

 2) The IKE_SA is now always registered with the manager and properly
    checked out, which also was only the case for existing IKE_SAs
    before.
2021-02-12 15:49:08 +01:00
Tobias Brunner c7a0f2698d Merge branch 'tls13'
This adds support for TLS 1.3 to libtls and adds several new features to
existing TLS versions (e.g. support for x25519/x448, EdDSA or RSA-PSS).

Unfortunately, TLS 1.3 is not really usable for TLS-based EAP methods in
practice because, in particular, key derivation is not yet standardized.
While it works between two strongSwan instances and even FreeRADIUS 3.0.21,
there will be compatibility issues in the future when implementations move
to a standardized scheme.  There are currently two Internet-Drafts in
development to specify that (see 121ac4b9e3 for details).  Until they are
more stable, the default maximum version is set to 1.2.

The default minimum version has also been increased to 1.2 and several
older/weaker cipher suites have been removed (e.g. with 3DES and MD5).
2021-02-12 15:32:03 +01:00
Tobias Brunner 74b9ba7cdb tls-crypto: Simplify and extend cipher config filter
This way we automatically can filter for newer algorithms (e.g.
chacha20poly1305).
2021-02-12 14:35:23 +01:00
Tobias Brunner 8b2b5a647b proposal: Add aliases for AES-GCM/CCM without explicit ICV length
These are mapped to use the default, maximum ICV length of 16 bytes.
2021-02-12 14:35:23 +01:00
Tobias Brunner 966a26eaa2 tls-server: Support x25519/448 for TLS 1.2 2021-02-12 14:35:23 +01:00
Tobias Brunner f77ecf0728 tls-crypto: Fallback to any supported ECDH group
If the default group listed in the cipher suite is not supported, we try
to use any other supported group (the groups are negotiated separately
so we are not locked in to a specific group).
2021-02-12 14:35:23 +01:00
Tobias Brunner 311405c34d tls-crypto: Don't filter suites with specific ECDH group if any is available
Since DH groups (or with TLS < 1.3 curves) are negotiated separately,
it doesn't matter which one is listed in the cipher suite as any one could
be used.
2021-02-12 14:35:23 +01:00
Tobias Brunner 85bde019d3 diffie-hellman: Classify x25519 and x448 as ECDH methods 2021-02-12 14:35:23 +01:00
Pascal Knecht e3757300eb tls-crypto: Add signature scheme config file filter
And add signature scheme unit tests.
2021-02-12 14:35:23 +01:00
Pascal Knecht e5b6565730 tls-crypto: Rename DH group/key exchange method config option
TLS key exchange methods are now configured with `ke_group`.
2021-02-12 14:35:23 +01:00
Tobias Brunner a60e248b0d libtls: Increase default min version to 1.2
The older versions are generally considered deprecated (there is an
Internet-Draft that aims to do that formally).
2021-02-12 14:35:23 +01:00
Tobias Brunner 3abcbf82b5 tls-peer: Verify server selects the same cipher suite after HelloRetryRequest
This is as per RFC 8446, section 4.1.4.
2021-02-12 14:35:23 +01:00
Tobias Brunner ab226b3927 tls-server: Select cipher suite also when handling HelloRetryRequest
This was previously treated like a resumption, which it is clearly not.
Also added a check that verifies that the same cipher suite is selected
during the retry, as per RFC 8446, section 4.1.4.
2021-02-12 14:35:23 +01:00
Tobias Brunner 111e907168 tls-server: Remove unused variable 2021-02-12 14:35:23 +01:00
Pascal Knecht dc9f6c68df libtls: Add downgrade protection for TLS 1.3 and TLS 1.2
Section 4.1.3 in RFC 8446 defines a new downgrade protection mechanism
that also affects TLS 1.2.
2021-02-12 14:35:23 +01:00
Shmulik Ladkani a4a128bd2f tls-server: Optionally omit CAs in CertificateRequest messages
Usually, the DNs of all loaded CA certificates are included in the
CertificateRequest messages sent by the server.

Alas, certain EAP-TLS clients fail to process this message if the
list is too long, returning the fatal TLS alert 'illegal parameter'.

This new option allows configuring whether CAs are included or an
empty list is sent (TLS 1.2), or the certificate_authorities extension
is omitted (TLS 1.3).  The list only serves as hint/constraint
for clients during certificate selection, they still have to provide
a certificate but are free to select any one they have available.

Closes strongswan/strongswan#187.
2021-02-12 14:35:23 +01:00
Tobias Brunner 083f38259c tls-eap: Conclude EAP method also after processing packets
With TLS 1.3, the server sends its Finished message first, so the
session is complete after processing the client's Finished message,
without having to send anything else (in particular no acknowledgement
as the last message from the client is no fragment).
2021-02-12 14:35:23 +01:00
Tobias Brunner a00ace0fe2 libtls: Only run socket tests with EdDSA keys if they are supported
ECDSA support is currently required to run the tests because ECDSA
cipher suites are not filtered when determining the supported cipher
suites.  Also required are ECDH groups.
2021-02-12 14:35:23 +01:00
Tobias Brunner 7b64880a8c tls-peer: Don't log anything if we are not sending supported groups 2021-02-12 14:35:23 +01:00
Tobias Brunner 8cf3998f1a tls-crypto: Only log modified TLS versions if successfully set
If no cipher suites are available, the new versions are the previous
values but reversed (i.e. the versions were not changed but we still
ended up with a log message saying "TLS min/max TLS 1.3/TLS 1.0 ...").

Also switched to using the numeric version names to avoid the repeated
"TLS" prefix.
2021-02-12 14:35:23 +01:00
Tobias Brunner 92aef122c3 libtls: Reduce default max version to 1.2
Using TLS 1.3 with various EAP methods is not yet fully standardized, so we
don't enable it by default yet.
2021-02-12 14:35:23 +01:00
Tobias Brunner 663969ddf7 libtls: Make min/max TLS version configurable
Except for the tls_test tool, the versions now default to those
configured in strongswan.conf.
2021-02-12 14:35:23 +01:00
Pascal Knecht 9389fef78a test-hkdf: Add two test cases and restructure all tests
RFC 8448 contains multiple TLS 1.3 message traces, this commit adds two
new test cases focusing on key derivation:

- Simple 1-RTT Handshake
- Resumed 0-RTT Handshake

Additionally, the whole test suite is restructured and duplicate code is
removed and consolidated.
2021-02-12 14:35:23 +01:00
Pascal Knecht 7797c058d9 tls-hkdf: Implement binder PSK generation 2021-02-12 14:35:23 +01:00
Pascal Knecht 3e535c31b4 tls-hkdf: Implement resumption key generation 2021-02-12 14:35:23 +01:00
Pascal Knecht 9ef46cfaf9 tls-peer: Mutual authentication support for TLS 1.3 2021-02-12 14:35:23 +01:00
Pascal Knecht 2d933f318b tls-peer: Derive application traffic keys after server finished message
The inbound key is used right away, the outbound key only after the
client finished message has been sent.
2021-02-12 14:35:23 +01:00
Pascal Knecht d41d8b0039 tls-peer: Use private key enumeration also in TLS versions < 1.2
Until now, key selection was based on tls_client_certificate_type_t and now
uses a simple mapping from these types to tls_signature_scheme_t.
2021-02-12 14:35:23 +01:00
Pascal Knecht d8e42a3d4e tls-crypto: Share private key search between client and server
This way the client also properly considers the TLS version and the signature
schemes supported by the server.

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2021-02-12 14:35:23 +01:00
Pascal Knecht 299cc80094 tls-test: Add support to require/verify client certificates
Also add detailed usage output with description of all options.
2021-02-12 14:35:23 +01:00
Pascal Knecht d2fc9b0961 tls-server: Mutual authentication support for TLS 1.3
This commit also addresses the side effect that additional messages have
an influence on the derivation of the application traffic secrets. Therefore,
key derivation is relocated after the server finished message has been sent,
so the additional messages from the client (Certificate, CertificateVerify)
don't affect the key derivation. Only the outbound key is switched there, the
inbound key remains in use until the client's finished message has been
processed.
2021-02-12 14:35:23 +01:00
Pascal Knecht dc49d457a2 tls-server: Terminate connection if peer certificate is required but not sent
This change mainly affects legacy TLS versions because TLS 1.3
connections are terminated by the server once the peer does not send a
CertificateVerify message next to its empty Certificate message.
2021-02-12 14:35:23 +01:00
Pascal Knecht 4bba89fff3 tls-server: Make CertificateRequest conditional in old TLS versions
The server implementation now only sends a CertificateRequest message if
it has identity information to verify client certificates.
2021-02-12 14:35:23 +01:00
Pascal Knecht 4635f348fa tls-server: Share trusted public key search between client and server 2021-02-12 14:35:23 +01:00
Pascal Knecht 6b23543abd tls-crypto: Move AEAD ownership to the protection layer
This separates key derivation from key switching.
2021-02-12 14:35:23 +01:00
Pascal Knecht 534a781646 tls-hkdf: Always use correct base key to derive finished message
The cached traffic secrets change once the application traffic secrets
are derived, but we must always use the correct base key to derive the
finished message, which are the handshake traffic secrets (RFC 8446,
section 4.4).
2021-02-12 14:35:23 +01:00
Pascal Knecht 0aaf1242d9 libtls: Add unit tests for Ed25519 and Ed448 keys
TLS 1.0 to TLS 1.3 socket connection tests with each key type.
2021-02-12 14:35:23 +01:00
Pascal Knecht 5e579ebe8f tls-test: Load keys of any type
Only RSA keys were possible until now.
2021-02-12 14:35:23 +01:00
Pascal Knecht 34f66ce6cb tls-crypto: Support EdDSA keys with ECDSA cipher suites
Ed25519 and Ed448 are now usable in all TLS versions for connections that
use an ECDSA cipher suite, as per RFC 8422.
2021-02-12 14:35:23 +01:00
Pascal Knecht 9803fb82f4 tls-server: Consider supported signature algorithms when selecting key/certificate
This won't work if the client doesn't send a `signature_algorithms`
extension.  But since the default is SHA1/RSA, most will send it to at
least announce stronger hash algorithms if not ECDSA.
2021-02-12 14:35:23 +01:00
Pascal Knecht 06112f3fe2 tls-crypto: Distinguish between signing and verifying signature schemes
strongSwan supports RSA_PSS_RSAE schemes for signing but does not
differentiate between rsaEncryption and rsassaPss encoding. Thus
RSA_PSS_PSS schemes are only used for verifying signatures.
2021-02-12 14:35:23 +01:00
Pascal Knecht e731396280 tls-server: Check if peer sent hash and signature algorithms
It is mandatory to receive the `signature_algorithms` extension when a
server is authenticating with a certificate, which is always the case.
2021-02-12 14:35:23 +01:00
Pascal Knecht 91c9e4d576 tls-crypto: Add missing signature scheme constants
Some peers, e.g. Firefox, send a wide range of signature algorithms. To
prevent numeric identifiers in the log these algorithms are added here.
2021-02-12 14:35:23 +01:00
Pascal Knecht 0dfe1590b6 tls-server: Fix invalid signature algorithm and supported groups parsing
The extension's content length field was wrongly added to the content data.

Fixes: 06109c4717 ("Implemented "signature algorithm" hello extension")
2021-02-12 14:35:23 +01:00
Pascal Knecht 3767a4a655 tls-server: Support multiple client key shares
A client can send one or multiple key shares from which the server picks
one it supports (checked in its preferred order).  A retry is requested if
none of the key shares are supported.
2021-02-12 14:35:23 +01:00
Pascal Knecht 64e2506f5b libtls: Add TLS version negotiation test cases
These client to server negotiation test cases are implemented:
- TLS 1.0 => TLS 1.3
- TLS 1.1 => TLS 1.3
- TLS 1.2 => TLS 1.3
- TLS 1.3 => TLS 1.3

- TLS 1.3 => TLS 1.0
- TLS 1.3 => TLS 1.1
- TLS 1.3 => TLS 1.2
- TLS 1.3 => TLS 1.3

- TLS 1.0 => TLS 1.2
- TLS 1.1 => TLS 1.2
- TLS 1.2 => TLS 1.2
- TLS 1.3 => TLS 1.2
2021-02-12 14:35:23 +01:00
Pascal Knecht c3e7132468 tls-server: Support HelloRetryRequest (HRR)
Adds support to request and handle retries with a different DH group.

Only the first key share extension sent by the client is currently
considered, so this might result in protocol errors if the server requests
a group for which the client already sent a key share.
2021-02-12 14:35:23 +01:00
Pascal Knecht e53bee9dbe tls-crypto: Add support to configure DH groups to use
And add new test cases to test TLS 1.3 connections for each supported DH
group.
2021-02-12 14:35:23 +01:00
Tobias Brunner 9514aa2dcc diffie-hellman: Add enum names that match proposal keywords 2021-02-12 14:35:23 +01:00
Pascal Knecht 066ac8809c tls-crypto: Generalizing DH group to TLS group mapping
This simplifies writing the key share extension as the TLS group does
not have to be cached.
2021-02-12 14:35:23 +01:00
Pascal Knecht ab70f68cf9 tls-server: Support KeyUpdate requests and answers 2021-02-12 14:35:23 +01:00
Pascal Knecht 5c4cb40e47 tls-server: Refactor writing of key share extensions
Client and server now share the same code to write this extension.
2021-02-12 14:35:23 +01:00
Pascal Knecht 7fbe2e27ec tls-server: TLS 1.3 support for TLS server implementation
Add basic support to establish a TLS 1.3 connection with a client capable
of the same protocol version.
2021-02-12 14:35:23 +01:00
Pascal Knecht 328d7af6d2 tls-crypto: Rename parameter to be more consistent
Also add missing parameter in documentation of calculate_finished method.
2021-02-12 14:35:23 +01:00
Pascal Knecht 6549adb608 tls-crypto: Fix invalid signature algorithm list building
List building also added an additional length field which is required by
client-side TLS extensions but not for server-side certificate request
extension. Now the method only returns a list of supported signature
algorithms and the implementation is responsible to add additional
length fields.

Fixes: 07f826af67 ("Fixed encoding of TLS extensions (elliptic_curves and signature_algorithms)")
2021-02-12 14:35:23 +01:00
Pascal Knecht f81c04e9e3 libtls: Add missing cipher suite and TLS extension constants
- TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
- TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
- TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256

- Encrypt then MAC
- Extended master secret
- Session ticket

and also add missing suites in the unit test.
2021-02-12 14:35:23 +01:00
Pascal Knecht d107198fcb tls-crypto: Rework cipher suite preference order
The reworked list follows the order of modern browsers such as
Firefox. The new order prefers more secure ciphers over weaker ones.
2021-02-12 14:35:23 +01:00
Tobias Brunner 06424efa17 tls-server: Determine supported/configured suites and versions early
If we don't do this, we might negotiate a TLS version for which we don't
have any suites configured, so that the cipher suite negotiation
subsequently fails.
2021-02-12 14:35:23 +01:00
Pascal Knecht 8a6edc08a4 tls-crypto: Check if TLS versions and cipher suites match
Only suggest TLS versions of supported cipher suites.  For instance, do not
suggest TLS 1.3 if none of its cipher suites (requiring GCM/CCM or
ChaPoly) are available.
2021-02-12 14:35:23 +01:00
Pascal Knecht f920125304 tls-peer: Don't initiate TLS connection if no cipher suites are supported
If zero cipher suites are left after all filters, tls-peer does not
try to establish a connection to the server anymore.
2021-02-12 14:35:23 +01:00
Tobias Brunner 06aad98ff0 tls-test: Make plugin list configurable via environment variable 2021-02-12 14:35:23 +01:00
Tobias Brunner 00a6280aab tls-peer: Return INVALID_STATE after changing TLS 1.3 keys
Even though we return from build(), we are not actually sending a response,
so we can't return NEED_MORE (would send an invalid ClientHello message) and
if we return SUCCESS, the EAP layer treats this as failure (there is a comment
in eap_authenticator_t about client methods never returning SUCCESS from
process()).  Instead we return INVALID_STATE, which allows tls_t.build() to
exit from the build() loop immediately and send the already generated Finished
message.
2021-02-12 14:35:23 +01:00
Tobias Brunner 121ac4b9e3 tls-crypto: Generate MSK for TLS 1.3
We generate material for both MSK and EMSK even though we only need the
former.  Because HKDF-Expand-Label(), on which the export functionality
is based, encodes the requested key length, we have to allocate the same
number of bytes as e.g. FreeRADIUS does (i.e. if we only request 64
bytes, those won't be the same as the first 64 bytes after requesting
128 bytes).

Unfortunately, key derivation for TLS-based methods is currently not
standardized for TLS 1.3.  There is a draft [1], which defines a scheme
that's different from previous versions (instead of individual label
strings it uses a single one and passes the EAP type/code as context
value to TLS-Export()).  The current code is compatible to FreeRADIUS
3.0.x, which doesn't implement it according to that draft yet (there are
unreleased changes for EAP-TLS, not for the other methods, but these only
switch the label, no context value is passed).  In a separate draft
for EAP-TLS [2] there is an altogether different scheme defined in the
latest version (label combined with EAP method, no context and separate
derivation for MSK and EMSK).

So this is a mess and we will have to change this later with the inevitable
compatibility issues (we should definitely disable TLS 1.3 by default).

[1] https://tools.ietf.org/html/draft-ietf-emu-tls-eap-types
[2] https://tools.ietf.org/html/draft-ietf-emu-eap-tls13
2021-02-12 14:35:23 +01:00
Tobias Brunner d2fe921cf5 tls-hkdf: Add method that allows exporting key material 2021-02-12 11:45:44 +01:00
Tobias Brunner 86cda1a3c0 tls-hkdf: Handle label expansion inside expand_label()
We have to expand arbitrary external labels the same way when exporting
key material.
2021-02-12 11:45:44 +01:00
Tobias Brunner 3e89d26e1c tls-hkdf: Pass secret to derive_secret() explicitly 2021-02-12 11:45:44 +01:00
Tobias Brunner 4e2b8f9c71 tls-hkdf: Store OKM in local variables 2021-02-12 11:45:44 +01:00
Tobias Brunner 1b593e1d48 tls-crypto: Add support for RSA-PSS signatures
PKCS#1 v1.5 signatures are not defined for use with TLS 1.3 (they can
only appear in certificates, we now send a signature_algorithms_cert
extension to indicate support for them).  So for RSA certificates, we
must support RSA-PSS signatures.

There are two sets of schemes, that are differentiated by the type of
RSA key used for the signature, one is for classic RSA keys (rsaEncryption
OID), which can also be used with PKCS#1 when using TLS 1.2, the other
is for RSA-PSS keys (RSASSA-PSS OID), which are not yet commonly
used (and can't be generated by our pki tool).  According to the RFC,
PSS must also be supported for TLS 1.2 if the schemes are included in
the signature_algorithms extension (e.g. OpenSSL does not use PKCS#1 v1.5
anymore if PSS is proposed).

This changes how these schemes are stored and enumerated (they are not
treated as combination of hash algo and key type anymore).

Legacy schemes (MD5/SHA-1) are removed.
2021-02-12 11:45:47 +01:00
Tobias Brunner e02f19e3c6 tls-peer: Support answering KeyUpdate requests 2021-02-12 11:45:44 +01:00
Tobias Brunner 27360d3407 tls-socket: Change how EOF of the underlying socket is handled
With the previous code, there was an issue when replying to TLS 1.3
post-handshake messages.  In this case, SUCCESS is eventually returned
from build(), however, no actual data has been received so in_done is 0.
This was interpreted as EOF, plain_eof was set to TRUE and no further data
was read from the socket afterwards.

Returning SUCCESS from build() if the exchange is initiated by
write_(), as is the case with the finished reply, never was a problem
because there the return value of 0 is not interpreted as EOF.
2021-02-12 11:45:44 +01:00
Tobias Brunner bfcb49b393 tls-peer: Add support to handle KeyUpdate message
We currently don't support switching our own keys and sending the
message if requested by the server.
2021-02-12 11:45:44 +01:00
Tobias Brunner 1466d4da25 tls-crypto: Add method to update application traffic keys 2021-02-12 11:45:44 +01:00
Tobias Brunner b51c1d468e tls-hkdf: Support updating client/server traffic secrets 2021-02-12 11:45:44 +01:00
Tobias Brunner 09fbaad6bd tls-socket: Don't fail reading if sending data failed
If data is processed that eventually includes a TLS close notify, build()
will fail after a close notify has been sent in turn.  However, propagating
that error immediately when reading prevented ever returning the data
already processed before the close notify was received.
2021-02-12 11:45:44 +01:00
Tobias Brunner d532d6c7bc tls-peer: Correctly handle classic ECDH key-share format
Similar to TLS 1.2 but uses a 16-bit length header.
2021-02-12 11:45:44 +01:00
Tobias Brunner 8e35b1f1a5 tls-test: Add options to configure TLS versions 2021-02-12 11:45:44 +01:00
Tobias Brunner a7f2818832 tls-socket: Allow configuring both minimum and maximum TLS versions 2021-02-12 11:45:44 +01:00
Tobias Brunner c4576a1f57 tls: Allow setting both minimum and maximum TLS versions
This allows to increase the initial minimum version and also prevents
sending a list of versions during retries when 1.3 was already
negotiated.
2021-02-12 11:45:44 +01:00
Tobias Brunner 2b6565c236 tls-peer: Handle HelloRetryRequest
Adds support to handle retries with different DH group and/or a cookie
extension.
2021-02-12 11:45:44 +01:00
Tobias Brunner 2271d67f07 tls-crypto: Add method to hash handshake data and use result as initial transcript
This is used for HelloRetryRequest.
2021-02-12 11:45:44 +01:00
Tobias Brunner 64e63c68c8 tls-crypto: Destroy HKDF instance if keys are derived multiple times
This will be the case during a retry.
2021-02-12 11:45:44 +01:00
Tobias Brunner 851b605e21 tls-peer: Refactor writing of extensions and use less hard-coded DH group
Note that this breaks connecting to many TLS 1.3 servers until we support
HelloRetryRequest as we now send a key_share for ECP_256 while still
proposing other groups, so many servers request to use CURVE_25519.
2021-02-12 11:45:44 +01:00
Tobias Brunner de31646a09 tls-peer: Refactor sending/processing finished message
Also fixes leaks.
2021-02-12 11:45:44 +01:00
Tobias Brunner 44cda40d58 tls-peer: Simply ignore certificate request context
This SHALL be zero length for server authentication anyway.
2021-02-12 11:45:44 +01:00
Tobias Brunner bfa3178836 tls-peer: Use existing code to verify certificate and signature 2021-02-12 11:45:44 +01:00
Tobias Brunner c78b2bee5d tls-peer: Refactor parsing of TLS extensions
Also adds proper error handling.
2021-02-12 11:45:44 +01:00
Tobias Brunner f0ed5f9125 tls-peer: Fix parsing of encrypted extensions 2021-02-12 11:45:44 +01:00
Tobias Brunner 4c40a3d3f0 tls-peer: Fix parsing of intermediate CA certificates 2021-02-12 11:45:44 +01:00
Tobias Brunner 2e1c0a2776 tls-crypto: Rename methods to calculate finished message
Instead of the version number use "legacy" for the one for earlier TLS
versions.
2021-02-12 11:45:44 +01:00
Tobias Brunner f116a4823f tls-crypto: Use internal PRF of tls-hkdf to generate finished message
Also adds additional checks.
2021-02-12 11:45:44 +01:00
Tobias Brunner a9f661f52a tls-hkdf: Add helper method to allocate data from the internal PRF 2021-02-12 11:45:44 +01:00
Tobias Brunner 6a0ee0c23c tls-hkdf: Cleanups and refactorings
The main refactoring is how secrets (PSK/DH) are handled.
2021-02-12 11:45:44 +01:00
Tobias Brunner de983a3cb9 tls-crypto: Simplify signature creation/verification 2021-02-12 11:45:44 +01:00
Tobias Brunner 2921f43705 tls-crypto: Simplify handshake/application key derivation and rename methods
Also consistently change the ciphers outside of tls_crypto_t and
simplify key derivation in tls_peer_t and fix a memory leak.
2021-02-12 11:45:44 +01:00
Tobias Brunner fff1974012 tls-hkdf: Make labels enum a proper type 2021-02-12 11:45:44 +01:00
Tobias Brunner 8495138d4a tls-peer: Support x25519/448 for TLS 1.2
These DH groups don't use the point format prefix (RFC 8422 deprecated
any other format anyway).  Since they are enumerated now, they can also
be used by servers for TLS 1.2.
2021-02-12 11:45:44 +01:00
Tobias Brunner 3101120c75 tls-crypto: Enumerate x25519/448 and rename constant for consistency 2021-02-12 11:45:44 +01:00
Tobias Brunner 53ba0801ac tls-crypto: Simplify hash algorithm handling 2021-02-12 11:45:44 +01:00
Tobias Brunner 43c8f950a7 tls-crypto: Delay instantiation of cipher suites
This way we can take into account the version set via setter on tls_t.
2021-02-12 11:45:44 +01:00
Tobias Brunner 281766c5e6 tls-crypto: Filter TLS cipher suites by min/max version
There is no point proposing legacy (or future) cipher suites depending on
the proposed TLS versions. It was actually possible to negotiate and use
cipher suites only defined for TLS 1.2 with earlier TLS versions.
2021-02-12 11:45:44 +01:00
Tobias Brunner 436571b2f0 tls-crypto: Correctly filter cipher suites based on PRF algorithms
The previous check operated on the first array element.
2021-02-12 11:45:44 +01:00
Tobias Brunner b7ea969b32 tls-crypto: Use correct key length for ChaCha20/Poly1305 2021-02-12 11:45:44 +01:00
Tobias Brunner ba3c90ded1 libtls: Some code style fixes 2021-02-12 11:45:44 +01:00
Tobias Brunner 4099035a0c tls-test: Make address family configurable and simplify DNS/socket handling 2021-02-12 11:45:44 +01:00
bytinbit 7a2b02667c libtls: Implement TLS 1.3 handshake on client-side
The code is a minimal handshake with the HelloRetryRequest message
implementation missing.
Can be tested with an OpenSSL server running TLS 1.3. The server must
be at least version 1.1.1 (September 2018).

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

Co-authored-by: bytinbit <meline.sieber@hsr.ch>
2021-02-12 11:45:44 +01:00
Tobias Brunner 3d83d348f4 libtls: Add support to run unit tests with a custom plugin list 2021-02-12 11:45:44 +01:00
Tobias Brunner 818dc86568 libtls: Add TLS 1.3 implementation of tls_aead_t
The key material, in particular the nonce/IV, is derived differently and
the IV is also generated in a different way.  Additionally, the actual
content type is encrypted and there may be optional padding to mask the
actual size of the encrypted data.
2021-02-12 11:45:44 +01:00
Tobias Brunner ba2bcdd882 libtls: Allow tls_aead_t to change the content type
The actual content type is encrypted with TLS 1.3, the type in the record
header is always Application Data.
2021-02-12 11:45:44 +01:00
Andreas Steffen 0d43b39931 testing: extended sleep time tkm/xfrmproxy tests 2021-02-12 09:44:00 +01:00
Andreas Steffen ab58f95b12 Version bump to 5.9.2dr2 2021-02-12 08:17:54 +01:00
Tobias Brunner cc25d2195a testing: Copy /etc/resolv.conf from host in chroot script
This makes installing packages etc. easier.
2021-02-11 16:41:06 +01:00
Tobias Brunner f3acc0a87b appveyor: Set timezone on the build system
For some reason, setting the time zone via TZ to `GST-1GDT` in the utils test
doesn't work anymore (the DST zone is not considered, it's as if only `GST-1`
was configured).
2021-02-11 16:40:58 +01:00
Tobias Brunner 8ff8b85ce6 appveyor: Create dummy strongswan.conf file to avoid log messages
Only relevant when increasing the verbosity, but causes quite a lot of
them then.
2021-02-11 16:40:58 +01:00
Tobias Brunner 671164865b appveyor: Print OpenSSL version 2021-02-11 16:40:58 +01:00
Tobias Brunner 781ad0b93b openssl: Allocate our own buffer for i2d_* wrapper macro
If we pass a pointer to NULL, the memory allocated by OpenSSL has to be
freed with OPENSSL_free().  Otherwise, this can lead to random
crashes/freezes for Windows builds as seen on AppVeyor.  To not
complicate things for callers of this macro, we allocate our own memory,
which we already do for other i2d_* calls.
2021-02-11 16:40:58 +01:00
Tobias Brunner 6a440f83ab openssl: Reset HMAC key if chunk_empty is passed
If no valid key is configured (e.g. because it's inadvertently uninitialized),
we should not just reuse the previous key.

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

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

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

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

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

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

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

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

Fixes: 74e02ff5e6 ("openssl: Mainly use EVP interface for ECDH")
2021-01-27 16:37:45 +01:00
Tobias Brunner 55df5e9797 openssl: Avoid conflicts with wincrypt.h on Windows
There are several conflicts with newer versions of OpenSSL (> 1.0).
2021-01-27 16:32:43 +01:00
Tobias Brunner a5f4b996bf appveyor: Also build against newer OpenSSL versions
The original version is 1.0.2, which we keep as that version is not in
use on other platforms anymore.
2021-01-27 16:32:43 +01:00
Michał Skalski 14a0c08235 Enable Windows CI build of pkcs11 plugin 2021-01-27 16:32:43 +01:00
Michał Skalski f30187d422 pkcs11: Fix build on Windows
Windows provides CreateMutexA/W with an alias called CreateMutex that
selects one of the other two based on the UNICODE constant.
2021-01-25 15:16:12 +01:00
Tobias Brunner 8d8739ace6 github: Enable farp plugin on macOS 2021-01-22 10:44:05 +01:00
Tobias Brunner 1af4ae8732 cirrus: Build farp plugin on FreeBSD 2021-01-22 10:44:05 +01:00
Dan James 95a0d800c9 farp: Add support for macOS and FreeBSD
Co-authored-by: Tobias Brunner <tobias@strongswan.org>

Closes strongswan/strongswan#189.
References #3498.
2021-01-22 10:44:05 +01:00
Tobias Brunner 8e367df6db Merge branch 'openssl-ecp'
Uses the EVP interface for ECDH with newer OpenSSL versions, which,
compared to the previous low-level use of EC_POINT_mul() supports
hardware offloading.  We used this because of the ecp_x_coordinate_only
option, which is now removed as it's been obsolete for a long time and
complicated the code.  There is still some legacy code for OpenSSL 1.0
and the old BoringSSL version we currently use for the Android app.

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

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

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

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

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

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

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

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

Fixes #3541.
2021-01-18 13:58:01 +01:00
Tobias Brunner f97875b72e Merge branch 'ike-update-event'
This modifies the signature of the listener_t::ike_update() callback so
that both addresses are passed and it's only called once if both
addresses change (e.g. for an address family switch).

The callback is now also triggered for MOBIKE updates and the event is
exposed via vici.

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

Also update TKM-RPC and TKM in testing scripts to version supporting the
reworked CC handling.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger 532023dcf1 testing: Use latest TKM RPC library
Brings some cleanups and minor improvements.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger eccca505aa testing: Use multi-CA aware TKM
Also add CA ID to tkm_keymanager command.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger d6cf4a165b testing: Add CA ID mappings to TKM tests
Extend the build-certs-chroot script is to fill in the public key
fingerprint of the CA certificate in the appropriate strongswan.con
files.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger f8242127a2 charon-tkm: Add support for multiple CAs
Load CA certificate id mapping from config and pass the correct CA ID to
TKM when checking certificate chains. The mapping of CA certificate to
CA ID is done via SHA-1 hash of the CA certificates subjectPublicKey.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger 73d2a11aee charon-tkm: Register TKM cred encoder before init
Make sure the credential encoder is available early to allow getting
public key fingerprints.
2021-01-08 17:22:36 +01:00
Adrian-Ken Rueegsegger 524751ae76 testing: Switch to https for codelabs recipes 2021-01-08 17:22:36 +01:00
Tobias Brunner fde5374a86 testing: Explicitly encode backing image format in metadata
Apparently, there is no probing anymore in newer versions of qemu due
to security considerations.
2021-01-08 11:39:44 +01:00
Andreas Steffen fcb595f961 Version bump to 5.9.2dr1 2021-01-08 11:00:15 +01:00
Andreas Steffen 2889133cc0 imc_attestation: Fixed double free of tpm_version_info chunk 2021-01-08 11:00:15 +01:00
Andreas Steffen 08760dd927 tpm: Intel FW TPM always uses locality 0 2021-01-08 11:00:15 +01:00
Andreas Steffen 2ea1dac203 libimcv: Support symlinks introduced by usrmerge
Debian, Ubuntu, Fedora et. al. started to apply usrmerge to their
latest Linux distributions, i.e.  /bin, /sbin, and /lib are now
symbolical links to /usr/bin, /usr/sbin, and /usr/lib, respectively.
Since executables and libraries are contained only once in Linux
packages (e.g. /bin/cp in coreutils but not /usr/bin/cp) this leads
to missing file measurments due to the symlinks when doing remote
attestation.

The new ita_attr_symlinks PA-TNC attribute fixes this problem by
collecting symbolic links pointing to directories on the client
platform.
2021-01-08 11:00:15 +01:00
Andreas Steffen 9b4a2322d6 libimcv: Evaluate IMA SHA-256 measurements 2021-01-08 11:00:15 +01:00
Tobias Brunner 839d6c8f80 github: Bump wolfSSL to 4.6.0
Also enables Brainpool curves (this only enables the BP curves, while
--enable-ecccustcurves=all would also enable several others we don't support).
2021-01-04 16:09:58 +01:00
Tobias Brunner ea7945a4f5 wolfssl: Disable ECC curves based on minimum ECC key size
wolfSSL 4.6.0 provides a new option to configure the minimum ECC key
size (--with-eccminsz), which currently defaults to 224 bits.
2021-01-04 16:09:56 +01:00
Tobias Brunner 6e2e359f38 wolfssl: Correctly enable Brainpool curves 2021-01-04 16:09:22 +01:00
Andreas Steffen f397fc02e9 configure: Fixed test for imv_swima 2020-12-24 13:08:49 +01:00
Tobias Brunner 51f4837628 cirrus: Build against tpm2-tss on FreeBSD
This was enabled in the port too.
2020-12-15 10:42:43 +01:00
Tobias Brunner ec9f986b61 Ignore verbose parser generator output file more generally
Depending on from where bison is called, the file might not end up in
the same directory as the .y file, but the location of the Makefile.
This has been seen on FreeBSD.
2020-12-15 10:42:43 +01:00
Tobias Brunner 192581e785 Replace two deprecated parser generator directives
There is a conflict between Flex's bison-bridge and Bison's api.prefix
options.  Apparently, the former was added without consulting the Bison
devs and requires YYSTYPE, which is not added to the header anymore by
the latter.  Instead, we just provide the proper definition of yyflex()
manually (as recommended by the Bison docs), so the option is not
required anymore.
2020-12-15 10:42:43 +01:00
Tobias Brunner 8468b43891 github: Prevent duplicate CI runs
This cancels previous runs of the same branch and skips runs of the same
content (e.g. after merges or tags).
2020-12-15 10:42:43 +01:00
Tobias Brunner de401e0e89 github: Migrate from Travis CI to Github Actions
On travis-ci.com (travis-ci.org will be discontinued by the end of the
year) we are now charged for each minute.  We only got 10000 credits in
a trial plan, which we used up with a few builds.  Minutes also cost a
different amount of credits on different platforms: 10 on Linux,
but 50 on macOS (installing the dependencies on macOS alone took 12-15
minutes on Travis for some reason, takes about half on Github's runners).

No native Windows build yet as we have the same issue as on AppVeyor where
threading/streaming tests might get stuck.  And there is also only a
single Windows platform to test on.  Plus building/testing on Windows is
very slow (and getting ccache to work seems tricky).

The 'sw_collector' test case had to be disabled because we can't access
/usr/local/share on the Github build hosts (the process is just blocked
in readdir() and eventually times out).

Unfortunately, we can't test on different architectures anymore (in
particular ARM and the big-endian IBM Z/x390x).
2020-12-15 10:42:43 +01:00
Tobias Brunner eb4cd8e3b1 imv-scanner: Fix potentially unsafe port filter attribute destruction
DESTROY_IF() checks if the given value is not NULL, before calling
destroy() on it, which does not work for sub-structs.  If
port_filter_attr is NULL, this could crash.
2020-12-03 12:19:06 +01:00
Tobias Brunner 25ec2d04aa child-rekey: Don't migrate child-create task if we already are deleting
If we are already deleting the old/redundant CHILD_SA, we must not
migrate the child-create task as that would destroy the new CHILD_SA we
already moved to the IKE_SA.

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

Fixes #3634.
2020-12-03 08:36:20 +01:00
Tobias Brunner 9248f636b0 kernel-netlink: Make sure we successfully opened a Netlink socket
This is in addition to the fix in the destructor in 991e9e5dc9.
2020-12-03 08:34:18 +01:00
Tobias Brunner e8fae43768 identification: Validate ASN.1 DN in from_data() constructor
The DN is otherwise not parsed until compared/printed.  This avoids
false detections as ASN.1 DN if e.g. an email address starts with "0",
which is 0x30 = ASN.1 sequence tag, and the next character denotes
the exact length of the rest of the string (see the unit tests for an
example).
2020-12-03 08:23:54 +01:00
Tobias Brunner 4c61d7aedc android: New release after avoiding marking VPN connections as metered 2020-12-02 16:09:38 +01:00
Tobias Brunner b32a9be419 android: Don't default to marking VPN connections as metered
For apps targeting Android 10, where a method to change this was added, the
default changed so that all VPN connections are marked as metered.  This means
certain background operations (e.g. syncing data) are not performed anymore
even when connected to a WiFi.  By setting this to false, the metered state
of the VPN connection reflects that of the underlying networks.
2020-12-01 16:00:09 +01:00
Tobias Brunner b58740996f testing: Use build-strongswan to implement build-rootimage 2020-11-27 12:05:22 +01:00
Tobias Brunner 88c94063d2 testing: Make building guest images after strongSwan optional
This is basically only for the build-rootimage use case.
2020-11-27 12:05:22 +01:00
Tobias Brunner 386e9a96a1 testing: Optionally build strongSwan from a release tarball
This will allow us to replace the build-rootimage script.
2020-11-27 12:05:22 +01:00
Tobias Brunner a7d920059e testing: Optionally replace root image when building strongSwan 2020-11-27 12:05:22 +01:00
Tobias Brunner c1dc7c4149 testing: Optionally use a new strongSwan build directory
This can be useful when building completely different versions for the
first time to avoid issues with build artifacts of previous builds.
2020-11-27 12:05:22 +01:00
Tobias Brunner 543d09c4b4 testing: Add option to build all software recipes when building strongSwan
This is like building the root image but using a specific strongSwan
source tree, which is helpful if code changes depend on other software
packages (e.g. TKM-related or testing new crypto libraries).  If the script
is called and the root image does not exist, the new option is enabled
automatically.

The option to build in a specific guest image is now also moved to an
explicit command line option so that the source dir path is the only
remaining positional argument (see --help for details).
2020-11-27 12:05:22 +01:00
Tobias Brunner edc55f0876 testing: Create root image if it does not exist yet when building strongSwan
This allows running the script directly after building the base image.
2020-11-27 12:05:22 +01:00
Tobias Brunner 29c59885ca Use Botan 2.17.1 for tests 2020-11-27 12:05:22 +01:00
Tobias Brunner 1c2f5eea2c testing: Improve building different revisions of Git-recipes
If we check out and build a certain revision of a dependency in a branch and
switch to another that requires a different revision and then switch back,
the previous approach installed the wrong revision as it would incorrectly
assume the required revision was already built and ready to install.
2020-11-27 12:05:22 +01:00
Tobias Brunner abb3f67bd1 pem: Make sure we actually parsed some data
This could happen if there is no separating empty line between header
and body.

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

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

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

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

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

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

    CommandException: Command failed: terminating SA failed

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

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

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

References #3602.
2020-10-30 09:58:42 +01:00
Tobias Brunner 6586f07162 ikev2: Clear fragments of a retransmitted message if we receive the next one
The message_t object used for defragmentation was only cleared after
all fragments have been received and the message was delivered.  So
if we received only some fragments of a retransmitted message, the
fragments of the next message were not processed (message_t returns
INVALID_ARG if the message ID does not match causing the message to
get ignored).  This rendered the IKE_SA unusable as the client
obviously never retransmitted the fragments of that previous message
after it received our response.
2020-10-29 14:06:19 +01:00
Tobias Brunner 364e69b683 Merge branch 'android-ipv6-transport'
Adds support to use IPv6 as transport addresses for IKE and ESP and a
bunch of fixes.  On Linux servers, this requires at least a 5.8 kernel so
UDP encapsulation for IPv6 is supported.

Fixes #892.
2020-10-29 11:23:48 +01:00
Tobias Brunner 01fee62f46 android: New release after adding IPv6 support and several fixes 2020-10-29 10:57:07 +01:00
Tobias Brunner ec317c29ca android: Throw an exception if UUID can't get parsed
The parser is quite picky and e.g. doesn't accept UUIDs without dashes.
Even without a specific error, this at least points the users into the
right direction.

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

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

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

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

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

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

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

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

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

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

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

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

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

References #3529.
2020-10-05 15:39:37 +02:00
Tobias Brunner 428c0b293d testing: Build certificates when make-testing is called 2020-09-30 12:52:43 +02:00
Mingli Yu a6cd662eed init: Remove obsolete StandardOutput setting from legacy systemd unit
The standard output value "syslog" was deprecated for a while and did fall
back to "journal". It causes a warning since systemd version 246 [1].

By removing the setting it will default to DefaultStandardOutput, which
defaults to "journal".

[1] https://github.com/systemd/systemd/blob/master/NEWS#L202

Closes strongswan/strongswan#181.
2020-09-30 12:51:08 +02:00
Tobias Brunner 040608a48d Simplify handling of terminating signals in all libcharon wrappers
Closes strongswan/strongswan#182.
2020-09-30 12:47:39 +02:00
Tobias Brunner ddc5b92dfb travis: Bump tpm2-tss to 2.4.3 2020-09-24 08:52:22 +02:00
Tobias Brunner 692feffaf3 lgtm: Fix building dependencies (in particular tpm2-tss)
This was moved to a separate step with 0ff939585e ("travis: Bump tpm2-tss
to 2.4.1") so packages are installed before these dependencies are built.
However, on LGTM, packages can't be installed explicitly, so `deps` is
a no-op and we still have to list some dependencies in the config.
2020-09-22 12:24:44 +02:00
Noel Kuntze d1d5659ead ike-vendor: Add option to send Cisco FLexVPN vendor ID
A new global option enables sending this vendor ID to prevent Cisco
devices from narrowing the initiator's local traffic selector to the
requested virtual IP, so e.g. 0.0.0.0/0 can be used instead.

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

Closes strongswan/strongswan#180.
2020-09-10 12:01:44 +02:00
Tobias Brunner dc0c20600f libipsec: Enable code coverage
Same as with libtls.
2020-09-09 13:25:30 +02:00
Tobias Brunner ed1ba70894 libtls: Enable code coverage
While the test runner was already correctly set up, the library itself
was not and no coverage was reported for any of its files.
2020-09-09 13:25:30 +02:00
Tobias Brunner d5d6d671fb leak-detective: Whitelist OPENSSL_init_ssl()
These leaks are reported with OpenSSL 1.1.0+ if the mysql plugin is loaded.
2020-09-09 13:25:30 +02:00
Tobias Brunner fd5cf31108 travis: Read project/organization for SonarCloud from environment variable 2020-09-09 13:25:30 +02:00
Tobias Brunner 76425800c4 Add project config for SonarCloud to ignore some files/rules
These settings have already been configured in the UI, but it might be
helpful to have them here so it's easier to set up the analysis of forks.
2020-09-09 13:25:30 +02:00
Tobias Brunner 6638191cd7 testing: Increase memory of alice by 20 MiB
It's ever so close with strongTNC, sometimes the OOM killer got triggered
and the tests failed, or even worse, the whole guest system got stuck.
This might just be enough for now.
2020-09-04 15:48:12 +02:00
Tobias Brunner 64148f046e testing: Fix dependency issue with strongTNC
Apparently, djangorestframework-camel-case, in the referenced version,
uses `six` but does not itself require/install it (later versions removed
Python 2 support altogether).
2020-09-04 14:56:58 +02:00
Tobias Brunner 565f022b5a Merge branch 'testing-buster'
Use Debian buster as base image for the testing environment.
2020-09-03 15:53:14 +02:00
Tobias Brunner 210c1e2628 testing: Fix route-based/net2net-xfrmi-ike scenario
On newer systems, the upper hard limit for open file descriptors (see
`ulimit -H -n`) was increased from 4096 to 524288.  Due to how python-daemon
closes potentially open file descriptors (basically stores them in a set,
removes those excluded by config, and loops through all of them), the updown
script was either killed immediately (by the OOM killer) or not ready yet
when updown events occurred.
2020-09-03 15:46:46 +02:00
Tobias Brunner 1496991078 leak-detective: Whitelist leaks that occur on Debian buster 2020-09-03 15:24:37 +02:00
Tobias Brunner 5bba0ec0f7 testing: Use Debian buster as base image 2020-09-03 15:24:37 +02:00
Tobias Brunner 1f97415fe7 testing: Use latest x509-ada release
This fixes an issue with newer compiler versions where crashes would be
caused if functions of the generated C X.509 parser are not aligned.
2020-09-03 15:24:37 +02:00
Tobias Brunner fb78b0e533 testing: Add man, valgrind and strace to base image 2020-09-03 13:34:19 +02:00
Tobias Brunner dcd8327933 testing: Install vici Python module manually
easy_install is not included in Debian's python-setuptools package
anymore, so we install it manually using setup.py.
2020-09-03 13:34:19 +02:00
Tobias Brunner d9785b36a3 testing: Replace deprecated/removed `pip install --download` command
It was deprecated for a while and has been replaced by `pip download`.
2020-09-03 13:34:19 +02:00
Tobias Brunner 94eebc9c2c testing: Use legacy iptables on Debian buster
The iptables-nft wrapper that uses the nftables framework can't handle
the CLUSTERIP target (plus we'd require nftables in the kernel).
2020-09-03 13:34:19 +02:00
Tobias Brunner 5c4ebbdde8 testing: Increase maximum guest image size
Seems that each Debian release increases the image size by about 200 MiB.
But increase it a bit more so we have room for logs/tools/debug symbols.
2020-09-03 13:34:19 +02:00
Tobias Brunner 3d1e2c56df testing: Use pkill to reload rsyslogd config/recreate log files
The PID location changes with newer Debian releases so it's more
portable this way.
2020-09-03 13:34:19 +02:00
Tobias Brunner d538b22afe testing: Remove deprecated UsePrivilegeSeparation option from sshd_config 2020-09-03 13:34:19 +02:00
Tobias Brunner 0d84b32e82 testing: Add Linux 5.8 kernel config
Enables TCP encap for ESP.
2020-09-03 13:34:19 +02:00
Tobias Brunner 5747ec4eae testing: Use host's /dev/urandom as /dev/random on guests via VirtIO RNG
Newer versions of systemd etc. seem to require quite a lot of entropy
from /dev/random while booting, which can block and therefore delay the
start of other services (in particular sshd) by more than a minute.
Using the host's /dev/urandom via VirtIO RNG, we can avoid blocking the
guests.

The required kernel options are added for kernel versions 5.4+.
2020-09-03 13:34:19 +02:00
Tobias Brunner 766017a8d3 libimcv: Add Debian 10.5 to IMV database 2020-09-03 13:34:19 +02:00
Tobias Brunner ad7d712cb5 testing: Support build with Debian buster base image 2020-09-03 13:33:32 +02:00
Tobias Brunner e96f58568e travis: Bump wolfSSL to 4.5.0 2020-08-31 17:49:10 +02:00
Tobias Brunner bdd058e36c imv-scanner: Fix potential buffer overflow
While `pos` was moved to the end, `len` was not adjusted (i.e. set to 0)
so later calls could write beyond the buffer.  However, the last port
written might have been incomplete, so instead we just reset the string.
2020-08-18 14:05:04 +02:00
Tobias Brunner 3f8eb2ebdf aesni: Remove useless algorithm assignments 2020-08-18 13:17:24 +02:00
Tobias Brunner 0ce2e00d94 vici: Don't use pytest-pycodestyle with Python 3.5
This causes problems due to a deprecation error during the Ubuntu Xenial
build on Travis.
2020-08-17 15:22:34 +02:00
Tobias Brunner 03a495f6fc travis: Bump tpm2-tss to 2.4.2 2020-08-17 13:45:15 +02:00
Andreas Steffen 2205c75bad Version bump to 5.9.0 2020-07-29 13:08:09 +02:00
Tobias Brunner ce5f9b83f6 NEWS: Add news for 5.9.0 2020-07-24 16:54:57 +02:00
Tobias Brunner 61af9a3478 vici: Fix typos in comments 2020-07-23 14:50:17 +02:00
Andreas Steffen 2eec7efd46 Version bump to 5.9.0rc1 2020-07-21 22:43:36 +02:00
Tobias Brunner 544ff81911 configure: Ignore unknown Git version number
Don't abort the script if the version is reported as UNKNOWN, which happens
on CI hosts where the repository is only cloned with a certain depth (which
may not include the latest tag).

Also, never map VERSION to UNKNOWN.

Fixes: 2e522952c7 ("configure: Optionally use version information obtained from Git in executables")
2020-07-21 12:49:13 +02:00
Tobias Brunner 59455137b4 Use Botan 2.15.0 for tests 2020-07-20 16:58:03 +02:00
Tobias Brunner edc7752802 unit-tests: Fix cancel_onoff test
If it takes a while to start one of the threads, another thread might already
have passed the usleep() call previously used and re-enabled cancelability
so that the loop that checked for it would never terminate.
2020-07-20 15:49:44 +02:00
Tobias Brunner 8a4e30ccef unit-tests: Print a header for each test function/iteration if verbosity is >= 0 2020-07-20 14:29:28 +02:00
Tobias Brunner 5c43a5bfa7 unit-tests: Add ability to filter test cases and functions 2020-07-20 14:29:12 +02:00
Tobias Brunner 2e522952c7 configure: Optionally use version information obtained from Git in executables
The variable GIT_VERSION is always defined, either obtained from Git or
a file that is embedded in tarballs when they are built.  Optionally,
that version is declared as VERSION in config.h so it will be used e.g. in
the daemons when they print the version number.

There is a check that should catch missing tags (i.e. if the version number
in AC_INIT() isn't a prefix of the version obtained via Git).
2020-07-20 14:10:52 +02:00
Tobias Brunner f77e8c171c openssl: Use consistent ifdefs to disable x25519/448
When compiling with OPENSSL_NO_ECDH but without OPENSSL_NO_EC the build
failed.
2020-07-20 14:10:05 +02:00
Tobias Brunner 6f9d5ea0f1 Merge branch 'vici-ca-certs'
These changes store all CA certificates in vici_authority_t, which avoids
issues with unloading authority sections or clearing credentials.

Closes strongswan/strongswan#172.
2020-07-20 14:07:47 +02:00
Tobias Brunner 3c5e7eaa88 vici: Keep track of all CA certificates in vici_authority_t
This way we only have one reference for each CA certificate, whether it
is loaded in an authority section, a connection or via load-certs() command.
It also avoids enumerating CA certificates multiple times if they are
loaded in different ways.
2020-07-20 14:05:39 +02:00
Tobias Brunner 3d3d5235aa object: Add helper for callbacks with two void pointers 2020-07-20 14:05:39 +02:00
Tobias Brunner d8a2c58229 vici: Make attribute certificates untrusted again
Fixes: 334119b843 ("Share vici_cert_info.c with vici_cred.c")
2020-07-20 14:05:39 +02:00
Tobias Brunner 6fc1b2c3d3 vici: Clear credential cache when unloading an authority section 2020-07-20 14:05:38 +02:00
Tobias Brunner 46ff268885 vici: Directly provide CA certificates in authority sections
With the previous approach, CA certificates that were not re-loaded via
load-cert() (e.g. from tokens or via absolute paths) would not be available
anymore after the clear-creds() command was used.  This avoids this
issue, but can cause duplicate CA certificates to get stored and enumerated,
so there might be a scaling factor.
2020-07-20 14:05:38 +02:00
Tobias Brunner 306c0c9f8e certificate: Extract helper function to filter certificates 2020-07-20 14:05:38 +02:00
Tobias Brunner dd7505af3e Merge branch 'ordered-hashtable'
This changes the hashtable implementation to that it maintains insertion
order.  This is then used in the vici plugin to store connections in a
hash table instead of a linked list, which makes managing them quite a
bit faster if there are lots of connections.

The old implementation is extracted into a new class (hashlist_t), which
optionally supports sorting keys and provides the previous get_match()
function.
2020-07-20 14:03:27 +02:00
Tobias Brunner 93b2c2066f hashtable: Use quadratic probing
This reduces the clustering problem (primary clustering) but is not
completely free of it (secondary clustering) it still reduces the maximum
and average probing lengths.
2020-07-20 13:50:11 +02:00
Tobias Brunner 736fae4e6c vici: Store configs in a hashtable
This makes updates more efficient if many configs are loaded. Configs
still have to be enumerated to select them.
2020-07-20 13:50:11 +02:00
Tobias Brunner 45376040ce hashtable: Maintain insertion order when enumerating
With the previous approach we'd require at least an additional pointer
per item to store them in a list (15-18% increase in the overhead per
item).  Instead we switch from handling collisions with overflow lists to
an open addressing scheme and store the actual table as variable-sized
indices pointing into an array of all inserted items in their original
order.

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

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

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

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

The maximum size is currently not changed.  With the new implementation
this translates to a hard limit for the maximum number of items that can be
held in the table (=CAPACITY(MAX_SIZE)).  Since this equals 715'827'882
items with the current settings, this shouldn't be a problem in practice,
the table alone would require 20 GiB in memory for that many items.  The
hashlist_t implementation doesn't have that limitation due to the overflow
lists (it can store beyond it's capacity) but it itself would require over
29 GiB of memory to hold that many items.
2020-07-20 13:50:11 +02:00
Tobias Brunner d9944102f5 hashlist: Move get_match() and sorting into a separate class
The main intention here is that we can change the hashtable_t
implementation without being impeded by the special requirements imposed
by get_match() and sorting the keys/items in buckets.
2020-07-20 13:50:11 +02:00
Tobias Brunner 4334f61284 unit-tests: Pass test iteration to fixtures 2020-07-20 13:50:11 +02:00
Tobias Brunner 31e6ca78df hashtable: Optionally collect and report profiling data 2020-07-20 13:50:11 +02:00
Tobias Brunner 87ceaefe2f hashtable: Optionally sort keys/items in buckets in a specific way
This can improve negative lookups, but is mostly intended to be used
with get_match() so keys/items can be matched/enumerated in a specific
order.  It's like storing sorted linked lists under a shared key but
with less memory overhead.
2020-07-20 13:50:11 +02:00
Tobias Brunner c66c850fc0 hashtable: Store items in buckets in insertion order
This is more predictable when using get_match() in particular because
the order does not change anymore when the table is rehashed.
2020-07-20 13:50:11 +02:00
Tobias Brunner 54a2b35f07 unit-tests: Add tests for larger number of items in hashtables 2020-07-20 13:50:11 +02:00
Tobias Brunner 13d302e95a unit-tests: Optionally report the times test cases ran 2020-07-20 13:50:11 +02:00
Tobias Brunner fd94c1301e kernel-netlink: Ignore preference for temporary addresses for IPv6 VIPs
They are not marked as temporary addresses so make sure we always return
them whether temporary addresses are preferred as source addresses or not
as we need to enumerate them when searching for addresses in traffic selectors
to install routes.

Fixes: 9f12b8a61c ("kernel-netlink: Enumerate temporary IPv6 addresses according to config")
2020-07-07 10:01:46 +02:00
Tobias Brunner 10a913685f charon-nm: Set DPD/close action to restart and enable indefinite keying tries
We don't track CHILD_SA down events anymore and rely on NM's initial timeout
to let the user know if the connection failed initially.  So we also don't
have to explicitly differentiate between initial connection failures and
later ones like we do an Android.  Also, with the default retransmission
settings, there will only be one keying try as NM's timeout is lower than
the combined retransmission timeout of 165s.

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

Fixes #3300.
2020-07-06 13:47:16 +02:00
Tobias Brunner feda4a3d37 vici: With start_action=start, terminate IKE_SA without children on unload
This includes IKE_SAs in CONNECTING state, which not yet have any
CHILD_SAs.

Closes strongswan/strongswan#175.
2020-07-01 15:59:41 +02:00
Boris Vanhoof 6870a9b590 eap-radius: Small spelling fix
Closes strongswan/strongswan#174.
2020-06-29 09:44:19 +02:00
Tobias Brunner f2d240954a testing: Skip tests with missing files, don't abort the test run
This allows simple test configs in testing/tests/local that are no
actual test cases.
2020-06-23 16:24:18 +02:00
Andreas Steffen d470422974 Version bump to 5.9.0dr2 2020-06-14 12:15:44 +02:00
Tobias Brunner 84bce03a64 testing: Fix SQL scenarios after preferring AEAD for ESP
sql/net2net-route|start-pem seem to be the only ones that configure a
proposal via database.
2020-06-12 13:45:58 +02:00
Tobias Brunner 4261f915d6 testing: Fix ikev2/net2net-fragmentation scenario
The IKE_AUTH message from moon is now larger because of the AEAD proposal.
2020-06-12 13:45:58 +02:00
Tobias Brunner 33412158f5 ike: Send AEAD ESP default proposal first
We generally prefer AEAD nowadays.

References #3461.
2020-06-12 13:47:13 +02:00
Tobias Brunner c7bef954ee proposal: Add AES-GCM to the ESP default AEAD proposal
References #3461.
2020-06-12 13:45:58 +02:00
Tobias Brunner bc40509057 ikev2: Ensure ALERT_RETRANSMIT_SEND_CLEARED is triggered
If a MOBIKE task is deferred, the retransmission counter is reset to 0
when reinitiating.  So if there were retransmits before, this alert would
not be triggered if a response is received now without retransmits.
2020-06-11 13:33:32 +02:00
Tobias Brunner 4b225bf866 travis: Don't pipe negative lgtm.com result into jq
The data might not be valid JSON.
2020-06-11 13:29:47 +02:00
Tobias Brunner 364d8b2628 ikev1: Ensure local IP is known as identity fallback during Main Mode
We usually have a local IP already via ike_sa_t::resolve_hosts() before
build_i() is called but if that's not the case, it's more likely we have
one after we processed the first response (it might also have changed).
There is a potential chance we still don't have one if the socket API
doesn't provide us with the destination address of received messages,
but that seems not very likely nowadays.
2020-06-11 13:29:47 +02:00
Andreas Steffen 12e4dbb231 Version bump to 5.9.0dr1 2020-06-06 15:02:42 +02:00
Tobias Brunner 59ebdac49b child-create: Don't reset DH group when retrying after INVALID_KE_PAYLOAD
migrate() is called before retrying.

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

Fixes: 1665a4e050 ("ikev1: Use actual local identity as initiator or aggressive mode responder")
2020-06-05 14:26:30 +02:00
Tobias Brunner 62367f2c01 ike: Fix retransmission timeouts if base is <= 1
Fixes: 72b282cf20 ("ike: Properly support high number of retransmission tries")
2020-06-05 13:44:00 +02:00
Tobias Brunner a5e4322348 android: New release after improving connectivity/scheduling 2020-06-02 14:55:58 +02:00
Tobias Brunner 763f07c531 travis: Add build of the Android app 2020-06-02 14:42:38 +02:00
Tobias Brunner eadba6d225 android: Suppress linting error in manifest related to cert import activity
<data> tags that only specify the mimeType attribute are perfectly fine
according to the docs.
2020-06-02 14:42:48 +02:00
Tobias Brunner 93d6fe3e4a android: Ignore some missing quantity lint errors
Once these strings are translated and the quantities are defined, this
attribute can be removed again.
2020-06-02 14:42:45 +02:00
Tobias Brunner 84924249aa android: Mock parseInetAddress() method to fix unit tests
The native parseInetAddressBytes() method called by that method is not
available when running the tests.

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

Fixes: 2ef473be15 ("android: Use helper to parse IP addresses where appropriate")
Fixes #3443.
2020-06-02 14:42:38 +02:00
Tobias Brunner a22a1493c3 Merge branch 'android-scheduler'
Starting with Android 6, the system will aggressively suspend apps when
the device is idle (Doze mode).  With Android 10 on a Pixel 4 this seems
to happen after about 70 minutes.  Then the scheduler thread in our
default scheduler is only woken rarely, combined with our previous use
of the monotonic clock it meant that events were executed with severe
delays and noticing that there was such a delay.  This was particularly
bad in regards to NAT keepalives as it usually meant that the device was
not reachable anymore from the outside.

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

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

Fixes #3364.
2020-06-02 14:34:31 +02:00
Tobias Brunner 04f4bef235 android: Add a preference flag to ignore battery optimizations
This allows users to ignore whether the app is on the device's power
whitelist without a warning.  The flag is currently not set
automatically if the user denies the request.
2020-06-02 14:07:06 +02:00
Tobias Brunner 5d01aaf91d android: Increase lifetimes a bit
This should avoid clashes of soft and hard lifetimes even if the app is
not whitelisted.
2020-06-02 14:07:06 +02:00
Tobias Brunner a0d32a2d13 android: Ask user to add our app to the device's power whitelist
This is necessary so we can actually schedule events accurately in Doze
mode. Otherwise, we'd only get woken in intervals of several minutes (up to
15 according to the docs) after about an hour.
2020-06-02 14:07:06 +02:00
Tobias Brunner d67a5b0c4d android: Use the default scheduler for short-term events
Using AlarmManager has quite some overhead, so we use our regular
scheduler for events that are to be executed in the near future.
2020-06-02 14:07:06 +02:00
Tobias Brunner 1b4c4123c2 android: Use Android-specific scheduler on Android 6 and later 2020-06-02 14:07:06 +02:00
Tobias Brunner b7d66ae2cd android: Add Android-specific implementation of scheduler_t
This uses AlarmManager to schedule events in a way that ensures the app
is woken up (requires whitelisting when in Doze mode to be woken up at
the exact time, otherwise there are delays of up to 15 minutes).
2020-06-02 14:07:06 +02:00
Tobias Brunner aaa908dc0a scheduler: Use timercmp(3) instead of a custom function 2020-06-02 14:07:06 +02:00
Tobias Brunner 2edc73d84e ike: Only track actually sent retransmits as outbound packets
Retransmission jobs for old requests for which we already received a
response previously left the impression that messages were sent more
recently than was actually the case.

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

I guess we could further differentiate between actual invalid states
(e.g. if we already received the response) and when we don't send a
retransmit for other reasons e.g. because the IKE_SA became stale.
2020-06-02 14:07:06 +02:00
Tobias Brunner f3695d089b android: Change how initial log handler is registered
Previously, if the two utility functions were called while the VPN
connection was established (i.e. charon was initialized) the logger for
libstrongswan would get reset to the initial log handler.  So certain
log messages would not get logged to the log file after the TUN device
was created (one of the helpers is used to convert IPs there).
2020-06-02 14:07:06 +02:00
Tobias Brunner 070cd12dfb android: Check the current path using DPD after a roaming event
A new NAT mapping might be created even if the IP stays the same.  Due to
the DPD fallback with NAT keep-alives this might only be necessary in
corner cases, if at all.
2020-06-02 14:07:06 +02:00
Tobias Brunner 6524bd3cd5 ike: Optionally use DPD to check if the current path still works
We could maybe check the duration of the last stale condition or when
the last packet was sent as filter to avoid unnecessary updates.
2020-06-02 14:07:06 +02:00
Tobias Brunner 664389ebc4 android: Enable switch from NAT interval to DPDs after 20 seconds 2020-06-02 14:07:06 +02:00
Tobias Brunner 0d4a5f6af6 ike: Add an option to trigger a DPD instead of a NAT keepalive
This is useful on Android where the app might not be able to send
keep-alives if the device is asleep for a while.  If the NAT mapping
has been deleted in the mean time, the NAT-D payloads allow detecting
this and connectivity can be restored by doing a MOBIKE update or
recreating the SA if the peer already deleted it because the client
wasn't reachable.
2020-06-02 14:07:06 +02:00
Tobias Brunner 31298187bf android: Switch to CLOCK_REALTIME on Android
This allows measuring the delay between events more accurately if a
device is often suspended.

While CLOCK_BOOTTIME would be preferable, Android's bionic C library
does not support it for condvars.
2020-06-02 13:57:37 +02:00
Tobias Brunner 3e358475bb time: Allow using different clocks
On some systems it might be preferable to use e.g. CLOCK_BOOTTIME
instead of CLOCK_MONOTONIC, which is also not affected by time
adjustments but includes times when the system was suspended.
2020-06-02 13:57:37 +02:00
Tobias Brunner 8b93510dac mutex: Don't use ...timedwait_monotonic() if clock is set via attribute
This allows using clocks other than CLOCK_MONOTONIC.
2020-06-02 13:57:37 +02:00
Tobias Brunner 6b3bf7cdac ike: Track NAT-keepalives as outbound packets 2020-06-02 13:57:37 +02:00
Tobias Brunner 491cdd59bd android: Fix app icon on Android versions < 5.0
XML resources are apparently not supported there.  Moving the icon to
the mipmap folders should fix that.  Aliases are defined for the icons on
Android < 8.0.
2020-06-02 13:57:37 +02:00
Tobias Brunner 3c8280960c android: Update Gradle plugin 2020-06-02 13:57:37 +02:00
Tobias Brunner 907a31db4c android: Again change how data source is handled in TileService
Evidently, onClick() may be called either before onStartListening() or
after onStopListening() has been called, which causes a crash when
trying to load a VpnProfile via mDataSource.

This partially reverts 3716af079e ("android: Avoid crash related to
TileService on Huawei devices").
2020-06-02 13:57:37 +02:00
Tobias Brunner 0ff939585e travis: Bump tpm2-tss to 2.4.1
Manually built dependencies are now built in a separate step after
packages have been installed as they might depend themselves on some
packages (e.g. tpm2-tss, which now requires libjson-c).
2020-05-26 11:06:07 +02:00
Thomas 04db34a3a7 charon-nm: Allow configurable remote traffic selectors
This change allows to customize the previously hard-coded remote traffic
selectors.

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

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

Closes strongswan/strongswan#173.
2020-05-25 11:50:46 +02:00
Tobias Brunner 3a54206c08 ikev2: Return to the original host if connection fails after redirection
If we fail connecting to the host we got redirected to, we should restart
with the original host where we might get redirected to a different host.

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

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

Closes strongswan/strongswan#171.
2020-05-19 17:33:20 +02:00
Tobias Brunner 3f454f33c0 nm: Version bump to 1.5.2 2020-05-19 16:17:05 +02:00
Tobias Brunner 1ebf63b966 nm: Move server port to options tab and position tabs to the left
Also shortened the title of the proposal tab.  This saves some additional
screen space.

Fixes #3448.
2020-05-19 16:17:24 +02:00
Tobias Brunner 7b15ecf82e nm: Use tabs for options/proposals to save screen space
The height of the dialog increased due to the recently added additional
fields for certificate selection and identities.  On some screens the
fields to configure custom proposals were not visible anymore.
Together with less spacing on the top level GtkBox this change reduces
the height by about 80 pixels.

Fixes #3448.
2020-05-19 16:17:05 +02:00
Tobias Brunner 73b60338dc nm: Migrate appdata to metainfo
The path '/usr/share/appdata' is deprecated as is the .appdata.xml
extension, files should be in installed in '/usr/share/metainfo' with
a .metainfo.xml extension.

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

Reference: 2.1.2. Filesystem locations
https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html
2020-05-11 09:57:37 +02:00
Tobias Brunner ecf187509a nm: Version bump to 1.5.1 2020-05-08 18:12:20 +02:00
Tobias Brunner d5d8375610 charon-nm: Clear secrets when disconnecting
The need_secrets() method is called before connect() (where we clear the
previous secrets too), so e.g. a password-protected private could be
decrypted with the cached password from earlier but if the password was not
stored with the connection, it would later fail as no password was requested
from the user that could be passed to connect().

References #3428.
2020-05-08 18:12:20 +02:00
Tobias Brunner 532d5fc85d nm: Fix password entry for private keys and allow saving it
On newer desktops the auth dialog is called with --external-ui-mode and
it seems that the password flag has to be set, otherwise the password is
not stored temporarily in the profile and passed to charon-nm (not sure
how this works exactly as need_secrets() is called multiple times even
after the password was already entered, only before doing so the last
time is the password available in that callback, but only if the flag
was set).  This now also allows storing the password for the private key
with the profile.

Fixes #3428.
2020-05-08 18:11:41 +02:00
Tobias Brunner 72b282cf20 ike: Properly support high number of retransmission tries
Due to the exponential backoff a high number of retransmits only
makes sense if retransmit_limit is set.  However, even with that there
was a problem.

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

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

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

The calculation in task_manager_total_retransmit_timeout() uses a double
variable and the result is in seconds so the maximum number would be higher
there (with the default settings 1205).  However, we want its result to
be based on the actual IKE retransmission behavior.
2020-05-07 15:05:55 +02:00
Tobias Brunner 066fa42fcb ike-auth: Add option to use EAP-only authentication without notify
Some peers apparently don't send the notify and still expect to
authenticate with EAP-only authentication.  This option allows forcing
the configured use of EAP-only authentication in that scenario.
2020-05-07 15:05:55 +02:00
Tobias Brunner 0184a69b7b child-create: Properly handle DH group during migration when reestablishing
If such a task was active while reestablishing it will get queued on the
new IKE_SA.  If the DH group is already set, the DH groups won't be
stripped from the proposals and a KE payload will be sent, which is invalid
during IKE_AUTH.  We don't want to reset the group if the task is part of a
child-rekey task.
2020-05-07 15:05:55 +02:00
Tobias Brunner 1665a4e050 ikev1: Use actual local identity as initiator or aggressive mode responder
If none is configured, there is a fallback to the IP address, which is
not stored on the static auth config, but is set on the IKE_SA.

Fixes #3394.
2020-05-07 15:05:55 +02:00
Tobias Brunner b8f02fc42d ikev1: Store fallback identity (IP address) on IKE_SA's auth-cfg
The other auth-cfg object is shared via peer-cfg, so we must not
modify it.  It's only stored to simplify memory management.

Fixes #3394.
2020-05-07 15:05:55 +02:00
Tobias Brunner 3d92cff726 lookip: Use line buffering for stdout
Otherwise, the output is buffered when e.g. piping the output to another
command (or file).  And it avoids having to call fflush() in the
interactive mode.

Fixes #3404.
2020-05-07 15:05:55 +02:00
Tobias Brunner 7ae4ced06f travis: Bump wolfSSL to 4.4.0
SHA-3 is only automatically enabled on x86/x64.  The tests are disabled
because we don't need them and they currently cause a compile warning/error
when built with clang on x64 (sizeof() on a pointer to an array).  If the
examples are enabled, another test suite is built, which includes the
disabled crypto tests.
2020-05-07 09:50:45 +02:00
Tobias Brunner 142b5e7944 wolfssl: Add support for Ed448 2020-05-07 09:33:43 +02:00
Tobias Brunner 59a987b8f3 wolfssl: Add support for x448 Diffie-Hellman 2020-05-07 09:33:43 +02:00
Tobias Brunner b06374f6a5 file-logger: Set owner/group of log file
The file is usually opened/created by root, however, if user/group IDs
are configured and the configuration is reloaded, the file will be reopened
as configured user.  Like with UNIX sockets we only attempt to change
the user if we have CAP_CHOWN allowing a start as regular user.

We don't have chown() on Windows, so check for it.
2020-05-07 09:30:57 +02:00
Tobias Brunner db772305c6 xfrmi: Only build if libcharon is built
The kernel-netlink plugin is only built if libcharon is.

Closes strongswan/strongswan#167.
2020-05-07 09:19:27 +02:00
Tobias Brunner b6fcdc71a6 pkcs11: Optionally hash data for PKCS#1 v1.5 RSA signatures in software
If cards/libraries don't support signature mechanisms with hashing, we fall
back to do it ourselves in software and pass the PKCS#1 digestInfo ASN.1
structure to sign via CKM_RSA_PKCS mechanism.

Closes strongswan/strongswan#168.
2020-05-07 09:11:19 +02:00
Tobias Brunner b3e7b79cc5 scripts: Initialize libstrongswan in id2sql to fix a crash
Since 770f4ccee1 ("identification: Optionally match RDNs in any order
and accept missing RDNs") the DN parser requires lib->settings.
2020-05-04 17:00:45 +02:00
Thomas Egerer d2c15b7bf9 vici: Allow maximum vici message size configuration via compile option
Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2020-04-14 16:55:49 +02:00
Tobias Brunner e0b1b12028 Use Botan 2.14.0 for tests
Requires at least GCC 5.0 to build with `--amalgamation`, so it's
disabled for our Ubuntu 16.04 build.
2020-04-07 16:37:27 +02:00
Andreas Steffen 3273667b0b Version bump to 5.8.4 2020-03-29 12:49:52 +02:00
Tobias Brunner c5c1898d73 openssl: Allow squeezing multiple times from SHAKE128/256 XOFs
OpenSSL currently doesn't support squeezing bytes out of an XOF multiple
times.  Unfortunately, EVP_DigestFinalXOF() completely resets the context
and later calls not simply fail, they cause a null-pointer dereference in
libcrypto.  This fixes the crash at the cost of repeating initializing
the whole state and allocating too much data for subsequent calls.

There is an open issue and PR that might add a function that allows
squeezing more data from an XOF in a future version of OpenSSL.
2020-03-29 12:49:52 +02:00
Tobias Brunner 6c98164f60 charon-nm: Allow using fixed source ports
This could be useful in cases a client behind a NAT has to be made reachable
via port forwarding.

Closes strongswan/strongswan#166.
2020-03-27 14:25:38 +01:00
Thomas Egerer 99bef7b686 settings: Use strtoul(3) for settings to int conversion
strtol(3) accepts values in the range of [LONG_MIN;LONG_MAX].  Based
on the architecture (32 or 64 bits), these values expand to either
0x8000000000000000/0x7fffffffffffffff for 64-bit builds, or
0x80000000/0x7fffffff for 32-bit builds.

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

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

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2020-03-26 15:26:59 +01:00
Tobias Brunner cb26c5547c quick-mode: Make sure we have a proposal before determining lifetimes
Fixes: e0dd36c9c7 ("ikev1: Get and set the lifetimes of the selected proposal/transform")
2020-03-26 08:41:00 +01:00
Tobias Brunner 6987f6b3eb unit-tests: Update expired certificates for TLS tests 2020-03-25 15:31:07 +01:00
Tobias Brunner b2d3726501 nm: Version bump to 1.5.0 2020-03-25 10:14:46 +01:00
Andreas Steffen 0728387ea9 Version bump to 5.8.3 2020-03-24 16:01:04 +01:00
Tobias Brunner 393e0167fd charon-nm: Correctly set remote auth class for PSK authentication
Fixes: bc3eda99ba ("charon-nm: Add support for EAP-TLS")
2020-03-20 16:06:12 +01:00
Andreas Steffen c88a4996fa Version bump to 5.8.3rc1 2020-03-19 08:43:10 +01:00
Tobias Brunner 298c389bfa NEWS: Add news for 5.8.3 2020-03-13 15:15:25 +01:00
Tobias Brunner 9f91f0b3c8 openssl: Add support for SHAKE128/256 2020-03-10 14:12:34 +01:00
Tobias Brunner 112de13f1f openssl: Add support for SHA-3 2020-03-10 14:12:34 +01:00
Tobias Brunner bbedad78c3 Merge branch 'throw-type-routes'
Implements simpler routes for passthrough policies on Linux, which
basically act as fallbacks on routes in other routing tables.  This way
they require less information (e.g. no interface or source IP) and can
be installed earlier and are not affected by updates.

Closes strongswan/strongswan#165.
Fixes #3118.
2020-03-10 12:49:53 +01:00
Tobias Brunner dfd261d2de kernel-netlink: Extract shared route handling code in net/ipsec 2020-03-10 10:30:39 +01:00
Tobias Brunner e23708bdf3 kernel-netlink: Don't require an interface name for passthrough policies 2020-03-10 10:26:42 +01:00
Tobias Brunner b0b6bd2470 kernel-netlink: Allow blank source address in routes for passthrough policies 2020-03-10 10:25:19 +01:00
Noel Kuntze 09f4bccfea kernel-netlink: Implement passthrough type routes and use them on Linux
Enables us to ignore any future kernel features for routes unless
we actually need to consider them for the source IP routes.

Also enables us to actually really skip IPsec processing for those networks
(because even the routes don't touch those packets). It's more what
users expect.

Co-authored-by: Tobias Brunner <tobias@strongswan.org>
2020-03-10 10:20:58 +01:00
Tobias Brunner 4958acc0c2 kernel-interface: Reallocate previously used reqids
This is mainly an issue on FreeBSD where the current kernel still only
allows the daemon to use reqids < IPSEC_MANUAL_REQID_MAX (0x3fff = 16383).

Fixes #2315.
2020-03-09 15:27:03 +01:00
Thomas Egerer 05e373aeb0 ike: Optionally allow private algorithms for IKE/CHILD_SAs
Charon refuses to make use of algorithms IDs from the private space
for unknown peer implementations [1]. If you chose to ignore and violate
that section of the RFC since you *know* your peers *must* support those
private IDs, there's no way to disable that behavior.

With this commit a strongswan.conf option is introduced which allows to
deliberately ignore parts of section 3.12 from the standard.

[1] http://tools.ietf.org/html/rfc7296#section-3.12

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2020-03-06 11:15:15 +01:00
Tobias Brunner 61769fd1e3 openssl: Don't check signature if issuer doesn't match always
Doing this for the self-signed check also (i.e. if this and issuer are
the same) is particularly useful if the issuer uses a different key type.
Otherwise, we'd try to verify the signature with an incompatible key
that would result in a log message.

Fixes #3357.
2020-03-06 11:12:07 +01:00
Tobias Brunner 5761077091 nm: Update NEWS for next release 2020-03-06 11:06:11 +01:00
Tobias Brunner 14a779956e Merge branch 'ikev1-transform-nr'
With these changes we return the lifetimes of the actually selected
transform back to the client, which is an issue if the peer uses
different lifetimes for different proposals.  We now also return the
correct transform and proposal IDs.

Fixes #3329.
2020-03-06 10:47:34 +01:00
Tobias Brunner e0dd36c9c7 ikev1: Get and set the lifetimes of the selected proposal/transform
Previously, we simply used the lifetimes of the first
proposal/transform, which is not correct if the initiator uses different
lifetimes in its proposals/transforms.
2020-03-06 10:31:30 +01:00
Tobias Brunner 1c6b43b8ea proposal-substructure: Start numbering IKEv1 proposals with 1 2020-03-06 10:31:30 +01:00
Tobias Brunner 859f9c8c83 proposal-substructure: Encode transform number of selected IKEv1 proposal 2020-03-06 10:31:30 +01:00
Tobias Brunner 7da3143aac proposal-substructure: Store transform number for IKEv1 proposals 2020-03-06 10:31:30 +01:00
Tobias Brunner e630f2d373 proposal: Add IKEv1 transform number on which a proposal is based 2020-03-06 10:31:30 +01:00
Tobias Brunner 479c85d569 libtls: Remove unused variable in TLS socket implementation
Not used anymore since c43e8fdec4 ("Block TLS read when sending data,
but have to wait for the handshake data first").
2020-03-06 10:30:16 +01:00
Andreas Steffen 68e8fedccb Version bump to 5.8.3dr1 2020-03-04 22:27:13 +01:00
Tobias Brunner 0399314903 script: Fix upper bounds
^ is the XOR operator.
2020-03-04 17:07:32 +01:00
Tobias Brunner e1cc667920 pubkey-speed: Add sanity check for the number of rounds
The allocated buffer for the signatures is based on this, which LGTM
doesn't like.
2020-03-03 11:34:22 +01:00
Tobias Brunner 7a13246668 crypt-burn: Add sanity check for buffer length
This value is passed to chunk_alloc(), which LGTM complains about.
2020-03-03 11:32:31 +01:00
Tobias Brunner 1966f4332b configure: Make sure Python is available for static builds
We need Python to create files that reference the plugin constructors.
Without it, empty files are created and plugins can't be loaded.

Fixes #3349.
2020-02-28 13:55:18 +01:00
Tobias Brunner 1f2c83db61 travis: Enable caching for sonarcloud scan 2020-02-21 16:11:44 +01:00
Tobias Brunner 96b61792df ike: Don't reestablish IKE_SAs for which a deletion is queued
If an IKE_SA is terminated while a task is active, the delete task is
simply queued (unless the deletion is forced).  If the active task times
out before any optional timeout associated with the termination hits, the
IKE_SA previously was reestablished without considering the termination
request.

Fixes #3335.
2020-02-21 10:38:13 +01:00
Tobias Brunner 17fc6234c4 Remove obsolete packages directory
These Debian package sources have not been updated for years and are
severely out-of-date.  Since the Debian packages are properly
maintained nowadays, we don't have to provide our own package sources
to serve as examples.

References #3344.
2020-02-21 09:52:49 +01:00
Tobias Brunner 89e5eb7213 travis: Bump tpm2-tss to 2.3.3 2020-02-21 09:52:49 +01:00
Tobias Brunner e365bef4a4 travis: Remove deprecated `sudo` option, set default OS
Also replaces `matrix` with the current official name `jobs`.
2020-02-21 09:49:27 +01:00
Tobias Brunner cfed3a87ee charon-nm: Use better default directory for D-Bus policy file
Also makes it configurable via configure script.  Depending on `$datadir` is
not ideal as package maintainers might set that to a custom value.  Depending
on `$datarootdir` might have been better, the default if pkg-config fails is
now based on that.

References #3339.
2020-02-21 09:46:13 +01:00
Tobias Brunner 658b6df4d8 travis: Add build tests for NM plugin 2020-02-14 14:53:26 +01:00
Tobias Brunner 7eab520bbf nm: Ignore generated POT file 2020-02-14 14:53:26 +01:00
Tobias Brunner ca3ff27101 nm: Only check PSK length if one is actually stored 2020-02-14 14:51:43 +01:00
Tobias Brunner c41419fa2e Merge commit 'nm-client-id'
Makes the client's IKE identity configurable in the NM GUI.  For PSK
authentication the identity is now configured via that new field
and not the username anymore (old configs still work and are migrated
when edited).  The client identity now also defaults to the IP address
if not configured when using EAP/PSK.

Fixes #2581.
2020-02-14 14:47:34 +01:00
Tobias Brunner d57d5f510d nm: Make local identity configurable
For PSK authentication we now use the local identity and not the username
field.
2020-02-14 14:45:32 +01:00
Tobias Brunner ff8f6b15aa charon-nm: Add support for custom local IKE identities 2020-02-14 14:35:44 +01:00
Tobias Brunner 571769fe50 Merge branch 'nm-reauth'
With these changes, the NM service should be able to handle
reauthentication (and redirection) by switching to the new IKE_SA and
not considering the old SA going down an error.

Fixes #852.
2020-02-14 13:58:50 +01:00
Tobias Brunner 5575aaf5c8 charon-nm: Keep listener registered even on failures
NM doesn't seem to terminate the daemon on failures, so we might not get
further events for later retries.
2020-02-14 13:55:42 +01:00
Tobias Brunner 3d2f5ae003 charon-nm: Support reauthentication and redirection 2020-02-14 13:55:42 +01:00
Tobias Brunner 4373a59bf5 Merge branch 'nm-eap-tls'
Adds support for EAP-TLS to the NM plugin.  The certificates/key
source (file, smartcard, agent) can now be selected independently of
the authentication method (i.e. for both certificate and EAP-TLS auth).

Fixes #2097.
2020-02-14 13:51:44 +01:00
Tobias Brunner 661e1044c0 nm: Make EAP-TLS configurable
A new combo field allows selecting where the certificate/key is stored.
2020-02-14 13:50:32 +01:00
Tobias Brunner bc3eda99ba charon-nm: Add support for EAP-TLS
The code is structured similar to that in the Android client, but two-round
authentication (cert+EAP) is not supported as that might require multiple
secrets ("password" is currently the only secret field used for every
method) and other details are currently missing too (like configurable
client identities).
2020-02-14 13:44:39 +01:00
Tobias Brunner 1157d3e031 Merge branch 'nm-server-port'
Adds the option to use a custom server port in the NM plugin.

Fixes #625.
2020-02-14 13:36:50 +01:00
Tobias Brunner e85a43b7b6 nm: Make server port configurable in GUI 2020-02-14 13:36:16 +01:00
Tobias Brunner 60777574c1 charon-nm: Add support for custom server ports 2020-02-14 13:36:16 +01:00
Tobias Brunner eb256e5ba1 Merge branch 'nm-remote-id'
This adds an optional field to the NM plugin to configure the server
identity, so it can differ from the address or certificate subject,
which are used by default.

It also updates the Glade file to GTK+ 3.2.

Closes strongswan/strongswan#57.
2020-02-14 13:32:06 +01:00
Tobias Brunner 7c6bb33151 nm: Update German translation 2020-02-14 11:19:49 +01:00
Tobias Brunner a7bda9a95e nm: Make remote identity editable in GUI 2020-02-14 11:19:49 +01:00
Tobias Brunner 19e64e101d charon-nm: Add support for a specific remote identity 2020-02-14 11:19:49 +01:00
Tobias Brunner f9956ca633 nm: Add hint regarding password storage policy
Requires targeting GTK 3.2.
2020-02-14 11:19:49 +01:00
Tobias Brunner 23de1602f9 nm: Replace the term "gateway" with "server" 2020-02-14 11:19:49 +01:00
Tobias Brunner d46f804b09 nm: Update Glade file for GTK 3.0
That's the version we check for in the configure script.
2020-02-14 11:19:49 +01:00
Tobias Brunner b2b69f4156 configure: Depend on libip4tc instead of libiptc
The libiptc meta-package apparently will be removed e.g. from Debian.
We currently only need IPv4 support in the connmark and forecast plugins.

Fixes #3338.
2020-02-14 10:07:23 +01:00
Tobias Brunner cb25022197 unit-tests: Increase timeout for test vectors suite
These occasionally fail due to the current timeout on IBM Power on Travis.
2020-02-13 16:42:13 +01:00
Tobias Brunner ead067e775 Revert "travis: Add workaround for a tox/virtualenv/six issue"
This reverts commit d450e926de.

Was fixed by making tox depend on newer versions of six so the package
gets installed/updated automatically now when installing tox.  There is
also some ongoing work that tries to make virtualenv work with older
versions of six.
2020-02-13 16:34:27 +01:00
Tobias Brunner 19b2f870e2 enumerator: Fall back to lstat() if stat() fails when enumerating dirs/files
This happens e.g. if the path is for an invalid symlink.
2020-02-13 11:54:19 +01:00
Tobias Brunner fdce492ed0 cirrus: Remove bashisms from test script to make it compatible with /bin/sh
Bash is not installed on the FreeBSD images here and the location would
be different anyway (`/usr/local/bin/bash`, so we'd have to change the
hashbang to e.g. `/usr/bin/env bash`).
2020-02-13 10:23:30 +01:00
Tobias Brunner d450e926de travis: Add workaround for a tox/virtualenv/six issue
virtualenv is installed as dependency of tox and 20.0.0 added a
dependency on a newer version of six, which is not automatically
installed/updated.
2020-02-12 11:20:02 +01:00
Josh Soref d30498edf1 ikev2: Fix spelling of routability
References strongswan/strongswan#164.
2020-02-11 18:23:34 +01:00
Josh Soref b3ab7a48cc Spelling fixes
* accumulating
* acquire
* alignment
* appropriate
* argument
* assign
* attribute
* authenticate
* authentication
* authenticator
* authority
* auxiliary
* brackets
* callback
* camellia
* can't
* cancelability
* certificate
* choinyambuu
* chunk
* collector
* collision
* communicating
* compares
* compatibility
* compressed
* confidentiality
* configuration
* connection
* consistency
* constraint
* construction
* constructor
* database
* decapsulated
* declaration
* decrypt
* derivative
* destination
* destroyed
* details
* devised
* dynamic
* ecapsulation
* encoded
* encoding
* encrypted
* enforcing
* enumerator
* establishment
* excluded
* exclusively
* exited
* expecting
* expire
* extension
* filter
* firewall
* foundation
* fulfillment
* gateways
* hashing
* hashtable
* heartbeats
* identifier
* identifiers
* identities
* identity
* implementers
* indicating
* initialize
* initiate
* initiation
* initiator
* inner
* instantiate
* legitimate
* libraries
* libstrongswan
* logger
* malloc
* manager
* manually
* measurement
* mechanism
* message
* network
* nonexistent
* object
* occurrence
* optional
* outgoing
* packages
* packets
* padding
* particular
* passphrase
* payload
* periodically
* policies
* possible
* previously
* priority
* proposal
* protocol
* provide
* provider
* pseudo
* pseudonym
* public
* qualifier
* quantum
* quintuplets
* reached
* reading
* recommendation to
* recommendation
* recursive
* reestablish
* referencing
* registered
* rekeying
* reliable
* replacing
* representing
* represents
* request
* request
* resolver
* result
* resulting
* resynchronization
* retriable
* revocation
* right
* rollback
* rule
* rules
* runtime
* scenario
* scheduled
* security
* segment
* service
* setting
* signature
* specific
* specified
* speed
* started
* steffen
* strongswan
* subjectaltname
* supported
* threadsafe
* traffic
* tremendously
* treshold
* unique
* uniqueness
* unknown
* until
* upper
* using
* validator
* verification
* version
* version
* warrior

Closes strongswan/strongswan#164.
2020-02-11 18:23:07 +01:00
Tobias Brunner baf29263d5 pem: Support parsing PEM-encoded Ed448 keys 2020-02-10 13:37:31 +01:00
Tobias Brunner 878afdf90b pki: Add support for Ed448 keys/certificates 2020-02-10 13:37:31 +01:00
Tobias Brunner 85a35fc99d openssl: Support certificates with Ed25519/448 keys 2020-02-10 13:37:31 +01:00
Tobias Brunner 3361f81f1c pkcs1: Support parsing Ed448 public keys 2020-02-10 13:37:31 +01:00
Tobias Brunner 18bee9306a nm: Replace deprecated g_type_class_add_private()
Fixes #2765, #3197.
2020-02-05 10:54:37 +01:00
Tobias Brunner 0f141fb095 soup: Use soup_session_new() to avoid deprecation warning
There are a ton of libsoup/GLib-related "leaks" that we can't whitelist
and with leak detective active there is a delay that interestingly doesn't
happen with soup_session_sync_new(), so tests failed with a timeout (actually
they hung due to the lock in the fetcher manager).
On Travis, the curl plugin is used for the tests, so that's not an issue
there (and without LD the tests complete quickly and successfully).
2020-02-05 10:49:35 +01:00
Tobias Brunner 5833bc4b9c travis: Build soup plugin
We disabled this due to issues with the GLib version shipped with
Ubuntu 12.04 (see ab23a0f86a).
2020-02-05 10:49:20 +01:00
Tobias Brunner f78dfb7e28 vici: Options are optional in get_pools() of Python bindings
Fixes #3319.
2020-02-03 10:52:31 +01:00
Tobias Brunner ef4113a49d libtpmtss: Fix problematic usage of chunk_from_chars() in TSS2 implementations
See 8ea13bbc5c for details.

References #3249.
2020-01-30 18:18:33 +01:00
Tobias Brunner 776433505b x509: Replace problematic calls of chunk_from_chars() for keyUsage extension
As noted in 8ea13bbc5c newer compilers might optimize out the
assignment leading to invalid values in the keyUsage extension (as the
length was still set, the extension was encoded, just not with the
intended values).

Fixes #3249.
2020-01-30 18:18:28 +01:00
Tobias Brunner d16e810778 pki: Remove unnecessary and problematic chunk_from_chars() usage in --signcrl
If the serial is not yet set, the same default value is set just below.

See 8ea13bbc5c for details on chunk_from_chars().

References #3249.
2020-01-30 18:18:14 +01:00
Tobias Brunner d5cf2d1f85 tls-crypto: Fix usage of chunk_from_chars()
See 8ea13bbc5c for details.

References #3249.
2020-01-30 18:18:06 +01:00
Tobias Brunner da9e4fa04b lgtm: Build external dependencies for a more complete analysis
The build system is a bit limited, only the repository directory and
LGTM_WORKSPACE is writable.  sudo doesn't work at all, for others we
don't have enough permission.
2020-01-30 17:12:48 +01:00
Tobias Brunner 2cb4af6696 wolfssl: Use pkg-config to check for wolfSSL
The other checks trigger an automatic install of the old and incompatible
Ubuntu package on LGTM.
2020-01-30 17:12:05 +01:00
Tobias Brunner 04ce39e7c0 libtpmtss: Only check for legacy TSS2 libs if newer are not found
On LGTM, legacy packages are installed automatically otherwise.
2020-01-30 15:37:45 +01:00
Tobias Brunner ed8430630f travis: tpm2-tss switched the default crypto backend to OpenSSL with 2.2.0 2020-01-30 15:37:45 +01:00
Tobias Brunner c9a3430368 travis: Trigger code review on lgtm.com
Only the master (daily) and pull requests are scanned automatically.
2020-01-30 15:37:45 +01:00
Tobias Brunner 48017a2740 conf: Complete ordering functions for ConfigOption class 2020-01-29 13:31:42 +01:00
Tobias Brunner 1147973661 pkcs11: Avoid naming conflict with method parameter 2020-01-28 15:32:43 +01:00
Tobias Brunner 18a3e6d80f systime-fix: Replace asctime() with thread-safe asctime_r()
According to the man page, the buffer should have room for at least
26 characters.
2020-01-28 15:32:43 +01:00
Tobias Brunner 584e8197fe load-tester: Avoid naming conflict with local certificate variables 2020-01-28 15:32:43 +01:00
Tobias Brunner a7126dd47e sw-collector: Avoid naming conflicts with local count variables 2020-01-28 15:32:43 +01:00
Tobias Brunner f168f5782b eap-aka-3gpp2: Fix a bunch of typos 2020-01-28 15:32:43 +01:00
Tobias Brunner 378fe7a4bf eap-aka-3gpp2: Avoid naming conflict with parameters of crypto functions 2020-01-28 15:32:43 +01:00
Tobias Brunner 719cfc7846 eap-aka-3gpp2: Avoid naming conflict with local AMF variable 2020-01-28 15:32:43 +01:00
Tobias Brunner b7019a5c9e pool: Avoid conflict with start/end variables used in many commands 2020-01-28 15:32:43 +01:00
Tobias Brunner 26f20cc258 aesni: Namespace include guard for AES-CMAC
Was the same as in the cmac plugin.
2020-01-28 15:32:43 +01:00
Tobias Brunner e438915e62 tls-prf: Remove unused/undeclared argument in TLS 1.0/1.1 PRF constructor 2020-01-28 15:32:43 +01:00
Tobias Brunner ea1f4cd7a9 pki: Avoid naming conflict with global variables for passed arguments 2020-01-28 15:32:43 +01:00
Tobias Brunner d493dc18d6 scepclient: Avoid name conflict with global PKCS#7 chunk
Use the same name as further down below in the file.

Fixes: 04ff78aa33 ("scepclient: Store received RA certificates, using CA cert name as base.")
2020-01-28 15:32:43 +01:00
Tobias Brunner 42928551ab starter: Avoid hiding global variable when checking PID file 2020-01-28 15:29:40 +01:00
Tobias Brunner cab86465bb copyright: Make strings static const
They are not used anywhere else.
2020-01-28 15:29:40 +01:00
Tobias Brunner 90df054f14 plugin-constructors: Remove unused import for `sys` 2020-01-28 15:29:40 +01:00
Tobias Brunner c584a6b2dc vici: Remove unused import in Python bindings 2020-01-28 15:29:40 +01:00
Tobias Brunner df4274171e vici: Remove unnecessary `pass` statement 2020-01-28 15:29:40 +01:00
Tobias Brunner 7bcbf20b3d array: Avoid overflow in size calculation
While it's unlikely that so many (large) items are allocated, this is
technically more correct.  The result previously could overflow an
unsigned int (the conversion to size_t happened afterwards).
2020-01-28 15:29:40 +01:00
Tobias Brunner 73ee7b6664 swanctl: Add missing header guards for load commands 2020-01-28 15:29:40 +01:00
Tobias Brunner 91c6387e69 swanctl: Add missing `extern` for `swanctl_dir` variable in header
This clearly never was correct, but didn't cause problems so far.
However, GCC 10 will default to `-fno-common` instead of
`-fcommon` (https://gcc.gnu.org/PR85678), so compilation there fails
with something like:

```
libtool: link: gcc ... -o .libs/swanctl ...
ld: commands/load_authorities.o:strongswan/src/swanctl/./swanctl.h:33:
  multiple definition of `swanctl_dir'; commands/load_all.o:strongswan/src/swanctl/./swanctl.h:33: first defined here
```

Fixes: 501bd53a6c ("swanctl: Make credential directories relative to swanctl.conf")
Closes strongswan/strongswan#163.
2020-01-28 15:29:40 +01:00
Tobias Brunner 8ea13bbc5c lgtm: Add query to detect problematic uses of chunk_from_chars()
GCC 9+ and clang 4+ (partially) optimize out usages of
chunk_from_chars() if the value is read outside of the block where the
macro is used.  For instance:

```
chunk_t chunk = chunk_empty;
if (...)
{
	chunk = chunk_from_chars(0x01, 0x06);
}
/* do something with chunk */
```

The chunk_from_chars() macro expands to a chunk_t declaration, which is
technically only defined inside that block.

Still, with older GCC versions the fourth line was compiled to something
like this:

```
mov     WORD PTR [rsp+14], 1537 # 0x0106 in little-endian
lea     rdx, [rsp+14]
mov     ecx, 2
```

However, with GCC 9.1 and -O2 the first instruction might be omitted
(strangely the others usually were not, so the chunk pointed to whatever
was stored on the stack).  It's not easily reproducible, so there are
situations where the seemingly identical code is not optimized in this
way.

This query should detect such problematic uses of the macro (definition
and usage in different blocks).

References #3249.
2020-01-27 18:31:09 +01:00
Tobias Brunner 9c6ab71782 lgtm: Add config for a more complete build on lgtm.com 2020-01-27 18:00:49 +01:00
Tobias Brunner 3be430cc13 travis: Build on ARM64, IBM Power and IBM Z architectures
IBM Z is big-endian, IBM Power runs in little-endian mode.

Botan requires a fix for issues with GCC and amalgamation enabled (target
pragma ‘*’ is invalid) on ARM64 and IBM Power, while wolfSSL can't be
compiled successfully on IBM Z without an additional patch.

libunwind is not available for x390x, but since we explicitly disable
such backtraces it's not necessary anyway.
2020-01-22 15:10:09 +01:00
Tobias Brunner 3bc0c9807a sha3: Fix readLane() macro on big-endian platforms 2020-01-20 11:05:17 +01:00
Tobias Brunner b0b928dd0a Use Botan 2.13.0 for tests 2020-01-16 08:30:47 +01:00
Tobias Brunner ce4ed21fcb scepclient: Add missing short options (-i, -T) 2020-01-15 12:02:18 +01:00
Tobias Brunner dc4058ef16 Merge branch 'vici-pytest'
Adds tox.ini to test with tox (which is now used on Travis) and includes
the tests in the source distribution.
2020-01-14 16:53:53 +01:00
Tobias Brunner ecf161e517 vici: Move Python test dir and include it in sdist
This is the recommended location and import config as it allows running the
tests against installed versions of the package.  And while the test file
itself is automatically included in the source distribution this way, the
__init__.py file is not, so we still have to update MANIFEST.in.
2020-01-14 16:53:19 +01:00
Tobias Brunner 6352954807 travis: Run python tests with tox 2020-01-14 15:27:06 +01:00
Tobias Brunner b723431540 vici: Run Python tests via tox if available
Since we use the serial test harness we can't use AM_TESTS_ENVIRONMENT.
The script is necessary for out-of-tree builds.
2020-01-14 15:26:52 +01:00
Tobias Brunner 574621d80a vici: Fix several PEP8 issues 2020-01-14 15:26:32 +01:00
Tobias Brunner d5153c5897 vici: Add tox.ini to run tests with tox
Some of the interpreters might not be available on the host system, use
--skip-missing-interpreters to not fail in that case.
2020-01-14 15:26:29 +01:00
Tobias Brunner c170bb593b vici: List newer Python versions in setup.py 2020-01-14 10:48:53 +01:00
Tobias Brunner 282c57b131 travis: Bump wolfSSL to 4.3.0 2020-01-13 15:49:57 +01:00
Tobias Brunner 846dde91ae wolfssl: Undef RSA_PSS_SALT_LEN_DEFAULT as wolfSSL 4.3.0 defines it as enum 2020-01-13 15:49:57 +01:00
Tobias Brunner 83c8f887d9 Revert "travis: Add a workaround for a bug regarding libtool installed via Homebrew"
This reverts commit 1806ba0890 as the
workaround is not required anymore and now actually fails because
pre-installed tools have a dependency on libtool.
2019-12-19 11:42:12 +01:00
Andreas Steffen e5f18a46b7 Version bump to 5.8.2 2019-12-17 14:30:41 +01:00
Andreas Steffen b9eade0ca2 Version bump to 5.8.2rc2 2019-12-16 22:11:43 +01:00
Tobias Brunner a3166c8188 kernel-netlink: Use correct config option name for HW offloading check
Fixes: a605452c03 ("kernel-netlink: Check for offloading support in constructor")
2019-12-13 17:20:51 +01:00
Tobias Brunner 8d9a7fcae3 drbg: Fix Doxygen group in headers 2019-12-12 11:09:06 +01:00
Tobias Brunner a669145086 Fixed some typos, courtesy of codespell 2019-12-12 11:09:06 +01:00
Tobias Brunner 174bfe51f9 NEWS: Added some news for 5.8.2 2019-12-12 11:09:06 +01:00
Thomas Egerer cf18951efd openssl: Make some additional arguments const
Related to openssl 1.1.x changes.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2019-12-11 13:09:04 +01:00
Tobias Brunner 8ee1242f14 libtpmtss: Convert RSA exponent to big-endian when provided by a TPM 2.0
While the TPM expects and returns the data in big-endian, the SAPI
implementation converts it to native-endianness.  As stated in the
SAPI specification (section 3.2):

  8. All SAPI data SHALL be in native-endian format.  This means that
     the SAPI implementation will do any endian conversion required for
     both inputs and outputs.

So to use the exponent in a chunk we have to convert it to big-endian again.

Fixes: 7533cedb9a ("libtpmtss: Read RSA public key exponent instead of assuming its value")
2019-12-10 15:19:32 +01:00
Tobias Brunner a84aeb01aa ikev2: Destroy IKE_SA if INVALID_SYNTAX notify is received in response
RFC 7296, section 2.21.3:

   If a peer parsing a request notices that it is badly formatted (after
   it has passed the message authentication code checks and window
   checks) and it returns an INVALID_SYNTAX notification, then this
   error notification is considered fatal in both peers, meaning that
   the IKE SA is deleted without needing an explicit Delete payload.
2019-12-09 12:26:54 +01:00
Tobias Brunner 10e0faf477 ikev2: Destroy IKE_SA when receiving invalid authenticated requests
RFC 7296, section 2.21.3:

   If a peer parsing a request notices that it is badly formatted (after
   it has passed the message authentication code checks and window
   checks) and it returns an INVALID_SYNTAX notification, then this
   error notification is considered fatal in both peers, meaning that
   the IKE SA is deleted without needing an explicit Delete payload.
2019-12-09 12:26:54 +01:00
Tobias Brunner 51ac22579d ikev2: Send INVALID_MAJOR_VERSION notify using the same exchange type and MID
This is per RFC 7296, section 1.5.
2019-12-09 12:26:54 +01:00
Tobias Brunner e3e0fe41ab sshkey: Rename variables that conflict with function argument 2019-12-09 11:34:30 +01:00
Tobias Brunner a6723ee3e0 chunk: Rename hash key variable to avoid conflicts with function arguments 2019-12-09 11:23:02 +01:00
Tobias Brunner d3ca9fcda4 attr: Remove unused/undeclared argument in provider constructor 2019-12-09 11:05:25 +01:00
Andreas Steffen c2d6ac1124 Version bump to 5.8.2rc1 2019-12-07 23:06:22 +01:00
Tobias Brunner 3d40bf6491 configure: Drop unnecessary gperf version check
While the check probably made sense when strongSwan 4.x was started, gperf
version 3.0.1 was released in 2003, so it's very unlikely that version 2.x
is still around anywhere.
2019-12-06 10:30:52 +01:00
Tobias Brunner 72373d940a configure: Abort if gperf is not found but generated files don't exist
When building from a tarball gperf is not required as the generated
files already exist, however, when building from the repository that's
not the case, so warn the user if gperf is not found.
2019-12-06 10:30:52 +01:00
Tobias Brunner 251ac44df3 configure: Declare GPERF and PERL as variables
These are documented in --help and will be cached.
2019-12-06 10:30:52 +01:00
Tobias Brunner c81a8a8f36 kernel-netlink: Properly compare routes for policies without gateway/netxhop
This happened when installing a duplicate bypass policy for a locally
connected subnet.  The destructor and the kernel-net part already
handle this correctly.
2019-12-06 10:28:13 +01:00
Tobias Brunner 6b347d5232 openssl: Ensure underlying hash algorithm is available during HMAC init
Without this we only would learn that the algorithm isn't actually
available (e.g. due to FIPS mode) when set_key() is called later, so there
isn't any automatic fallback to other implementations.

Fixes #3284.
2019-12-06 10:27:24 +01:00
Tobias Brunner 96b8fa72b3 Merge branch 'ca-identity-constraint'
This adds a new constraint for vici/swanctl.conf that enforces that the
certificate chain of the remote peer contains a CA certificate with a
specific identity.

This is similar to the existing CA constraints, but doesn't require that
the CA certificate is locally installed, for instance, intermediate CA
certificates received by the peers.

Wildcard identity matching (e.g. "..., OU=Research, CN=*") could also be
used for the latter, but requires trust in the intermediate CA to only
issue certificates with legitimate subject DNs (e.g. the "Sales" CA must
not issue certificates with "OU=Research").  With the new constraint
that's not necessary as long as a path length constraint prevents
intermediate CAs from issuing further intermediate CAs.
2019-12-06 10:23:59 +01:00
Tobias Brunner ae9b748a77 vici: Log certificate constraints for loaded configs 2019-12-06 10:07:47 +01:00
Martin Willi f95d512251 testing: Use identity based CA restrictions in rw-hash-and-url-multi-level
This is a prominent example where the identity based CA constraint is
benefical. While the description of the test claims a strict binding
of the client to the intermediate CA, this is not fully true if CA operators
are not fully trusted: A rogue OU=Sales intermediate may issue certificates
containing a OU=Research.

By binding the connection to the CA, we can avoid this, and using the identity
based constraint still allows moon to receive the intermediate over IKE
or hash-and-url.
2019-12-06 10:07:47 +01:00
Martin Willi 026024bc02 swanctl: Include ca_id property in list-conns command 2019-12-06 10:07:46 +01:00
Martin Willi 55fc514ed2 swanctl: Document the remote ca_id option for identity based CA constraints 2019-12-06 10:07:46 +01:00
Martin Willi 3c71a3201f vici: Introduce a ca_id option identity based CA certificate constraints 2019-12-06 10:07:46 +01:00
Martin Willi c70201f1e3 auth-cfg: Add support for identity based CA authentication constraints
Enforcing CA based constraints previously required the CA certificate file
to be locally installed. This is problematic from a maintencance perspective
when having many intermediate CAs, and is actually redundant if the client
sends its intermediate cert in the request.

The alternative was to use Distinguished Name matching in the subject
identity to indirectly check for the issuing CA by some RDN field, such as OU.
However, this requires trust in the intermediate CA to issue only certificates
with legitime subject identities.

This new approach checks for an intermediate CA by comparing the issuing
identity. This does not require trust in the intermediate, as long as
a path len constraint prevents that intermediate to issue further
intermediate certificates.
2019-12-06 10:07:46 +01:00
Tobias Brunner 7035340b21 farp: Ignore SAs with 0.0.0.0/0 remote traffic selector
This is mostly to avoid hijacking the local LAN if the farp plugin is
inadvertently active on a roadwarrior.

Fixes #3116.
2019-12-06 10:06:16 +01:00
Tobias Brunner 202c204785 farp: Only cache IPv4 traffic selectors
Since ARP is IPv4 only there is no point caching IPv6 traffic
selectors/CHILD_SAs.
2019-12-06 09:58:29 +01:00
Tobias Brunner dc1e02e1de Merge branch 'ocsp-nonce'
This makes sure the nonce sent in an OCSP request is contained in the
response (it also fixes parsing the nonce, which didn't matter so far
as it was never used)
2019-12-06 09:53:26 +01:00
Tobias Brunner 27756b081c revocation: Check that nonce in OCSP response matches 2019-12-06 09:52:30 +01:00
Tobias Brunner cd0e4d5297 x509: Correctly parse nonce in OCSP response
Fixes: d7dc677ee5 ("x509: Correctly encode nonce in OCSP request")
2019-12-06 09:52:30 +01:00
Tobias Brunner 5333db58ac x509: Add getter for nonce in OCSP request/response implementations 2019-12-06 09:50:55 +01:00
Tobias Brunner 5b23427b37 credentials: Add getter for nonce in OCSP request and response interface 2019-12-06 09:50:55 +01:00
Andreas Steffen a43407df52 drbg: Don't generate more than 2^16 bytes 2019-11-28 21:29:26 +01:00
Tobias Brunner 8b6aadae9c Merge branch 'aes-ecb'
Adds support for AES in ECB mode (where supported by the underlying
library/API) and uses it for the CTR-DRBG implementation.
2019-11-28 17:16:36 +01:00
Andreas Steffen 86a4b95eac drbg: Use AES_ECB encryption 2019-11-28 17:03:09 +01:00
Andreas Steffen b7e840af5c gcrypt: Added AES_ECB support 2019-11-28 17:03:09 +01:00
Andreas Steffen a46e436e29 af-alg: Added AES_ECB support 2019-11-28 17:03:09 +01:00
Andreas Steffen f884ee6497 aes: Added AES_ECB support 2019-11-28 17:03:09 +01:00
Andreas Steffen 6f44bd6fe8 openssl: Added AES_ECB support 2019-11-28 17:03:08 +01:00
Andreas Steffen 20f3d04b13 aesni: Added AES_ECB support 2019-11-28 17:03:08 +01:00
Tobias Brunner 1352413272 vici: Update Python egg if strongSwan version changed
Mainly useful when using the build-strongswan script of the testing
environment.
2019-11-28 16:52:30 +01:00
Andreas Steffen 11e9d2b8d1 drbg: The drbg instance owns the entropy rng 2019-11-28 09:55:56 +01:00
5291 changed files with 68446 additions and 30540 deletions

View File

@ -3,6 +3,7 @@ clone_depth: 50
image:
- Visual Studio 2015
- Visual Studio 2017
- Visual Studio 2019
environment:
global:
@ -18,12 +19,21 @@ environment:
# bits: 32
install:
- tzutil /s "Central European Standard Time"
- set MSYS_SH=C:\msys%BITS%\usr\bin\sh.exe
- set MSYSTEM=MINGW%BITS%
- set TEST=win%BITS%
- |
set IMG=%APPVEYOR_BUILD_WORKER_IMAGE:~-4%
set OPENSSL=OpenSSL
IF "%IMG%" == "2017" set OPENSSL=OpenSSL-v11
IF "%IMG%" == "2019" set OPENSSL=OpenSSL-v111
set OPENSSL_DIR=/c/%OPENSSL%-%TEST%
C:\%OPENSSL%-%TEST%\bin\openssl.exe version -a
build_script:
- '%MSYS_SH% --login -c ". /etc/profile && cd $APPVEYOR_BUILD_FOLDER && ./scripts/test.sh deps"'
test_script:
- '%MSYS_SH% --login -c ". /etc/profile && touch /$MSYSTEM/etc/strongswan.conf"'
- '%MSYS_SH% --login -c ". /etc/profile && cd $APPVEYOR_BUILD_FOLDER && ./scripts/test.sh"'

View File

@ -1,12 +1,12 @@
freebsd_instance:
image: freebsd-12-0-release-amd64
image_family: freebsd-12-2
env:
TESTS_REDUCED_KEYLENGTHS: yes
LEAK_DETECTIVE: no
MONOLITHIC: no
TEST: freebsd
TRAVIS_OS_NAME: freebsd
OS_NAME: freebsd
task:
install_script: ./scripts/test.sh deps

35
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,35 @@
---
name: "🐛 Bug report"
about: Report a reproducible bug or regression
labels: bug, needs triage
---
<!--
IMPORTANT: Please use the [discussion forum](https://github.com/strongswan/strongswan/discussions)
for questions and configuration problems etc., only report actual bugs here.
Your issue will otherwise be closed immediately.
-->
**System (please complete the following information):**
- OS: [e.g. Ubuntu 20.04]
- Kernel version (if applicable): [e.g. 5.10]
- strongSwan version(s): [e.g. 5.9.2]
- Tested/confirmed with the latest version: [yes/no]
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. ...
2. ...
3. ...
**Expected behavior**
A clear and concise description of what you expected to happen.
**Logs/Backtraces**
If applicable, add logs or backtraces to help explain your problem.
**Additional context**
Add any other context about the problem here.

5
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: "🤔 Question and Help"
url: https://github.com/strongswan/strongswan/discussions
about: This issue tracker is not for support questions. Please refer to the strongSwan community's help and discussion forum

View File

@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
labels: enhancement, needs triage
---
<!--
IMPORTANT: Please consider discussing the requested feature in the
[forum](https://github.com/strongswan/strongswan/discussions) first.
-->
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions, workarounds or
features you've considered.
**Additional context**
Add any other context about the feature request here.

16
.github/actions/default/action.yml vendored Normal file
View File

@ -0,0 +1,16 @@
name: "Default CI Build Steps"
runs:
using: "composite"
steps:
- name: "Install Dependencies"
run: ./scripts/test.sh deps
shell: bash
- name: "Install Python Dependencies"
run: ./scripts/test.sh pydeps
shell: bash
- name: "Build Dependencies"
run: ./scripts/test.sh build-deps
shell: bash
- name: "Build/Tests"
run: ./scripts/test.sh
shell: bash

54
.github/workflows/android.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Android
on: [push, pull_request]
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 400M
CC: gcc
OS_NAME: linux
jobs:
pre-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip-check.outputs.should_skip }}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
android:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
env:
TEST: android
# since the NDK is newly installed every time, we have to use this to avoid cache misses
CCACHE_COMPILERCHECK: content
steps:
# even though we don't specify a specific version in our gradle files, the
# build fails without this because some arbitrary NDK version, that's
# weirdly not installed, is requested
- name: Install NDK
run: yes | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'ndk;21.0.6113669'
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-android-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-android-${{ github.ref }}:
ccache-android-
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -s
- uses: actions/upload-artifact@v2
with:
name: Lint Results
path: src/frontends/android/app/build/reports/lint-results.xml

37
.github/workflows/lgtm.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: lgtm.com
on: [push]
env:
OS_NAME: linux
jobs:
pre-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip-check.outputs.should_skip }}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
lgtm:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
env:
TEST: lgtm
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
# we don't use github/codeql-action because we can't exclude queries there,
# so we continue to use the approach we used on Travis
- env:
LGTM_TOKEN: ${{ secrets.LGTM_TOKEN }}
LGTM_PROJECT: ${{ secrets.LGTM_PROJECT }}
BUILD_NUMBER: ${{ github.run_id }}
COMMIT_ID: ${{ github.sha }}
COMMIT_BASE: ${{ github.event.before }}
uses: ./.github/actions/default

200
.github/workflows/linux.yml vendored Normal file
View File

@ -0,0 +1,200 @@
name: Linux
on: [push, pull_request]
env:
# this test case does not actually test anything but tries to access system
# directories that might be inaccessible on build hosts
TESTS_CASES_EXCLUDE: sw_collector
TESTS_REDUCED_KEYLENGTHS: yes
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 200M
OS_NAME: linux
jobs:
pre-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip-check.outputs.should_skip }}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
latest:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
test: [ all, default, printf-builtin ]
compiler: [ gcc, clang ]
leak-detective: [ no, yes ]
monolithic: [ no, yes ]
exclude:
# leaks will show up whether we build monolithic or not
- leak-detective: yes
monolithic: yes
# monolithic builds don't affect the printf-hook implementation
- test: printf-builtin
monolithic: yes
include:
- test: apidoc
- test: coverage
- test: dist
- test: nm-no-glib
- test: fuzzing
compiler: clang
monolithic: yes
env:
LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
MONOLITHIC: ${{ matrix.monolithic || 'no' }}
CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.ccache
# with regards to ccache, monolithic builds don't differ from regular
# builds and, similarly, builds with leak-detective only differ in two
# files (LD itself and library.c); but different tests build different
# dependencies, so different caches are needed
key: ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-
ccache-${{ runner.os }}-${{ env.CC }}-
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ success() && matrix.test == 'coverage' }}
run: bash <(curl -s https://codecov.io/bash)
- if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Logs ${{ github.job }}
path: config.log
retention-days: 5
crypto-plugins:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
test: [ botan, wolfssl, openssl, gcrypt ]
leak-detective: [ no, yes ]
env:
LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
TEST: ${{ matrix.test }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-
ccache-${{ runner.os }}-${{ env.CC }}-
ccache-${{ runner.os }}-${{ env.CC }}-all-${{ github.ref }}:${{ github.sha }}
ccache-${{ runner.os }}-${{ env.CC }}-all-${{ github.ref }}:
ccache-${{ runner.os }}-${{ env.CC }}-all-
ccache-${{ runner.os }}-${{ env.CC }}-
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Logs ${{ github.job }}
path: config.log
retention-days: 5
bionic:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-18.04
strategy:
matrix:
test: [ all ]
compiler: [ gcc, clang ]
include:
- test: nm
env:
LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }}
UBUNTU_BIONIC: yes
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-bionic-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-bionic-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
ccache-bionic-${{ env.CC }}-${{ matrix.test }}-
ccache-bionic-${{ env.CC }}-
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Logs ${{ github.job }}
path: config.log
retention-days: 5
xenial:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-16.04
strategy:
matrix:
test: [ all ]
compiler: [ gcc, clang ]
include:
- test: openssl-1.0
- test: openssl-1.0
leak-detective: yes
env:
LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
CC: ${{ matrix.compiler || 'gcc' }}
TEST: ${{ matrix.test }}
# this is the default with newer versions and fixes builds with clang
CCACHE_CPP2: true
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-xenial-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-xenial-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
ccache-xenial-${{ env.CC }}-${{ matrix.test }}-
ccache-xenial-${{ env.CC }}-
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Logs ${{ github.job }}
path: config.log
retention-days: 5

49
.github/workflows/macos.yml vendored Normal file
View File

@ -0,0 +1,49 @@
name: macOS
on: [push, pull_request]
env:
TESTS_REDUCED_KEYLENGTHS: yes
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 100M
OS_NAME: macos
jobs:
pre-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip-check.outputs.should_skip }}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
macos:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: macos-latest
env:
TEST: macos
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/Library/Caches/ccache
key: ccache-${{ runner.os }}-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-${{ github.ref }}:
ccache-${{ runner.os }}-
- run: |
brew install ccache
echo "PATH=$(brew --prefix)/opt/ccache/libexec:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Logs ${{ github.job }}
path: config.log
retention-days: 5

65
.github/workflows/sonarcloud.yml vendored Normal file
View File

@ -0,0 +1,65 @@
name: SonarCloud
on: [push]
env:
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 200M
OS_NAME: linux
jobs:
pre-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip-check.outputs.should_skip }}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
sonarcloud:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
env:
TEST: sonarcloud
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v2
with:
path: |
~/.ccache
~/.sonar-cache
key: ccache-sonarcloud-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-sonarcloud-${{ github.ref }}:
ccache-sonarcloud-
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
# using SonarSource/sonarcloud-github-action is currently not recommended
# for C builds, so we follow the "any CI" instructions
- name: Install sonar-scanner
env:
SONAR_SCANNER_VERSION: 4.4.0.2170
run: |
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "SONAR_SCANNER_OPTS=-server" >> $GITHUB_ENV
curl --create-dirs -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "PATH=$HOME/.sonar/build-wrapper-linux-x86:$SONAR_SCANNER_HOME/bin:$PATH" >> $GITHUB_ENV
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BUILD_NUMBER: ${{ github.run_id }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_PROJECT: ${{ secrets.SONAR_PROJECT }}
SONAR_ORGANIZATION: ${{ secrets.SONAR_ORGANIZATION }}
uses: ./.github/actions/default
- run: ccache -s

56
.github/workflows/windows.yml vendored Normal file
View File

@ -0,0 +1,56 @@
name: Windows
on: [push, pull_request]
env:
TESTS_REDUCED_KEYLENGTHS: yes
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPRESS: true
CCACHE_MAXSIZE: 200M
# since the compilers are newly installed every time, we have to use this to
# avoid cache misses
CCACHE_COMPILERCHECK: content
MONOLITHIC: yes
jobs:
pre-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip-check.outputs.should_skip }}
steps:
- id: skip-check
uses: fkirc/skip-duplicate-actions@master
with:
concurrent_skipping: 'same_content'
cross-compile:
needs: pre-check
if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
strategy:
matrix:
test: [ win64, win32 ]
env:
OS_NAME: linux
TEST: ${{ matrix.test }}
steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-${{ matrix.test }}-${{ github.ref }}:
ccache-${{ runner.os }}-${{ matrix.test }}-
- run: |
sudo apt-get install -qq ccache
echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
ccache -z
- uses: ./.github/actions/default
- run: ccache -s
- if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: Logs ${{ github.job }}
path: config.log
retention-days: 5

46
.lgtm.yml Normal file
View File

@ -0,0 +1,46 @@
queries:
- exclude: cpp/fixme-comment
# this rule produces too many false positives due to our custom specifiers and
# the use of void pointers in swanctl
- exclude: cpp/wrong-type-format-argument
extraction:
cpp:
prepare:
packages:
# for tss2
- libssl-dev
- libjson-c-dev
- libcurl4-openssl-dev
after_prepare:
- export DEPS_BUILD_DIR=$LGTM_WORKSPACE/deps
- mkdir -p $DEPS_BUILD_DIR
- export DEPS_PREFIX=$DEPS_BUILD_DIR/usr
- mkdir -p $DEPS_PREFIX
- export PKG_CONFIG_PATH="$DEPS_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
- export LD_LIBRARY_PATH="$DEPS_PREFIX/lib:$LD_LIBRARY_PATH"
- mkdir -p $LGTM_WORKSPACE/bin
# sudo doesn't work on the build hosts
- ln -s /usr/bin/nice $LGTM_WORKSPACE/bin/sudo
# for ldconfig we don't have enough permissions
- ln -s /bin/true $LGTM_WORKSPACE/bin/ldconfig
# likewise for apt-get
- ln -s /bin/echo $LGTM_WORKSPACE/bin/apt-get
- export PATH=$LGTM_WORKSPACE/bin:$PATH
- export TEST=all
- ./scripts/test.sh build-deps
- rm $LGTM_WORKSPACE/bin/*
configure:
command:
# follows the "all" build in test.sh (without custom-compiled stuff)
- ./autogen.sh
- ./configure --enable-all --disable-android-dns --disable-android-log
--disable-kernel-pfroute --disable-keychain
--disable-lock-profiler --disable-padlock --disable-fuzzing
--disable-osx-attr --disable-tkm --disable-uci
--disable-unwind-backtraces
--disable-svc --disable-dbghelp-backtraces --disable-socket-win
--disable-kernel-wfp --disable-kernel-iph --disable-winhttp
--disable-af-alg --disable-coverage
--disable-python-eggs-install
--disable-monolithic --disable-leak-detective

View File

@ -0,0 +1,51 @@
/**
* @name Invalid use of chunk_from_chars() macro
* @description The chunk_from_chars() macro creates a temporary chunk_t, which
* is not defined outside of the block in which it has been used,
* therefore, compilers might optimize out the assignment.
* @kind path-problem
* @problem.severity error
* @id strongswan/invalid-chunk-from-chars
* @tags correctness
* @precision very-high
*/
import cpp
import DataFlow::PathGraph
import semmle.code.cpp.dataflow.DataFlow
class ChunkFromChars extends Expr {
ChunkFromChars() {
this = any(MacroInvocation mi |
mi.getOutermostMacroAccess().getMacroName() = "chunk_from_chars"
/* ignore global static uses of the macro */
and exists (Block b | mi.getExpr().getEnclosingBlock() = b)
).getExpr()
}
}
class ChunkFromCharsUsage extends DataFlow::Configuration {
ChunkFromCharsUsage() { this = "ChunkFromCharsUsage" }
override predicate isSource(DataFlow::Node source) {
source.asExpr() instanceof ChunkFromChars
}
override predicate isSink(DataFlow::Node sink) {
exists(sink.asExpr())
}
override predicate isBarrierOut(DataFlow::Node node) {
/* don't track beyond function calls */
exists(FunctionCall fc | node.asExpr().getParent*() = fc)
}
}
Block enclosingBlock(Block b) {
result = b.getEnclosingBlock()
}
from ChunkFromCharsUsage usage, DataFlow::PathNode source, DataFlow::PathNode sink
where
usage.hasFlowPath(source, sink)
and not source.getNode().asExpr().getEnclosingBlock() = enclosingBlock*(sink.getNode().asExpr().getEnclosingBlock())
select source, source, sink, "Invalid use of chunk_from_chars() result in sibling/parent block."

View File

@ -1,99 +0,0 @@
language: c
sudo: required
dist: bionic
# don't build tags separately
if: tag IS blank
compiler: gcc
cache: ccache
before_install:
- travis_retry ./scripts/test.sh deps
- travis_retry ./scripts/test.sh pydeps
before_script:
- sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0 || true
script:
- ./scripts/test.sh
after_success:
if [ "$TEST" == "coverage" ]; then
bash <(curl -s https://codecov.io/bash);
fi
after_failure:
- cat config.log
- sleep 1
env:
global:
- TESTS_REDUCED_KEYLENGTHS=yes
- LEAK_DETECTIVE=no
- MONOLITHIC=no
matrix:
include:
- env: TEST=sonarcloud
if: type = push AND env(SONAR_TOKEN) IS present
git:
depth: false
addons:
sonarcloud:
organization: "strongswan"
- env: TEST=osx
compiler: clang
os: osx
- env: TEST=all
- env: TEST=all
compiler: clang
- env: TEST=all
dist: xenial
- env: TEST=all
dist: xenial
compiler: clang
- env: TEST=all MONOLITHIC=yes
- env: TEST=all MONOLITHIC=yes
compiler: clang
- env: TEST=all LEAK_DETECTIVE=yes
- env: TEST=all LEAK_DETECTIVE=yes
compiler: clang
- env: TEST=coverage
- env: TEST=fuzzing MONOLITHIC=yes
compiler: clang
- env: TEST=win64 MONOLITHIC=yes
- env: TEST=win32 MONOLITHIC=yes
- env: TEST=dist
# "default" with GCC is already tested with "dist" above
- env: TEST=default
compiler: clang
- env: TEST=default MONOLITHIC=yes
- env: TEST=default MONOLITHIC=yes
compiler: clang
- env: TEST=default LEAK_DETECTIVE=yes
- env: TEST=default LEAK_DETECTIVE=yes
compiler: clang
# we can't test Vstr as negative int args are not properly passed to CBs
- env: TEST=printf-builtin
- env: TEST=printf-builtin
compiler: clang
- env: TEST=printf-builtin LEAK_DETECTIVE=yes
- env: TEST=printf-builtin LEAK_DETECTIVE=yes
compiler: clang
# the crypto plugins are build-tested with clang via "all" above
- env: TEST=botan
- env: TEST=botan LEAK_DETECTIVE=yes
- env: TEST=wolfssl
- env: TEST=wolfssl LEAK_DETECTIVE=yes
- env: TEST=openssl
- env: TEST=openssl LEAK_DETECTIVE=yes
- env: TEST=openssl-1.0
dist: xenial
- env: TEST=openssl-1.0 LEAK_DETECTIVE=yes
dist: xenial
- env: TEST=gcrypt
- env: TEST=gcrypt LEAK_DETECTIVE=yes
- env: TEST=apidoc

View File

@ -1990,12 +1990,6 @@ EXTERNAL_GROUPS = YES
EXTERNAL_PAGES = YES
# The PERL_PATH should be the absolute path and name of the perl script
# interpreter (i.e. the result of 'which perl').
# The default file (with absolute path) is: /usr/bin/perl.
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
@ -2009,15 +2003,6 @@ PERL_PATH = /usr/bin/perl
CLASS_DIAGRAMS = YES
# You can define message sequence charts within doxygen comments using the \msc
# command. Doxygen will then run the mscgen tool (see:
# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
# You can include diagrams made with dia in doxygen documentation. Doxygen will
# then run dia to produce the diagram and insert it in the documentation. The
# DIA_PATH tag allows you to specify the directory where the dia binary resides.

View File

@ -38,6 +38,9 @@ Android.common.mk : Android.common.mk.in configure.ac
-e "s:\@PACKAGE_VERSION\@:$(PACKAGE_VERSION):" \
$(srcdir)/$@.in > $@
dist-hook:
@echo $(GIT_VERSION) > $(distdir)/.tarball-git-version
Doxyfile : Doxyfile.in
$(AM_V_GEN) \
sed \

271
NEWS
View File

@ -1,9 +1,258 @@
strongswan-5.9.3
----------------
- Added AES_ECB, SHA-3 and SHAKE-256 support to wolfssl plugin.
- Added AES_CCM and SHA-3 signature support to openssl plugin.
- The x509 and openssl plugins now consider the authorityKeyIdentifier, if
available, before verifying signatures, which avoids unnecessary signature
verifications after a CA key rollover if both certificates are loaded.
- The pkcs11 plugin better handles optional attributes like CKA_TRUSTED, which
previously depended on a version check.
- charon-nm now supports using SANs as client identities, not only full DNs.
- charon-tkm now handles IKE encryption.
- A MOBIKE update is sent again if a a change in the NAT mappings is detected
but the endpoints stay the same.
- Converted most of the test case scenarios to the vici interface
strongswan-5.9.2
----------------
- Together with a Linux 5.8 kernel supporting the IMA measurement of the GRUB
bootloader and the Linux kernel, the strongSwan Attestation IMC allows to do
remote attestation of the complete boot phase. A recent TPM 2.0 device with a
SHA-256 PCR bank is required, so that both BIOS and IMA file measurements are
based on SHA-256 hashes.
- Our own TLS library (libtls) that we use for TLS-based EAP methods and PT-TLS
gained experimental support for TLS 1.3. Thanks to Méline Sieber (client) and
Pascal Knecht (client and server) for their work on this.
Because the use of TLS 1.3 with these EAP methods is not yet standardized (two
Internet-Drafts are being worked on), the default maximum version is currently
set to TLS 1.2, which is now also the default minimum version. However the TNC
test scenarios using PT-TLS transport already use TLS 1.3.
- Other improvements for libtls also affect older TLS versions. For instance, we
added support for ECDH with Curve25519/448 (DH groups may also be configured
now), for EdDSA keys and certificates and for RSA-PSS signatures. Support for
old and weak cipher suites has been removed (e.g. with 3DES and MD5) as well
as signature schemes with SHA-1.
- The listener_t::ike_update event is now also called for MOBIKE updates. Its
signature has changed so we only have to call it once if both addresses/ports
have changed (e.g. for an address family switch). The event is now also
exposed via vici.
- The farp plugin has been ported to macOS and FreeBSD. Thanks to Dan James for
working on this.
- To fix DNS server installation with systemd-resolved, charon-nm now creates a
dummy TUN device again (was removed with 5.5.1).
- The botan plugin can use rng_t implementations provided by other plugins when
generating keys etc. if the Botan library supports it.
- charon-tkm now supports multiple CAs and is configured via vici/swanctl.
- Simple glob patterns (e.g. include conf.d/*.conf) now also work on Windows.
Handling of forward slashes in paths on Windows has also been improved.
- The abbreviations for the 'surname' and 'serial number' RDNs in ASN.1 DNs have
been changed to align with RFC 4519: The abbreviation for 'surname' is now
"SN" (was "S" before), which was previously used for 'serial number' that can
now be specified as "serialNumber" only.
- An issue with Windows clients requesting previous IPv6 but not IPv4 virtual
IP addresses has been fixed.
- ike_sa_manager_t: Checking out IKE_SAs by config is now atomic (e.g. when
acquires for different children of the same connection arrive concurrently).
The checkout_new() method has been renamed to create_new(). A new
checkout_new() method allows registering a new IKE_SA with the manager before
checking it in, so jobs can be queued without losing them as they can block
on checking out the new SA.
strongswan-5.9.1
----------------
- Remote attestation via TNC supports the SHA-256 based TPM 2.0 BIOS/EFI
measurements introduced with the Linux 5.4 kernel.
- Nonces in OCSP responses are not enforced anymore and only validated if a
nonce is actually contained.
- Fixed an issue when only some fragments of a retransmitted IKEv2 message were
received, which prevented processing a following fragmented message.
- All queued vici messages are now sent to subscribed clients during shutdown,
which includes ike/child-updown events triggered when all SAs are deleted.
- CHILD_SA IP addresses are updated before installation to allow MOBIKE updates
while retransmitting a CREATE_CHILD_SA request.
- When looking for a route to the peer, the kernel-netlink plugin ignores the
current source address if it's deprecated.
- The file and syslog loggers support logging the log level of each message
after the subsystem (e.g. [IKE2]).
- charon-nm is now properly terminated during system shutdown.
- Improved support for EdDSA keys in vici/swanctl, in particular, encrypted
keys are now supported.
- A new global strongswan.conf option allows sending the Cisco FlexVPN vendor ID
to prevent Cisco devices from narrowing a 0.0.0.0/0 traffic selector.
- The openssl plugin accepts CRLs issued by non-CA certificates if they contain
the cRLSign keyUsage flag (the x509 plugin already does this since 4.5.1).
- Attributes in PKCS#7 containers, as used in SCEP, are now properly
DER-encoded, i.e. sorted.
- The load-tester plugin now supports virtual IPv6 addresses and IPv6 source
address pools.
strongswan-5.9.0
----------------
- We prefer AEAD algorithms for ESP and therefore put AES-GCM in a default AEAD
proposal in front of the previous default proposal.
- The NM backend now clears cached credentials when disconnecting, has DPD and
and close action set to restart, and supports custom remote TS via 'remote-ts'
option (no GUI support).
- The pkcs11 plugin falls back to software hashing for PKCS#1v1.5 RSA signatures
if mechanisms with hashing (e.g. CKM_SHA256_RSA_PKCS) are not supported.
- The owner/group of log files is now set so the daemon can reopen them if the
config is reloaded and it doesn't run as root.
- The wolfssl plugin (with wolfSSL 4.4.0+) supports x448 DH and Ed448 keys.
- The vici plugin stores all CA certificates in one location, which avoids
issues with unloading authority sections or clearing all credentials.
- When unloading a vici connection with start_action=start, any related IKE_SAs
without children are now terminated (including those in CONNECTING state).
- The hashtable implementation has been changed so it maintains insertion order.
This was mainly done so the vici plugin can store its connections in a
hashtable, which makes managing high numbers of connections faster.
- The default maximum size for vici messages (512 KiB) can now be changed via
VICI_MESSAGE_SIZE_MAX compile option.
- The charon.check_current_path option allows forcing a DPD exchange to check if
the current path still works whenever interface/address-changes are detected.
- It's possible to use clocks other than CLOCK_MONOTONIC (e.g. CLOCK_BOOTTIME)
via TIME_CLOCK_ID compile option if clock_gettime() is available and
pthread_condattr_setclock() supports that clock.
- Test cases and functions can now be filtered when running the unit tests.
strongswan-5.8.4
----------------
- In IKEv1 Quick Mode make sure that a proposal exists before determining
lifetimes (fixes crash due to null pointer exception).
- OpenSSL currently doesn't support squeezing bytes out of a SHAKE128/256
XOF (eXtended Output Function) multiple times. Unfortunately,
EVP_DigestFinalXOF() completely resets the context and later calls not
simply fail, they cause a null-pointer dereference in libcrypto. This
fixes the crash at the cost of repeating initializing the whole state
and allocating too much data for subsequent calls.
strongswan-5.8.3
----------------
- Updates for the NM backend (and plugin), among others: EAP-TLS authentication,
configurable local and remote IKE identities, custom server port, redirection
and reauthentication support.
- Previously used reqids are now reallocated to workaround an issue on FreeBSD
where the daemon can't use reqids > 16383.
- On Linux, throw type routes are installed for passthrough policies. They act
as fallbacks on routes in other tables and require less information, so they
can be installed earlier and are not affected by updates.
- For IKEv1, the lifetimes of the selected transform are returned to the
initiator, which is an issue with peers that propose different lifetimes in
different transforms. We also return the correct transform and proposal IDs.
- IKE_SAs are not re-established anymore if a deletion has been queued.
- Added support for Ed448 keys and certificates via openssl plugin and pki tool.
The openssl plugin also supports SHA-3 and SHAKE128/256.
- The use of algorithm IDs from the private use ranges can now be enabled
globally, to use them even if no strongSwan vendor ID was exchanged.
strongswan-5.8.2
----------------
- Identity-based CA constraints are supported via vici/swanctl.conf. They
enforce that the remote's certificate chain contains a CA certificate with a
specific identity. While similar to the existing CA constraints, they don't
require that the CA certificate is locally installed such as intermediate CA
certificates received from peers. Compared to wildcard identity matching (e.g.
"..., OU=Research, CN=*") this requires less trust in the intermediate CAs (to
only issue certificates with legitimate subject DNs) as long as path length
basic constraints prevent them from issuing further intermediate CAs.
- Intermediate CA certificates may now be sent in hash-and-URL encoding by
configuring a base URL for the parent CA.
- Implemented NIST SP-800-90A Deterministic Random Bit Generator (DRBG)
based on AES-CTR and SHA2-HMAC modes. Currently used by gmp and ntru plugins.
- Random nonces sent in an OCSP requests are now expected in the corresponding
OCSP responses.
- The kernel-netlink plugin ignores deprecated IPv6 addresses for MOBIKE.
Whether temporary or permanent IPv6 addresses are included depends on the
charon.prefer_temporary_addrs setting.
- Extended Sequence Numbers (ESN) are configured via PF_KEY if supported by the
kernel.
- Unique section names are used for CHILD_SAs in vici child-updown events and
more information (e.g. statistics) are included for individually deleted
CHILD_SAs (in particular for IKEv1).
- So fallbacks to other plugins work properly, creating HMACs via openssl plugin
now fails instantly if the underlying hash algorithm isn't supported (e.g.
MD5 in FIPS-mode).
- Exponents of RSA keys read from TPM 2.0 via SAPI are now correctly converted.
- Routing table IDs > 255 are supported for custom routes on Linux.
- The D-Bus config file for charon-nm is now installed in
$(datadir)/dbus-1/system.d instead of $(sysconfdir)/dbus-1/system.d.
- INVALID_MAJOR_VERSION notifies are now correctly sent in messages of the same
exchange type and using the same message ID as the request.
- IKEv2 SAs are immediately destroyed when sending or receiving INVALID_SYNTAX
notifies in authenticated messages.
strongswan-5.8.1
----------------
@ -145,7 +394,7 @@ strongswan-5.7.0
for low-exponent keys (i.e. with e=3). CVE-2018-16151 has been assigned to
the problem of accepting random bytes after the OID of the hash function in
such signatures, and CVE-2018-16152 has been assigned to the issue of not
verifying that the parameters in the ASN.1 algorithmIdentitifer structure is
verifying that the parameters in the ASN.1 algorithmIdentifier structure is
empty. Other flaws that don't lead to a vulnerability directly (e.g. not
checking for at least 8 bytes of padding) have no separate CVE assigned.
@ -651,7 +900,7 @@ strongswan-5.3.3
- In the bliss plugin the c_indices derivation using a SHA-512 based random
oracle has been fixed, generalized and standardized by employing the MGF1 mask
generation function with SHA-512. As a consequence BLISS signatures unsing the
generation function with SHA-512. As a consequence BLISS signatures using the
improved oracle are not compatible with the earlier implementation.
- Support for auto=route with right=%any for transport mode connections has
@ -1226,7 +1475,7 @@ strongswan-5.0.1
- The PA-TNC and PB-TNC protocols can now process huge data payloads
>64 kB by distributing PA-TNC attributes over multiple PA-TNC messages
and these messages over several PB-TNC batches. As long as no
consolidated recommandation from all IMVs can be obtained, the TNC
consolidated recommendation from all IMVs can be obtained, the TNC
server requests more client data by sending an empty SDATA batch.
- The rightgroups2 ipsec.conf option can require group membership during
@ -1948,7 +2197,7 @@ strongswan-4.3.1
- The nm plugin also accepts CA certificates for gateway authentication. If
a CA certificate is configured, strongSwan uses the entered gateway address
as its idenitity, requiring the gateways certificate to contain the same as
as its identity, requiring the gateways certificate to contain the same as
subjectAltName. This allows a gateway administrator to deploy the same
certificates to Windows 7 and NetworkManager clients.
@ -1995,7 +2244,7 @@ strongswan-4.3.0
Initiators and responders can use several authentication rounds (e.g. RSA
followed by EAP) to authenticate. The new ipsec.conf leftauth/rightauth and
leftauth2/rightauth2 parameters define own authentication rounds or setup
constraints for the remote peer. See the ipsec.conf man page for more detials.
constraints for the remote peer. See the ipsec.conf man page for more details.
- If glibc printf hooks (register_printf_function) are not available,
strongSwan can use the vstr string library to run on non-glibc systems.
@ -2494,7 +2743,7 @@ strongswan-4.1.5
strongswan-4.1.4
----------------
- The pluto IKEv1 daemon now exhibits the same behaviour as its
- The pluto IKEv1 daemon now exhibits the same behavior as its
IKEv2 companion charon by inserting an explicit route via the
_updown script only if a sourceip exists. This is admissible
since routing through the IPsec tunnel is handled automatically
@ -2741,7 +2990,7 @@ strongswan-4.0.4
- Added support for preshared keys in IKEv2. PSK keys configured in
ipsec.secrets are loaded. The authby parameter specifies the authentication
method to authentificate ourself, the other peer may use PSK or RSA.
method to authenticate ourself, the other peer may use PSK or RSA.
- Changed retransmission policy to respect the keyingtries parameter.
@ -2879,7 +3128,7 @@ strongswan-2.7.0
left|rightfirewall keyword causes the automatic insertion
and deletion of ACCEPT rules for tunneled traffic upon
the successful setup and teardown of an IPsec SA, respectively.
left|rightfirwall can be used with KLIPS under any Linux 2.4
left|rightfirewall can be used with KLIPS under any Linux 2.4
kernel or with NETKEY under a Linux kernel version >= 2.6.16
in conjunction with iptables >= 1.3.5. For NETKEY under a Linux
kernel version < 2.6.16 which does not support IPsec policy
@ -3000,7 +3249,7 @@ strongswan-2.6.0
to replace the various shell and awk starter scripts (setup, _plutoload,
_plutostart, _realsetup, _startklips, _confread, and auto). Since
ipsec.conf is now parsed only once, the starting of multiple tunnels is
accelerated tremedously.
accelerated tremendously.
- Added support of %defaultroute to the ipsec starter. If the IP address
changes, a HUP signal to the ipsec starter will automatically
@ -3134,9 +3383,9 @@ strongswan-2.5.1
- Under the native IPsec of the Linux 2.6 kernel, a %trap eroute
installed either by setting auto=route in ipsec.conf or by
a connection put into hold, generates an XFRM_AQUIRE event
a connection put into hold, generates an XFRM_ACQUIRE event
for each packet that wants to use the not-yet existing
tunnel. Up to now each XFRM_AQUIRE event led to an entry in
tunnel. Up to now each XFRM_ACQUIRE event led to an entry in
the Quick Mode queue, causing multiple IPsec SA to be
established in rapid succession. Starting with strongswan-2.5.1
only a single IPsec SA is established per host-pair connection.

View File

@ -1,4 +1,4 @@
# strongSwan Configuration #
## Patched version, containing patch to disable parsing of AUTH payload in IKEv2 Phase2, because we only want EAP-AKA ##
## Overview ##
@ -570,7 +570,7 @@ RSA or ECDSA private key. For details, refer to the TPM 2.0
In a next step the command
pki --req --type priv --in moonKey.pem \
--dn "C=CH, O=strongswan, CN=moon.strongswan.org \
--dn "C=CH, O=strongswan, CN=moon.strongswan.org" \
--san moon.strongswan.org --outform pem > moonReq.pem
creates a PKCS#10 certificate request that has to be signed by the CA.

View File

@ -639,7 +639,7 @@ following entries are required in `/etc/ipsec.conf`:
conn rw1
right=%any
righsubnet=10.4.0.5/32
rightsubnet=10.4.0.5/32
conn rw2
right=%any

48
SECURITY.md Normal file
View File

@ -0,0 +1,48 @@
# Security Policy
## Reporting a Vulnerability
Please report any security-relevant flaw to security@strongswan.org. Whenever
possible encrypt your email with the [PGP key](https://pgp.key-server.io/0x1EB41ECF25A536E4)
with key ID 0x1EB41ECF25A536E4.
## Severity Classification
* **High Severity Flaw**
* Allows remote access to the VPN with improper, missing, or invalid
credentials
* Allows local escalation of privileges on the server
* Plain text traffic on the secure interface
* Key generation and crypto flaws that reduce the difficulty in decrypting
secure traffic
* **Medium Severity Flaw**
* Remotely crashing the strongSwan daemon, which would allow DoS attacks on
the VPN service
* **Low Severity Flaw**
* All other minor issues not directly compromising security or availability
of the strongSwan daemon or the host the daemon is running on
## Action Taken
For **high** and **medium** severity vulnerabilities we are generally going to
apply for a [CVE Identifier](https://cve.mitre.org/cve/identifiers/) first.
Next we notify all known strongSwan customers and the major Linux
distributions, giving them a time of about three weeks to patch their software
release. On a predetermined date, we officially issue an advisory and a patch
for the vulnerability and usually a new stable strongSwan release containing
the security fix.
Minor vulnerabilities of **low** severity usually will be fixed immediately
in our repository and released with the next stable release.
## List of Reported and Fixed Security Flaws
A list of all reported strongSwan high and medium security flaws may be
found in the [CVE database](https://nvd.nist.gov/vuln/search/results?query=strongswan).
The corresponding security patches are published on https://download.strongswan.org/security/.

View File

@ -33,6 +33,7 @@ plugins = \
plugins/attr.opt \
plugins/attr-sql.opt \
plugins/bliss.opt \
plugins/botan.opt \
plugins/bypass-lan.opt \
plugins/certexpire.opt \
plugins/coupling.opt \

View File

@ -68,8 +68,9 @@ import sys
import re
from textwrap import TextWrapper
from argparse import ArgumentParser
from functools import cmp_to_key
from functools import cmp_to_key, total_ordering
@total_ordering
class ConfigOption:
"""Representing a configuration option or described section in strongswan.conf"""
def __init__(self, path, default = None, section = False, commented = False, include = False):
@ -83,6 +84,9 @@ class ConfigOption:
self.desc = []
self.options = []
def __eq__(self, other):
return self.name == other.name
def __lt__(self, other):
return self.name < other.name

View File

@ -29,6 +29,9 @@ charon.filelog.<name>.ike_name = no
Prefix each log entry with the connection name and a unique numerical
identifier for each IKE_SA.
charon.filelog.<name>.log_level = no
Add the log level of each message after the subsystem (e.g. [IKE2]).
charon.filelog.<name>.time_format
Prefix each log entry with a timestamp. The option accepts a format string
as passed to **strftime**(3).
@ -64,3 +67,6 @@ charon.syslog.<facility>.<subsystem> = <default>
charon.syslog.<facility>.ike_name = no
Prefix each log entry with the connection name and a unique numerical
identifier for each IKE_SA.
charon.syslog.<facility>.log_level = no
Add the log level of each message after the subsystem (e.g. [IKE2]).

View File

@ -8,6 +8,10 @@ charon {}
**charon-cmd** instead of **charon**). For many options defaults can be
defined in the **libstrongswan** section.
charon.accept_private_algs = no
Deliberately violate the IKE standard's requirement and allow the use of
private algorithm identifiers, even if the peer implementation is unknown.
charon.accept_unencrypted_mainmode_messages = no
Accept unencrypted ID and HASH payloads in IKEv1 Main Mode.
@ -36,6 +40,29 @@ charon.cache_crls = no
Certification Authority (CA) to **/etc/ipsec.d/crls** (stroke) or
**/etc/swanctl/x509crl** (vici), respectively.
charon.check_current_path = no
Whether to use DPD to check if the current path still works after any
changes to interfaces/addresses.
By default, after detecting any changes to interfaces and/or addresses no
action is taken if the current path to the remote peer still looks usable.
Enabling this option will use DPD to check if the path actually still works,
or, for instance, the peer removed the state after a longer phase without
connectivity. It will also trigger a MOBIKE update if NAT mappings were
removed during the downtime.
charon.cisco_flexvpn = no
Send the Cisco FlexVPN vendor ID payload (IKEv2 only).
Send the Cisco FlexVPN vendor ID payload, which is required in order to make
Cisco brand devices allow negotiating a local traffic selector (from
strongSwan's point of view) that is not the assigned virtual IP address if
such an address is requested by strongSwan. Sending the Cisco FlexVPN
vendor ID prevents the peer from narrowing the initiator's local traffic
selector and allows it to e.g. negotiate a TS of 0.0.0.0/0 == 0.0.0.0/0
instead. This has been tested with a "tunnel mode ipsec ipv4" Cisco
template but should also work for GRE encapsulation.
charon.cisco_unity = no
Send Cisco Unity vendor ID payload (IKEv1 only).
@ -102,9 +129,6 @@ charon.dns2
charon.dos_protection = yes
Enable Denial of Service protection using cookies and aggressiveness checks.
charon.ecp_x_coordinate_only = yes
Compliance with the errata for RFC 4753.
charon.flush_auth_cfg = no
Free objects during authentication (might conflict with plugins).
@ -116,6 +140,10 @@ charon.flush_auth_cfg = no
charon.follow_redirects = yes
Whether to follow IKEv2 redirects (RFC 5685).
charon.force_eap_only_authentication = no
Violate RFC 5998 and use EAP-only authentication even if the peer did not
send an EAP_ONLY_AUTHENTICATION notify during IKE_AUTH.
charon.fragment_size = 1280
Maximum size (complete IP datagram size in bytes) of a sent IKE fragment
when using proprietary IKEv1 or standardized IKEv2 fragmentation, defaults
@ -212,6 +240,11 @@ charon.interfaces_use
charon.keep_alive = 20s
NAT keep alive interval.
charon.keep_alive_dpd_margin = 0s
Number of seconds the keep alive interval may be exceeded before a DPD is
sent instead of a NAT keep alive (0 to disable). This is only useful if a
clock is used that includes time spent suspended (e.g. CLOCK_BOOTTIME).
charon.leak_detective.detailed = yes
Includes source file names and line numbers in leak detective output.
@ -440,6 +473,24 @@ charon.tls.mac
charon.tls.suites
List of TLS cipher suites.
charon.tls.ke_group
List of TLS key exchange groups.
charon.tls.signature
List of TLS signature schemes.
charon.tls.send_certreq_authorities = yes
Whether to include CAs in a server's CertificateRequest message.
Whether to include CAs in a server's CertificateRequest message. May be
disabled if clients can't handle a long list of CAs.
charon.tls.version_min = 1.2
Minimum TLS version to negotiate.
charon.tls.version_max = 1.2
Maximum TLS version to negotiate.
charon.user
Name of the user the daemon changes to after startup.

6
conf/plugins/botan.opt Normal file
View File

@ -0,0 +1,6 @@
charon.plugins.botan.internal_rng_only = no
Force the use of Botan's internal RNG.
If enabled, only Botan's internal RNG will be used throughout the plugin.
Otherwise, and if supported by Botan, rng_t implementations provided by
other loaded plugins will be used as RNG.

View File

@ -10,6 +10,9 @@ libimcv.plugins.imc-attestation.aik_pubkey =
libimcv.plugins.imc-attestation.aik_handle =
AIK object handle.
libimcv.plugins.imc-attestation.hash_algorithm = sha384
Preferred measurement hash algorithm.
libimcv.plugins.imc-attestation.mandatory_dh_groups = yes
Enforce mandatory Diffie-Hellman groups.
@ -44,3 +47,7 @@ libimcv.plugins.imc-attestation.pcr18_meas =
libimcv.plugins.imc-attestation.pcr18_after =
PCR18 value after measurement.
libimcv.plugins.imc-attestation.pcr_padding = no
Whether to pad IMA SHA1 measurements values when extending into
SHA256 PCR bank.

View File

@ -7,7 +7,7 @@ libimcv.plugins.imv-attestation.mandatory_dh_groups = yes
libimcv.plugins.imv-attestation.dh_group = ecp256
Preferred Diffie-Hellman group.
libimcv.plugins.imv-attestation.hash_algorithm = sha256
libimcv.plugins.imv-attestation.hash_algorithm = sha384
Preferred measurement hash algorithm.
libimcv.plugins.imv-attestation.min_nonce_len = 0

View File

@ -25,7 +25,7 @@ charon.plugins.load-tester.crl
certificates.
charon.plugins.load-tester.delay = 0
Delay between initiatons for each thread.
Delay between initiations for each thread.
charon.plugins.load-tester.delete_after_established = no
Delete an IKE_SA as soon as it has been established.
@ -66,7 +66,7 @@ charon.plugins.load-tester.initiators = 0
Number of concurrent initiator threads to use in load test.
charon.plugins.load-tester.initiator_auth = pubkey
Authentication method(s) the intiator uses.
Authentication method(s) the initiator uses.
charon.plugins.load-tester.initiator_id =
Initiator ID used in load test.
@ -119,7 +119,7 @@ charon.plugins.load-tester.responder_tsr = initiator_tsr
Traffic selector on responder side, as narrowed by responder.
charon.plugins.load-tester.request_virtual_ip = no
Request an INTERNAL_IPV4_ADDR from the server.
Request an INTERNAL_IPV4_ADDR and INTERNAL_IPV6_ADDR from the server.
charon.plugins.load-tester.shutdown_when_complete = no
Shutdown the daemon after all IKE_SAs have been established.

View File

@ -74,7 +74,7 @@ libtls library messages
libipsec library messages
.TP
.B lib
libstrongwan library messages
libstrongswan library messages
.TP
.B tnc
Trusted Network Connect

View File

@ -3,6 +3,8 @@
# Copyright (C) 2006-2019 Andreas Steffen
# Copyright (C) 2006-2014 Martin Willi
# HSR Hochschule fuer Technik Rapperswil
# Copyright (C) 2017 Domonkos P. Tomcsanyi
# umlaut Communications Gmbh.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
@ -19,7 +21,7 @@
# initialize & set some vars
# ============================
AC_INIT([strongSwan],[5.8.2dr2])
AC_INIT([strongSwan],[5.9.3])
AM_INIT_AUTOMAKE(m4_esyscmd([
echo tar-ustar
echo subdir-objects
@ -55,7 +57,7 @@ ARG_WITH_SUBST([piddir], [/var/run], [set path for PID and UNIX sock
ARG_WITH_SUBST([ipsecdir], [${libexecdir%/}/ipsec], [set installation path for ipsec tools])
ARG_WITH_SUBST([ipseclibdir], [${libdir%/}/ipsec], [set installation path for ipsec libraries])
ARG_WITH_SUBST([plugindir], [${ipseclibdir%/}/plugins], [set the installation path of plugins])
ARG_WITH_SUBST([imcvdir], [${ipseclibdir%/}/imcvs], [set the installation path of IMC and IMV dynamic librariers])
ARG_WITH_SUBST([imcvdir], [${ipseclibdir%/}/imcvs], [set the installation path of IMC and IMV dynamic libraries])
ARG_WITH_SUBST([nm-ca-dir], [/usr/share/ca-certificates], [directory the NM backend uses to look up trusted root certificates])
ARG_WITH_SUBST([swanctldir], [${sysconfdir}/swanctl], [base directory for swanctl configuration files and credentials])
ARG_WITH_SUBST([linux-headers], [\${top_srcdir}/src/include], [set directory of linux header files to use])
@ -77,6 +79,15 @@ fi
ARG_WITH_SET([systemdsystemunitdir], [$systemdsystemunitdir_default], [directory for systemd service files])
AC_SUBST(systemdsystemunitdir)
AC_ARG_WITH(
[dbuspolicydir],
AS_HELP_STRING([--with-dbuspolicydir=arg],[directory for D-Bus policies (default: ${dbusdatadir|datarootdir}/dbus-1/system.d)]),
[dbuspolicydir="$withval"],
[PKG_CHECK_VAR([dbusdatadir], [dbus-1], [datadir], , [dbusdatadir="${datarootdir}"])
dbuspolicydir="${dbusdatadir}/dbus-1/system.d"]
)
AC_SUBST(dbuspolicydir)
AC_ARG_WITH(
[user],
AS_HELP_STRING([--with-user=user],[change user of the daemons to "user" after startup (default is "root").]),
@ -190,7 +201,8 @@ ARG_ENABL_SET([eap-sim-pcsc], [enable EAP-SIM backend based on a smartcard rea
ARG_ENABL_SET([eap-aka], [enable EAP AKA authentication module.])
ARG_ENABL_SET([eap-aka-3gpp], [enable EAP AKA backend implementing 3GPP MILENAGE algorithms in software.])
ARG_ENABL_SET([eap-aka-3gpp2], [enable EAP AKA backend implementing 3GPP2 algorithms in software. Requires libgmp.])
ARG_ENABL_SET([eap-simaka-sql], [enable EAP-SIM/AKA backend based on a triplet/quintuplet SQL database.])
ARG_ENABL_SET([eap-simaka-pcsc], [enable EAP-SIM/AKA backend based on a smartcard reader. Requires libpcsclite.])
ARG_ENABL_SET([eap-simaka-sql], [enable EAP-SIM/AKA backend based on a triplet/quintuplet SQL database.])
ARG_ENABL_SET([eap-simaka-pseudonym], [enable EAP-SIM/AKA pseudonym storage plugin.])
ARG_ENABL_SET([eap-simaka-reauth], [enable EAP-SIM/AKA reauthentication data storage plugin.])
ARG_ENABL_SET([eap-identity], [enable EAP module providing EAP-Identity helper.])
@ -317,6 +329,7 @@ ARG_ENABL_SET([tss-tss2], [enable the use of the TSS 2.0 Trusted Software
# compile options
ARG_ENABL_SET([coverage], [enable lcov coverage report generation.])
ARG_ENABL_SET([git-version], [use output of 'git describe' as version information in executables.])
ARG_ENABL_SET([leak-detective], [enable malloc hooks to find memory leaks.])
ARG_ENABL_SET([lock-profiler], [enable lock/mutex profiling code.])
ARG_ENABL_SET([log-thread-ids], [use thread ID, if available, instead of an incremented value starting from 1, to identify threads.])
@ -374,33 +387,35 @@ AC_PROG_LEX
AC_PROG_YACC
AM_PATH_PYTHON(,,[:])
AC_PATH_PROG([PERL], [perl], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
AC_ARG_VAR([PERL], [the Perl interpreter])
AC_PATH_PROG([GPERF], [gperf], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
AC_ARG_VAR([GPERF], [the GNU gperf program])
# because gperf is not needed by end-users we just report it but do not abort on failure
AC_MSG_CHECKING([gperf version >= 3.0.0])
# because gperf is not needed by end-users we only abort if generated files don't exist
AC_MSG_CHECKING([gperf len type])
if test -x "$GPERF"; then
if test "`$GPERF --version | $AWK -F' ' '/^GNU gperf/ { print $3 }' | $AWK -F. '{ print $1 }'`" -ge "3"; then
GPERF_OUTPUT="`echo foo | ${GPERF}`"
AC_COMPILE_IFELSE(
GPERF_OUTPUT="`echo foo | ${GPERF}`"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <string.h>
const char *in_word_set(const char*, size_t); $GPERF_OUTPUT]])],
[GPERF_LEN_TYPE=size_t],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <string.h>
const char *in_word_set(const char*, size_t); $GPERF_OUTPUT]])],
[GPERF_LEN_TYPE=size_t],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <string.h>
const char *in_word_set(const char*, unsigned); $GPERF_OUTPUT]])],
[GPERF_LEN_TYPE=unsigned],
[AC_MSG_ERROR([unable to determine gperf len type])]
)]
)
AC_SUBST(GPERF_LEN_TYPE)
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
const char *in_word_set(const char*, unsigned); $GPERF_OUTPUT]])],
[GPERF_LEN_TYPE=unsigned],
[AC_MSG_ERROR([unable to determine gperf len type])]
)]
)
AC_SUBST(GPERF_LEN_TYPE)
AC_MSG_RESULT([$GPERF_LEN_TYPE])
else
AC_MSG_RESULT([not found])
GPERF_TEST_FILE="$srcdir/src/libstrongswan/crypto/proposal/proposal_keywords_static.c"
if test ! -f "$GPERF_TEST_FILE"; then
AC_MSG_ERROR([GNU gperf required to generate e.g. $GPERF_TEST_FILE])
fi
fi
# ========================
@ -650,7 +665,7 @@ AC_CHECK_FUNC(
]
)
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom getpwnam_r getgrnam_r getpwuid_r)
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom getpwnam_r getgrnam_r getpwuid_r chown)
AC_CHECK_FUNCS(fmemopen funopen mmap memrchr setlinebuf strptime dirfd sigwaitinfo explicit_bzero)
AC_CHECK_FUNC([syslog], [
@ -1027,26 +1042,28 @@ if test x$tss_tss2 = xtrue; then
PKG_CHECK_MODULES(tss2_esys, [tss2-esys],
[tss2_esys=true; AC_DEFINE([TSS2_ESYS], [], [use TSS2 v2 Extended System API])],
[tss2_esys=false])
PKG_CHECK_MODULES(tss2_tabrmd, [tcti-tabrmd],
[tss2_tabrmd=true; AC_DEFINE([TSS2_TCTI_TABRMD], [], [use TCTI Access Broker and Resource Mamager])],
[tss2_tabrmd=false])
PKG_CHECK_MODULES(tss2_socket, [tcti-socket],
[tss2_socket=true; AC_DEFINE([TSS2_TCTI_SOCKET], [], [use TCTI Sockets])],
[tss2_socket=false])
if test x$tss2_sys = xtrue; then
AC_DEFINE([TSS_TSS2_V2], [], [use TSS 2.0 v2 libraries])
AC_SUBST(tss2_CFLAGS, "$tss2_sys_CFLAGS")
AC_SUBST(tss2_LIBS, "$tss2_sys_LIBS")
elif test x$tss2_tabrmd = xtrue -o x$tss2_socket = xtrue; then
AC_DEFINE([TSS_TSS2_V1], [], [use TSS 2.0 v1 libraries])
AC_SUBST(tss2_CFLAGS, "$tss2_tabrmd_CFLAGS $tss2_socket_CFLAGS")
AC_SUBST(tss2_LIBS, "$tss2_tabrmd_LIBS $tss2_socket_LIBS")
else
AC_MSG_FAILURE([no TSS2 TCTI or SAPI libraries detected])
PKG_CHECK_MODULES(tss2_tabrmd, [tcti-tabrmd],
[tss2_tabrmd=true; AC_DEFINE([TSS2_TCTI_TABRMD], [], [use TCTI Access Broker and Resource Manager])],
[tss2_tabrmd=false])
PKG_CHECK_MODULES(tss2_socket, [tcti-socket],
[tss2_socket=true; AC_DEFINE([TSS2_TCTI_SOCKET], [], [use TCTI Sockets])],
[tss2_socket=false])
if test x$tss2_tabrmd = xtrue -o x$tss2_socket = xtrue; then
AC_DEFINE([TSS_TSS2_V1], [], [use TSS 2.0 v1 libraries])
AC_SUBST(tss2_CFLAGS, "$tss2_tabrmd_CFLAGS $tss2_socket_CFLAGS")
AC_SUBST(tss2_LIBS, "$tss2_tabrmd_LIBS $tss2_socket_LIBS")
else
AC_MSG_FAILURE([no TSS2 TCTI or SAPI libraries detected])
fi
fi
fi
if test x$imc_swima = xtrue -o $imv_swima = xtrue; then
if test x$imc_swima = xtrue -o x$imv_swima = xtrue; then
PKG_CHECK_MODULES(json, [json-c], [],
[PKG_CHECK_MODULES(json, [json])])
AC_SUBST(json_CFLAGS)
@ -1139,11 +1156,9 @@ if test x$openssl = xtrue; then
fi
if test x$wolfssl = xtrue; then
wolfssl_lib=wolfssl
AC_CHECK_LIB([$wolfssl_lib],[wolfSSL_Init],[LIBS="$LIBS"],
[AC_MSG_ERROR([wolfSSL lib$wolfssl_lib not found])],[$DLLIB])
AC_SUBST(WOLFSSL_LIB, [-l$wolfssl_lib])
AC_CHECK_HEADER([wolfssl/options.h],,[AC_MSG_ERROR([wolfSSL header wolfssl/options.h not found!])])
PKG_CHECK_MODULES(wolfssl, [wolfssl])
AC_SUBST(wolfssl_CFLAGS)
AC_SUBST(wolfssl_LIBS)
fi
if test x$gcrypt = xtrue; then
@ -1161,9 +1176,14 @@ if test x$gcrypt = xtrue; then
fi
if test x$botan = xtrue; then
PKG_CHECK_MODULES(botan, [botan-2])
PKG_CHECK_MODULES(botan, [botan-3], [],
[PKG_CHECK_MODULES(botan, [botan-2])])
AC_SUBST(botan_CFLAGS)
AC_SUBST(botan_LIBS)
saved_LIBS=$LIBS
LIBS="$botan_LIBS"
AC_CHECK_FUNCS(botan_rng_init_custom)
LIBS=$saved_LIBS
fi
if test x$uci = xtrue; then
@ -1186,10 +1206,23 @@ if test x$eap_sim_pcsc = xtrue; then
AC_SUBST(pcsclite_LIBS)
fi
if test x$eap_simaka_pcsc = xtrue; then
PKG_CHECK_MODULES(pcsclite, [libpcsclite])
AC_SUBST(pcsclite_CFLAGS)
AC_SUBST(pcsclite_LIBS)
fi
if test x$nm = xtrue; then
PKG_CHECK_MODULES(nm, [gthread-2.0 libnm])
AC_SUBST(nm_CFLAGS)
AC_SUBST(nm_LIBS)
AC_MSG_CHECKING([for D-Bus policy directory])
if test -n "$dbuspolicydir" -a "x$dbuspolicydir" != xno; then
AC_MSG_RESULT([$dbuspolicydir])
else
AC_MSG_ERROR([not found (try --with-dbuspolicydir)])
fi
fi
if test x$xauth_pam = xtrue; then
@ -1198,7 +1231,7 @@ if test x$xauth_pam = xtrue; then
fi
if test x$connmark = xtrue -o x$forecast = xtrue; then
PKG_CHECK_MODULES(libiptc, [libiptc])
PKG_CHECK_MODULES(libiptc, [libip4tc])
AC_SUBST(libiptc_CFLAGS)
AC_SUBST(libiptc_LIBS)
fi
@ -1247,6 +1280,11 @@ if test x$bfd_backtraces = xtrue; then
AC_CHECK_LIB([bfd],[bfd_init],[LIBS="$LIBS"],[AC_MSG_ERROR([binutils libbfd not found!])],[])
AC_CHECK_HEADER([bfd.h],[AC_DEFINE([HAVE_BFD_H],,[have binutils bfd.h])],
[AC_MSG_ERROR([binutils bfd.h header not found!])])
AC_CHECK_DECLS(
[bfd_section_flags, bfd_get_section_flags,
bfd_section_vma, bfd_get_section_vma,
bfd_section_size, bfd_get_section_size], [], [],
[[#include <bfd.h>]])
BFDLIB="-lbfd"
AC_SUBST(BFDLIB)
fi
@ -1343,6 +1381,7 @@ if test x$python_eggs = xtrue; then
else
AC_SUBST(PYTHONEGGINSTALLDIR, "--install-dir $pythoneggdir")
fi
AC_PATH_PROG([TOX], [tox], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
AC_PATH_PROG([PY_TEST], [py.test], [], [$PATH:/bin:/usr/bin:/usr/local/bin])
fi
AM_CONDITIONAL(PYTHON_EGGS_INSTALL, [test "x$python_eggs_install" = xtrue])
@ -1360,6 +1399,27 @@ AC_CACHE_CHECK(
)
if test "x$ss_cv_static_plugin_constructors" = xyes; then
static_plugin_constructors=true
if test "$PYTHON" = ":"; then
AC_MSG_FAILURE([Python is required to resolve plugin constructors statically])
fi
fi
AC_MSG_CHECKING([version from Git repository])
AC_SUBST(GIT_VERSION, [$($srcdir/scripts/git-version "$srcdir")])
case "$GIT_VERSION" in
"$PACKAGE_VERSION"*)
AC_MSG_RESULT([$GIT_VERSION])
;;
UNKNOWN)
AC_MSG_RESULT([$GIT_VERSION (could be due to insufficient clone depth)])
;;
*)
AC_MSG_ERROR([$PACKAGE_VERSION is not a prefix of $GIT_VERSION, tag missing?])
;;
esac
if test x$git_version = xtrue -a "$GIT_VERSION" != "UNKNOWN"; then
AC_DEFINE_UNQUOTED(VERSION, ["$GIT_VERSION"])
fi
# ===============================================
@ -1482,6 +1542,7 @@ ADD_PLUGIN([eap-sim-pcsc], [c charon])
ADD_PLUGIN([eap-aka], [c charon])
ADD_PLUGIN([eap-aka-3gpp], [c charon])
ADD_PLUGIN([eap-aka-3gpp2], [c charon])
ADD_PLUGIN([eap-simaka-pcsc], [c charon])
ADD_PLUGIN([eap-simaka-sql], [c charon])
ADD_PLUGIN([eap-simaka-pseudonym], [c charon])
ADD_PLUGIN([eap-simaka-reauth], [c charon])
@ -1653,6 +1714,7 @@ AM_CONDITIONAL(USE_RADATTR, test x$radattr = xtrue)
AM_CONDITIONAL(USE_EAP_SIM, test x$eap_sim = xtrue)
AM_CONDITIONAL(USE_EAP_SIM_FILE, test x$eap_sim_file = xtrue)
AM_CONDITIONAL(USE_EAP_SIM_PCSC, test x$eap_sim_pcsc = xtrue)
AM_CONDITIONAL(USE_EAP_SIMAKA_PCSC, test x$eap_simaka_pcsc = xtrue)
AM_CONDITIONAL(USE_EAP_SIMAKA_SQL, test x$eap_simaka_sql = xtrue)
AM_CONDITIONAL(USE_EAP_SIMAKA_PSEUDONYM, test x$eap_simaka_pseudonym = xtrue)
AM_CONDITIONAL(USE_EAP_SIMAKA_REAUTH, test x$eap_simaka_reauth = xtrue)
@ -1762,7 +1824,8 @@ AM_CONDITIONAL(USE_LEGACY_SYSTEMD, test -n "$systemdsystemunitdir" -a "x$systemd
AM_CONDITIONAL(USE_RUBY_GEMS, test x$ruby_gems = xtrue)
AM_CONDITIONAL(USE_PYTHON_EGGS, test x$python_eggs = xtrue)
AM_CONDITIONAL(USE_PERL_CPAN, test x$perl_cpan = xtrue)
AM_CONDITIONAL(USE_PY_TEST, test "x$PY_TEST" != x)
AM_CONDITIONAL(USE_TOX, test "x$TOX" != x)
AM_CONDITIONAL(USE_PY_TEST, test "x$PY_TEST" != x -a "x$TOX" = x)
# ========================
# set global definitions
@ -1944,6 +2007,7 @@ AC_CONFIG_FILES([
src/libcharon/plugins/eap_sim/Makefile
src/libcharon/plugins/eap_sim_file/Makefile
src/libcharon/plugins/eap_sim_pcsc/Makefile
src/libcharon/plugins/eap_simaka_pcsc/Makefile
src/libcharon/plugins/eap_simaka_sql/Makefile
src/libcharon/plugins/eap_simaka_pseudonym/Makefile
src/libcharon/plugins/eap_simaka_reauth/Makefile

View File

@ -4,7 +4,6 @@ After=syslog.target network-online.target
[Service]
ExecStart=@SBINDIR@/@IPSEC_SCRIPT@ start --nofork
StandardOutput=syslog
Restart=on-abnormal
[Install]

View File

@ -1,19 +0,0 @@
SOURCE:=../../src/frontends/gnome
VERSION:=1.3.1
source: prepare
cd build/NetworkManager-strongswan-$(VERSION) && debuild -S
prepare: clean
mkdir build
make -C $(SOURCE) dist-gzip
mv $(SOURCE)/NetworkManager-strongswan-$(VERSION).tar.gz build/network-manager-strongswan_$(VERSION).orig.tar.gz
tar -zxv -C build -f build/network-manager-strongswan_$(VERSION).orig.tar.gz
dch -b -v $(VERSION)
cp -R debian build/NetworkManager-strongswan-$(VERSION)
clean:
rm -Rf build
.PHONY: source prepare clean

View File

@ -1,54 +0,0 @@
network-manager-strongswan (1.3.1-1) unstable; urgency=low
* New upstream release, adds PSK support
* Invoke charon-nm as IKE backend (Closes: #741415)
* Hand over maintenance to Debian strongSwan Maintainers (pkg-swan)
-- Martin <martin@strongswan.org> Thu, 24 Apr 2014 15:42:39 +0200
network-manager-strongswan (1.3.0-1) unstable; urgency=low
* New upstream release, support for NetworkManager 0.9 (Closes: #639400)
-- Martin Willi <martin@strongswan.org> Mon, 02 Jul 2012 09:55:20 +0200
network-manager-strongswan (1.1.2-2) unstable; urgency=low
* Do not install unused libtool and static libraries
(Closes: #622499)
-- Martin Willi <martin@strongswan.org> Tue, 19 Apr 2011 11:07:10 +0200
network-manager-strongswan (1.1.2-1) unstable; urgency=low
* New upstream release, fixes pkgconfig for new libnm-glib packages
(Closes: #569302)
-- Martin Willi <martin@strongswan.org> Thu, 18 Feb 2010 09:41:39 +0100
network-manager-strongswan (1.1.1-2) unstable; urgency=low
* Added ${shlibs:Depends} dependency
* Reload network-manager after installation, reloading dbus is insufficient.
* Fixed debhelper-but-no-misc-depends, out-of-date-standards-version and
copyright-without-copyright-notice lintian warnings
-- Martin Willi <martin@strongswan.org> Mon, 12 Oct 2009 10:19:40 +0200
network-manager-strongswan (1.1.1-1) unstable; urgency=low
* New upstream release fixing a crasher when saving connections
* Fix "Wrong path to network-manager initscript in postinst"
Reload dbus instead of network-manager, as other VPN plugins do.
(Closes: #529189)
* Fix "FTBFS: No package 'libnm-util' found"
added dependencies to libnm-util-dev and libnm-glib-vpn-dev
(Closes: #528977)
-- Martin Willi <martin@strongswan.org> Tue, 19 May 2009 13:16:51 +0200
network-manager-strongswan (1.1.0-1) unstable; urgency=low
* Initial Debian packaging of NetworkManager plugin for strongSwan
-- Martin Willi <martin@strongswan.org> Wed, 25 Mar 2009 09:07:05 +0100

View File

@ -1,31 +0,0 @@
Source: network-manager-strongswan
Section: net
Priority: extra
Maintainer: strongSwan Maintainers <pkg-swan-devel@lists.alioth.debian.org>
Uploaders: Rene Mayrhofer <rmayr@debian.org>,
Yves-Alexis Perez <corsac@debian.org>,
Romain Francoise <rfrancoise@debian.org>
Build-Depends: cdbs,
debhelper (>= 7),
network-manager-dev (>= 0.9),
libnm-util-dev (>= 0.9),
libnm-glib-dev (>= 0.9),
libnm-glib-vpn-dev (>= 0.9),
libdbus-glib-1-dev,
libgnomeui-dev,
automake,
gnome-common,
Standards-Version: 3.9.1
Package: network-manager-strongswan
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, strongswan-nm, network-manager (>= 0.9)
Description: network management framework (strongSwan plugin)
NetworkManager attempts to keep an active network connection available at
all times. It is intended primarily for laptops where it allows easy
switching between local wireless networks, it's also useful on desktops
with a selection of different interfaces to use. It is not intended for
usage on servers.
.
This package provides a VPN plugin for strongSwan, providing easy access to
IKEv2 IPSec VPN's.

View File

@ -1,10 +0,0 @@
Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=59
Name: NetworkManager-strongswan
Source: http://download.strongswan.org/NetworkManager
Copyright: 2008-2009, Martin Willi <martin@strongswan.org>
2005-2008, Dan Williams
2005, David Zeuthen
License: GPL-2
On Debian systems the full text of the GNU General Public License can be found
in the `/usr/share/common-licenses/GPL-2' file.

View File

@ -1,19 +0,0 @@
#!/bin/sh
set -e
case "$1" in
configure)
if [ -x "/etc/init.d/network-manager" ]; then
if [ -x /usr/sbin/invoke-rc.d ]; then
invoke-rc.d network-manager force-reload || true
else
/etc/init.d/network-manager force-reload || true
fi
fi
;;
esac
#DEBHELPER#
exit 0

View File

@ -1,16 +0,0 @@
#!/usr/bin/make -f
include /usr/share/cdbs/1/rules/debhelper.mk
include /usr/share/cdbs/1/class/autotools.mk
DEB_CONFIGURE_EXTRA_FLAGS := --with-charon=/usr/lib/ipsec/charon-nm
DEB_CONFIGURE_LIBEXECDIR := "\$$(prefix)/lib/NetworkManager"
DEB_DH_MAKESHLIBS_ARGS_ALL := -X/usr/lib/NetworkManager/
DEB_DH_INSTALL_SOURCEDIR := debian/tmp
install/network-manager-strongswan::
rm debian/network-manager-strongswan/usr/lib/NetworkManager/libnm-strongswan-properties.*a

View File

@ -1,19 +0,0 @@
SOURCE=../..
VERSION:=5.0.1dr1
source: prepare
cd build/strongswan-$(VERSION) && debuild -S
prepare: clean
mkdir build
make -C $(SOURCE) dist-gzip
mv $(SOURCE)/strongswan-$(VERSION).tar.gz build/strongswan_$(VERSION).orig.tar.gz
tar -zxv -C build -f build/strongswan_$(VERSION).orig.tar.gz
dch -b -v $(VERSION)
cp -R debian build/strongswan-$(VERSION)
clean:
rm -Rf build
.PHONY: source prepare clean

View File

@ -1,5 +0,0 @@
strongswan (5.0.1dr1) unstable; urgency=low
* New package for strongSwan 5.0 series
-- Martin Willi <martin@strongswan.org> Mon, 02 Jul 2012 18:48:55 +0200

View File

@ -1 +0,0 @@
7

View File

@ -1,61 +0,0 @@
Source: strongswan
Section: net
Priority: extra
Maintainer: Martin Willi <martin@strongswan.org>
Standards-Version: 3.9.2
Build-Depends: debhelper (>= 7.0.0), libssl-dev (>= 0.9.8), libcap-dev, network-manager-dev (>= 0.9), libnm-glib-dev (>= 0.9), libcurl4-openssl-dev | libcurl4-gnutls-dev | libcurl4-nss-dev, libldap2-dev, libmysqlclient-dev, libsqlite3-dev
Homepage: http://www.strongswan.org
Package: strongswan
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: IPsec VPN solution.
strongSwan is a IPsec based VPN solution for the Linux kernel. It uses the
native IPsec stack and runs on any recent 2.6 kernel (no patching required).
It supports both, the IKEv1 and the newer IKEv2 protocols.
.
This package contains the IKEv1/IKEv2 keying daemon charon and command line
configuration backend.
Package: strongswan-tools
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Additional command line tools for strongSwan.
This packages provides pki and other strongSwan utilities.
Package: strongswan-nm
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, network-manager (>= 0.9)
Description: strongSwan plugin to interact with NetworkManager
This plugin provides an interface which allows NetworkManager to configure
and control the IKEv2 daemon directly through DBUS. It is designed to work
in conjunction with the network-manager-strongswan package, providing
a simple graphical frontend to configure IPsec based VPNs.
Package: libstrongswan
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: strongSwan utility and crypto library
libstrongswan is the underlying library of charon and other strongSwan
components. It is built in a modular way and is extendable through various
plugins.
Package: libstrongswan-dev
Architecture: any
Priority: optional
Depends: ${misc:Depends}, libstrongswan (=${binary:Version})
Section: devel
Description: strongSwan development headers
C header files to develop with libstrongswan.
Package: strongswan-dbg
Architecture: any
Section: debug
Priority: extra
Depends: ${misc:Depends}, strongswan, libstrongswan
Description: strongSwan library and binaries - debugging symbols
StrongSwan is an IPsec-based VPN solution for the Linux kernel. It uses the
native IPsec stack and runs on any recent 2.6 kernel (no patching required).
It supports both IKEv1 and the newer IKEv2 protocols.
.
This package provides the symbols needed for debugging of strongswan.

View File

@ -1,2 +0,0 @@
usr/lib/strongswan/include/config.h usr/lib/strongswan/include/
usr/include/strongswan/* usr/include/strongswan/

View File

@ -1,31 +0,0 @@
etc/strongswan.conf etc/
usr/lib/strongswan/libstrongswan.so* usr/lib/strongswan/
usr/lib/strongswan/libcharon.so* usr/lib/strongswan/
usr/lib/strongswan/libtls.so* usr/lib/strongswan/
usr/lib/strongswan/plugins/libstrongswan-x509.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-pubkey.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-xcbc.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-random.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-agent.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-openssl.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-ldap.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-curl.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-kernel-netlink.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-eap-identity.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-eap-mschapv2.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-eap-tls.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-eap-md5.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-pkcs1.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-revocation.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-nonce.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-pkcs8.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-pem.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-socket-default.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-constraints.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-ctr.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-ccm.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-cmac.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-gcm.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-xauth-generic.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-xauth-eap.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-pkcs11.so* usr/lib/strongswan/plugins/

View File

@ -1,71 +0,0 @@
#!/usr/bin/make -f
#export DH_VERBOSE=1
CC = gcc
CFLAGS = -Wall -Wno-format -Wno-pointer-sign -g
CONFIGURE_ARGS = \
--prefix=/usr --libexecdir=/usr/lib --sysconfdir=/etc --enable-curl \
--enable-ldap --disable-aes --disable-des --disable-md5 --disable-sha1 \
--disable-sha2 --disable-fips-prf --disable-gmp --disable-pgp --disable-dnskey \
--enable-mysql --enable-sqlite --enable-eap-identity --enable-eap-md5 \
--enable-eap-mschapv2 --enable-eap-tls --enable-eap-radius --enable-xauth-eap \
--enable-farp --enable-attr-sql --enable-dhcp --enable-openssl --enable-agent \
--enable-pkcs11 --enable-ctr --enable-ccm --enable-gcm --enable-addrblock \
--enable-nm --disable-hmac --with-capabilities=libcap \
--with-ipsecdir=/usr/lib/strongswan --with-ipseclibdir=/usr/lib/strongswan \
--with-dev-headers=/usr/include/strongswan
ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O2
endif
ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
MAKEFLAGS += -j$(NUMJOBS)
endif
ifeq ($(DEB_BUILD_ARCH_CPU),i386)
CONFIGURE_ARGS += --enable-padlock
endif
build:
dh_testdir
./configure $(CONFIGURE_ARGS) CC="$(CC)" CFLAGS="$(CFLAGS)"
$(MAKE)
touch build
clean:
dh_testdir
dh_testroot
rm -f build
[ ! -f Makefile ] || $(MAKE) clean
dh_clean
install: build
dh_testdir
dh_testroot
dh_clean
dh_installdirs
$(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
binary-indep: build install
binary-arch: build install
dh_testdir
dh_testroot
dh_installchangelogs NEWS
dh_installdocs README
dh_installinit --name=ipsec
dh_install -s
dh_link
dh_strip --dbg=strongswan-dbg
dh_compress
dh_fixperms -Xetc/ipsec.secrets -Xetc/ipsec.d
dh_makeshlibs
dh_installdeb
dh_shlibdeps
dh_gencontrol -s
dh_md5sums
dh_builddeb -s
binary: binary-indep binary-arch
.PHONY: build clean binary-indep binary-arch binary install

View File

@ -1 +0,0 @@
usr/lib/strongswan/charon-nm usr/lib/strongswan/

View File

@ -1,133 +0,0 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: vpn
# Required-Start: $network $local_fs
# Required-Stop: $network $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Strongswan IPsec services
### END INIT INFO
# Author: Rene Mayrhofer <rene@mayrhofer.eu.org>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="strongswan IPsec services"
NAME=ipsec
DAEMON=/usr/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- start \
|| return 2
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
# give the proper signal to stop
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- stop \
|| return 2
# but kill if that didn't work
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
do_reload() {
$DAEMON reload
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
$DAEMON status
;;
reload|force-reload)
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
log_end_msg $?
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -1,3 +0,0 @@
usr/lib/strongswan/scepclient usr/lib/strongswan/
usr/lib/strongswan/pki usr/lib/strongswan/
usr/share/man/man8/scepclient.8 usr/share/man/man8/

View File

@ -1,36 +0,0 @@
usr/lib/strongswan/_updown usr/lib/strongswan/
usr/lib/strongswan/_updown_espmark usr/lib/strongswan/
usr/lib/strongswan/starter usr/lib/strongswan/
usr/lib/strongswan/_copyright usr/lib/strongswan/
usr/lib/strongswan/pool usr/lib/strongswan/
usr/lib/strongswan/libradius.so* usr/lib/strongswan/
usr/sbin/ipsec usr/sbin/
etc/ipsec.conf etc/
etc/ipsec.d etc/
etc/ipsec.d/reqs etc/ipsec.d/
etc/ipsec.d/cacerts etc/ipsec.d/
etc/ipsec.d/aacerts etc/ipsec.d/
etc/ipsec.d/acerts etc/ipsec.d/
etc/ipsec.d/ocspcerts etc/ipsec.d/
etc/ipsec.d/private etc/ipsec.d/
etc/ipsec.d/crls etc/ipsec.d/
etc/ipsec.d/certs etc/ipsec.d/
usr/share/man/man8/ipsec.8 usr/share/man/man8/
usr/share/man/man8/_updown.8 usr/share/man/man8/
usr/share/man/man8/_updown_espmark.8 usr/share/man/man8/
usr/share/man/man5/ipsec.conf.5 usr/share/man/man5/
usr/share/man/man5/ipsec.secrets.5 usr/share/man/man5/
usr/share/man/man5/strongswan.conf.5 usr/share/man/man5/
usr/lib/strongswan/charon usr/lib/strongswan/
usr/lib/strongswan/stroke usr/lib/strongswan/
usr/lib/strongswan/plugins/libstrongswan-stroke.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-updown.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-attr-sql.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-mysql.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-sqlite.so usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-addrblock.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-eap-radius.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-dhcp.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-farp.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-attr.so* usr/lib/strongswan/plugins/
usr/lib/strongswan/plugins/libstrongswan-resolve.so* usr/lib/strongswan/plugins/

View File

@ -1,2 +0,0 @@
version=3
http://download.strongswan.org/strongswan-([\d.]+)\.tar\.bz2

View File

@ -1,3 +1,5 @@
EXTRA_DIST = git-version
AM_CPPFLAGS = \
-I$(top_srcdir)/src/libstrongswan \
-I$(top_srcdir)/src/libtls \

View File

@ -196,6 +196,11 @@ int main(int argc, char *argv[])
if (argc > 2)
{
len = atoi(argv[2]);
if (len > (1 << 30))
{
fprintf(stderr, "buffer too large (1 GiB limit)\n");
return 1;
}
}
if (argc > 3)
{

16
scripts/git-version Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
SRCDIR=$1
TARBALL=$SRCDIR/.tarball-git-version
if test -f $TARBALL; then
V=$(cat $TARBALL)
elif test -d $SRCDIR/.git; then
V=$(git -C $SRCDIR describe --tags HEAD 2>/dev/null)
fi
if test -z "$V"; then
V="UNKNOWN"
fi
echo $V

View File

@ -14,6 +14,8 @@
*/
#include <stdio.h>
#include <library.h>
#include <utils/identification.h>
/**
@ -25,6 +27,9 @@ int main(int argc, char *argv[])
chunk_t enc;
int i;
library_init(NULL, "id2sql");
atexit(library_deinit);
if (argc < 2)
{
return -1;
@ -45,6 +50,7 @@ int main(int argc, char *argv[])
printf("%02x", (unsigned int)enc.ptr[i]);
}
printf("'\n");
id->destroy(id);
return 0;
}

View File

@ -56,6 +56,10 @@ int main(int argc, char *argv[])
}
rounds = atoi(argv[3]);
if (rounds < 0 || rounds > (1 << 26))
{ /* arbitrary limit to the number of chunk_t/sigs that fit into 1 GiB */
usage();
}
if (streq(argv[2], "rsa"))
{

View File

@ -1,11 +1,11 @@
#!/bin/sh
# Build script for Travis CI
# Build script for CI
build_botan()
{
# same revision used in the build recipe of the testing environment
BOTAN_REV=2.12.1
BOTAN_DIR=$TRAVIS_BUILD_DIR/../botan
BOTAN_REV=2.18.0
BOTAN_DIR=$DEPS_BUILD_DIR/botan
if test -d "$BOTAN_DIR"; then
return
@ -22,7 +22,8 @@ build_botan()
--disable-modules=locking_allocator"
fi
# disable some larger modules we don't need for the tests
BOTAN_CONFIG="$BOTAN_CONFIG --disable-modules=pkcs11,tls,x509,xmss"
BOTAN_CONFIG="$BOTAN_CONFIG --disable-modules=pkcs11,tls,x509,xmss
--prefix=$DEPS_PREFIX"
git clone https://github.com/randombit/botan.git $BOTAN_DIR &&
cd $BOTAN_DIR &&
@ -36,8 +37,8 @@ build_botan()
build_wolfssl()
{
WOLFSSL_REV=v4.2.0-stable
WOLFSSL_DIR=$TRAVIS_BUILD_DIR/../wolfssl
WOLFSSL_REV=0caf3ba456f1 # v4.7.1r + SHA-3 fix
WOLFSSL_DIR=$DEPS_BUILD_DIR/wolfssl
if test -d "$WOLFSSL_DIR"; then
return
@ -45,10 +46,15 @@ build_wolfssl()
echo "$ build_wolfssl()"
WOLFSSL_CFLAGS="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DES_ECB"
WOLFSSL_CONFIG="--enable-keygen --enable-rsapss --enable-aesccm
--enable-aesctr --enable-des3 --enable-camellia
--enable-curve25519 --enable-ed25519"
WOLFSSL_CFLAGS="-DWOLFSSL_PUBLIC_MP -DWOLFSSL_DES_ECB -DHAVE_AES_ECB \
-DHAVE_ECC_BRAINPOOL -DWOLFSSL_MIN_AUTH_TAG_SZ=8"
WOLFSSL_CONFIG="--prefix=$DEPS_PREFIX
--disable-crypttests --disable-examples
--enable-aesccm --enable-aesctr --enable-camellia
--enable-curve25519 --enable-curve448 --enable-des3
--enable-ecccustcurves --enable-ed25519 --enable-ed448
--enable-keygen --enable-md4 --enable-rsapss --enable-sha3
--enable-shake256"
git clone https://github.com/wolfSSL/wolfssl.git $WOLFSSL_DIR &&
cd $WOLFSSL_DIR &&
@ -63,9 +69,9 @@ build_wolfssl()
build_tss2()
{
TSS2_REV=2.3.1
TSS2_REV=2.4.3
TSS2_PKG=tpm2-tss-$TSS2_REV
TSS2_DIR=$TRAVIS_BUILD_DIR/../$TSS2_PKG
TSS2_DIR=$DEPS_BUILD_DIR/$TSS2_PKG
TSS2_SRC=https://github.com/tpm2-software/tpm2-tss/releases/download/$TSS2_REV/$TSS2_PKG.tar.gz
if test -d "$TSS2_DIR"; then
@ -74,23 +80,24 @@ build_tss2()
echo "$ build_tss2()"
# the default version of libgcrypt in Ubuntu 16.04 is too old
sudo apt-get update -qq && \
sudo apt-get install -qq libgcrypt20-dev &&
curl -L $TSS2_SRC | tar xz -C $TRAVIS_BUILD_DIR/.. &&
curl -L $TSS2_SRC | tar xz -C $DEPS_BUILD_DIR &&
cd $TSS2_DIR &&
./configure --disable-doxygen-doc &&
./configure --prefix=$DEPS_PREFIX --disable-doxygen-doc &&
make -j4 >/dev/null &&
sudo make install >/dev/null &&
sudo ldconfig || exit $?
cd -
}
if test -z $TRAVIS_BUILD_DIR; then
TRAVIS_BUILD_DIR=$PWD
fi
: ${BUILD_DIR=$PWD}
: ${DEPS_BUILD_DIR=$BUILD_DIR/..}
: ${DEPS_PREFIX=/usr/local}
cd $TRAVIS_BUILD_DIR
if [ -e /etc/os-release ]; then
. /etc/os-release
elif [ -e /usr/lib/os-release ]; then
. /usr/lib/os-release
fi
TARGET=check
@ -111,17 +118,17 @@ openssl*)
gcrypt)
CONFIG="--disable-defaults --enable-pki --enable-gcrypt --enable-pkcs1"
export TESTS_PLUGINS="test-vectors pkcs1 gcrypt!"
DEPS="libgcrypt11-dev"
if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "20.04" ]; then
DEPS="libgcrypt20-dev"
else
DEPS="libgcrypt11-dev"
fi
;;
botan)
CONFIG="--disable-defaults --enable-pki --enable-botan --enable-pem"
export TESTS_PLUGINS="test-vectors pem botan!"
# we can't use the old package that comes with Ubuntu so we build from
# the current master until 2.8.0 is released and then probably switch to
# that unless we need newer features (at least 2.7.0 plus PKCS#1 patch is
# currently required)
DEPS=""
if test "$1" = "deps"; then
if test "$1" = "build-deps"; then
build_botan
fi
;;
@ -130,7 +137,7 @@ wolfssl)
export TESTS_PLUGINS="test-vectors pem wolfssl!"
# build with custom options to enable all the features the plugin supports
DEPS=""
if test "$1" = "deps"; then
if test "$1" = "build-deps"; then
build_wolfssl
fi
;;
@ -138,13 +145,21 @@ printf-builtin)
CONFIG="--with-printf-hooks=builtin"
;;
all|coverage|sonarcloud)
if [ "$TEST" = "sonarcloud" ]; then
if [ -z "$SONAR_PROJECT" -o -z "$SONAR_ORGANIZATION" -o -z "$SONAR_TOKEN" ]; then
echo "The SONAR_PROJECT, SONAR_ORGANIZATION and SONAR_TOKEN" \
"environment variables are required to run this test"
exit 1
fi
fi
CONFIG="--enable-all --disable-android-dns --disable-android-log
--disable-kernel-pfroute --disable-keychain
--disable-lock-profiler --disable-padlock --disable-fuzzing
--disable-osx-attr --disable-tkm --disable-uci
--disable-soup --disable-unwind-backtraces
--disable-unwind-backtraces
--disable-svc --disable-dbghelp-backtraces --disable-socket-win
--disable-kernel-wfp --disable-kernel-iph --disable-winhttp"
--disable-kernel-wfp --disable-kernel-iph --disable-winhttp
--disable-python-eggs-install"
# not enabled on the build server
CONFIG="$CONFIG --disable-af-alg"
if test "$TEST" != "coverage"; then
@ -153,13 +168,27 @@ all|coverage|sonarcloud)
# not actually required but configure checks for it
DEPS="$DEPS lcov"
fi
# Botan requires newer compilers, so disable it on Ubuntu 16.04
if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "16.04" ]; then
CONFIG="$CONFIG --disable-botan"
fi
DEPS="$DEPS libcurl4-gnutls-dev libsoup2.4-dev libunbound-dev libldns-dev
libmysqlclient-dev libsqlite3-dev clearsilver-dev libfcgi-dev
libpcsclite-dev libpam0g-dev binutils-dev libunwind8-dev libnm-dev
libjson-c-dev iptables-dev python-pip libtspi-dev libsystemd-dev"
PYDEPS="pytest"
if test "$1" = "deps"; then
build_botan
libldap2-dev libpcsclite-dev libpam0g-dev binutils-dev libnm-dev
libgcrypt20-dev libjson-c-dev python3-pip libtspi-dev libsystemd-dev"
if [ "$ID" = "ubuntu" -a "$VERSION_ID" = "20.04" ]; then
DEPS="$DEPS libiptc-dev"
else
DEPS="$DEPS iptables-dev python3-setuptools"
fi
# tox has dependencies that can't be resolved on 16.04 (even with pip)
if [ "$ID" != "ubuntu" -o "$VERSION_ID" != "16.04" ]; then
PYDEPS="tox"
fi
if test "$1" = "build-deps"; then
if [ "$ID" != "ubuntu" -o "$VERSION_ID" != "16.04" ]; then
build_botan
fi
build_wolfssl
build_tss2
fi
@ -170,7 +199,7 @@ win*)
--enable-constraints --enable-revocation --enable-pem --enable-pkcs1
--enable-pkcs8 --enable-x509 --enable-pubkey --enable-acert
--enable-eap-tnc --enable-eap-ttls --enable-eap-identity
--enable-updown --enable-ext-auth --enable-libipsec
--enable-updown --enable-ext-auth --enable-libipsec --enable-pkcs11
--enable-tnccs-20 --enable-imc-attestation --enable-imv-attestation
--enable-imc-os --enable-imv-os --enable-tnc-imv --enable-tnc-imc
--enable-pki --enable-swanctl --enable-socket-win
@ -178,11 +207,10 @@ win*)
# no make check for Windows binaries unless we run on a windows host
if test "$APPVEYOR" != "True"; then
TARGET=
CCACHE=ccache
else
CONFIG="$CONFIG --enable-openssl"
CFLAGS="$CFLAGS -I/c/OpenSSL-$TEST/include"
LDFLAGS="-L/c/OpenSSL-$TEST"
CFLAGS="$CFLAGS -I$OPENSSL_DIR/include"
LDFLAGS="-L$OPENSSL_DIR"
export LDFLAGS
fi
CFLAGS="$CFLAGS -mno-ms-bitfields"
@ -191,30 +219,37 @@ win*)
win64)
CONFIG="--host=x86_64-w64-mingw32 $CONFIG --enable-dbghelp-backtraces"
DEPS="gcc-mingw-w64-x86-64 binutils-mingw-w64-x86-64 mingw-w64-x86-64-dev $DEPS"
CC="$CCACHE x86_64-w64-mingw32-gcc"
CC="x86_64-w64-mingw32-gcc"
;;
win32)
CONFIG="--host=i686-w64-mingw32 $CONFIG"
DEPS="gcc-mingw-w64-i686 binutils-mingw-w64-i686 mingw-w64-i686-dev $DEPS"
CC="$CCACHE i686-w64-mingw32-gcc"
CC="i686-w64-mingw32-gcc"
;;
esac
;;
osx)
android)
if test "$1" = "deps"; then
git clone git://git.strongswan.org/android-ndk-boringssl.git -b ndk-static \
src/frontends/android/app/src/main/jni/openssl
fi
TARGET=distdir
;;
macos)
# this causes a false positive in ip-packet.c since Xcode 8.3
CFLAGS="$CFLAGS -Wno-address-of-packed-member"
# use the same options as in the Homebrew Formula
CONFIG="--disable-defaults --enable-charon --enable-cmd --enable-constraints
--enable-curl --enable-eap-gtc --enable-eap-identity
--enable-eap-md5 --enable-eap-mschapv2 --enable-ikev1 --enable-ikev2
--enable-kernel-libipsec --enable-kernel-pfkey
--enable-eap-md5 --enable-eap-mschapv2 --enable-farp --enable-ikev1
--enable-ikev2 --enable-kernel-libipsec --enable-kernel-pfkey
--enable-kernel-pfroute --enable-nonce --enable-openssl
--enable-osx-attr --enable-pem --enable-pgp --enable-pkcs1
--enable-pkcs8 --enable-pki --enable-pubkey --enable-revocation
--enable-scepclient --enable-socket-default --enable-sshkey
--enable-stroke --enable-swanctl --enable-unity --enable-updown
--enable-x509 --enable-xauth-generic"
DEPS="bison gettext openssl curl"
DEPS="automake autoconf libtool bison gettext openssl curl"
BREW_PREFIX=$(brew --prefix)
export PATH=$BREW_PREFIX/opt/bison/bin:$PATH
export ACLOCAL_PATH=$BREW_PREFIX/opt/gettext/share/aclocal:$ACLOCAL_PATH
@ -241,10 +276,11 @@ freebsd)
--enable-eap-radius --enable-eap-sim --enable-eap-sim-file
--enable-gcm --enable-ipseckey --enable-kernel-libipsec
--enable-load-tester --enable-ldap --enable-mediation
--enable-mysql --enable-sqlite --enable-tpm --enable-unbound
--enable-unity --enable-xauth-eap --enable-xauth-pam
--with-printf-hooks=builtin --enable-attr-sql --enable-sql"
DEPS="gmp openldap-client libxml2 mysql80-client sqlite3 unbound ldns"
--enable-mysql --enable-sqlite --enable-tpm --enable-tss-tss2
--enable-unbound --enable-unity --enable-xauth-eap --enable-xauth-pam
--with-printf-hooks=builtin --enable-attr-sql --enable-sql
--enable-farp"
DEPS="git gmp openldap-client libxml2 mysql80-client sqlite3 unbound ldns tpm2-tss"
export GPERF=/usr/local/bin/gperf
export LEX=/usr/local/bin/flex
;;
@ -258,7 +294,7 @@ fuzzing)
if test -z "$1"; then
if test -z "$FUZZING_CORPORA"; then
git clone --depth 1 https://github.com/strongswan/fuzzing-corpora.git fuzzing-corpora
export FUZZING_CORPORA=$TRAVIS_BUILD_DIR/fuzzing-corpora
export FUZZING_CORPORA=$BUILD_DIR/fuzzing-corpora
fi
# these are about the same as those on OSS-Fuzz (except for the
# symbolize options and strip_path_prefix)
@ -270,6 +306,17 @@ fuzzing)
symbolize=1:handle_segv=1:fast_unwind_on_fatal=0:external_symbolizer_path=/usr/bin/llvm-symbolizer-3.5
fi
;;
nm|nm-no-glib)
DEPS="gnome-common libsecret-1-dev libgtk-3-dev libnm-dev libnma-dev"
if test "$TEST" = "nm"; then
DEPS="$DEPS libnm-glib-vpn-dev libnm-gtk-dev"
else
CONFIG="$CONFIG --without-libnm-glib"
fi
cd src/frontends/gnome
# don't run ./configure with ./autogen.sh
export NOCONFIGURE=1
;;
dist)
TARGET=distcheck
;;
@ -278,22 +325,83 @@ apidoc)
CONFIG="--disable-defaults"
TARGET=apidoc
;;
lgtm)
if [ -z "$LGTM_PROJECT" -o -z "$LGTM_TOKEN" ]; then
echo "The LGTM_PROJECT and LGTM_TOKEN environment variables" \
"are required to run this test"
exit 0
fi
DEPS="jq"
if test -z "$1"; then
base=$COMMIT_BASE
# after rebases or for new/duplicate branches, the passed base commit
# ID might not be valid
git rev-parse -q --verify $base^{commit}
if [ $? != 0 ]; then
# this will always compare against master, while via base we
# otherwise only contains "new" commits
base=$(git merge-base origin/master ${COMMIT_ID})
fi
base=$(git rev-parse $base)
echo "Starting code review for $COMMIT_ID (base $base) on lgtm.com"
git diff --binary $base > lgtm.patch || exit $?
curl -s -X POST --data-binary @lgtm.patch \
"https://lgtm.com/api/v1.0/codereviews/${LGTM_PROJECT}?base=${base}&external-id=${BUILD_NUMBER}" \
-H 'Content-Type: application/octet-stream' \
-H 'Accept: application/json' \
-H "Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res || exit $?
lgtm_check_url=$(jq -r '."task-result-url"' lgtm.res)
if [ -z "$lgtm_check_url" -o "$lgtm_check_url" = "null" ]; then
cat lgtm.res
exit 1
fi
lgtm_url=$(jq -r '."task-result"."results-url"' lgtm.res)
echo "Progress and full results: ${lgtm_url}"
echo -n "Waiting for completion: "
lgtm_status=pending
while [ "$lgtm_status" = "pending" ]; do
sleep 15
curl -s -X GET "${lgtm_check_url}" \
-H 'Accept: application/json' \
-H "Authorization: Bearer ${LGTM_TOKEN}" > lgtm.res
if [ $? != 0 ]; then
echo -n "-"
continue
fi
echo -n "."
lgtm_status=$(jq -r '.status' lgtm.res)
done
echo ""
if [ "$lgtm_status" != "success" ]; then
lgtm_message=$(jq -r '.["status-message"]' lgtm.res)
echo "Code review failed: ${lgtm_message}"
exit 1
fi
lgtm_new=$(jq -r '.languages[].new' lgtm.res | awk '{t+=$1} END {print t}')
lgtm_fixed=$(jq -r '.languages[].fixed' lgtm.res | awk '{t+=$1} END {print t}')
echo -n "Code review complete: "
printf "%b\n" "\e[1;31m${lgtm_new}\e[0m new alerts, \e[1;32m${lgtm_fixed}\e[0m fixed"
exit $lgtm_new
fi
;;
*)
echo "$0: unknown test $TEST" >&2
exit 1
;;
esac
if test "$1" = "deps"; then
case "$TRAVIS_OS_NAME" in
case "$1" in
deps)
case "$OS_NAME" in
linux)
sudo apt-get update -qq && \
sudo apt-get install -qq bison flex gperf gettext $DEPS
;;
osx)
macos)
brew update && \
# workaround for issue #6352
brew uninstall --force libtool && brew install libtool && \
brew install $DEPS
;;
freebsd)
@ -302,12 +410,17 @@ if test "$1" = "deps"; then
;;
esac
exit $?
fi
if test "$1" = "pydeps"; then
test -z "$PYDEPS" || pip -q install --user $PYDEPS
;;
pydeps)
test -z "$PYDEPS" || pip3 -q install --user $PYDEPS
exit $?
fi
;;
build-deps)
exit
;;
*)
;;
esac
CONFIG="$CONFIG
--disable-dependency-tracking
@ -332,12 +445,6 @@ esac
echo "$ make $TARGET"
case "$TEST" in
sonarcloud)
# there is an issue with the platform detection that causes sonarqube to
# fail on bionic with "ERROR: ld.so: object '...libinterceptor-${PLATFORM}.so'
# from LD_PRELOAD cannot be preloaded (cannot open shared object file)"
# https://jira.sonarsource.com/browse/CPP-2027
BW_PATH=$(dirname $(which build-wrapper-linux-x86-64))
cp $BW_PATH/libinterceptor-x86_64.so $BW_PATH/libinterceptor-haswell.so
# without target, coverage is currently not supported anyway because
# sonarqube only supports gcov, not lcov
build-wrapper-linux-x86-64 --out-dir bw-output make -j4 || exit $?
@ -357,13 +464,24 @@ apidoc)
;;
sonarcloud)
sonar-scanner \
-Dsonar.projectKey=strongswan \
-Dsonar.projectVersion=$(git describe)+${TRAVIS_BUILD_NUMBER} \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.projectKey=${SONAR_PROJECT} \
-Dsonar.organization=${SONAR_ORGANIZATION} \
-Dsonar.login=${SONAR_TOKEN} \
-Dsonar.projectVersion=$(git describe)+${BUILD_NUMBER} \
-Dsonar.sources=. \
-Dsonar.cfamily.threads=2 \
-Dsonar.cfamily.cache.enabled=true \
-Dsonar.cfamily.cache.path=$HOME/.sonar-cache \
-Dsonar.cfamily.build-wrapper-output=bw-output || exit $?
rm -r bw-output .scannerwork
;;
android)
rm -r strongswan-*
cd src/frontends/android
echo "$ ./gradlew build"
NDK_CCACHE=ccache ./gradlew build || exit $?
;;
*)
;;
esac

View File

@ -1,4 +1,8 @@
/*
* Copyright (C) 2020 Pascal Knecht
* Copyright (C) 2020 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* Copyright (C) 2010 Martin Willi
* Copyright (C) 2010 revosec AG
*
@ -33,8 +37,28 @@
static void usage(FILE *out, char *cmd)
{
fprintf(out, "usage:\n");
fprintf(out, " %s --connect <address> --port <port> [--key <key] [--cert <file>]+ [--times <n>]\n", cmd);
fprintf(out, " %s --listen <address> --port <port> --key <key> [--cert <file>]+ [--times <n>]\n", cmd);
fprintf(out, " %s --connect <address> --port <port> [--key <key] [--cert <file>] [--cacert <file>]+ [--times <n>]\n", cmd);
fprintf(out, " %s --listen <address> --port <port> --key <key> --cert <file> [--cacert <file>]+ [--auth-optional] [--times <n>]\n", cmd);
fprintf(out, "\n");
fprintf(out, "options:\n");
fprintf(out, " --help print help and exit\n");
fprintf(out, " --connect <address> connect to a server on dns name or ip address\n");
fprintf(out, " --listen <address> listen on dns name or ip address\n");
fprintf(out, " --port <port> specify the port to use\n");
fprintf(out, " --cert <file> certificate to authenticate itself\n");
fprintf(out, " --key <file> private key to authenticate itself\n");
fprintf(out, " --cacert <file> certificate to verify other peer\n");
fprintf(out, " --auth-optional don't enforce client authentication\n");
fprintf(out, " --times <n> specify the amount of repeated connection establishments\n");
fprintf(out, " --ipv4 use IPv4\n");
fprintf(out, " --ipv6 use IPv6\n");
fprintf(out, " --min-version <version> specify the minimum TLS version, supported versions:\n");
fprintf(out, " 1.0 (default), 1.1, 1.2 and 1.3\n");
fprintf(out, " --max-version <version> specify the maximum TLS version, supported versions:\n");
fprintf(out, " 1.0, 1.1, 1.2 and 1.3 (default)\n");
fprintf(out, " --version <version> set one specific TLS version to use, supported versions:\n");
fprintf(out, " 1.0, 1.1, 1.2 and 1.3\n");
fprintf(out, " --debug <debug level> set debug level, default is 1\n");
}
/**
@ -85,14 +109,17 @@ static identification_t *find_client_id()
* Client routine
*/
static int run_client(host_t *host, identification_t *server,
identification_t *client, int times, tls_cache_t *cache)
identification_t *client, int times, tls_cache_t *cache,
tls_version_t min_version, tls_version_t max_version,
tls_flag_t flags)
{
tls_socket_t *tls;
int fd, res;
while (times == -1 || times-- > 0)
{
fd = socket(AF_INET, SOCK_STREAM, 0);
DBG2(DBG_TLS, "connecting to %#H", host);
fd = socket(host->get_family(host), SOCK_STREAM, 0);
if (fd == -1)
{
DBG1(DBG_TLS, "opening socket failed: %s", strerror(errno));
@ -105,7 +132,8 @@ static int run_client(host_t *host, identification_t *server,
close(fd);
return 1;
}
tls = tls_socket_create(FALSE, server, client, fd, cache, TLS_1_2, TRUE);
tls = tls_socket_create(FALSE, server, client, fd, cache, min_version,
max_version, flags);
if (!tls)
{
close(fd);
@ -125,8 +153,9 @@ static int run_client(host_t *host, identification_t *server,
/**
* Server routine
*/
static int serve(host_t *host, identification_t *server,
int times, tls_cache_t *cache)
static int serve(host_t *host, identification_t *server, identification_t *client,
int times, tls_cache_t *cache, tls_version_t min_version,
tls_version_t max_version, tls_flag_t flags)
{
tls_socket_t *tls;
int fd, cfd;
@ -162,7 +191,8 @@ static int serve(host_t *host, identification_t *server,
}
DBG1(DBG_TLS, "%#H connected", host);
tls = tls_socket_create(TRUE, server, NULL, cfd, cache, TLS_1_2, TRUE);
tls = tls_socket_create(TRUE, server, client, cfd, cache, min_version,
max_version, flags);
if (!tls)
{
close(fd);
@ -207,8 +237,8 @@ static bool load_key(char *filename)
{
private_key_t *key;
key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_RSA,
BUILD_FROM_FILE, filename, BUILD_END);
key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY, KEY_ANY,
BUILD_FROM_FILE, filename, BUILD_END);
if (!key)
{
DBG1(DBG_TLS, "loading key from '%s' failed", filename);
@ -251,11 +281,14 @@ static void cleanup()
*/
static void init()
{
char *plugins;
library_init(NULL, "tls_test");
dbg = dbg_tls;
lib->plugins->load(lib->plugins, PLUGINS);
plugins = getenv("PLUGINS") ?: PLUGINS;
lib->plugins->load(lib->plugins, plugins);
creds = mem_cred_create();
lib->credmgr->add_set(lib->credmgr, &creds->set);
@ -267,8 +300,10 @@ int main(int argc, char *argv[])
{
char *address = NULL;
bool listen = FALSE;
int port = 0, times = -1, res;
identification_t *server, *client;
int port = 0, times = -1, res, family = AF_UNSPEC;
identification_t *server, *client = NULL;
tls_version_t min_version = TLS_SUPPORTED_MIN, max_version = TLS_SUPPORTED_MAX;
tls_flag_t flags = TLS_FLAG_ENCRYPTION_OPTIONAL;
tls_cache_t *cache;
host_t *host;
@ -277,14 +312,21 @@ int main(int argc, char *argv[])
while (TRUE)
{
struct option long_opts[] = {
{"help", no_argument, NULL, 'h' },
{"connect", required_argument, NULL, 'c' },
{"listen", required_argument, NULL, 'l' },
{"port", required_argument, NULL, 'p' },
{"cert", required_argument, NULL, 'x' },
{"key", required_argument, NULL, 'k' },
{"times", required_argument, NULL, 't' },
{"debug", required_argument, NULL, 'd' },
{"help", no_argument, NULL, 'h' },
{"connect", required_argument, NULL, 'c' },
{"listen", required_argument, NULL, 'l' },
{"port", required_argument, NULL, 'p' },
{"cert", required_argument, NULL, 'x' },
{"key", required_argument, NULL, 'k' },
{"cacert", required_argument, NULL, 'f' },
{"times", required_argument, NULL, 't' },
{"ipv4", no_argument, NULL, '4' },
{"ipv6", no_argument, NULL, '6' },
{"min-version", required_argument, NULL, 'm' },
{"max-version", required_argument, NULL, 'M' },
{"version", required_argument, NULL, 'v' },
{"auth-optional", no_argument, NULL, 'n' },
{"debug", required_argument, NULL, 'd' },
{0,0,0,0 }
};
switch (getopt_long(argc, argv, "", long_opts, NULL))
@ -306,6 +348,13 @@ int main(int argc, char *argv[])
return 1;
}
continue;
case 'f':
if (!load_certificate(optarg))
{
return 1;
}
client = identification_create_from_encoding(ID_ANY, chunk_empty);
continue;
case 'l':
listen = TRUE;
/* fall */
@ -326,6 +375,40 @@ int main(int argc, char *argv[])
case 'd':
tls_level = atoi(optarg);
continue;
case '4':
family = AF_INET;
continue;
case '6':
family = AF_INET6;
continue;
case 'm':
if (!enum_from_name(tls_numeric_version_names, optarg,
&min_version))
{
fprintf(stderr, "unknown minimum TLS version: %s\n", optarg);
return 1;
}
continue;
case 'M':
if (!enum_from_name(tls_numeric_version_names, optarg,
&max_version))
{
fprintf(stderr, "unknown maximum TLS version: %s\n", optarg);
return 1;
}
continue;
case 'v':
if (!enum_from_name(tls_numeric_version_names, optarg,
&min_version))
{
fprintf(stderr, "unknown TLS version: %s\n", optarg);
return 1;
}
max_version = min_version;
continue;
case 'n':
flags |= TLS_FLAG_CLIENT_AUTH_OPTIONAL;
continue;
default:
usage(stderr, argv[0]);
return 1;
@ -337,7 +420,7 @@ int main(int argc, char *argv[])
usage(stderr, argv[0]);
return 1;
}
host = host_create_from_dns(address, 0, port);
host = host_create_from_dns(address, family, port);
if (!host)
{
DBG1(DBG_TLS, "resolving hostname %s failed", address);
@ -347,12 +430,15 @@ int main(int argc, char *argv[])
cache = tls_cache_create(100, 30);
if (listen)
{
res = serve(host, server, times, cache);
res = serve(host, server, client, times, cache, min_version,
max_version, flags);
}
else
{
DESTROY_IF(client);
client = find_client_id();
res = run_client(host, server, client, times, cache);
res = run_client(host, server, client, times, cache, min_version,
max_version, flags);
DESTROY_IF(client);
}
cache->destroy(cache);

42
sonar-project.properties Normal file
View File

@ -0,0 +1,42 @@
# exclude these files completely
sonar.exclusions=\
src/manager/templates/static/jquery.js, \
src/include/linux/**, \
src/frontends/**, \
**/data.sql, \
**/test.sql, \
**/tables.sql, \
**/ipsec.sql
# don't report duplications in these files
sonar.cpd.exclusions=\
src/libstrongswan/crypto/proposal/proposal_keywords_static.c, \
src/libstrongswan/settings/settings_parser.*, \
src/libstrongswan/settings/settings_lexer.c, \
src/starter/keywords.c, \
src/starter/parser/parser.*, \
src/starter/parser/lexer.c, \
src/stroke/stroke_keywords.c, \
**/suites/test_*.c, \
**/data.sql
# the following settings are officially only available via UI
# ignore issues in these generated files
sonar.issue.ignore.allfile=a1,a2,a3
sonar.issue.ignore.allfile.a1.fileRegexp=generated by flex
sonar.issue.ignore.allfile.a2.fileRegexp=made by GNU Bison
sonar.issue.ignore.allfile.a3.fileRegexp=produced by gperf
# ignore some rules
sonar.issue.ignore.multicriteria=m1,m2,m3,m4,m5
sonar.issue.ignore.multicriteria.m1.ruleKey=c:SingleDeclarationPerStatement
sonar.issue.ignore.multicriteria.m1.resourceKey=**/*
sonar.issue.ignore.multicriteria.m2.ruleKey=c:FunctionEllipsis
sonar.issue.ignore.multicriteria.m2.resourceKey=**/*
sonar.issue.ignore.multicriteria.m3.ruleKey=c:S936
sonar.issue.ignore.multicriteria.m3.resourceKey=**/*
sonar.issue.ignore.multicriteria.m4.ruleKey=c:S1172
sonar.issue.ignore.multicriteria.m4.resourceKey=**/*
sonar.issue.ignore.multicriteria.m5.ruleKey=plsql:SingleLineCommentsSyntaxCheck
sonar.issue.ignore.multicriteria.m5.resourceKey=**/*

View File

@ -42,6 +42,9 @@ endif
if USE_LIBCHARON
SUBDIRS += libcharon
if USE_KERNEL_NETLINK
SUBDIRS += xfrmi
endif
endif
if USE_FILE_CONFIG
@ -143,7 +146,3 @@ endif
if USE_TPM
SUBDIRS += tpm_extendpcr
endif
if USE_KERNEL_NETLINK
SUBDIRS += xfrmi
endif

View File

@ -58,14 +58,14 @@ static const char *copyright[] = {
NULL,
};
char usage[] = "Usage: ipsec _copyright";
struct option opts[] = {
static const char usage[] = "Usage: ipsec _copyright";
static const struct option opts[] = {
{"help", 0, NULL, 'h',},
{"version", 0, NULL, 'v',},
{0, 0, NULL, 0, },
};
char me[] = "ipsec _copyright"; /* for messages */
static const char me[] = "ipsec _copyright"; /* for messages */
int
main(int argc, char *argv[])

View File

@ -43,7 +43,7 @@
# is the name of the ipsec interface to be used.
#
# PLUTO_REQID
# is the requid of the AH|ESP policy
# is the reqid of the AH|ESP policy
#
# PLUTO_PROTO
# is the negotiated IPsec protocol, ah|esp

View File

@ -134,14 +134,10 @@ static int run()
break;
}
case SIGINT:
{
DBG1(DBG_DMN, "signal of type SIGINT received. Shutting down");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return 0;
}
case SIGTERM:
{
DBG1(DBG_DMN, "signal of type SIGTERM received. Shutting down");
DBG1(DBG_DMN, "%s received, shutting down",
sig == SIGINT ? "SIGINT" : "SIGTERM");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return 0;
}

View File

@ -362,9 +362,8 @@ static child_cfg_t* create_child_cfg(private_cmd_connection_t *this,
}
else
{
child_cfg->add_proposal(child_cfg, proposal_create_default_aead(PROTO_ESP));
child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
child_cfg->add_proposal(child_cfg,
proposal_create_default_aead(PROTO_ESP));
}
while (this->local_ts->remove_first(this->local_ts, (void**)&ts) == SUCCESS)
{

View File

@ -23,7 +23,6 @@ charon_nm_LDADD = \
$(top_builddir)/src/libcharon/libcharon.la \
-lm $(PTHREADLIB) $(ATOMICLIB) $(DLLIB) ${nm_LIBS}
dbusservicedir = $(datadir)/dbus-1/system.d
dbusservice_DATA = nm-strongswan-service.conf
dbuspolicy_DATA = nm-strongswan-service.conf
EXTRA_DIST = $(dbusservice_DATA)
EXTRA_DIST = $(dbuspolicy_DATA)

View File

@ -94,14 +94,10 @@ static void run()
switch (sig)
{
case SIGINT:
{
DBG1(DBG_DMN, "signal of type SIGINT received. Shutting down");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return;
}
case SIGTERM:
{
DBG1(DBG_DMN, "signal of type SIGTERM received. Shutting down");
DBG1(DBG_DMN, "%s received, shutting down",
sig == SIGINT ? "SIGINT" : "SIGTERM");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return;
}
@ -196,9 +192,9 @@ int main(int argc, char *argv[])
"charon-nm.syslog.daemon.default", 1));
charon->load_loggers(charon);
/* use random ports to avoid conflicts with regular charon */
lib->settings->set_int(lib->settings, "charon-nm.port", 0);
lib->settings->set_int(lib->settings, "charon-nm.port_nat_t", 0);
/* default to random ports to avoid conflicts with regular charon */
lib->settings->set_default_str(lib->settings, "charon-nm.port", "0");
lib->settings->set_default_str(lib->settings, "charon-nm.port_nat_t", "0");
DBG1(DBG_DMN, "Starting charon NetworkManager backend (strongSwan "VERSION")");
if (lib->integrity)

View File

@ -14,6 +14,9 @@
* for more details.
*/
#include <sys/types.h>
#include <unistd.h>
#include "nm_service.h"
#include "nm_creds.h"
#include "nm_handler.h"
@ -44,7 +47,7 @@ struct nm_backend_t {
nm_creds_t *creds;
/**
* attribute handler regeisterd at the daemon
* attribute handler registered at the daemon
*/
nm_handler_t *handler;
};
@ -54,12 +57,21 @@ struct nm_backend_t {
*/
static nm_backend_t *nm_backend = NULL;
/**
* Terminate the daemon if signaled by NM
*/
static void terminate(void *plugin, void *arg)
{
kill(getpid(), SIGTERM);
}
/**
* NM plugin processing routine, creates and handles NMVpnServicePlugin
*/
static job_requeue_t run(nm_backend_t *this)
{
this->loop = g_main_loop_new(NULL, FALSE);
g_signal_connect(this->plugin, "quit", G_CALLBACK(terminate), NULL);
g_main_loop_run(this->loop);
return JOB_REQUEUE_NONE;
}

View File

@ -28,8 +28,6 @@
/**
* Initialize the NetworkManager backend.
*
* @return TRUE, if initialization was successful
*/
void nm_backend_register();

View File

@ -77,32 +77,11 @@ struct private_nm_creds_t {
};
/**
* Enumerator for user certificate
* Enumerator for user certificate (lock has to be locked)
*/
static enumerator_t *create_usercert_enumerator(private_nm_creds_t *this,
certificate_type_t cert, key_type_t key)
{
public_key_t *public;
if (cert != CERT_ANY && cert != this->usercert->get_type(this->usercert))
{
return NULL;
}
if (key != KEY_ANY)
{
public = this->usercert->get_public_key(this->usercert);
if (!public)
{
return NULL;
}
if (public->get_type(public) != key)
{
public->destroy(public);
return NULL;
}
public->destroy(public);
}
this->lock->read_lock(this->lock);
return enumerator_create_cleaner(
enumerator_create_single(this->usercert, NULL),
(void*)this->lock->unlock, this->lock);
@ -114,6 +93,8 @@ static enumerator_t *create_usercert_enumerator(private_nm_creds_t *this,
typedef struct {
/** ref to credential credential store */
private_nm_creds_t *this;
/** certificate type we are looking for */
certificate_type_t type;
/** type of key we are looking for */
key_type_t key;
/** CA certificate ID */
@ -131,55 +112,36 @@ CALLBACK(cert_filter, bool,
cert_data_t *data, enumerator_t *orig, va_list args)
{
certificate_t *cert, **out;
public_key_t *public;
VA_ARGS_VGET(args, out);
while (orig->enumerate(orig, &cert))
{
public = cert->get_public_key(cert);
if (!public)
if (certificate_matches(cert, data->type, data->key, data->id))
{
continue;
}
if (data->key != KEY_ANY && public->get_type(public) != data->key)
{
public->destroy(public);
continue;
}
if (data->id && data->id->get_type(data->id) == ID_KEY_ID &&
public->has_fingerprint(public, data->id->get_encoding(data->id)))
{
public->destroy(public);
*out = cert;
return TRUE;
}
public->destroy(public);
if (data->id && !cert->has_subject(cert, data->id))
{
continue;
}
*out = cert;
return TRUE;
}
return FALSE;
}
/**
* Create enumerator for trusted certificates
* Create enumerator for trusted certificates (lock has to be locked)
*/
static enumerator_t *create_trusted_cert_enumerator(private_nm_creds_t *this,
key_type_t key, identification_t *id)
certificate_type_t type, key_type_t key,
identification_t *id)
{
cert_data_t *data;
INIT(data,
.this = this,
.id = id,
.type = type,
.key = key,
.id = id,
);
this->lock->read_lock(this->lock);
return enumerator_create_filter(
this->certs->create_enumerator(this->certs),
cert_filter, data, cert_data_destroy);
@ -189,16 +151,14 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*,
private_nm_creds_t *this, certificate_type_t cert, key_type_t key,
identification_t *id, bool trusted)
{
this->lock->read_lock(this->lock);
if (id && this->usercert &&
id->equals(id, this->usercert->get_subject(this->usercert)))
certificate_matches(this->usercert, cert, key, id))
{
return create_usercert_enumerator(this, cert, key);
}
if (cert == CERT_X509 || cert == CERT_ANY)
{
return create_trusted_cert_enumerator(this, key, id);
}
return NULL;
return create_trusted_cert_enumerator(this, cert, key, id);
}
METHOD(credential_set_t, create_private_enumerator, enumerator_t*,
@ -285,7 +245,7 @@ METHOD(credential_set_t, create_shared_enumerator, enumerator_t*,
{
goto no_secret;
}
if (me && !me->equals(me, this->user))
if (me && !me->matches(me, this->user))
{
goto no_secret;
}

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 2017 Lubomir Rintel
*
* Copyright (C) 2013-2019 Tobias Brunner
* Copyright (C) 2013-2020 Tobias Brunner
* Copyright (C) 2008-2009 Martin Willi
* HSR Hochschule fuer Technik Rapperswil
*
@ -23,11 +23,10 @@
#include <utils/identification.h>
#include <config/peer_cfg.h>
#include <credentials/certificates/x509.h>
#include <networking/tun_device.h>
#include <stdio.h>
G_DEFINE_TYPE(NMStrongswanPlugin, nm_strongswan_plugin, NM_TYPE_VPN_SERVICE_PLUGIN)
/**
* Private data of NMStrongswanPlugin
*/
@ -42,13 +41,17 @@ typedef struct {
nm_creds_t *creds;
/* attribute handler for DNS/NBNS server information */
nm_handler_t *handler;
/* dummy TUN device */
tun_device_t *tun;
/* name of the connection */
char *name;
} NMStrongswanPluginPrivate;
G_DEFINE_TYPE_WITH_PRIVATE(NMStrongswanPlugin, nm_strongswan_plugin, NM_TYPE_VPN_SERVICE_PLUGIN)
#define NM_STRONGSWAN_PLUGIN_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), \
NM_TYPE_STRONGSWAN_PLUGIN, NMStrongswanPluginPrivate))
((NMStrongswanPluginPrivate*) \
nm_strongswan_plugin_get_instance_private (o))
/**
* Convert an address chunk to a GValue
@ -111,7 +114,8 @@ static GVariant* handler_to_variant(nm_handler_t *handler, char *variant_type,
static void signal_ip_config(NMVpnServicePlugin *plugin,
ike_sa_t *ike_sa, child_sa_t *child_sa)
{
NMStrongswanPluginPrivate *priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
NMStrongswanPlugin *pub = (NMStrongswanPlugin*)plugin;
NMStrongswanPluginPrivate *priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(pub);
GVariantBuilder builder, ip4builder, ip6builder;
GVariant *ip4config, *ip6config;
enumerator_t *enumerator;
@ -127,7 +131,18 @@ static void signal_ip_config(NMVpnServicePlugin *plugin,
/* NM apparently requires to know the gateway */
other = ike_sa->get_other_host(ike_sa);
g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_EXT_GATEWAY,
host_to_variant(other));
host_to_variant(other));
/* systemd-resolved requires a device to properly install DNS servers, but
* Netkey does not use one. Passing the physical interface is not ideal,
* as NM fiddles around with it and systemd-resolved likes a separate
* device. So we pass a dummy TUN device along for NM etc. to play with...
*/
if (priv->tun)
{
g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_TUNDEV,
g_variant_new_string (priv->tun->get_name(priv->tun)));
}
/* pass the first virtual IPs we got or use the physical IP */
enumerator = ike_sa->create_virtual_ip_enumerator(ike_sa, TRUE);
@ -239,80 +254,79 @@ static void signal_ip_config(NMVpnServicePlugin *plugin,
*/
static void signal_failure(NMVpnServicePlugin *plugin, NMVpnPluginFailure failure)
{
nm_handler_t *handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin)->handler;
NMStrongswanPlugin *pub = (NMStrongswanPlugin*)plugin;
nm_handler_t *handler = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(pub)->handler;
handler->reset(handler);
nm_vpn_service_plugin_failure(plugin, failure);
}
/**
* Implementation of listener_t.ike_state_change
*/
static bool ike_state_change(listener_t *listener, ike_sa_t *ike_sa,
ike_sa_state_t state)
METHOD(listener_t, ike_state_change, bool,
NMStrongswanPluginPrivate *this, ike_sa_t *ike_sa, ike_sa_state_t state)
{
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
if (private->ike_sa == ike_sa && state == IKE_DESTROYING)
if (this->ike_sa == ike_sa && state == IKE_DESTROYING)
{
signal_failure(private->plugin, NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
return FALSE;
signal_failure(this->plugin, NM_VPN_PLUGIN_FAILURE_LOGIN_FAILED);
}
return TRUE;
}
/**
* Implementation of listener_t.child_state_change
*/
static bool child_state_change(listener_t *listener, ike_sa_t *ike_sa,
child_sa_t *child_sa, child_sa_state_t state)
METHOD(listener_t, child_state_change, bool,
NMStrongswanPluginPrivate *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
child_sa_state_t state)
{
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
if (private->ike_sa == ike_sa && state == CHILD_DESTROYING)
if (this->ike_sa == ike_sa && state == CHILD_DESTROYING)
{
signal_failure(private->plugin, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
return FALSE;
signal_failure(this->plugin, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
}
return TRUE;
}
/**
* Implementation of listener_t.child_updown
*/
static bool child_updown(listener_t *listener, ike_sa_t *ike_sa,
child_sa_t *child_sa, bool up)
METHOD(listener_t, ike_rekey, bool,
NMStrongswanPluginPrivate *this, ike_sa_t *old, ike_sa_t *new)
{
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
if (private->ike_sa == ike_sa)
{
if (up)
{ /* disable initiate-failure-detection hooks */
private->listener.ike_state_change = NULL;
private->listener.child_state_change = NULL;
signal_ip_config(private->plugin, ike_sa, child_sa);
}
else
{
signal_failure(private->plugin, NM_VPN_PLUGIN_FAILURE_CONNECT_FAILED);
return FALSE;
}
}
return TRUE;
}
/**
* Implementation of listener_t.ike_rekey
*/
static bool ike_rekey(listener_t *listener, ike_sa_t *old, ike_sa_t *new)
{
NMStrongswanPluginPrivate *private = (NMStrongswanPluginPrivate*)listener;
if (private->ike_sa == old)
if (this->ike_sa == old)
{ /* follow a rekeyed IKE_SA */
private->ike_sa = new;
this->ike_sa = new;
}
return TRUE;
}
METHOD(listener_t, ike_reestablish_pre, bool,
NMStrongswanPluginPrivate *this, ike_sa_t *old, ike_sa_t *new)
{
if (this->ike_sa == old)
{ /* ignore child state changes during redirects etc. (task migration) */
this->listener.child_state_change = NULL;
}
return TRUE;
}
METHOD(listener_t, ike_reestablish_post, bool,
NMStrongswanPluginPrivate *this, ike_sa_t *old, ike_sa_t *new,
bool initiated)
{
if (this->ike_sa == old && initiated)
{ /* if we get redirected during IKE_AUTH we just migrate to the new SA */
this->ike_sa = new;
/* re-register hooks to detect initiation failures */
this->listener.ike_state_change = _ike_state_change;
this->listener.child_state_change = _child_state_change;
}
return TRUE;
}
METHOD(listener_t, child_updown, bool,
NMStrongswanPluginPrivate *this, ike_sa_t *ike_sa, child_sa_t *child_sa,
bool up)
{
if (this->ike_sa == ike_sa && up)
{
/* disable initiate-failure-detection hooks */
this->listener.ike_state_change = NULL;
this->listener.child_state_change = NULL;
signal_ip_config(this->plugin, ike_sa, child_sa);
}
return TRUE;
}
@ -370,18 +384,223 @@ static identification_t *find_smartcard_key(NMStrongswanPluginPrivate *priv,
return id;
}
/**
* Add a client auth config for certificate authentication
*/
static bool add_auth_cfg_cert(NMStrongswanPluginPrivate *priv,
NMSettingVpn *vpn, peer_cfg_t *peer_cfg,
GError **err)
{
identification_t *id = NULL;
certificate_t *cert = NULL;
auth_cfg_t *auth;
const char *str, *method, *cert_source;
method = nm_setting_vpn_get_data_item(vpn, "method");
cert_source = nm_setting_vpn_get_data_item(vpn, "cert-source") ?: method;
if (streq(cert_source, "smartcard"))
{
char *pin;
pin = (char*)nm_setting_vpn_get_secret(vpn, "password");
if (pin)
{
id = find_smartcard_key(priv, pin);
}
if (!id)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"No usable smartcard certificate found.");
return FALSE;
}
}
/* ... or certificate/private key authentication */
else if ((str = nm_setting_vpn_get_data_item(vpn, "usercert")))
{
public_key_t *public;
private_key_t *private = NULL;
bool agent = streq(cert_source, "agent");
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_FROM_FILE, str, BUILD_END);
if (!cert)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Loading peer certificate failed.");
return FALSE;
}
/* try agent */
str = nm_setting_vpn_get_secret(vpn, "agent");
if (agent && str)
{
public = cert->get_public_key(cert);
if (public)
{
private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
public->get_type(public),
BUILD_AGENT_SOCKET, str,
BUILD_PUBLIC_KEY, public,
BUILD_END);
public->destroy(public);
}
if (!private)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Connecting to SSH agent failed.");
}
}
/* ... or key file */
str = nm_setting_vpn_get_data_item(vpn, "userkey");
if (!agent && str)
{
char *secret;
secret = (char*)nm_setting_vpn_get_secret(vpn, "password");
if (secret)
{
priv->creds->set_key_password(priv->creds, secret);
}
private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
KEY_ANY, BUILD_FROM_FILE, str, BUILD_END);
if (!private)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Loading private key failed.");
}
}
if (private)
{
id = cert->get_subject(cert);
id = id->clone(id);
priv->creds->set_cert_and_key(priv->creds, cert, private);
}
else
{
DESTROY_IF(cert);
return FALSE;
}
}
else
{
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Certificate is missing.");
return FALSE;
}
auth = auth_cfg_create();
if (streq(method, "eap-tls"))
{
auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_EAP);
auth->add(auth, AUTH_RULE_EAP_TYPE, EAP_TLS);
auth->add(auth, AUTH_RULE_AAA_IDENTITY,
identification_create_from_string("%any"));
}
else
{
auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PUBKEY);
}
if (cert)
{
auth->add(auth, AUTH_RULE_SUBJECT_CERT, cert->get_ref(cert));
}
str = nm_setting_vpn_get_data_item(vpn, "local-identity");
if (str)
{
identification_t *local_id;
local_id = identification_create_from_string((char*)str);
if (local_id)
{
id->destroy(id);
id = local_id;
}
}
auth->add(auth, AUTH_RULE_IDENTITY, id);
peer_cfg->add_auth_cfg(peer_cfg, auth, TRUE);
return TRUE;
}
/**
* Add a client auth config for username/password authentication
*/
static bool add_auth_cfg_pw(NMStrongswanPluginPrivate *priv,
NMSettingVpn *vpn, peer_cfg_t *peer_cfg,
GError **err)
{
identification_t *user = NULL, *id = NULL;
auth_cfg_t *auth;
const char *str, *method;
method = nm_setting_vpn_get_data_item(vpn, "method");
str = nm_setting_vpn_get_data_item(vpn, "user");
if (str)
{
user = identification_create_from_string((char*)str);
}
else
{
user = identification_create_from_string("%any");
}
str = nm_setting_vpn_get_data_item(vpn, "local-identity");
if (str)
{
id = identification_create_from_string((char*)str);
}
else
{
id = user->clone(user);
}
str = nm_setting_vpn_get_secret(vpn, "password");
if (streq(method, "psk"))
{
if (strlen(str) < 20)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Pre-shared key is too short.");
user->destroy(user);
id->destroy(id);
return FALSE;
}
priv->creds->set_username_password(priv->creds, id, (char*)str);
}
else
{
priv->creds->set_username_password(priv->creds, user, (char*)str);
}
auth = auth_cfg_create();
auth->add(auth, AUTH_RULE_AUTH_CLASS,
streq(method, "psk") ? AUTH_CLASS_PSK : AUTH_CLASS_EAP);
/* in case EAP-PEAP or EAP-TTLS is used we currently accept any identity */
auth->add(auth, AUTH_RULE_AAA_IDENTITY,
identification_create_from_string("%any"));
auth->add(auth, AUTH_RULE_EAP_IDENTITY, user);
auth->add(auth, AUTH_RULE_IDENTITY, id);
peer_cfg->add_auth_cfg(peer_cfg, auth, TRUE);
return TRUE;
}
/**
* Connect function called from NM via DBUS
*/
static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
GError **err)
{
NMStrongswanPlugin *pub = (NMStrongswanPlugin*)plugin;
NMStrongswanPluginPrivate *priv;
NMSettingConnection *conn;
NMSettingVpn *vpn;
enumerator_t *enumerator;
identification_t *user = NULL, *gateway = NULL;
const char *str;
identification_t *gateway = NULL;
const char *str, *method;
bool virtual, proposal;
proposal_t *prop;
ike_cfg_t *ike_cfg;
@ -390,10 +609,9 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
traffic_selector_t *ts;
ike_sa_t *ike_sa;
auth_cfg_t *auth;
auth_class_t auth_class = AUTH_CLASS_EAP;
certificate_t *cert = NULL;
x509_t *x509;
bool agent = FALSE, smartcard = FALSE, loose_gateway_id = FALSE;
bool loose_gateway_id = FALSE;
ike_cfg_create_t ike = {
.version = IKEV2,
.local = "%any",
@ -404,7 +622,6 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
peer_cfg_create_t peer = {
.cert_policy = CERT_SEND_IF_ASKED,
.unique = UNIQUE_REPLACE,
.keyingtries = 1,
.rekey_time = 36000, /* 10h */
.jitter_time = 600, /* 10min */
.over_time = 600, /* 10min */
@ -418,12 +635,14 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
},
},
.mode = MODE_TUNNEL,
.dpd_action = ACTION_RESTART,
.close_action = ACTION_RESTART,
};
/**
* Read parameters
*/
priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(pub);
conn = NM_SETTING_CONNECTION(nm_connection_get_setting(connection,
NM_TYPE_SETTING_CONNECTION));
vpn = NM_SETTING_VPN(nm_connection_get_setting(connection,
@ -437,6 +656,11 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
priv->name);
DBG4(DBG_CFG, "%s",
nm_setting_to_string(NM_SETTING(vpn)));
if (!priv->tun)
{
DBG1(DBG_CFG, "failed to create dummy TUN device, might affect DNS "
"server installation negatively");
}
ike.remote = (char*)nm_setting_vpn_get_data_item(vpn, "address");
if (!ike.remote || !*ike.remote)
{
@ -444,31 +668,17 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
"Gateway address missing.");
return FALSE;
}
str = nm_setting_vpn_get_data_item(vpn, "server-port");
if (str && strlen(str))
{
ike.remote_port = settings_value_as_int((char*)str, ike.remote_port);
}
str = nm_setting_vpn_get_data_item(vpn, "virtual");
virtual = streq(str, "yes");
str = nm_setting_vpn_get_data_item(vpn, "encap");
ike.force_encap = streq(str, "yes");
str = nm_setting_vpn_get_data_item(vpn, "ipcomp");
child.options |= streq(str, "yes") ? OPT_IPCOMP : 0;
str = nm_setting_vpn_get_data_item(vpn, "method");
if (streq(str, "psk"))
{
auth_class = AUTH_CLASS_PSK;
}
else if (streq(str, "agent"))
{
auth_class = AUTH_CLASS_PUBKEY;
agent = TRUE;
}
else if (streq(str, "key"))
{
auth_class = AUTH_CLASS_PUBKEY;
}
else if (streq(str, "smartcard"))
{
auth_class = AUTH_CLASS_PUBKEY;
smartcard = TRUE;
}
/**
* Register credentials
@ -489,14 +699,6 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
return FALSE;
}
priv->creds->add_certificate(priv->creds, cert);
x509 = (x509_t*)cert;
if (!(x509->get_flags(x509) & X509_CA))
{ /* For a gateway certificate, we use the cert subject as identity. */
gateway = cert->get_subject(cert);
gateway = gateway->clone(gateway);
DBG1(DBG_CFG, "using gateway certificate, identity '%Y'", gateway);
}
}
else
{
@ -504,139 +706,29 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
priv->creds->load_ca_dir(priv->creds, lib->settings->get_str(
lib->settings, "charon-nm.ca_dir", NM_CA_DIR));
}
if (!gateway)
str = nm_setting_vpn_get_data_item(vpn, "remote-identity");
if (str)
{
/* If the user configured a CA certificate, we use the IP/DNS
* of the gateway as its identity. This identity will be used for
* certificate lookup and requires the configured IP/DNS to be
* included in the gateway certificate. */
gateway = identification_create_from_string((char*)str);
}
else if (cert)
{
x509 = (x509_t*)cert;
if (!(x509->get_flags(x509) & X509_CA))
{ /* for server certificates, we use the subject as identity */
gateway = cert->get_subject(cert);
gateway = gateway->clone(gateway);
}
}
if (!gateway || gateway->get_type(gateway) == ID_ANY)
{
/* if the user configured a CA certificate (or an invalid identity),
* we use the IP/hostname of the server */
gateway = identification_create_from_string(ike.remote);
DBG1(DBG_CFG, "using CA certificate, gateway identity '%Y'", gateway);
loose_gateway_id = TRUE;
}
if (auth_class == AUTH_CLASS_EAP ||
auth_class == AUTH_CLASS_PSK)
{
/* username/password or PSK authentication ... */
str = nm_setting_vpn_get_data_item(vpn, "user");
if (str)
{
user = identification_create_from_string((char*)str);
str = nm_setting_vpn_get_secret(vpn, "password");
if (auth_class == AUTH_CLASS_PSK &&
strlen(str) < 20)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"pre-shared key is too short.");
gateway->destroy(gateway);
user->destroy(user);
return FALSE;
}
priv->creds->set_username_password(priv->creds, user, (char*)str);
}
}
if (auth_class == AUTH_CLASS_PUBKEY)
{
if (smartcard)
{
char *pin;
pin = (char*)nm_setting_vpn_get_secret(vpn, "password");
if (pin)
{
user = find_smartcard_key(priv, pin);
}
if (!user)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"no usable smartcard certificate found.");
gateway->destroy(gateway);
return FALSE;
}
}
/* ... or certificate/private key authenitcation */
else if ((str = nm_setting_vpn_get_data_item(vpn, "usercert")))
{
public_key_t *public;
private_key_t *private = NULL;
cert = lib->creds->create(lib->creds, CRED_CERTIFICATE, CERT_X509,
BUILD_FROM_FILE, str, BUILD_END);
if (!cert)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Loading peer certificate failed.");
gateway->destroy(gateway);
return FALSE;
}
/* try agent */
str = nm_setting_vpn_get_secret(vpn, "agent");
if (agent && str)
{
public = cert->get_public_key(cert);
if (public)
{
private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
public->get_type(public),
BUILD_AGENT_SOCKET, str,
BUILD_PUBLIC_KEY, public,
BUILD_END);
public->destroy(public);
}
if (!private)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Connecting to SSH agent failed.");
}
}
/* ... or key file */
str = nm_setting_vpn_get_data_item(vpn, "userkey");
if (!agent && str)
{
char *secret;
secret = (char*)nm_setting_vpn_get_secret(vpn, "password");
if (secret)
{
priv->creds->set_key_password(priv->creds, secret);
}
private = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
KEY_ANY, BUILD_FROM_FILE, str, BUILD_END);
if (!private)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Loading private key failed.");
}
}
if (private)
{
user = cert->get_subject(cert);
user = user->clone(user);
priv->creds->set_cert_and_key(priv->creds, cert, private);
}
else
{
DESTROY_IF(cert);
gateway->destroy(gateway);
return FALSE;
}
}
}
if (!user)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Configuration parameters missing.");
gateway->destroy(gateway);
return FALSE;
}
DBG1(DBG_CFG, "using gateway identity '%Y'", gateway);
/**
* Set up configurations
@ -660,7 +752,6 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
enumerator->destroy(enumerator);
ike_cfg->destroy(ike_cfg);
gateway->destroy(gateway);
user->destroy(user);
return FALSE;
}
ike_cfg->add_proposal(ike_cfg, prop);
@ -679,12 +770,45 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
peer_cfg->add_virtual_ip(peer_cfg, host_create_any(AF_INET));
peer_cfg->add_virtual_ip(peer_cfg, host_create_any(AF_INET6));
}
method = nm_setting_vpn_get_data_item(vpn, "method");
if (streq(method, "cert") ||
streq(method, "eap-tls") ||
streq(method, "key") ||
streq(method, "agent") ||
streq(method, "smartcard"))
{
if (!add_auth_cfg_cert (priv, vpn, peer_cfg, err))
{
peer_cfg->destroy(peer_cfg);
ike_cfg->destroy(ike_cfg);
gateway->destroy(gateway);
return FALSE;
}
}
else if (streq(method, "eap") ||
streq(method, "psk"))
{
if (!add_auth_cfg_pw(priv, vpn, peer_cfg, err))
{
peer_cfg->destroy(peer_cfg);
ike_cfg->destroy(ike_cfg);
gateway->destroy(gateway);
return FALSE;
}
}
else
{
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"Configuration parameters missing.");
peer_cfg->destroy(peer_cfg);
ike_cfg->destroy(ike_cfg);
gateway->destroy(gateway);
return FALSE;
}
auth = auth_cfg_create();
auth->add(auth, AUTH_RULE_AUTH_CLASS, auth_class);
auth->add(auth, AUTH_RULE_IDENTITY, user);
peer_cfg->add_auth_cfg(peer_cfg, auth, TRUE);
auth = auth_cfg_create();
if (auth_class == AUTH_CLASS_PSK)
if (streq(method, "psk"))
{
auth->add(auth, AUTH_RULE_AUTH_CLASS, AUTH_CLASS_PSK);
}
@ -720,15 +844,39 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
}
else
{
child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
child_cfg->add_proposal(child_cfg, proposal_create_default_aead(PROTO_ESP));
child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
}
ts = traffic_selector_create_dynamic(0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, TRUE, ts);
ts = traffic_selector_create_from_cidr("0.0.0.0/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
ts = traffic_selector_create_from_cidr("::/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
str = nm_setting_vpn_get_data_item(vpn, "remote-ts");
if (str && strlen(str))
{
enumerator = enumerator_create_token(str, ";", "");
while (enumerator->enumerate(enumerator, &str))
{
ts = traffic_selector_create_from_cidr((char*)str, 0, 0, 65535);
if (!ts)
{
g_set_error(err, NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
"Invalid remote traffic selector.");
enumerator->destroy(enumerator);
child_cfg->destroy(child_cfg);
peer_cfg->destroy(peer_cfg);
return FALSE;
}
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
}
enumerator->destroy(enumerator);
}
else
{
ts = traffic_selector_create_from_cidr("0.0.0.0/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
ts = traffic_selector_create_from_cidr("::/0", 0, 0, 65535);
child_cfg->add_traffic_selector(child_cfg, FALSE, ts);
}
peer_cfg->add_child_cfg(peer_cfg, child_cfg);
/**
@ -736,26 +884,20 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
*/
ike_sa = charon->ike_sa_manager->checkout_by_config(charon->ike_sa_manager,
peer_cfg);
peer_cfg->destroy(peer_cfg);
if (!ike_sa)
{
peer_cfg->destroy(peer_cfg);
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
"IKE version not supported.");
return FALSE;
}
if (!ike_sa->get_peer_cfg(ike_sa))
{
ike_sa->set_peer_cfg(ike_sa, peer_cfg);
}
peer_cfg->destroy(peer_cfg);
/**
* Register listener, enable initiate-failure-detection hooks
*/
priv->ike_sa = ike_sa;
priv->listener.ike_state_change = ike_state_change;
priv->listener.child_state_change = child_state_change;
charon->bus->add_listener(charon->bus, &priv->listener);
priv->listener.ike_state_change = _ike_state_change;
priv->listener.child_state_change = _child_state_change;
/**
* Initiate
@ -763,7 +905,6 @@ static gboolean connect_(NMVpnServicePlugin *plugin, NMConnection *connection,
child_cfg->get_ref(child_cfg);
if (ike_sa->initiate(ike_sa, child_cfg, 0, NULL, NULL) != SUCCESS)
{
charon->bus->remove_listener(charon->bus, &priv->listener);
charon->ike_sa_manager->checkin_and_destroy(charon->ike_sa_manager, ike_sa);
g_set_error(err, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
@ -781,58 +922,64 @@ static gboolean need_secrets(NMVpnServicePlugin *plugin, NMConnection *connectio
const char **setting_name, GError **error)
{
NMSettingVpn *settings;
const char *method, *path;
const char *method, *cert_source, *path;
bool need_secret = FALSE;
settings = NM_SETTING_VPN(nm_connection_get_setting(connection,
NM_TYPE_SETTING_VPN));
method = nm_setting_vpn_get_data_item(settings, "method");
if (method)
{
if (streq(method, "eap") || streq(method, "psk"))
if (streq(method, "cert") ||
streq(method, "eap-tls") ||
streq(method, "key") ||
streq(method, "agent") ||
streq(method, "smartcard"))
{
if (nm_setting_vpn_get_secret(settings, "password"))
cert_source = nm_setting_vpn_get_data_item(settings, "cert-source");
if (!cert_source)
{
return FALSE;
cert_source = method;
}
}
else if (streq(method, "agent"))
{
if (nm_setting_vpn_get_secret(settings, "agent"))
if (streq(cert_source, "agent"))
{
return FALSE;
need_secret = !nm_setting_vpn_get_secret(settings, "agent");
}
}
else if (streq(method, "key"))
{
path = nm_setting_vpn_get_data_item(settings, "userkey");
if (path)
else if (streq(cert_source, "smartcard"))
{
private_key_t *key;
need_secret = !nm_setting_vpn_get_secret(settings, "password");
}
else
{
need_secret = TRUE;
path = nm_setting_vpn_get_data_item(settings, "userkey");
if (path)
{
private_key_t *key;
/* try to load/decrypt the private key */
key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
KEY_ANY, BUILD_FROM_FILE, path, BUILD_END);
if (key)
{
key->destroy(key);
return FALSE;
}
else if (nm_setting_vpn_get_secret(settings, "password"))
{
return FALSE;
/* try to load/decrypt the private key */
key = lib->creds->create(lib->creds, CRED_PRIVATE_KEY,
KEY_ANY, BUILD_FROM_FILE, path, BUILD_END);
if (key)
{
key->destroy(key);
need_secret = FALSE;
}
else if (nm_setting_vpn_get_secret(settings, "password"))
{
need_secret = FALSE;
}
}
}
}
else if (streq(method, "smartcard"))
else if (streq(method, "eap") ||
streq(method, "psk"))
{
if (nm_setting_vpn_get_secret(settings, "password"))
{
return FALSE;
}
need_secret = !nm_setting_vpn_get_secret(settings, "password");
}
}
*setting_name = NM_SETTING_VPN_SETTING_NAME;
return TRUE;
return need_secret;
}
/**
@ -856,6 +1003,11 @@ static gboolean do_disconnect(gpointer plugin)
enumerator->destroy(enumerator);
charon->controller->terminate_ike(charon->controller, id, FALSE,
controller_cb_empty, NULL, 0);
/* clear secrets as we are asked for new secrets (where we'd find
* the cached secrets from earlier connections) before we clear
* them in connect() */
priv->creds->clear(priv->creds);
return FALSE;
}
}
@ -888,11 +1040,33 @@ static void nm_strongswan_plugin_init(NMStrongswanPlugin *plugin)
priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
priv->plugin = NM_VPN_SERVICE_PLUGIN(plugin);
memset(&priv->listener, 0, sizeof(listener_t));
priv->listener.child_updown = child_updown;
priv->listener.ike_rekey = ike_rekey;
priv->listener.child_updown = _child_updown;
priv->listener.ike_rekey = _ike_rekey;
priv->listener.ike_reestablish_pre = _ike_reestablish_pre;
priv->listener.ike_reestablish_post = _ike_reestablish_post;
charon->bus->add_listener(charon->bus, &priv->listener);
priv->tun = tun_device_create(NULL);
priv->name = NULL;
}
/**
* Destructor
*/
static void nm_strongswan_plugin_dispose(GObject *obj)
{
NMStrongswanPlugin *plugin;
NMStrongswanPluginPrivate *priv;
plugin = NM_STRONGSWAN_PLUGIN(obj);
priv = NM_STRONGSWAN_PLUGIN_GET_PRIVATE(plugin);
if (priv->tun)
{
priv->tun->destroy(priv->tun);
priv->tun = NULL;
}
G_OBJECT_CLASS (nm_strongswan_plugin_parent_class)->dispose (obj);
}
/**
* Class constructor
*/
@ -901,11 +1075,10 @@ static void nm_strongswan_plugin_class_init(
{
NMVpnServicePluginClass *parent_class = NM_VPN_SERVICE_PLUGIN_CLASS(strongswan_class);
g_type_class_add_private(G_OBJECT_CLASS(strongswan_class),
sizeof(NMStrongswanPluginPrivate));
parent_class->connect = connect_;
parent_class->need_secrets = need_secrets;
parent_class->disconnect = disconnect;
G_OBJECT_CLASS(strongswan_class)->dispose = nm_strongswan_plugin_dispose;
}
/**

View File

@ -29,7 +29,7 @@ PLUGINS = \
pem \
socket-default \
openssl \
stroke
vici
all: build_charon

View File

@ -15,7 +15,6 @@ project Build_Common is
"-gnatygAdISuxo",
"-gnata",
"-gnatVa",
"-gnat05",
"-gnatf",
"-fstack-check",
"-gnato",

View File

@ -118,14 +118,10 @@ static void run()
switch (sig)
{
case SIGINT:
{
DBG1(DBG_DMN, "signal of type SIGINT received. Shutting down");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return;
}
case SIGTERM:
{
DBG1(DBG_DMN, "signal of type SIGTERM received. Shutting down");
DBG1(DBG_DMN, "%s received, shutting down",
sig == SIGINT ? "SIGINT" : "SIGTERM");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return;
}
@ -327,9 +323,18 @@ int main(int argc, char *argv[])
goto deinit;
}
if (!register_ca_mapping())
{
DBG1(DBG_DMN, "no CA certificate ID mapping defined - aborting %s", dmn_name);
goto deinit;
}
/* register TKM keymat variant */
keymat_register_constructor(IKEV2, (keymat_constructor_t)tkm_keymat_create);
/* register TKM credential encoder */
lib->encoding->add_encoder(lib->encoding, tkm_encoder_encode);
/* initialize daemon */
if (!charon->initialize(charon, PLUGINS))
{
@ -371,9 +376,6 @@ int main(int argc, char *argv[])
creds = tkm_cred_create();
lib->credmgr->add_set(lib->credmgr, (credential_set_t*)creds);
/* register TKM credential encoder */
lib->encoding->add_encoder(lib->encoding, tkm_encoder_encode);
/* add handler for fatal signals,
* INT and TERM are handled by sigwaitinfo() in run() */
action.sa_flags = 0;
@ -408,6 +410,7 @@ int main(int argc, char *argv[])
deinit:
destroy_dh_mapping();
destroy_ca_mapping();
libcharon_deinit();
tkm_deinit();
unlink_pidfile();

View File

@ -119,6 +119,8 @@ void tkm_deinit()
ees_server_finalize();
ike_finalize();
tkmlib_final();
free(this);
tkm = NULL;

View File

@ -0,0 +1,245 @@
/*
* Copyright (C) 2020 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* Copyright (C) 2020 secunet Security Networks AG
* Copyright (C) 2020 Stefan Berghofer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <errno.h>
#include <crypto/iv/iv_gen.h>
#include <tkm/constants.h>
#include <tkm/client.h>
#include "tkm_aead.h"
#include "tkm_utils.h"
typedef struct private_aead_t private_aead_t;
/**
* AEAD implementation using TKM
*/
struct private_aead_t {
/**
* Public interface
* */
aead_t public;
/**
* Internal IV generator for TKM
*/
iv_gen_t iv_gen;
/**
* ISA context id
*/
isa_id_type isa_ctx_id;
/**
* Block length of encryption algorithm
*/
block_len_type block_len;
/**
* Length of integrity check value
*/
icv_len_type icv_len;
/**
* Length of initialization vector
*/
iv_len_type iv_len;
};
METHOD(iv_gen_t, get_iv, bool,
iv_gen_t *this, uint64_t seq, size_t size, uint8_t *buffer)
{
return TRUE;
}
METHOD(iv_gen_t, allocate_iv, bool,
iv_gen_t *this, uint64_t seq, size_t size, chunk_t *chunk)
{
*chunk = chunk_alloc(size);
return get_iv(this, seq, chunk->len, chunk->ptr);
}
METHOD(aead_t, encrypt, bool,
private_aead_t *this, chunk_t plain, chunk_t assoc,
chunk_t iv, chunk_t *encrypted)
{
aad_plain_type aad_plain;
iv_encrypted_icv_type iv_encrypted_icv;
result_type res;
aad_plain = (aad_plain_type){
.size = assoc.len + plain.len,
};
if (aad_plain.size > sizeof(aad_plain.data))
{
DBG1(DBG_IKE, "%u exceeds buffer size %u, encryption failed (isa: "
"%llu)", aad_plain.size, sizeof(aad_plain.data), this->isa_ctx_id);
return FALSE;
}
memcpy(aad_plain.data, assoc.ptr, assoc.len);
memcpy(aad_plain.data + assoc.len, plain.ptr, plain.len);
res = ike_isa_encrypt(this->isa_ctx_id, assoc.len, aad_plain,
&iv_encrypted_icv);
if (res != TKM_OK)
{
DBG1(DBG_IKE, "encryption failed (isa: %llu)", this->isa_ctx_id);
return FALSE;
}
if (encrypted)
{
sequence_to_chunk(iv_encrypted_icv.data, iv_encrypted_icv.size,
encrypted);
}
else
{
memcpy(plain.ptr, iv_encrypted_icv.data + iv.len,
iv_encrypted_icv.size - iv.len);
}
memcpy(iv.ptr, iv_encrypted_icv.data, iv.len);
return TRUE;
}
METHOD(aead_t, decrypt, bool,
private_aead_t *this, chunk_t encrypted, chunk_t assoc, chunk_t iv,
chunk_t *plain)
{
aad_iv_encrypted_icv_type aad_iv_encrypted_icv;
decrypted_type decrypted;
result_type res;
aad_iv_encrypted_icv = (aad_iv_encrypted_icv_type){
.size = assoc.len + iv.len + encrypted.len,
};
if (aad_iv_encrypted_icv.size > sizeof(aad_iv_encrypted_icv.data))
{
DBG1(DBG_IKE, "%u exceeds buffer size %u, decryption failed (isa: "
"%llu)", aad_iv_encrypted_icv.size,
sizeof(aad_iv_encrypted_icv.data), this->isa_ctx_id);
return FALSE;
}
memcpy(aad_iv_encrypted_icv.data, assoc.ptr, assoc.len);
memcpy(aad_iv_encrypted_icv.data + assoc.len, iv.ptr, iv.len);
memcpy(aad_iv_encrypted_icv.data + assoc.len + iv.len, encrypted.ptr,
encrypted.len);
res = ike_isa_decrypt(this->isa_ctx_id, assoc.len, aad_iv_encrypted_icv,
&decrypted);
if (res != TKM_OK)
{
DBG1(DBG_IKE, "decryption failed (isa: %llu)", this->isa_ctx_id);
return FALSE;
}
if (plain)
{
sequence_to_chunk(decrypted.data, decrypted.size, plain);
}
else
{
memcpy(encrypted.ptr, decrypted.data, decrypted.size);
}
return TRUE;
}
METHOD(aead_t, get_block_size, size_t,
private_aead_t *this)
{
return this->block_len;
}
METHOD(aead_t, get_icv_size, size_t,
private_aead_t *this)
{
return this->icv_len;
}
METHOD(aead_t, get_iv_size, size_t,
private_aead_t *this)
{
return this->iv_len;
}
METHOD(aead_t, get_iv_gen, iv_gen_t*,
private_aead_t *this)
{
return &this->iv_gen;
}
METHOD(aead_t, get_key_size, size_t,
private_aead_t *this)
{
return 1;
}
METHOD(aead_t, set_key, bool,
private_aead_t *this, chunk_t key)
{
return TRUE;
}
METHOD(aead_t, destroy, void,
private_aead_t *this)
{
free(this);
}
/*
* Described in header
*/
aead_t *tkm_aead_create(isa_id_type isa_ctx_id, block_len_type block_len,
icv_len_type icv_len, iv_len_type iv_len)
{
private_aead_t *aead;
INIT(aead,
.public = {
.encrypt = _encrypt,
.decrypt = _decrypt,
.get_block_size = _get_block_size,
.get_icv_size = _get_icv_size,
.get_iv_size = _get_iv_size,
.get_iv_gen = _get_iv_gen,
.get_key_size = _get_key_size,
.set_key = _set_key,
.destroy = _destroy,
},
.iv_gen = {
.get_iv = _get_iv,
.allocate_iv = _allocate_iv,
.destroy = (void *)nop,
},
.isa_ctx_id = isa_ctx_id,
.block_len = block_len,
.icv_len = icv_len,
.iv_len = iv_len,
);
return &aead->public;
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2020 secunet Security Networks AG
* Copyright (C) 2020 Stefan Berghofer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @defgroup tkm-aead aead
* @{ @ingroup tkm
*/
#ifndef TKM_AEAD_H_
#define TKM_AEAD_H_
typedef struct tkm_aead_t tkm_aead_t;
#include <crypto/aead.h>
#include <tkm/types.h>
/**
* Create an AEAD implementation providing encryption and integrity protection
* using TKM.
*
* @param isa_ctx_id id of ISA context to use for encryption/decryption
* @param block_len block length of encryption algorithm
* @param icv_len length of integrity check value
* @param iv_len length of initialization vector
* @return created aead_t object
*/
aead_t *tkm_aead_create(isa_id_type isa_ctx_id, block_len_type block_len,
icv_len_type icv_len, iv_len_type iv_len);
#endif /** TKM_AEAD_H_ @}*/

View File

@ -25,6 +25,7 @@
#include "tkm_utils.h"
#include "tkm_diffie_hellman.h"
#include "tkm_keymat.h"
#include "tkm_aead.h"
typedef struct private_tkm_keymat_t private_tkm_keymat_t;
@ -44,14 +45,9 @@ struct private_tkm_keymat_t {
bool initiator;
/**
* Inbound AEAD.
* AEAD implementation.
*/
aead_t *aead_in;
/**
* Outbound AEAD.
*/
aead_t *aead_out;
aead_t *aead;
/**
* ISA context id.
@ -79,91 +75,6 @@ struct private_tkm_keymat_t {
hash_algorithm_set_t *hash_algorithms;
};
/**
* Create AEAD transforms from given key chunks.
*
* @param in inbound AEAD transform to allocate, NULL if failed
* @param out outbound AEAD transform to allocate, NULL if failed
* @param sk_ai SK_ai key chunk
* @param sk_ar SK_ar key chunk
* @param sk_ei SK_ei key chunk
* @param sk_er SK_er key chunk
* @param enc_alg encryption algorithm to use
* @param int_alg integrity algorithm to use
* @param key_size encryption key size in bytes
* @param initiator TRUE if initiator
*/
static void aead_create_from_keys(aead_t **in, aead_t **out,
const chunk_t * const sk_ai, const chunk_t * const sk_ar,
const chunk_t * const sk_ei, const chunk_t * const sk_er,
const uint16_t enc_alg, const uint16_t int_alg,
const uint16_t key_size, bool initiator)
{
*in = *out = NULL;
signer_t *signer_i, *signer_r;
crypter_t *crypter_i, *crypter_r;
iv_gen_t *ivg_i, *ivg_r;
signer_i = lib->crypto->create_signer(lib->crypto, int_alg);
signer_r = lib->crypto->create_signer(lib->crypto, int_alg);
if (signer_i == NULL || signer_r == NULL)
{
DBG1(DBG_IKE, "%N %N not supported!",
transform_type_names, INTEGRITY_ALGORITHM,
integrity_algorithm_names, int_alg);
return;
}
crypter_i = lib->crypto->create_crypter(lib->crypto, enc_alg, key_size);
crypter_r = lib->crypto->create_crypter(lib->crypto, enc_alg, key_size);
if (crypter_i == NULL || crypter_r == NULL)
{
signer_i->destroy(signer_i);
signer_r->destroy(signer_r);
DBG1(DBG_IKE, "%N %N (key size %d) not supported!",
transform_type_names, ENCRYPTION_ALGORITHM,
encryption_algorithm_names, enc_alg, key_size);
return;
}
DBG4(DBG_IKE, "Sk_ai %B", sk_ai);
if (!signer_i->set_key(signer_i, *sk_ai))
{
return;
}
DBG4(DBG_IKE, "Sk_ar %B", sk_ar);
if (!signer_r->set_key(signer_r, *sk_ar))
{
return;
}
DBG4(DBG_IKE, "Sk_ei %B", sk_ei);
if (!crypter_i->set_key(crypter_i, *sk_ei))
{
return;
}
DBG4(DBG_IKE, "Sk_er %B", sk_er);
if (!crypter_r->set_key(crypter_r, *sk_er))
{
return;
}
ivg_i = iv_gen_create_for_alg(enc_alg);
ivg_r = iv_gen_create_for_alg(enc_alg);
if (!ivg_i || !ivg_r)
{
return;
}
if (initiator)
{
*in = aead_create(crypter_r, signer_r, ivg_r);
*out = aead_create(crypter_i, signer_i, ivg_i);
}
else
{
*in = aead_create(crypter_i, signer_i, ivg_i);
*out = aead_create(crypter_r, signer_r, ivg_r);
}
}
METHOD(keymat_t, get_version, ike_version_t,
private_tkm_keymat_t *this)
{
@ -187,46 +98,15 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
chunk_t nonce_i, chunk_t nonce_r, ike_sa_id_t *id,
pseudo_random_function_t rekey_function, chunk_t rekey_skd)
{
uint16_t enc_alg, int_alg, key_size;
uint64_t nc_id, spi_loc, spi_rem;
chunk_t *nonce, c_ai, c_ar, c_ei, c_er;
chunk_t *nonce;
tkm_diffie_hellman_t *tkm_dh;
dh_id_type dh_id;
nonce_type nonce_rem;
result_type res;
key_type sk_ai, sk_ar, sk_ei, sk_er;
/* Check encryption and integrity algorithms */
if (!proposal->get_algorithm(proposal, ENCRYPTION_ALGORITHM, &enc_alg,
&key_size))
{
DBG1(DBG_IKE, "no %N selected", transform_type_names,
ENCRYPTION_ALGORITHM);
return FALSE;
}
if (encryption_algorithm_is_aead(enc_alg))
{
DBG1(DBG_IKE, "AEAD algorithm %N not supported",
encryption_algorithm_names, enc_alg);
return FALSE;
}
if (!proposal->get_algorithm(proposal, INTEGRITY_ALGORITHM, &int_alg, NULL))
{
DBG1(DBG_IKE, "no %N selected", transform_type_names,
INTEGRITY_ALGORITHM);
return FALSE;
}
if (!(enc_alg == ENCR_AES_CBC && key_size == 256 &&
int_alg == AUTH_HMAC_SHA2_512_256))
{
DBG1(DBG_IKE, "the TKM only supports aes256-sha512 at the moment, "
"please update your configuration");
return FALSE;
}
DBG2(DBG_IKE, "using %N for encryption, %N for integrity",
encryption_algorithm_names, enc_alg, integrity_algorithm_names,
int_alg);
block_len_type block_len;
icv_len_type icv_len;
iv_len_type iv_len;
/* Acquire nonce context id */
nonce = this->initiator ? &nonce_i : &nonce_r;
@ -266,7 +146,7 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
"spi_rem: %llx)", nc_id, dh_id, spi_loc, spi_rem);
res = ike_isa_create(this->isa_ctx_id, this->ae_ctx_id, 1, dh_id, nc_id,
nonce_rem, this->initiator, spi_loc, spi_rem,
&sk_ai, &sk_ar, &sk_ei, &sk_er);
&block_len, &icv_len, &iv_len);
}
else
{
@ -291,8 +171,8 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
this->ae_ctx_id = isa_info.ae_id;
res = ike_isa_create_child(this->isa_ctx_id, isa_info.parent_isa_id, 1,
dh_id, nc_id, nonce_rem, this->initiator,
spi_loc, spi_rem, &sk_ai, &sk_ar, &sk_ei,
&sk_er);
spi_loc, spi_rem, &block_len, &icv_len,
&iv_len);
chunk_free(&rekey_skd);
}
@ -302,25 +182,7 @@ METHOD(keymat_v2_t, derive_ike_keys, bool,
return FALSE;
}
sequence_to_chunk(sk_ai.data, sk_ai.size, &c_ai);
sequence_to_chunk(sk_ar.data, sk_ar.size, &c_ar);
sequence_to_chunk(sk_ei.data, sk_ei.size, &c_ei);
sequence_to_chunk(sk_er.data, sk_er.size, &c_er);
aead_create_from_keys(&this->aead_in, &this->aead_out, &c_ai, &c_ar, &c_ei,
&c_er, enc_alg, int_alg, key_size / 8,
this->initiator);
chunk_clear(&c_ai);
chunk_clear(&c_ar);
chunk_clear(&c_ei);
chunk_clear(&c_er);
if (!this->aead_in || !this->aead_out)
{
DBG1(DBG_IKE, "could not initialize AEAD transforms");
return FALSE;
}
this->aead = tkm_aead_create(this->isa_ctx_id, block_len, icv_len, iv_len);
/* TODO: Add failure handler (see keymat_v2.c) */
@ -380,7 +242,7 @@ METHOD(keymat_v2_t, derive_child_keys, bool,
METHOD(keymat_t, get_aead, aead_t*,
private_tkm_keymat_t *this, bool in)
{
return in ? this->aead_in : this->aead_out;
return this->aead;
}
METHOD(keymat_v2_t, get_auth_octets, bool,
@ -474,8 +336,7 @@ METHOD(keymat_t, destroy, void,
}
DESTROY_IF(this->hash_algorithms);
DESTROY_IF(this->aead_in);
DESTROY_IF(this->aead_out);
DESTROY_IF(this->aead);
chunk_free(&this->auth_payload);
chunk_free(&this->other_init_msg);
free(this);

View File

@ -15,8 +15,11 @@
*/
#include <stdarg.h>
#include <inttypes.h>
#include <daemon.h>
#include <collections/array.h>
#include <collections/hashtable.h>
#include <encoding/payloads/auth_payload.h>
#include <utils/chunk.h>
#include <tkm/types.h>
@ -30,6 +33,8 @@
typedef struct private_tkm_listener_t private_tkm_listener_t;
static hashtable_t *ca_map = NULL;
/**
* Private data of a tkm_listener_t object.
*/
@ -45,7 +50,7 @@ struct private_tkm_listener_t {
/**
* Return id of remote identity.
*
* TODO: Replace this with the lookup for the remote identitiy id.
* TODO: Replace this with the lookup for the remote identity id.
*
* Currently the reqid of the first child SA in peer config of IKE SA is
* returned. Might choose wrong reqid if IKE SA has multiple child configs
@ -90,97 +95,132 @@ static bool build_cert_chain(const ike_sa_t * const ike_sa, cc_id_type cc_id)
rounds = ike_sa->create_auth_cfg_enumerator((ike_sa_t *)ike_sa, FALSE);
while (rounds->enumerate(rounds, &auth))
{
cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
cert = auth->get(auth, AUTH_RULE_CA_CERT);
if (cert)
{
chunk_t enc_user_cert;
ri_id_type ri_id;
certificate_type user_cert;
auth_rule_t rule;
enumerator_t *enumerator;
ca_id_type ca_id;
public_key_t *pubkey;
certificate_type ca_cert;
chunk_t enc_ca_cert, fp;
array_t *im_certs = NULL;
uint64_t *raw_id;
/* set user certificate */
if (!cert->get_encoding(cert, CERT_ASN1_DER, &enc_user_cert))
pubkey = cert->get_public_key(cert);
if (!pubkey)
{
DBG1(DBG_IKE, "unable to extract encoded user certificate");
DBG1(DBG_IKE, "unable to get CA certificate pubkey");
rounds->destroy(rounds);
return FALSE;
}
if (!pubkey->get_fingerprint(pubkey, KEYID_PUBKEY_SHA1, &fp))
{
DBG1(DBG_IKE, "unable to extract CA certificate fingerprint");
rounds->destroy(rounds);
pubkey->destroy(pubkey);
return FALSE;
}
pubkey->destroy(pubkey);
raw_id = ca_map->get(ca_map, &fp);
if (!raw_id || *raw_id == 0)
{
DBG1(DBG_IKE, "error mapping CA certificate (fp: %#B) to "
"ID", &fp);
rounds->destroy(rounds);
return FALSE;
}
ca_id = *raw_id;
if (!cert->get_encoding(cert, CERT_ASN1_DER, &enc_ca_cert))
{
DBG1(DBG_IKE, "unable to extract encoded CA certificate");
rounds->destroy(rounds);
return FALSE;
}
ri_id = get_remote_identity_id(ike_sa->get_peer_cfg((ike_sa_t *)ike_sa));
chunk_to_sequence(&enc_user_cert, &user_cert, sizeof(certificate_type));
chunk_free(&enc_user_cert);
if (ike_cc_set_user_certificate(cc_id, ri_id, 1, user_cert) != TKM_OK)
chunk_to_sequence(&enc_ca_cert, &ca_cert,
sizeof(certificate_type));
chunk_free(&enc_ca_cert);
if (ike_cc_check_ca(cc_id, ca_id, ca_cert) != TKM_OK)
{
DBG1(DBG_IKE, "error setting user certificate of cert chain"
" (cc_id: %llu)", cc_id);
DBG1(DBG_IKE, "CA certificate (fp: %#B, cc_id: %llu) does not"
" match trusted CA (ca_id: %llu)", &fp, cc_id, ca_id);
rounds->destroy(rounds);
return FALSE;
}
/* process intermediate CA certificates */
/* process intermediate CA certificates in reverse order */
enumerator = auth->create_enumerator(auth);
while (enumerator->enumerate(enumerator, &rule, &cert))
{
if (rule == AUTH_RULE_IM_CERT)
{
chunk_t enc_im_cert;
certificate_type im_cert;
if (!cert->get_encoding(cert, CERT_ASN1_DER, &enc_im_cert))
{
DBG1(DBG_IKE, "unable to extract encoded intermediate CA"
" certificate");
rounds->destroy(rounds);
enumerator->destroy(enumerator);
return FALSE;
}
chunk_to_sequence(&enc_im_cert, &im_cert,
sizeof(certificate_type));
chunk_free(&enc_im_cert);
if (ike_cc_add_certificate(cc_id, 1, im_cert) != TKM_OK)
{
DBG1(DBG_IKE, "error adding intermediate certificate to"
" cert chain (cc_id: %llu)", cc_id);
rounds->destroy(rounds);
enumerator->destroy(enumerator);
return FALSE;
}
array_insert_create(&im_certs, ARRAY_TAIL, cert);
}
}
enumerator->destroy(enumerator);
/* finally add CA certificate */
cert = auth->get(auth, AUTH_RULE_CA_CERT);
while (array_remove(im_certs, ARRAY_TAIL, &cert))
{
chunk_t enc_im_cert;
certificate_type im_cert;
if (!cert->get_encoding(cert, CERT_ASN1_DER, &enc_im_cert))
{
DBG1(DBG_IKE, "unable to extract encoded intermediate CA"
" certificate");
rounds->destroy(rounds);
array_destroy(im_certs);
return FALSE;
}
chunk_to_sequence(&enc_im_cert, &im_cert,
sizeof(certificate_type));
chunk_free(&enc_im_cert);
if (ike_cc_add_certificate(cc_id, 1, im_cert) != TKM_OK)
{
DBG1(DBG_IKE, "error adding intermediate certificate to"
" cert chain (cc_id: %llu)", cc_id);
rounds->destroy(rounds);
array_destroy(im_certs);
return FALSE;
}
}
array_destroy(im_certs);
/* finally add user certificate and check chain */
cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
if (cert)
{
const ca_id_type ca_id = 1;
certificate_type ca_cert;
chunk_t enc_ca_cert;
chunk_t enc_user_cert;
ri_id_type ri_id;
certificate_type user_cert;
if (!cert->get_encoding(cert, CERT_ASN1_DER, &enc_ca_cert))
/* set user certificate */
if (!cert->get_encoding(cert, CERT_ASN1_DER, &enc_user_cert))
{
DBG1(DBG_IKE, "unable to extract encoded CA certificate");
DBG1(DBG_IKE, "unable to extract encoded user certificate");
rounds->destroy(rounds);
return FALSE;
}
chunk_to_sequence(&enc_ca_cert, &ca_cert,
sizeof(certificate_type));
chunk_free(&enc_ca_cert);
if (ike_cc_add_certificate(cc_id, 1, ca_cert) != TKM_OK)
chunk_to_sequence(&enc_user_cert, &user_cert, sizeof(certificate_type));
chunk_free(&enc_user_cert);
if (ike_cc_add_certificate(cc_id, 1, user_cert) != TKM_OK)
{
DBG1(DBG_IKE, "error adding CA certificate to cert chain "
"(cc_id: %llu)", cc_id);
DBG1(DBG_IKE, "error adding user certificate to cert chain"
" (cc_id: %llu)", cc_id);
rounds->destroy(rounds);
return FALSE;
}
if (ike_cc_check_ca(cc_id, ca_id) != TKM_OK)
ri_id = get_remote_identity_id(ike_sa->get_peer_cfg((ike_sa_t *)ike_sa));
if (ike_cc_check_chain(cc_id, ri_id) != TKM_OK)
{
DBG1(DBG_IKE, "certificate chain (cc_id: %llu) not based on"
" trusted CA (ca_id: %llu)", cc_id, ca_id);
DBG1(DBG_IKE, "error checking cert chain (cc_id: %llu)", cc_id);
rounds->destroy(rounds);
return FALSE;
}
@ -190,12 +230,12 @@ static bool build_cert_chain(const ike_sa_t * const ike_sa, cc_id_type cc_id)
}
else
{
DBG1(DBG_IKE, "no CA certificate");
DBG1(DBG_IKE, "no subject certificate for remote peer");
}
}
else
{
DBG1(DBG_IKE, "no subject certificate for remote peer");
DBG1(DBG_IKE, "no CA certificate");
}
}
@ -368,3 +408,112 @@ tkm_listener_t *tkm_listener_create()
return &this->public;
}
static u_int hash(const chunk_t *key)
{
return chunk_hash(*key);
}
static bool equals(const chunk_t *key, const chunk_t *other_key)
{
return chunk_equals(*key, *other_key);
}
static u_int id_hash(const uint64_t *key)
{
return chunk_hash(chunk_create((u_char*)key, sizeof(uint64_t)));
}
static bool id_equals(const uint64_t *key, const uint64_t *other_key)
{
return *key == *other_key;
}
/*
* Described in header.
*/
int register_ca_mapping()
{
char *section, *tkm_ca_id_str, *key_fp_str;
chunk_t *key_fp;
uint64_t *tkm_ca_id;
hashtable_t *id_map;
enumerator_t *enumerator;
bool err = FALSE;
ca_map = hashtable_create((hashtable_hash_t)hash,
(hashtable_equals_t)equals, 8);
id_map = hashtable_create((hashtable_hash_t)id_hash,
(hashtable_equals_t)id_equals, 8);
enumerator = lib->settings->create_section_enumerator(lib->settings,
"%s.ca_mapping",
lib->ns);
while (enumerator->enumerate(enumerator, &section))
{
tkm_ca_id_str = lib->settings->get_str(lib->settings,
"%s.ca_mapping.%s.id", NULL,
lib->ns, section);
tkm_ca_id = malloc_thing(uint64_t);
*tkm_ca_id = settings_value_as_uint64(tkm_ca_id_str, 0);
key_fp_str = lib->settings->get_str(lib->settings,
"%s.ca_mapping.%s.fingerprint", NULL,
lib->ns, section);
if (key_fp_str)
{
key_fp = malloc_thing(chunk_t);
*key_fp = chunk_from_hex(chunk_from_str(key_fp_str), NULL);
}
if (!*tkm_ca_id || !key_fp_str || !key_fp->len ||
id_map->get(id_map, tkm_ca_id) != NULL)
{
DBG1(DBG_CFG, "error adding CA ID mapping '%s': ID %s, FP '%s'",
section, tkm_ca_id_str, key_fp_str);
free(tkm_ca_id);
if (key_fp_str)
{
chunk_free(key_fp);
free(key_fp);
}
err = TRUE;
}
else
{
DBG2(DBG_CFG, "adding CA ID mapping '%s': ID %" PRIu64 ", FP '%#B'",
section, *tkm_ca_id, key_fp);
ca_map->put(ca_map, key_fp, tkm_ca_id);
/* track CA IDs for uniqueness, set value to not-NULL */
id_map->put(id_map, tkm_ca_id, id_map);
}
}
enumerator->destroy(enumerator);
id_map->destroy(id_map);
return err ? 0 : ca_map->get_count(ca_map);
}
/*
* Described in header.
*/
void destroy_ca_mapping()
{
enumerator_t *enumerator;
chunk_t *key;
uint64_t *value;
if (ca_map)
{
enumerator = ca_map->create_enumerator(ca_map);
while (enumerator->enumerate(enumerator, &key, &value))
{
chunk_free(key);
free(key);
free(value);
}
enumerator->destroy(enumerator);
ca_map->destroy(ca_map);
}
ca_map = NULL;
}

View File

@ -42,6 +42,18 @@ struct tkm_listener_t {
void (*destroy)(tkm_listener_t *this);
};
/**
* Loads CA certificate fingerprint to TKM CA id mapping from config.
*
* @return number of registered mappings
*/
int register_ca_mapping();
/**
* Destroy CA certificate fingerprint to TKM CA id mapping.
*/
void destroy_ca_mapping();
/**
* Create a tkm_listener instance.
*

View File

@ -126,14 +126,10 @@ static void run()
break;
}
case SIGINT:
{
DBG1(DBG_DMN, "signal of type SIGINT received. Shutting down");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return;
}
case SIGTERM:
{
DBG1(DBG_DMN, "signal of type SIGTERM received. Shutting down");
DBG1(DBG_DMN, "%s received, shutting down",
sig == SIGINT ? "SIGINT" : "SIGTERM");
charon->bus->alert(charon->bus, ALERT_SHUTDOWN_SIGNAL, sig);
return;
}

View File

@ -108,7 +108,7 @@ The following CHILD_SA specific configuration options are supported:
lts: Local side traffic selectors, comma separated CIDR subnets
rts: Remote side traffic selectors, comma separated CIDR subnets
transport: Propose IPsec transport mode instead of tunnel mode
tfc_padding: Inject Traffic Flow Confidentialty bytes to align packets to the
tfc_padding: Inject Traffic Flow Confidentiality bytes to align packets to the
given length
proposal: CHILD_SA proposal list, same syntax as IKE_SA proposal list
@ -271,7 +271,7 @@ Currently, the following hooks are defined with the following options:
request: yes to set in request, no in response
id: IKEv2 message identifier of message to mangle
from: proposal number to mangle
to: new porposal number to set instead of from
to: new proposal number to set instead of from
set_reserved: set arbitrary reserved bits/bytes in payloads
request: yes to set in request, no in response
id: IKEv2 message identifier of message to mangle

View File

@ -192,9 +192,8 @@ static child_cfg_t *load_child_config(private_config_t *this,
}
else
{
child_cfg->add_proposal(child_cfg, proposal_create_default_aead(PROTO_ESP));
child_cfg->add_proposal(child_cfg, proposal_create_default(PROTO_ESP));
child_cfg->add_proposal(child_cfg,
proposal_create_default_aead(PROTO_ESP));
}
token = settings->get_str(settings, "configs.%s.%s.lts", NULL, config, child);

View File

@ -129,7 +129,7 @@ static bool load_cert(settings_t *settings, bool trusted)
}
/**
* Load certificates from the confiuguration file
* Load certificates from the configuration file
*/
static bool load_certs(settings_t *settings, char *dir)
{
@ -163,7 +163,7 @@ static bool load_certs(settings_t *settings, char *dir)
}
/**
* Load private keys from the confiuguration file
* Load private keys from the configuration file
*/
static bool load_keys(settings_t *settings, char *dir)
{
@ -382,7 +382,7 @@ static void load_log_levels(file_logger_t *logger, char *section)
static void load_logger_options(file_logger_t *logger, char *section)
{
char *time_format;
bool add_ms, ike_name;
bool add_ms, ike_name, log_level;
time_format = conftest->test->get_str(conftest->test,
"log.%s.time_format", NULL, section);
@ -390,8 +390,10 @@ static void load_logger_options(file_logger_t *logger, char *section)
"log.%s.time_add_ms", FALSE, section);
ike_name = conftest->test->get_bool(conftest->test,
"log.%s.ike_name", FALSE, section);
log_level = conftest->test->get_bool(conftest->test,
"log.%s.log_level", FALSE, section);
logger->set_options(logger, time_format, add_ms, ike_name);
logger->set_options(logger, time_format, add_ms, ike_name, log_level);
}
/**
@ -457,7 +459,7 @@ int main(int argc, char *argv[])
lib->credmgr->add_set(lib->credmgr, &conftest->creds->set);
logger = file_logger_create("stdout");
logger->set_options(logger, NULL, FALSE, FALSE);
logger->set_options(logger, NULL, FALSE, FALSE, FALSE);
logger->open(logger, FALSE, FALSE);
logger->set_level(logger, DBG_ANY, LEVEL_CTRL);
charon->bus->add_logger(charon->bus, &logger->logger);

View File

@ -1,14 +1,14 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 29
defaultConfig {
applicationId "org.strongswan.android"
minSdkVersion 15
targetSdkVersion 28
versionCode 69
versionName "2.2.1"
targetSdkVersion 29
versionCode 74
versionName "2.3.2"
}
sourceSets.main {
@ -46,9 +46,13 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.28.2'
testImplementation 'org.powermock:powermock-core:2.0.2'
testImplementation 'org.powermock:powermock-module-junit4:2.0.2'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012-2018 Tobias Brunner
Copyright (C) 2012-2020 Tobias Brunner
Copyright (C) 2012 Giuliano Grassi
Copyright (C) 2012 Ralf Sager
HSR Hochschule fuer Technik Rapperswil
@ -16,12 +16,14 @@
for more details.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.strongswan.android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<application
android:name=".logic.StrongSwanApplication"
@ -140,7 +142,7 @@
android:name=".ui.TrustedCertificateImportActivity"
android:label="@string/import_certificate"
android:theme="@style/TransparentActivity" >
<intent-filter>
<intent-filter tools:ignore="AppLinkUrlError">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="application/x-x509-ca-cert" />

View File

@ -36,6 +36,7 @@ public class VpnProfile implements Cloneable
public static final int FLAGS_DISABLE_OCSP = 1 << 2;
public static final int FLAGS_STRICT_REVOCATION = 1 << 3;
public static final int FLAGS_RSA_PSS = 1 << 4;
public static final int FLAGS_IPv6_TRANSPORT = 1 << 5;
private String mName, mGateway, mUsername, mPassword, mCertificate, mUserCertificate;
private String mRemoteId, mLocalId, mExcludedSubnets, mIncludedSubnets, mSelectedApps;

View File

@ -235,7 +235,7 @@ public class VpnProfileDataSource
{
ContentValues values = new ContentValues();
values.put(KEY_UUID, UUID.randomUUID().toString());
db.update(TABLE_VPNPROFILE, values, KEY_ID + " = " + cursor.getLong(cursor.getColumnIndex(KEY_ID)), null);
db.update(TABLE_VPNPROFILE, values, KEY_ID + " = " + cursor.getLong(cursor.getColumnIndexOrThrow(KEY_ID)), null);
}
cursor.close();
db.setTransactionSuccessful();
@ -433,29 +433,29 @@ public class VpnProfileDataSource
private VpnProfile VpnProfileFromCursor(Cursor cursor)
{
VpnProfile profile = new VpnProfile();
profile.setId(cursor.getLong(cursor.getColumnIndex(KEY_ID)));
profile.setUUID(UUID.fromString(cursor.getString(cursor.getColumnIndex(KEY_UUID))));
profile.setName(cursor.getString(cursor.getColumnIndex(KEY_NAME)));
profile.setGateway(cursor.getString(cursor.getColumnIndex(KEY_GATEWAY)));
profile.setVpnType(VpnType.fromIdentifier(cursor.getString(cursor.getColumnIndex(KEY_VPN_TYPE))));
profile.setUsername(cursor.getString(cursor.getColumnIndex(KEY_USERNAME)));
profile.setPassword(cursor.getString(cursor.getColumnIndex(KEY_PASSWORD)));
profile.setCertificateAlias(cursor.getString(cursor.getColumnIndex(KEY_CERTIFICATE)));
profile.setUserCertificateAlias(cursor.getString(cursor.getColumnIndex(KEY_USER_CERTIFICATE)));
profile.setMTU(getInt(cursor, cursor.getColumnIndex(KEY_MTU)));
profile.setPort(getInt(cursor, cursor.getColumnIndex(KEY_PORT)));
profile.setSplitTunneling(getInt(cursor, cursor.getColumnIndex(KEY_SPLIT_TUNNELING)));
profile.setLocalId(cursor.getString(cursor.getColumnIndex(KEY_LOCAL_ID)));
profile.setRemoteId(cursor.getString(cursor.getColumnIndex(KEY_REMOTE_ID)));
profile.setExcludedSubnets(cursor.getString(cursor.getColumnIndex(KEY_EXCLUDED_SUBNETS)));
profile.setIncludedSubnets(cursor.getString(cursor.getColumnIndex(KEY_INCLUDED_SUBNETS)));
profile.setSelectedAppsHandling(getInt(cursor, cursor.getColumnIndex(KEY_SELECTED_APPS)));
profile.setSelectedApps(cursor.getString(cursor.getColumnIndex(KEY_SELECTED_APPS_LIST)));
profile.setNATKeepAlive(getInt(cursor, cursor.getColumnIndex(KEY_NAT_KEEPALIVE)));
profile.setFlags(getInt(cursor, cursor.getColumnIndex(KEY_FLAGS)));
profile.setIkeProposal(cursor.getString(cursor.getColumnIndex(KEY_IKE_PROPOSAL)));
profile.setEspProposal(cursor.getString(cursor.getColumnIndex(KEY_ESP_PROPOSAL)));
profile.setDnsServers(cursor.getString(cursor.getColumnIndex(KEY_DNS_SERVERS)));
profile.setId(cursor.getLong(cursor.getColumnIndexOrThrow(KEY_ID)));
profile.setUUID(UUID.fromString(cursor.getString(cursor.getColumnIndexOrThrow(KEY_UUID))));
profile.setName(cursor.getString(cursor.getColumnIndexOrThrow(KEY_NAME)));
profile.setGateway(cursor.getString(cursor.getColumnIndexOrThrow(KEY_GATEWAY)));
profile.setVpnType(VpnType.fromIdentifier(cursor.getString(cursor.getColumnIndexOrThrow(KEY_VPN_TYPE))));
profile.setUsername(cursor.getString(cursor.getColumnIndexOrThrow(KEY_USERNAME)));
profile.setPassword(cursor.getString(cursor.getColumnIndexOrThrow(KEY_PASSWORD)));
profile.setCertificateAlias(cursor.getString(cursor.getColumnIndexOrThrow(KEY_CERTIFICATE)));
profile.setUserCertificateAlias(cursor.getString(cursor.getColumnIndexOrThrow(KEY_USER_CERTIFICATE)));
profile.setMTU(getInt(cursor, cursor.getColumnIndexOrThrow(KEY_MTU)));
profile.setPort(getInt(cursor, cursor.getColumnIndexOrThrow(KEY_PORT)));
profile.setSplitTunneling(getInt(cursor, cursor.getColumnIndexOrThrow(KEY_SPLIT_TUNNELING)));
profile.setLocalId(cursor.getString(cursor.getColumnIndexOrThrow(KEY_LOCAL_ID)));
profile.setRemoteId(cursor.getString(cursor.getColumnIndexOrThrow(KEY_REMOTE_ID)));
profile.setExcludedSubnets(cursor.getString(cursor.getColumnIndexOrThrow(KEY_EXCLUDED_SUBNETS)));
profile.setIncludedSubnets(cursor.getString(cursor.getColumnIndexOrThrow(KEY_INCLUDED_SUBNETS)));
profile.setSelectedAppsHandling(getInt(cursor, cursor.getColumnIndexOrThrow(KEY_SELECTED_APPS)));
profile.setSelectedApps(cursor.getString(cursor.getColumnIndexOrThrow(KEY_SELECTED_APPS_LIST)));
profile.setNATKeepAlive(getInt(cursor, cursor.getColumnIndexOrThrow(KEY_NAT_KEEPALIVE)));
profile.setFlags(getInt(cursor, cursor.getColumnIndexOrThrow(KEY_FLAGS)));
profile.setIkeProposal(cursor.getString(cursor.getColumnIndexOrThrow(KEY_IKE_PROPOSAL)));
profile.setEspProposal(cursor.getString(cursor.getColumnIndexOrThrow(KEY_ESP_PROPOSAL)));
profile.setDnsServers(cursor.getString(cursor.getColumnIndexOrThrow(KEY_DNS_SERVERS)));
return profile;
}

View File

@ -35,7 +35,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.preference.PreferenceManager;
import android.security.KeyChain;
import android.security.KeyChainException;
import android.system.OsConstants;
@ -77,6 +76,7 @@ import java.util.SortedSet;
import androidx.core.app.NotificationCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
public class CharonVpnService extends VpnService implements Runnable, VpnStateService.VpnStateListener
{
@ -288,7 +288,8 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
SimpleFetcher.enable();
addNotification();
mBuilderAdapter.setProfile(mCurrentProfile);
if (initializeCharon(mBuilderAdapter, mLogFile, mAppDir, mCurrentProfile.getVpnType().has(VpnTypeFeature.BYOD)))
if (initializeCharon(mBuilderAdapter, mLogFile, mAppDir, mCurrentProfile.getVpnType().has(VpnTypeFeature.BYOD),
(mCurrentProfile.getFlags() & VpnProfile.FLAGS_IPv6_TRANSPORT) != 0))
{
Log.i(TAG, "charon started");
@ -775,9 +776,10 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
* @param logfile absolute path to the logfile
* @param appdir absolute path to the data directory of the app
* @param byod enable BYOD features
* @param ipv6 enable IPv6 transport
* @return TRUE if initialization was successful
*/
public native boolean initializeCharon(BuilderAdapter builder, String logfile, String appdir, boolean byod);
public native boolean initializeCharon(BuilderAdapter builder, String logfile, String appdir, boolean byod, boolean ipv6);
/**
* Deinitialize charon, provided by libandroidbridge.so
@ -820,6 +822,12 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
PendingIntent pending = PendingIntent.getActivity(context, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
builder.setConfigureIntent(pending);
/* mark all VPN connections as unmetered (default changed for Android 10) */
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
{
builder.setMetered(false);
}
return builder;
}

View File

@ -21,7 +21,6 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
import android.os.Build;
@ -126,10 +125,12 @@ public class NetworkManager extends BroadcastReceiver implements Runnable
}
}
@SuppressWarnings("deprecation")
public boolean isConnected()
{
/* deprecated since API level 29 */
ConnectivityManager cm = (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = null;
android.net.NetworkInfo info = null;
if (cm != null)
{
info = cm.getActiveNetworkInfo();

View File

@ -0,0 +1,169 @@
/*
* Copyright (C) 2020 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
package org.strongswan.android.logic;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Build;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.UUID;
import androidx.annotation.RequiresApi;
public class Scheduler extends BroadcastReceiver
{
private final String EXECUTE_JOB = "org.strongswan.android.Scheduler.EXECUTE_JOB";
private final Context mContext;
private final AlarmManager mManager;
private final PriorityQueue<ScheduledJob> mJobs;
public Scheduler(Context context)
{
mContext = context;
mManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
mJobs = new PriorityQueue<>();
IntentFilter filter = new IntentFilter();
filter.addAction(EXECUTE_JOB);
mContext.registerReceiver(this, filter);
}
/**
* Remove all pending jobs and unregister the receiver.
* Called via JNI.
*/
public void Terminate()
{
synchronized (this)
{
mJobs.clear();
}
mManager.cancel(createIntent());
mContext.unregisterReceiver(this);
}
/**
* Allocate a job ID. Called via JNI.
*
* @return random ID for a new job
*/
public String allocateId()
{
return UUID.randomUUID().toString();
}
/**
* Create a pending intent to execute a job.
*
* @return pending intent
*/
private PendingIntent createIntent()
{
/* using component/class doesn't work with dynamic broadcast receivers */
Intent intent = new Intent(EXECUTE_JOB);
intent.setPackage(mContext.getPackageName());
return PendingIntent.getBroadcast(mContext, 0, intent, 0);
}
/**
* Schedule executing a job in the future.
* Called via JNI from different threads.
*
* @param id job ID
* @param ms delta in milliseconds when the job should be executed
*/
@RequiresApi(api = Build.VERSION_CODES.M)
public void scheduleJob(String id, long ms)
{
synchronized (this)
{
ScheduledJob job = new ScheduledJob(id, System.currentTimeMillis() + ms);
mJobs.add(job);
if (job == mJobs.peek())
{ /* update the alarm if the job has to be executed before all others */
PendingIntent pending = createIntent();
mManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, job.Time, pending);
}
}
}
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
public void onReceive(Context context, Intent intent)
{
ArrayList<ScheduledJob> jobs = new ArrayList<>();
long now = System.currentTimeMillis();
synchronized (this)
{
ScheduledJob job = mJobs.peek();
while (job != null)
{
if (job.Time > now)
{
break;
}
jobs.add(mJobs.remove());
job = mJobs.peek();
}
if (job != null)
{
PendingIntent pending = createIntent();
mManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, job.Time, pending);
}
}
for (ScheduledJob job : jobs)
{
executeJob(job.Id);
}
}
/**
* Execute the job with the given ID.
*
* @param id job ID
*/
public native void executeJob(String id);
/**
* Keep track of scheduled jobs.
*/
private static class ScheduledJob implements Comparable<ScheduledJob>
{
String Id;
long Time;
ScheduledJob(String id, long time)
{
Id = id;
Time = time;
}
@Override
public int compareTo(ScheduledJob o)
{
return Long.compare(Time, o.Time);
}
}
}

View File

@ -118,7 +118,7 @@ public class SimpleFetcher
/**
* Disable the fetcher and abort any future requests.
*
* The native thread is not cancelable as it is working on an IKE_SA (cancelling the methods of
* The native thread is not cancelable as it is working on an IKE_SA (canceling the methods of
* HttpURLConnection is not reliably possible anyway), so to abort while fetching we cancel the
* Future (causing a return from fetch() immediately) and let the executor thread continue its
* thing in the background.

View File

@ -88,7 +88,7 @@ public class ImcStateFragment extends Fragment implements VpnStateListener
context.bindService(new Intent(context, VpnStateService.class),
mServiceConnection, Service.BIND_AUTO_CREATE);
/* hide it initially */
getFragmentManager().beginTransaction().hide(this).commit();
getParentFragmentManager().beginTransaction().hide(this).commit();
}
@Override
@ -192,7 +192,7 @@ public class ImcStateFragment extends Fragment implements VpnStateListener
public void updateView()
{
FragmentManager fm = getFragmentManager();
FragmentManager fm = getParentFragmentManager();
if (fm == null)
{
return;

View File

@ -66,7 +66,7 @@ public class MainActivity extends AppCompatActivity implements OnVpnProfileSelec
ActionBar bar = getSupportActionBar();
bar.setDisplayShowHomeEnabled(true);
bar.setDisplayShowTitleEnabled(false);
bar.setIcon(R.drawable.ic_launcher);
bar.setIcon(R.mipmap.ic_app);
/* load CA certificates in a background task */
new LoadCertificatesTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

View File

@ -81,7 +81,7 @@ public class RemediationInstructionsFragment extends ListFragment
{
super.onStart();
boolean two_pane = getFragmentManager().findFragmentById(R.id.remediation_instruction_fragment) != null;
boolean two_pane = getParentFragmentManager().findFragmentById(R.id.remediation_instruction_fragment) != null;
if (two_pane)
{ /* two-pane layout, make list items selectable */
getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);

View File

@ -202,7 +202,7 @@ public class TrustedCertificateImportActivity extends AppCompatActivity
certificate = (X509Certificate)getArguments().getSerializable(VpnProfileDataSource.KEY_CERTIFICATE);
return new AlertDialog.Builder(getActivity())
.setIcon(R.drawable.ic_launcher)
.setIcon(R.mipmap.ic_app)
.setTitle(R.string.import_certificate)
.setMessage(certificate.getSubjectDN().toString())
.setPositiveButton(R.string.import_certificate, new DialogInterface.OnClickListener()

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2018 Tobias Brunner
* Copyright (C) 2012-2020 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@ -19,12 +19,18 @@ import android.app.Dialog;
import android.app.Service;
import android.content.ActivityNotFoundException;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.net.Uri;
import android.net.VpnService;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.PowerManager;
import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
@ -36,13 +42,16 @@ import org.strongswan.android.data.VpnProfileDataSource;
import org.strongswan.android.data.VpnType.VpnTypeFeature;
import org.strongswan.android.logic.VpnStateService;
import org.strongswan.android.logic.VpnStateService.State;
import org.strongswan.android.utils.Constants;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.preference.PreferenceManager;
public class VpnProfileControlActivity extends AppCompatActivity
{
@ -51,6 +60,7 @@ public class VpnProfileControlActivity extends AppCompatActivity
public static final String EXTRA_VPN_PROFILE_ID = "org.strongswan.android.VPN_PROFILE_ID";
private static final int PREPARE_VPN_SERVICE = 0;
private static final int ADD_TO_POWER_WHITELIST = 1;
private static final String WAITING_FOR_RESULT = "WAITING_FOR_RESULT";
private static final String PROFILE_NAME = "PROFILE_NAME";
private static final String PROFILE_REQUIRES_PASSWORD = "REQUIRES_PASSWORD";
@ -181,6 +191,34 @@ public class VpnProfileControlActivity extends AppCompatActivity
}
}
/**
* Check if we are on the system's power whitelist, if necessary, or ask the user
* to add us.
* @return true if profile can be initiated immediately
*/
private boolean checkPowerWhitelist()
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
PowerManager pm = (PowerManager)this.getSystemService(Context.POWER_SERVICE);
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
if (!pm.isIgnoringBatteryOptimizations(this.getPackageName()) &&
!pref.getBoolean(Constants.PREF_IGNORE_POWER_WHITELIST, false))
{
if (getSupportFragmentManager().isStateSaved())
{ /* we might get called via service connection and manual onActivityResult()
* call when the activity is not active anymore and fragment transactions
* would cause an illegalStateException */
return false;
}
PowerWhitelistRequired whitelist = new PowerWhitelistRequired();
whitelist.show(getSupportFragmentManager(), DIALOG_TAG);
return false;
}
}
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
@ -190,11 +228,14 @@ public class VpnProfileControlActivity extends AppCompatActivity
mWaitingForResult = false;
if (resultCode == RESULT_OK && mProfileInfo != null)
{
if (mService != null)
if (checkPowerWhitelist())
{
mService.connect(mProfileInfo, true);
if (mService != null)
{
mService.connect(mProfileInfo, true);
}
finish();
}
finish();
}
else
{ /* this happens if the always-on VPN feature is activated by a different app or the user declined */
@ -207,6 +248,14 @@ public class VpnProfileControlActivity extends AppCompatActivity
VpnNotSupportedError.showWithMessage(this, R.string.vpn_not_supported_no_permission);
}
break;
case ADD_TO_POWER_WHITELIST:
mWaitingForResult = false;
if (mProfileInfo != null && mService != null)
{
mService.connect(mProfileInfo, true);
}
finish();
break;
default:
super.onActivityResult(requestCode, resultCode, data);
}
@ -531,6 +580,34 @@ public class VpnProfileControlActivity extends AppCompatActivity
}
}
/**
* Class that displays a warning before asking the user to add the app to the
* device's power whitelist.
*/
public static class PowerWhitelistRequired extends AppCompatDialogFragment
{
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.power_whitelist_title)
.setMessage(R.string.power_whitelist_text)
.setPositiveButton(android.R.string.ok, (dialog, id) -> {
VpnProfileControlActivity activity = (VpnProfileControlActivity)getActivity();
activity.mWaitingForResult = true;
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS,
Uri.parse("package:" + activity.getPackageName()));
activity.startActivityForResult(intent, ADD_TO_POWER_WHITELIST);
}).create();
}
@Override
public void onCancel(@NonNull DialogInterface dialog)
{
getActivity().finish();
}
}
/**
* Class representing an error message which is displayed if VpnService is
* not supported on the current device.
@ -556,7 +633,6 @@ public class VpnProfileControlActivity extends AppCompatActivity
return new AlertDialog.Builder(getActivity())
.setTitle(R.string.vpn_not_supported_title)
.setMessage(messageId)
.setCancelable(false)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener()
{
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2012-2019 Tobias Brunner
* Copyright (C) 2012-2020 Tobias Brunner
* Copyright (C) 2012 Giuliano Grassi
* Copyright (C) 2012 Ralf Sager
* HSR Hochschule fuer Technik Rapperswil
@ -124,6 +124,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
private Switch mUseOcsp;
private Switch mStrictRevocation;
private Switch mRsaPss;
private Switch mIPv6Transport;
private EditText mNATKeepalive;
private TextInputLayoutHelper mNATKeepaliveWrap;
private EditText mIncludedSubnets;
@ -194,6 +195,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
mUseOcsp = findViewById(R.id.use_ocsp);
mStrictRevocation= findViewById(R.id.strict_revocation);
mRsaPss= findViewById(R.id.rsa_pss);
mIPv6Transport= findViewById(R.id.ipv6_transport);
mIncludedSubnets = (EditText)findViewById(R.id.included_subnets);
mIncludedSubnetsWrap = (TextInputLayoutHelper)findViewById(R.id.included_subnets_wrap);
mExcludedSubnets = (EditText)findViewById(R.id.excluded_subnets);
@ -712,6 +714,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
flags |= !mUseOcsp.isChecked() ? VpnProfile.FLAGS_DISABLE_OCSP : 0;
flags |= mStrictRevocation.isChecked() ? VpnProfile.FLAGS_STRICT_REVOCATION : 0;
flags |= mRsaPss.isChecked() ? VpnProfile.FLAGS_RSA_PSS : 0;
flags |= mIPv6Transport.isChecked() ? VpnProfile.FLAGS_IPv6_TRANSPORT : 0;
mProfile.setFlags(flags);
mProfile.setIncludedSubnets(getString(mIncludedSubnets));
mProfile.setExcludedSubnets(getString(mExcludedSubnets));
@ -782,6 +785,7 @@ public class VpnProfileDetailActivity extends AppCompatActivity
mUseOcsp.setChecked(flags == null || (flags & VpnProfile.FLAGS_DISABLE_OCSP) == 0);
mStrictRevocation.setChecked(flags != null && (flags & VpnProfile.FLAGS_STRICT_REVOCATION) != 0);
mRsaPss.setChecked(flags != null && (flags & VpnProfile.FLAGS_RSA_PSS) != 0);
mIPv6Transport.setChecked(flags != null && (flags & VpnProfile.FLAGS_IPv6_TRANSPORT) != 0);
/* check if the user selected a user certificate previously */
useralias = savedInstanceState == null ? useralias : savedInstanceState.getString(VpnProfileDataSource.KEY_USER_CERTIFICATE);

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2019 Tobias Brunner
* Copyright (C) 2016-2020 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@ -463,8 +463,7 @@ public class VpnProfileImportActivity extends AppCompatActivity
}
catch (IllegalArgumentException e)
{
e.printStackTrace();
return null;
throw new JSONException(getString(R.string.profile_import_failed_value, "uuid"));
}
ParsedVpnProfile profile = new ParsedVpnProfile();
Integer flags = 0;
@ -528,6 +527,11 @@ public class VpnProfileImportActivity extends AppCompatActivity
profile.setDnsServers(getAddressList(obj, "dns-servers"));
profile.setMTU(getInteger(obj, "mtu", Constants.MTU_MIN, Constants.MTU_MAX));
profile.setNATKeepAlive(getInteger(obj, "nat-keepalive", Constants.NAT_KEEPALIVE_MIN, Constants.NAT_KEEPALIVE_MAX));
if (obj.optBoolean("ipv6-transport", false))
{
flags |= VpnProfile.FLAGS_IPv6_TRANSPORT;
}
JSONObject split = obj.optJSONObject("split-tunneling");
if (split != null)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Tobias Brunner
* Copyright (C) 2018-2019 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@ -25,7 +25,6 @@ import android.content.SharedPreferences;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
@ -36,9 +35,12 @@ import org.strongswan.android.data.VpnType;
import org.strongswan.android.logic.VpnStateService;
import org.strongswan.android.utils.Constants;
import androidx.preference.PreferenceManager;
@TargetApi(Build.VERSION_CODES.N)
public class VpnTileService extends TileService implements VpnStateService.VpnStateListener
{
private boolean mListening;
private VpnProfileDataSource mDataSource;
private VpnStateService mService;
private final ServiceConnection mServiceConnection = new ServiceConnection()
@ -53,7 +55,7 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
public void onServiceConnected(ComponentName name, IBinder service)
{
mService = ((VpnStateService.LocalBinder)service).getService();
if (mDataSource != null)
if (mListening && mDataSource != null)
{
mService.registerListener(VpnTileService.this);
updateTile();
@ -69,6 +71,9 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
Context context = getApplicationContext();
context.bindService(new Intent(context, VpnStateService.class),
mServiceConnection, Service.BIND_AUTO_CREATE);
mDataSource = new VpnProfileDataSource(this);
mDataSource.open();
}
@Override
@ -80,15 +85,15 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
{
getApplicationContext().unbindService(mServiceConnection);
}
mDataSource.close();
mDataSource = null;
}
@Override
public void onStartListening()
{
super.onStartListening();
mDataSource = new VpnProfileDataSource(this);
mDataSource.open();
mListening = true;
if (mService != null)
{
@ -101,14 +106,12 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
public void onStopListening()
{
super.onStopListening();
mListening = false;
if (mService != null)
{
mService.unregisterListener(this);
}
mDataSource.close();
mDataSource = null;
}
private VpnProfile getProfile()
@ -119,8 +122,7 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
{
uuid = pref.getString(Constants.PREF_MRU_VPN_PROFILE, null);
}
return mDataSource.getVpnProfile(uuid);
return mDataSource != null ? mDataSource.getVpnProfile(uuid) : null;
}
@Override
@ -134,7 +136,7 @@ public class VpnTileService extends TileService implements VpnStateService.VpnSt
{
profile = getProfile();
}
else
else if (mDataSource != null)
{ /* always get the plain profile without cached password */
profile = mDataSource.getVpnProfile(profile.getId());
}

Some files were not shown because too many files have changed in this diff Show More