18041 Commits

Author SHA1 Message Date
Tobias Brunner
9b2e9a943c processor: Fix incompatible function types warnings 2021-11-17 18:06:20 +01:00
Tobias Brunner
0917edb468 blocking-queue: Fix incompatible function types warning 2021-11-17 17:46:27 +01:00
Andreas Steffen
fe5399d287 Merge branch 'rsa-oaep-encryption' 2021-11-11 10:03:17 +01:00
Andreas Steffen
519db56f2f testing: Added RSA PKCS1 encryption tests 2021-11-10 21:06:10 +01:00
Andreas Steffen
6bb5c4f2bb testing: Added RSA OAEP encryption tests 2021-11-10 21:06:10 +01:00
Andreas Steffen
93bf894cd2 gcrypt: Support RSA OAEP SHA1 encryption/decryption 2021-11-10 21:06:10 +01:00
Andreas Steffen
b50e8a88ff gcrypt: Enable RSA PKCS1 encryption/decryption 2021-11-10 20:17:49 +01:00
Andreas Steffen
be52ad7c6d botan: RSA OAEP labels are not supported 2021-11-10 20:03:22 +01:00
Andreas Steffen
9cfdc32597 wolfssl: Support OAEP labels 2021-11-10 20:03:22 +01:00
Andreas Steffen
6adb543341 openssl: Implemented RSA OAEP encryption/decryption with optional labels 2021-11-10 20:03:22 +01:00
Andreas Steffen
4abb29f639 credentials: Added void *params to public_key encrypt() and private_key decrypt() methods 2021-11-09 17:58:28 +01:00
Andreas Steffen
c8341fca61 botan: Fully enable RSA OAEP decryption 2021-11-09 17:58:28 +01:00
Tobias Brunner
f4bfdec21f kernel-pfroute: Set lower MTU on TUN devices
The default MTU of 1500 is too high if kernel-libipsec is used (considering
the overhead of UDP-encapsulated ESP), but might also have an effect if
a TUN device is only used to install a virtual IP (the route points to it,
so the system might use its MTU and 1500 would still be too high).

This also works around an issue on macOS 12 where no RTM_IFINFO event
is sent for the newly created TUN device (neither for the creation,
setting it "up", nor adding the address).  Changing the MTU, however,
triggers such an event and we can detect the virtual IP.

Closes strongswan/strongswan#707
2021-11-09 09:43:01 +01:00
Tobias Brunner
eb19699a7a ike: Fix length of vendor ID Cisco VPN 3000 client
The actual length of the data is 16 bytes.

Fixes: 6c49ddfbca72 ("ike: Add additional Vendor IDs for third-party implementations")
2021-11-03 11:01:09 +01:00
Volker Rümelin
9747376c69 ike: Fix prefix length and data of vendor ID Cisco VPN Concentrator
Currently the length of vendor ID Cisco VPN Concentrator is 16
bytes but the string has only 13+1 bytes. The actual vendor
ID has 16 bytes with a prefix length of 14 bytes and two version
bytes.

Fixes: 6c49ddfbca72 ("ike: Add additional Vendor IDs for third-party implementations")
2021-11-03 11:01:09 +01:00
Volker Rümelin
865a387c6c ikev1: Fix prefix length of vendor ID Cisco Unity
Before commit 6c49ddfbca ("ike: Add additional Vendor IDs for
third-party implementations") the prefix length of vendor ID
Cisco Unity was hardcoded to 14. Since we need to know the actual
length of this VID to send it, the length can't be overloaded
with a prefix length. Revert part of commit 6c49ddfbca to
fix this problem.

Fixes: 6c49ddfbca72 ("ike: Add additional Vendor IDs for third-party implementations")
2021-11-03 11:00:59 +01:00
Volker Rümelin
5e1d1cd30f ikev1: Fix prefix length of vendor ID MS NT5 ISAKMPOAKLEY
Before commit 6c49ddfbca ("ike: Add additional Vendor IDs for
third-party implementations") the prefix length of vendor ID
MS NT5 ISAKMPOAKLEY was hardcoded to 16. Change the prefix length
accordingly.

Fixes: 6c49ddfbca72 ("ike: Add additional Vendor IDs for third-party implementations")
2021-11-03 10:25:51 +01:00
Tobias Brunner
d1278ed926 Use wolfSSL 5.0.0 for tests 2021-11-02 09:41:25 +01:00
Tobias Brunner
e19eb070fa Use Botan 2.18.2 for tests 2021-10-29 09:07:38 +02:00
Andreas Steffen
bcbf1862d7 Version bump to 5.9.5dr1 5.9.5dr1 2021-10-26 08:04:19 +02:00
Andreas Steffen
f0935a63ed testing: Optimized plugin use in pkcs8 scenarios 2021-10-23 11:44:15 +02:00
Andreas Steffen
9c7288d6f1 testing: Minimum required plugins for net2net-pkcs12 scenarios 2021-10-22 11:39:20 +02:00
Tobias Brunner
8c48de739d testing: Use AES and SHA-256 to protect PKCS#12 files
The -aes128 option is used when encrypting private keys read from a
PKCS#12 file, not when generating such a file.
2021-10-18 14:27:14 +02:00
Andreas Steffen
66fa7c959a Version bump to 5.9.4 5.9.4 2021-10-18 11:45:53 +02:00
Andreas Steffen
8cc89b505e testing: Correctly remove pkcs8 key after test case 2021-10-18 11:45:31 +02:00
Tobias Brunner
fed5c7e0d4 NEWS: Add news for 5.9.4 2021-10-18 11:27:29 +02:00
Tobias Brunner
d6d31fce23 pkcs8: Don't forward NULL parameters when parsing keys
Other plugins don't expect this build part for RSA keys and will fail
parsing the keys further.
2021-10-18 11:24:11 +02:00
Tobias Brunner
02e4f994ec signature-params: Reject schemes other than RSASSA-PSS with parameters
NULL parameters (for classic PKCS#1 signature schemes) are explicitly
allowed (for any schemes for now), but we only expect parameters for
RSASSA-PSS.  Before enforcing this, it was possible to modify the
parameters in the signatureAlgorithm field of the outer X.509 Certificate
structure to something different than the signature field of the signed,
inner tbsCertificate structure, allowing generating infinite versions
of valid certificates with different binary encodings.  Now we accept at
most two (NULL and absent parameters).
2021-10-14 18:59:07 +02:00
Tobias Brunner
f061dedcb7 asn1: Return any parameters of algorithmIdentifier structures
Previously, only parameters of type OID, SEQUENCE and OCTET STRING were
returned (so e.g. random integers could be put in parameters and we
wouldn't know about it).

Log output is basically the same as with asn1_parser_t before, except
that parameters are always dumped (if any), that wasn't the case before
because ASN1_RAW (instead of ASN1_OBJ) was used.
2021-10-14 18:59:07 +02:00
Tobias Brunner
dceed8e099 cert-cache: Prevent crash due to integer overflow/sign change
random() allocates values in the range [0, RAND_MAX], with RAND_MAX usually
equaling INT_MAX = 2^31-1.  Previously, values between 0 and 31 were added
directly to that offset before applying`% CACHE_SIZE` to get an index into
the cache array.  If the random value was very high, this resulted in an
integer overflow and a negative index value and, therefore, an out-of-bounds
access of the array and in turn dereferencing invalid pointers when trying
to acquire the read lock.  This most likely results in a segmentation fault.

Fixes: 764e8b2211ce ("reimplemented certificate cache")
Fixes: CVE-2021-41991
2021-10-14 18:59:07 +02:00
Tobias Brunner
234302a108 gmp: Reject RSASSA-PSS signatures with negative salt length
The `salt_len` field is signed because negative values are used to indicate
automatic salt lengths when generating signatures.  This must never be the
case when validating them.

Not checking this could lead to an integer overflow below.  The value is
assigned to the `len` field of a chunk (`size_t`), which is further used
in calculations to check the padding structure and (if that is passed by
a matching crafted signature value) eventually a memcpy() that will result
in a segmentation fault.

Fixes: 7d6b81648b2d ("gmp: Add support for RSASSA-PSS signature verification")
Fixes: CVE-2021-41990
2021-10-14 18:59:07 +02:00
Tobias Brunner
03fbceb3f5 signature-params: Reject RSASSA-PSS params that result in negative salt len
The `salt_len` member in the struct is of type `ssize_t` because we use
negative values for special automatic salt lengths when generating
signatures.  This change ensures that `salt_len` will not overflow the
`len` fields of chunks (`size_t`), which could lead to integer overflows
when validating signatures (see the next commit).

Fixes: a22316520b91 ("signature-params: Add functions to parse/build ASN.1 RSASSA-PSS params")
2021-10-14 18:59:07 +02:00
Tobias Brunner
2403154f95 pki: Use correct enum value to initialize ID type in --keyid command 2021-10-13 15:17:09 +02:00
Tobias Brunner
b241e944fa cirrus: Use specific package name for OpenLDAP
Seems the openldap-client alias is gone.
2021-10-12 14:55:55 +02:00
Tobias Brunner
e7f0c6f778 cirrus: Also build on FreeBSD 13.0 2021-10-12 14:49:03 +02:00
Andreas Steffen
1ecb0b8133 Version bump to 5.9.4rc1 5.9.4rc1 2021-10-12 08:54:03 +02:00
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
e49197f15eef ("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 e49197f15eef 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: e49197f15eef ("pki: Don't generate negative random serial numbers in X.509 certificates")
Closes strongswan/strongswan#631
2021-10-06 09:10:12 +02:00
Andreas Steffen
740038e401 Version bump to 5.9.4dr3 5.9.4dr3 2021-10-04 15:47:05 +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
5c24b05f0c Merge branch 'testing-bullseye'
Use Debian bullseye as base image for the testing environment.
2021-10-01 17:13:18 +02:00