Commit graph

702 commits

Author SHA1 Message Date
James Lucas
fd09728bb6
Fix bug GH-9356: Incomplete SAN validation of IPv6 address
IPv6 addresses are valid entries in subjectAltNames. Certificate
Authorities may issue certificates including IPv6 addresses except
if they fall within addresses in the RFC 4193 range. Google and
CloudFlare provide IPv6 addresses in their DNS over HTTPS services.

Internal CAs do not have those restrictions and can issue Unique
local addresses in certificates.

Closes GH-11145
2023-06-09 16:33:46 +01:00
Niels Dossche
974dba3b80
Fix duplicated FILE section in test bug80747.phpt
Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-23 13:50:49 +00:00
Jakub Zelenka
500b28ad04
Fix GH-10000: Test failures when OpenSSL compiled with no-dsa 2022-11-25 14:02:03 +00:00
Jakub Zelenka
ce57221376 Fix GH-9064: PHP fails to build if openssl was built with no-ec 2022-11-25 12:49:12 +00:00
George Peter Banyard
a4acba9e52
Add missing EXTENSION section to tests 2022-10-27 14:39:43 +01:00
Jakub Zelenka
93bed982e8
Merge branch 'PHP-8.0' into PHP-8.1 2022-08-17 19:50:16 +01:00
Jakub Zelenka
84dcf578b1
Fix GH-9339: OpenSSL oid_file path check warning contains uninitialized path 2022-08-17 19:49:36 +01:00
Jakub Zelenka
56382493eb
Merge branch 'PHP-8.0' into PHP-8.1 2022-06-09 23:02:50 +01:00
Jakub Zelenka
2f78c1f9d9 Fix and improve OpenSSL VCWD path checking test for bug #50293 2022-06-09 23:01:52 +01:00
Jakub Zelenka
95f6984216
Merge branch 'PHP-8.0' into PHP-8.1 2022-06-09 20:09:57 +01:00
Jakub Zelenka
cb9a48a0c5
Pass signature to openssl_verify in bug81713 test 2022-06-09 20:09:08 +01:00
Jakub Zelenka
976cbba76e Merge branch 'PHP-8.0' into PHP-8.1 2022-06-09 19:55:46 +01:00
Jakub Zelenka
b765d4cd41 Fix bug #50293 and #81713: file path checking in OpenSSL functions
It introduces a single function to check file paths passed to OpenSSL
functions. It expands the path, check null bytes and finally does
an open basedir check.
2022-06-09 19:49:59 +01:00
Remi Collet
03a4ccd912
use sha256 in openssl test suite 2022-06-01 11:46:47 +02:00
Jakub Zelenka
74f75db0c3
Fix bug #79589: ssl3_read_n:unexpected eof while reading
The unexpected EOF failure was introduced in OpenSSL 3.0 to prevent
truncation attack. However there are many non complaint servers and
it is causing break for many users including potential majority
of those where the truncation attack is not applicable. For that reason
we try to keep behavior consitent with older OpenSSL versions which is
also the path chosen by some other languages and web servers.

Closes GH-8369
2022-05-15 16:52:12 +01:00
Christoph M. Becker
f19250a3a1
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix openssl_x509_checkpurpose_basic.phpt
2021-12-12 14:28:16 +01:00
Christoph M. Becker
2c2b0abd4a
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix openssl_x509_checkpurpose_basic.phpt
2021-12-12 14:27:07 +01:00
Christoph M. Becker
98175fc7f1
Fix openssl_x509_checkpurpose_basic.phpt
This test fails because san-cert.pem and san-ca.pem have expired.  We
fix that by using the CertificateGenerator to generate temporary certs
during the test run.  Since san-cert.pem and san-ca.pem have been
identical, we only generate one certificate.

Closes GH-7763.
2021-12-12 14:26:17 +01:00
Nikita Popov
7f0d3f5413 Fixed bug #81502
Allow $tag to be null. This is the value that openssl_encrypt()
sets it to for non-AEAD ciphers, so we should also accept this
as an input to openssl_decrypt().

Prior to PHP 8.1, null was accepted in weak mode due to the special
treatment of null arguments to internal functions.
2021-10-08 14:07:05 +02:00
Jakub Zelenka
43f0141d74
Make OpenSSL tests less dependent on system config
It fixes dependencies on system config if running tests with OpenSSL 3.0
2021-09-12 20:30:02 +01:00
Nikita Popov
e5f53e1ca1 Fork openssl_error_string() test for OpenSSL
The used error code differ signficantly, so use a separate test
file.

openssl_encrypt() no longer throws an error for invalid key length,
which looks like an upstream bug.
2021-08-10 11:50:18 +02:00
Nikita Popov
3724b49aa9 Use param API to create RSA key
Instead of deprecated low-level API.

A caveat here is that when using the high-level API, OpenSSL 3
requires that if the prime factors are set, the CRT parameters
are also set. See https://github.com/openssl/openssl/issues/16271.

As such, add CRT parameters to the manual construction test.

This fixes the last deprecation warnings in openssl.c, but there
are more elsewhere.
2021-08-09 17:02:17 +02:00
Nikita Popov
246698671f Test calculation of EC public key from private key 2021-08-09 12:01:35 +02:00
Jakub Zelenka
c90c9c7545
Make CertificateGenerator not dependent on external config in OpenSSL 3.0 2021-08-08 20:54:46 +01:00
Nikita Popov
f2d3e75933 Do not special case export of EC keys
All other private keys are exported in PKCS#8 format, while EC
keys use traditional format. Switch them to use PKCS#8 format as
well.

As the OpenSSL docs say:

> PEM_write_bio_PrivateKey_traditional() writes out a private key
> in the "traditional" format with a simple private key marker and
> should only be used for compatibility with legacy programs.
2021-08-06 11:25:44 +02:00
Nikita Popov
5843ba518c Generate pkcs12_read test inputs on the fly
The old p12_with_extra_certs.p12 file uses an unsupported something.
2021-08-06 10:48:03 +02:00
Nikita Popov
a2c201351b Use different cipher in one more CMS test
Followup to ec4d926a80 -- I failed
to squash in this commit.
2021-08-06 10:23:23 +02:00
Nikita Popov
d23a8b33ab Skip some tests if cipher not available 2021-08-06 10:22:39 +02:00
Nikita Popov
1cf4fb739f Use larger key size for DSA/DH tests
OpenSSL 3 validates allowed sizes strictly, pick minimum sizes
that are supported.
2021-08-05 17:47:56 +02:00
Nikita Popov
ec4d926a80 Use different algorithm in cms tests
Same as with pkcs7, switch these tests to use an algorithm that
OpenSSL 3 supports out of the box.

Once again, we should consider changing the default or making it
required.
2021-08-05 16:32:27 +02:00
Nikita Popov
563b3e3472 Use different algorithm in pkcs7 tests
The default of OPENSSL_CIPHER_RC2_40 is no longer (non-legacy)
supported in OpenSSL 3, specify a newer cipher instead.

We should probably either change the default (if acceptable) or
make the parameter required.
2021-08-05 16:16:58 +02:00
Nikita Popov
7168f71e00 Add test for openssl_dh_compute_key()
This function was not tested at all :(
2021-08-05 15:49:35 +02:00
Nikita Popov
cd8bf0b6bd Relax error check
The precise error is version-dependent, just check that there
is some kind of error reported.
2021-08-05 11:50:11 +02:00
Nikita Popov
13313d9b1b Use EVP_PKEY APIs for key generation
Use high level API instead of deprecated low level API.
2021-08-05 11:17:13 +02:00
Nikita Popov
384ad6e224 Use EVP_PKEY APIs for openssl_private_encrypt/public_decrypt
Use high level APIs instead of deprecated low level APIs.
2021-08-04 16:58:41 +02:00
Nikita Popov
0233afae27 Use EVP_PKEY API for openssl_public_encrypt/private_decrypt
Use the high level API instead of the deprecated low level API.
2021-08-04 16:44:29 +02:00
Nikita Popov
503146aa87 Avoid RC4 use in another test 2021-08-04 12:57:15 +02:00
Nikita Popov
9695936341 Don't test legacy algorithms in SPKI tests
MD4 and RMD160 may not be available on newer OpenSSL versions.
2021-08-04 12:02:58 +02:00
Nikita Popov
046b36bcf8 Use different cipher in openssl_seal() test
RC4 is insecure and not supported in newer versions.
2021-08-04 12:02:57 +02:00
Nikita Popov
0a530d7650 Adjust some tests for whitespace differences in OpenSSL 3
A trailing newline is no longer present in OpenSSL 3.
2021-08-04 10:01:19 +02:00
Nikita Popov
3ea57cf838 Reduce security level in some OpenSSL tests
This allows tests using older protocols and algorithms to work
under OpenSSL 3.

Also account for minor changes in error reporting.
2021-08-04 10:00:40 +02:00
Nikita Popov
6249172ae3 Optimize openssl memory leak test
Just do one call and check whether memory usage changes. Looping
this 100000 times is extremely slow with debug builds of openssl.
2021-08-04 10:00:28 +02:00
Christoph M. Becker
58ca47a06f
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #52093: openssl_csr_sign truncates $serial
2021-07-01 15:46:07 +02:00
Christoph M. Becker
5b0a46908c
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #52093: openssl_csr_sign truncates $serial
2021-07-01 15:43:52 +02:00
Christoph M. Becker
334387bb70
Fix #52093: openssl_csr_sign truncates $serial
We use `ASN1_INTEGER_set_int64()` if supported[1], to avoid the
truncation of the integer.

[1] <https://www.openssl.org/docs/man1.1.0/man3/ASN1_INTEGER_set_int64.html#HISTORY>

Closes GH-7209.
2021-07-01 15:42:02 +02:00
Nikita Popov
6600ad6067 Add some missing EXTENSIONS sections to misc tests 2021-06-14 14:52:44 +02:00
Christoph M. Becker
4633a90202
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix test wrt. OPENSSL_CONF
2021-06-13 16:56:02 +02:00
Christoph M. Becker
876bf8800a
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix test wrt. OPENSSL_CONF
2021-06-13 16:54:52 +02:00
Christoph M. Becker
d15e10d7ab
Fix test wrt. OPENSSL_CONF
This test is supposed to verify the path of the default OpenSSL config
file; it will fail, though, if OPENSSL_CONF is explicitly set, so we
explicitly unset this environment variable for this test.
2021-06-13 16:53:45 +02:00
Nikita Popov
39131219e8
Migrate more SKIPIF -> EXTENSIONS (#7139)
This is a mix of more automated and manual migration. It should remove all applicable extension_loaded() checks outside of skipif.inc files.
2021-06-11 12:58:44 +02:00