Commit Graph
14005 Commits
Author SHA1 Message Date
Tobias Brunner c6cde0c8b6 pki: Ensure allocated serial numbers don't start with a zero byte
If the randomly allocated serial starts with 0x80, the fix added with
e49197f15e ("pki: Don't generate negative random serial numbers in
X.509 certificates") causes the value to become zero.  So the encoded
ASN.1 integer will start with a zero byte, which is only correct if the
integer would otherwise be interpreted as negative, i.e. the next byte
starts with the most significant bit set.  If that isn't the case, the
encoding is technically invalid and might get rejected by strict parsers.

Note that e49197f15e did not actually fix a violation of RFC 5280 as
asn1_integer() assumes all passed numbers are positive and automatically
adds a zero prefix if the MSB is set.  What it did instead (or at least
attempted to) is ensure that the generated serial is a positive 64-bit
number in two's complement. The difference can be seen in the output of
`openssl x509 -text`.  While 8-byte serials with the MSB set are printed
as hex dump:

    Serial Number:
            af:e2:e1:47:0f:66:b5:a4

    (The encoding is 02:09:00:af:e2:e1:47:0f:66:b5:a4)

those without MSB set are actually printed as number:

    Serial Number: 289805014144645117 (0x405981ffa37f7fd)

    (The encoding is 02:08:04:05:98:1F:FA:37:F7:FD)

The reason is that OpenSSL only does the latter if the number fits into a
signed `long` variable, which isn't the case if a positive 64-bit number
has the MSB set (i.e. has a zero prefix) as it would be interpreted as
negative number in two's complement.  OpenSSL does print negative serial
numbers (even if it's a violation of the RFC), but only if they were
encoded as such, i.e. if there was no zero prefix:

    Serial Number: -5492225205882687294 (-0x4c384db9c7158f3e)

    (The encoding is 02:08:b3:c7:b2:46:38:ea:70:c2)

Fixes: e49197f15e ("pki: Don't generate negative random serial numbers in X.509 certificates")
Closes strongswan/strongswan#631
2021-10-06 09:10:12 +02:00
Tobias Brunner 128d054407 Clear static buffer returned by getpass() 2021-10-04 11:30:03 +02:00
Tobias Brunner de442491d9 swanctl: Clear config from memory
The 'secrets' section in the config file may contain passwords/PINs.
2021-10-04 11:30:03 +02:00
Tobias Brunner f3a5b54ab3 settings: Add destructor that wipes contents 2021-10-04 11:30:03 +02:00
Tobias Brunner 57faf886db stroke: Clear ipsec.secrets file from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner b667eb37b9 swanctl: Clear possibly unencrypted key/container files from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner 3a739424e1 pem: Clear possibly unencrypted key file from memory 2021-10-04 11:30:03 +02:00
Tobias Brunner e2e21f2486 chunk: Optionally clear mmap'd chunk before unmapping
This is mostly for the non-mmap case as with mmap available, access to the
unmapped memory isn't easily possible (e.g. opening the same area with
MAP_ANONYMOUS | MAP_UNINITIALIZED is usually prevented by the missing
CONFIG_MMAP_ALLOW_UNINITIALIZED option in most kernels).
2021-10-04 11:30:03 +02:00
Tobias Brunner b9aafa7ebf vici: Clear all request messages in case they contain secrets 2021-10-04 11:30:03 +02:00
Tobias Brunner 4bea9e8b60 vici: Clear cached strings in case the message contained shared secrets 2021-10-04 11:30:03 +02:00
Tobias Brunner 66e80f3d1b pem: Clear chunks after decrypting files 2021-10-04 11:30:03 +02:00
Tobias Brunner 16d91ab761 shared-key: Clear shared secret when destroyed 2021-10-04 11:30:03 +02:00
Tobias Brunner f2420cee49 libimcv: Add Debian 11 (bullseye) to IMV database 2021-10-01 15:05:44 +02:00
Tobias Brunner f92ad8454b openssl: Use correct key types when adopting Ed25519/448 keys
Fixes: cbf07ab5b0 ("openssl: Add support for Ed25519/Ed448")
2021-10-01 15:04:13 +02:00
Tobias Brunner c463a14483 openssl: Remove workaround for Brainpool ECDH curves for older OpenSSL versions
Using the workaround with the EVP interface, which we use to derive shared
keys since 74e02ff5e6 ("openssl: Mainly use EVP interface for ECDH"),
would actually require us to register the OIDs of these curves as NID.
Otherwise, the two EC_GROUPs used by private and public key objects
are not considered the same and the key derivation fails.

Since the curves are supported by OpenSSL since 1.0.2 it's probably rare to
find a version without them nowadays.  One exception is the old BoringSSL
version we still use on Android, which defines the NIDs but not the curve
data.  However, that version also lacks support to register OIDs as NIDs,
so the only option to support these groups there would be to got back to not
using the EVP interface, which isn't in anyone's interest.  If there really
is a need for them there, we could probably patch BoringSSL or use OpenSSL.
2021-10-01 15:04:13 +02:00
Tobias Brunner 72e5b3b702 crl: Fix compilation with OpenSSL 3.0
Closes strongswan/strongswan#635
2021-09-30 11:57:43 +02:00
Tobias Brunner b94236487c kernel-pfkey: Wipe request/response messages when managing SAs 2021-09-23 15:28:22 +02:00
Tobias Brunner e166e6913c Change shebang for Python scripts to use python3 2021-09-21 12:51:47 +02:00
Tobias Brunner a5662e8f6e keymat_v2: Properly wipe DH secret during IKE_SA rekeying
While `secret` is wiped explicitly, it wasn't when concatenating with
the nonces.
2021-09-20 16:10:03 +02:00
Andreas Steffen 91896264b2 sec-updater: Use latest versions 2021-09-09 22:54:38 +02:00
Andreas Steffen d23ca7f345 os_info: Parse /etc/os-release first 2021-09-09 22:54:38 +02:00
Tobias Brunner a415761a8e vici: Update supported Python versions 2021-09-09 12:30:17 +02:00
Noel Kuntze fbd4930323 vici: Add DBG4 messages that print loaded shared keys and PINs
Closes strongswan/strongswan#217
2021-09-02 10:42:41 +02:00
Tobias Brunner 3c0d7ec531 ike: Initiate new IKE_SA not until all children are queued
If there are many CHILD_SAs, the time between initiating the new IKE_SA
and checking it in might be longer (depending on what else is going on
in the daemon) than the retransmission timeout and no retransmits might
be sent afterwards for this SA (it will just linger around dead).
Calling initiate() last should avoid that (we do this similarly for MBB
reauthentication).
2021-08-24 14:31:55 +02:00
Tobias Brunner 23e46ea5ab ikev2: Only request reauth during IKE_AUTH if active reauth is not possible
If we can initiate the reauthentication ourselves, there is no reason to
explicitly request the peer to do so (at basically the same time).
2021-08-24 14:31:55 +02:00
Tobias Brunner 0d373e25e0 ike-rekey: Respond with TEMPORARY_FAILURE while reauthenticating
This could lead to duplicates as the new IKE_SA can't delete the old one
once reauthentication is complete if it was replaced by a rekeying.
2021-08-24 14:31:55 +02:00
Tobias Brunner 36161febd3 ike: Don't rekey IKE_SA while reauthenticating
If we are using make-before-break reauthentication, this could lead to
duplicates as the new IKE_SA wouldn't be able to delete the previous
one if it was replaced by a rekeying.
2021-08-24 14:31:55 +02:00
Tobias Brunner 48fbe1d2d5 ike-delete: Don't call reestablish() when reauthenticating
If we initiated a make-before-break reauthentication and the peer
concurrently deletes the IKE_SA (e.g. because it uses break-before-make
reauthentication), we would create a duplicate IKE_SA (the condition forces
a recreation of all existing CHILD_SAs because reestablish() is also called
to complete a break-before-make reauthentication).
2021-08-24 14:31:55 +02:00
Tobias Brunner 57e68ab9c5 openssl: Improve compatibility to newer BoringSSL releases
Closes strongswan/strongswan#352
2021-08-24 14:20:37 +02:00
Tobias Brunner 5821f2cc01 pubkey: Ignore X.509 flags passed to the parser 2021-08-23 17:59:39 +02:00
Tobias Brunner 4dfa31c8a0 pubkey: Don't assume blobs are only ASN.1 DER
Also forward the blob's type when parsing pubkeys.
2021-08-23 17:59:39 +02:00
Tobias Brunner de5609b297 vici: Use the more generic BUILD_BLOB to parse certificates/public keys 2021-08-23 17:59:39 +02:00
Tobias Brunner 8d422d2c83 tpm_extendpcr: Support platforms not having syslog() 2021-08-23 11:30:15 +02:00
Tobias Brunner 4aa6da69aa tpm_extendpcr: Build does not depend on tpm plugin but libtpmtss
The utility basically requires a TSS, the tpm plugin is not used at all.
2021-08-23 10:44:41 +02:00
Tobias Brunner 5126e7c0fc libtpmtss: Initialize library from all users
Previously, only the tpm plugin initialized the library, so in order
to use a TPM 2.0 (a required TCTI library is loaded via init), it was
necessary to load it even if none of its actual features were used.
2021-08-20 17:10:11 +02:00
Tobias Brunner 64b281723c openssl: Use a longer key to test/initialize HMAC instances
OpenSSL enforces a minimum of 14 bytes (112 bits) on the key size when
used in FIPS-mode (as required by SP 800-131A).  So by using an empty
string, instantiation always failed.  32 bytes (256 bits) should be safe
for now.

Closes strongswan/strongswan#557
2021-08-19 14:06:19 +02:00
Tobias Brunner 1c4e134f26 kernel-netlink: Initialize ifreq structs when detecting offload capability 2021-08-11 15:35:52 +02:00
Tobias Brunner 358d3d0ba1 android: New release after adding button to install PKCS#12 and SDK update
It also includes an unreleased change that affects when/how DNS servers
are applied to the TUN device.
2021-07-14 09:59:02 +02:00
Tobias Brunner a14337bcde android: Request QUERY_ALL_PACKAGES permission
This is required when targeting Android 11 (API 30) in order to see all
packages, which we use to allow selecting apps ex-/included from VPN
profiles and for the EAP-TNC use case.
2021-07-14 09:59:02 +02:00
Tobias Brunner 3eadd0fc3a android: Add Triple-T metadata for F-Droid
We currently don't use Triple-T but the metadata is also parsed by F-Droid
to provide information for included apps.
2021-07-14 09:59:02 +02:00
Tobias Brunner 2f1bf11dca android: Add a button to install user certificates
Newer Android versions don't provide this option anymore on the
selection dialog.
2021-07-14 09:59:02 +02:00
Tobias Brunner b3cdbe6693 android: Replace deprecated Switch with SwitchCompat 2021-07-14 09:59:02 +02:00
Tobias Brunner 26354d0aba android: Replace deprecated AsyncTask instances
As suggested by the Android docs, we use a global thread pool and handler
to avoid recreating them repeatedly.  Four threads should be more than
enough as we only use this to load CA certificates when the app starts
initially and to load user certs when editing a profile.
2021-07-14 09:59:02 +02:00
Tobias Brunner a8cc146240 android: Migrate from deprecated ViewPager to ViewPager2 for CA cert lists 2021-07-13 14:26:38 +02:00
Tobias Brunner c976165533 android: Replace deprecated FileObserver() constructor with newer SDKs 2021-07-13 14:25:46 +02:00
Tobias Brunner dc351a30e1 android: Replace usage of deprecated Handler() constructor 2021-07-13 14:25:46 +02:00
Tobias Brunner 93c494e295 android: Replace deprecated onActivityCreated() with onViewCreated() 2021-07-13 14:25:46 +02:00
Tobias Brunner 7cd50aeb64 android: Replace deprecated startActivityForResult/onActivityResult usage 2021-07-13 14:25:44 +02:00
Tobias Brunner a885e38265 android: Set compile-/targetSdkVersion to 30
This will be mandatory for new apps in August and for existing apps
in November.  However, several classes like AsyncTask are now deprecated
so this needs some work to avoid warnings and problems in the future.
2021-07-13 14:18:42 +02:00
Tobias Brunner 6f3725ea8b android: Replace jcenter with mavenCentral repository 2021-07-13 14:18:42 +02:00