18040 Commits

Author SHA1 Message Date
Tobias Brunner
78927145fe ike-mobike: Support IKE_INTERMEDIATE exchange between IKE_SA_INIT and IKE_AUTH
This changes the MID of the first IKE_AUTH message.
2021-10-18 18:49:11 +02:00
Tobias Brunner
9f1497d41c ike-config: Support IKE_INTERMEDIATE exchange between IKE_SA_INIT and IKE_AUTH
This changes the MID of the first IKE_AUTH message.
2021-10-18 18:49:11 +02:00
Tobias Brunner
b979511fcb ike-cert-post: Make absolutely sure certificates are only added to IKE_AUTH
The AUTH payload check should be fine, but add some extra checks just to make
really sure and also for clarification.
2021-10-18 18:49:11 +02:00
Tobias Brunner
3234407a95 ike-cert-pre: Support IKE_INTERMEDIATE exchange between IKE_SA_INIT and IKE_AUTH
The first IKE_AUTH does not have MID 1 if that's the case.
2021-10-18 18:49:11 +02:00
Tobias Brunner
004f440f54 status: Add return_need_more() utility function 2021-10-18 18:49:11 +02:00
Tobias Brunner
ec12550000 message: Add rules for IKE_FOLLOWUP_KE exchanges 2021-10-18 18:49:11 +02:00
Tobias Brunner
ef3b6bd45e wip: ike-header: Add IKE_FOLLOWUP_KE exchange type 2021-10-18 18:49:11 +02:00
Tobias Brunner
ba4b27af8b message: Add rules for IKE_INTERMEDIATE exchanges 2021-10-18 18:49:11 +02:00
Tobias Brunner
082a688efd wip: ike-header: Add IKE_INTERMEDIATE exchange type 2021-10-18 18:49:11 +02:00
Tobias Brunner
6b176421b1 wip: notify-payload: Add notify types for multiple key exchanges 2021-10-18 18:49:11 +02:00
Tobias Brunner
d25198a1dd wip: notify-payload: Add notify type for IKE_INTERMEDIATE exchange 2021-10-18 18:49:11 +02:00
Tobias Brunner
d65ae2952a proposal-substructure: Encode additional key exchange methods 2021-10-18 18:49:11 +02:00
Tobias Brunner
8b1a0ba16a child-cfg: Add method to check if an algorithm is proposed 2021-10-18 18:49:11 +02:00
Tobias Brunner
a0356e1861 child-cfg: Generalize get_ke_method() method 2021-10-18 18:49:11 +02:00
Tobias Brunner
da9bedd021 ike-cfg: Generalize get_ke_method() method 2021-10-18 18:49:11 +02:00
Tobias Brunner
f5b7f34876 proposal: Generalize KE methods 2021-10-18 18:49:11 +02:00
Tobias Brunner
1944dbf80d proposal: Make all key exchange transforms optional in ESP/AH proposals 2021-10-18 18:49:11 +02:00
Tobias Brunner
204715d4a3 proposal: Skip all KE transforms if PROPOSAL_SKIP_KE given 2021-10-18 18:49:11 +02:00
Tobias Brunner
c5902bb02e transform: Add helper to check if transform type negotiates key exchange 2021-10-18 18:49:11 +02:00
Tobias Brunner
504a266700 transform: Add additional key exchange transform types 2021-10-18 18:49:11 +02:00
Andreas Steffen
d8d08169bd Rename MODP_NONE to KE_NONE 2021-10-18 18:49:11 +02:00
Tobias Brunner
fe036d9d71 Rename diffie_hellman_t to key_exchange_t and change the interface etc.
This makes it more generic so we can use it for QSKE methods.
2021-10-18 18:49:11 +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
Tobias Brunner
3edf3856d4 testing: Use Debian bullseye as base image 2021-10-01 15:05:44 +02:00