openssl.git
23 months agoFix memory leak in ossl_rsa_fromdata.
slontis [Fri, 24 Jun 2022 04:01:07 +0000 (14:01 +1000)]
Fix memory leak in ossl_rsa_fromdata.

Occurs if a malloc failure happens inside collect_numbers()

Reported via #18365

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18646)

(cherry picked from commit 28adea95975c3ea53fc590efda35dee13efd4767)

23 months agoAdd a test for an all 0 RSA key
Matt Caswell [Fri, 24 Jun 2022 10:02:22 +0000 (11:02 +0100)]
Add a test for an all 0 RSA key

Testing a key with all values set to 0.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18651)

(cherry picked from commit 995eccb611431a4857cac3283e2442c01109d428)

23 months agoThe rsa_validate_keypair_multiprime() function return is not boolean
Matt Caswell [Fri, 24 Jun 2022 10:01:22 +0000 (11:01 +0100)]
The rsa_validate_keypair_multiprime() function return is not boolean

A -ve return value from this function indicates an error which we should
treat as a failure to validate.

Fixes #18538

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18651)

(cherry picked from commit 518f1ee81d5a6910365ef404888d0e119a87fd81)

23 months agoImprove checks for invalid saltlen in DER writer.
Daniel Fiala [Wed, 22 Jun 2022 18:49:51 +0000 (20:49 +0200)]
Improve checks for invalid saltlen in DER writer.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18615)

(cherry picked from commit 08f876d0dea184b071a5aded4c55317e5a63c80e)

23 months agoder_writer: Use uint32_t instead of long.
Daniel Fiala [Mon, 20 Jun 2022 16:40:30 +0000 (18:40 +0200)]
der_writer: Use uint32_t instead of long.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18615)

(cherry picked from commit 59196250cb45ecd128d2f8bbc47de612167606d3)

23 months agoAdd checks for saltlen and trailerfield to rsa key writer.
Daniel Fiala [Sun, 19 Jun 2022 21:40:46 +0000 (23:40 +0200)]
Add checks for saltlen and trailerfield to rsa key writer.

Fixes openssl#18168.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18615)

(cherry picked from commit 48320997b49b07b5abadec89c7fbe5d5f3d41da4)

23 months agoFix a memory leak in EC_GROUP_new_from_ecparameters
Bernd Edlinger [Wed, 22 Jun 2022 15:05:55 +0000 (17:05 +0200)]
Fix a memory leak in EC_GROUP_new_from_ecparameters

This can be reproduced with my error injection patch.

The test vector has been validated on the 1.1.1 branch
but the issue is of course identical in all branches.

$ ERROR_INJECT=1656112173 ../util/shlib_wrap.sh ./x509-test ./corpora/x509/fe543a8d7e09109a9a08114323eefec802ad79e2
    #0 0x7fb61945eeba in __sanitizer_print_stack_trace ../../../../gcc-trunk/libsanitizer/asan/asan_stack.cpp:87
    #1 0x402f84 in my_malloc fuzz/test-corpus.c:114
    #2 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
    #3 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
    #4 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
    #5 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
    #6 0x7fb618e7aa13 in asn1_string_to_bn crypto/asn1/a_int.c:503
    #7 0x7fb618e7aa13 in ASN1_INTEGER_to_BN crypto/asn1/a_int.c:559
    #8 0x7fb618fd8e79 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:814
    #9 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
    #10 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
    #11 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
    #12 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
    #13 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
    #14 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
    #15 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
    #16 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
    #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #20 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #21 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #22 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #23 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
    #24 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
    #25 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
    #26 0x402afb in testfile fuzz/test-corpus.c:182
    #27 0x402656 in main fuzz/test-corpus.c:226
    #28 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
    #29 0x402756  (/home/ed/OPC/openssl/fuzz/x509-test+0x402756)

=================================================================
==12221==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
    #2 0x7fb618ef5f11 in BN_new crypto/bn/bn_lib.c:246
    #3 0x7fb618ef82f4 in BN_bin2bn crypto/bn/bn_lib.c:440
    #4 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
    #5 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
    #6 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
    #7 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
    #8 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
    #9 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
    #10 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
    #11 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
    #12 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
    #13 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #14 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #15 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #16 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #17 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #18 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #19 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
    #20 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
    #21 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
    #22 0x402afb in testfile fuzz/test-corpus.c:182
    #23 0x402656 in main fuzz/test-corpus.c:226
    #24 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

Indirect leak of 56 byte(s) in 1 object(s) allocated from:
    #0 0x7fb61945309f in __interceptor_malloc ../../../../gcc-trunk/libsanitizer/asan/asan_malloc_linux.cpp:69
    #1 0x7fb619092430 in CRYPTO_zalloc crypto/mem.c:230
    #2 0x7fb618ef7561 in bn_expand_internal crypto/bn/bn_lib.c:280
    #3 0x7fb618ef7561 in bn_expand2 crypto/bn/bn_lib.c:304
    #4 0x7fb618ef819d in BN_bin2bn crypto/bn/bn_lib.c:454
    #5 0x7fb618fd8933 in EC_GROUP_new_from_ecparameters crypto/ec/ec_asn1.c:618
    #6 0x7fb618fd98e8 in EC_GROUP_new_from_ecpkparameters crypto/ec/ec_asn1.c:935
    #7 0x7fb618fd9aec in d2i_ECPKParameters crypto/ec/ec_asn1.c:966
    #8 0x7fb618fdace9 in d2i_ECParameters crypto/ec/ec_asn1.c:1184
    #9 0x7fb618fd1fc7 in eckey_type2param crypto/ec/ec_ameth.c:119
    #10 0x7fb618fd57b4 in eckey_pub_decode crypto/ec/ec_ameth.c:165
    #11 0x7fb6191a9c62 in x509_pubkey_decode crypto/x509/x_pubkey.c:124
    #12 0x7fb6191a9e42 in pubkey_cb crypto/x509/x_pubkey.c:46
    #13 0x7fb618eac032 in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:432
    #14 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #15 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #16 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #17 0x7fb618eacaf5 in asn1_template_noexp_d2i crypto/asn1/tasn_dec.c:643
    #18 0x7fb618ead288 in asn1_template_ex_d2i crypto/asn1/tasn_dec.c:518
    #19 0x7fb618eab9ce in asn1_item_embed_d2i crypto/asn1/tasn_dec.c:382
    #20 0x7fb618eadd1f in ASN1_item_ex_d2i crypto/asn1/tasn_dec.c:124
    #21 0x7fb618eade35 in ASN1_item_d2i crypto/asn1/tasn_dec.c:114
    #22 0x40310c in FuzzerTestOneInput fuzz/x509.c:33
    #23 0x402afb in testfile fuzz/test-corpus.c:182
    #24 0x402656 in main fuzz/test-corpus.c:226
    #25 0x7fb618551f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)

SUMMARY: AddressSanitizer: 80 byte(s) leaked in 2 allocation(s).

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/18633)

(cherry picked from commit be50862e72d96e599f1111bbb69f41b5af651c97)

23 months agoAdded documentation for PEM_X509_INFO_read() and PEM_X509_INFO_read_bio()
Allan [Mon, 20 Jun 2022 08:22:50 +0000 (01:22 -0700)]
Added documentation for PEM_X509_INFO_read() and PEM_X509_INFO_read_bio()

Fixes #18342
Fixes <propq> to I<propq>
Updated copyright year

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18623)

(cherry picked from commit 9454423bf1eac4c75e70ff4fd67456e4cfb05a92)

23 months agoUpdate fips source checksums to drop the unwanted headers
Tomas Mraz [Wed, 22 Jun 2022 13:08:58 +0000 (15:08 +0200)]
Update fips source checksums to drop the unwanted headers

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18630)

23 months agoAvoid including decoder/encoder/store headers into fips module
Tomas Mraz [Wed, 22 Jun 2022 13:08:18 +0000 (15:08 +0200)]
Avoid including decoder/encoder/store headers into fips module

Fixes #18618

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18630)

23 months agoFix compile issues in test/v3ext.c with no-rfc3779
Bernd Edlinger [Fri, 17 Jun 2022 08:25:24 +0000 (10:25 +0200)]
Fix compile issues in test/v3ext.c with no-rfc3779

There are no ASIdentifiers if OPENSSL_NO_RFC3779 is defined,
therefore the test cannot be compiled.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18634)

(cherry picked from commit b76efe61ea9710a8f69e1cb8caf1aeb2ba6f1ebe)

23 months agoAdd a CI workflow for no-rfc3779
Bernd Edlinger [Fri, 17 Jun 2022 07:30:04 +0000 (09:30 +0200)]
Add a CI workflow for no-rfc3779

Currently this configurations seem to be failing.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18634)

(cherry picked from commit a09adac311975afcb5ad099b2e1cfc7eb1e72865)

23 months agoTest whether decoded-from-explicit survives import/export
Tomas Mraz [Mon, 20 Jun 2022 10:18:44 +0000 (12:18 +0200)]
Test whether decoded-from-explicit survives import/export

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18629)

23 months agoThe flag "decoded-from-explicit" must be imp/exportable
Tomas Mraz [Mon, 20 Jun 2022 10:10:06 +0000 (12:10 +0200)]
The flag "decoded-from-explicit" must be imp/exportable

Otherwise the information that the EC group was imported from
explicit parameters is lost when the key is moved across providers.

Fixes #18600

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18629)

23 months agoput_str: Use memcpy instead of strncpy
Tomas Mraz [Wed, 22 Jun 2022 10:50:52 +0000 (12:50 +0200)]
put_str: Use memcpy instead of strncpy

This fixes a warning from latest gcc.

There is no point in using strncpy here as we
intentionally copy only the string contents without
the terminating NUL. The len is set from strlen().

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18628)

23 months agoFix the checks of X509_LOOKUP_* functions
Peiwei Hu [Tue, 24 May 2022 16:14:35 +0000 (00:14 +0800)]
Fix the checks of X509_LOOKUP_* functions

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18400)

(cherry picked from commit e22ea36fa8296b402348da8f5ab5e258be8402cf)

23 months agoFix the checks of X509_REVOKED_add1_ext_i2d
Peiwei Hu [Tue, 24 May 2022 16:09:54 +0000 (00:09 +0800)]
Fix the checks of X509_REVOKED_add1_ext_i2d

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18400)

(cherry picked from commit c540a82767954a616934ba6caa6ddc736502c574)

23 months agocrypto/http/http_client.c: Add the check for OPENSSL_strdup
Jiasheng Jiang [Wed, 22 Jun 2022 08:41:12 +0000 (16:41 +0800)]
crypto/http/http_client.c: Add the check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(), it should
be better to check the return value and return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18624)

(cherry picked from commit 816d6e578ccc4d8ae41de77e3069762d03079d18)

23 months agorsa: fix bn_reduce_once_in_place call for rsaz_mod_exp_avx512_x2
Xi Ruoyao [Wed, 22 Jun 2022 10:07:05 +0000 (18:07 +0800)]
rsa: fix bn_reduce_once_in_place call for rsaz_mod_exp_avx512_x2

bn_reduce_once_in_place expects the number of BN_ULONG, but factor_size
is moduli bit size.

Fixes #18625.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18626)

(cherry picked from commit 4d8a88c134df634ba610ff8db1eb8478ac5fd345)

23 months agotest/v3nametest.c: Add check for OPENSSL_malloc
Jiasheng Jiang [Wed, 15 Jun 2022 07:37:36 +0000 (15:37 +0800)]
test/v3nametest.c: Add check for OPENSSL_malloc

As the potential failure of the OPENSSL_malloc(),
it should be better to add the check and return
error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18573)

(cherry picked from commit b147b9daf17744d529f23b5da40397a6071a88aa)

23 months agotest/evp_test.c: Add check for OPENSSL_strdup
Jiasheng Jiang [Fri, 17 Jun 2022 08:57:15 +0000 (16:57 +0800)]
test/evp_test.c: Add check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18592)

(cherry picked from commit 5203a8dfdc209f05c7dbd9c1e5208743fcaa6752)

23 months agoImprove diagnostics on setting groups
Dmitry Belyavskiy [Fri, 17 Jun 2022 08:08:22 +0000 (10:08 +0200)]
Improve diagnostics on setting groups

- If keymgmmt is not available, it's not an error but the error message
  persists in stack
- when setting groups, it's worth saying which group is not available
Fixes #18585

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18591)

(cherry picked from commit ce8822b7e5f4fdf836677faee336a5cf996d4363)

23 months agoapps/s_server.c: Add check for OPENSSL_strdup
Jiasheng Jiang [Fri, 17 Jun 2022 09:44:24 +0000 (17:44 +0800)]
apps/s_server.c: Add check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18595)

(cherry picked from commit a6a2dd9f60b3f3e93de1337ee84f9e8f33bc86a8)

23 months agocrypto/x509/by_store.c: Add check for OPENSSL_strdup
Jiasheng Jiang [Fri, 17 Jun 2022 09:07:15 +0000 (17:07 +0800)]
crypto/x509/by_store.c: Add check for OPENSSL_strdup

As the potential failure of the OPENSSL_strdup(),
it should be better to check the return value and
return error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18593)

(cherry picked from commit e163969d3580e5b797fcebde0d3000302912ef18)

23 months agoPrepare for 3.0.5
Matt Caswell [Tue, 21 Jun 2022 13:31:08 +0000 (14:31 +0100)]
Prepare for 3.0.5

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

23 months agoPrepare for release of 3.0.4 openssl-3.0.4
Matt Caswell [Tue, 21 Jun 2022 13:30:58 +0000 (14:30 +0100)]
Prepare for release of 3.0.4

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

23 months agomake update
Matt Caswell [Tue, 21 Jun 2022 13:30:57 +0000 (14:30 +0100)]
make update

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

23 months agoUse --release in dev/release.sh
Hugo Landau [Fri, 13 May 2022 12:11:44 +0000 (13:11 +0100)]
Use --release in dev/release.sh

Fixes #18243.
Fixes #18242.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18305)

23 months agoUpdate copyright year
Matt Caswell [Tue, 21 Jun 2022 13:03:39 +0000 (14:03 +0100)]
Update copyright year

Reviewed-by: Richard Levitte <levitte@openssl.org>
Release: yes

23 months agoUpdate CHANGES.md and NEWS.md for new release
Matt Caswell [Mon, 20 Jun 2022 13:14:20 +0000 (14:14 +0100)]
Update CHANGES.md and NEWS.md for new release

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Release: yes

23 months agoc_rehash: Drop the issuer_name_hash= prefix from the CRL hash
Tomas Mraz [Mon, 13 Jun 2022 15:10:15 +0000 (17:10 +0200)]
c_rehash: Drop the issuer_name_hash= prefix from the CRL hash

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
23 months agoFix file operations in c_rehash.
Daniel Fiala [Sun, 29 May 2022 18:11:24 +0000 (20:11 +0200)]
Fix file operations in c_rehash.

CVE-2022-2068

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
23 months agoproviders/implementations/exchange/kdf_exch.c: fix unavailable SIZE_MAX
Richard Levitte [Mon, 20 Jun 2022 06:23:27 +0000 (08:23 +0200)]
providers/implementations/exchange/kdf_exch.c: fix unavailable SIZE_MAX

SIZE_MAX is used in a recent fix of this file, but without including
internal/numbers.h, so that macro ends up not existing on some platforms,
resulting in build failures.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18605)

23 months agoClarify use of EGD for HPNS in rand/rand_egd.c comments.
Randall S. Becker [Tue, 14 Jun 2022 10:10:53 +0000 (06:10 -0400)]
Clarify use of EGD for HPNS in rand/rand_egd.c comments.

Signed-off-by: Randall S. Becker <randall.becker@nexbridge.ca>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18565)

23 months agoFix documentation of BIO_FLAGS_BASE64_NO_NL
Fraser Tweedale [Wed, 15 Jun 2022 00:50:57 +0000 (10:50 +1000)]
Fix documentation of BIO_FLAGS_BASE64_NO_NL

Commit 8bfb7506d210841f2ee4eda8afe96441a0e33fa5 updated
`BIO_f_base64(3)` to improve the documentation of the
`BIO_FLAGS_BASE64_NO_NL` flag.  In particular, the updated text
states that when this flag is used, all newlines in the input are
ignored.  This is incorrect, as the following program proves:

```c

unsigned char *in_buf =
    "IlRoZSBxdWljayBicm93biBmb3gganVt\ncHMgb3ZlciBhIGxhenkgZG9nLiI=\n";

int main(int argc, char **argv) {
    BIO *b64 = BIO_new(BIO_f_base64());
    if (b64 == NULL) return 1;
    BIO_set_flags(b64, BIO_get_flags(b64) | BIO_FLAGS_BASE64_NO_NL);
    int in_len = strlen(in_buf);
    BIO *in = BIO_new_mem_buf(in_buf, in_len);
    if (in == NULL) return 2;
    in = BIO_push(b64, in);
    unsigned char *out_buf = calloc(in_len, sizeof(unsigned char));
    if (out_buf == NULL) return 3;
    size_t out_len;
    int r = BIO_read_ex(in, out_buf, in_len, &out_len);
    printf("rv = %d\n", r);
    printf("decoded = %s\n", out_buf);
    return 0;
}
```

Update the text of `BIO_f_base64(3)` to clarify that when the flag
is set, the data must be all on one line (with or without a trailing
newline character).

Signed-off-by: Fraser Tweedale <ftweedal@redhat.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18568)

(cherry picked from commit 0edcbacca99ab2b716da395f204610fc2775ea83)

23 months agoHave set_dateopt() return 1 on success to make -dateopt work
Hartmut Holzgraefe [Tue, 14 Jun 2022 08:39:47 +0000 (10:39 +0200)]
Have set_dateopt() return 1 on success to make -dateopt work

Fixes #18553

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18554)

23 months agotest/recipes/*.t: setup() doesn't play well with spaces in the argument
Richard Levitte [Fri, 10 Jun 2022 17:50:01 +0000 (19:50 +0200)]
test/recipes/*.t: setup() doesn't play well with spaces in the argument

The argument translates into a directory name, and there are platforms
that don't allow spaces (at least not easily), which makes the test fail.
This modifies it to conform a bit better to the usual form for that arg.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18531)

(cherry picked from commit e3ba938b584275839dda404d846abdb06a88693f)

23 months agoFix for OSSL_PARAM sample code referencing OSSL_PARAM_UTF8_PTR
Michael Baentsch [Tue, 7 Jun 2022 06:28:26 +0000 (08:28 +0200)]
Fix for OSSL_PARAM sample code referencing OSSL_PARAM_UTF8_PTR

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18490)

(cherry picked from commit 809526a06c1305d67a8f231ca15cd27ec800efce)

23 months agoAdd an extra reduction step to RSAZ mod_exp implementations
Tomas Mraz [Thu, 9 Jun 2022 14:20:05 +0000 (16:20 +0200)]
Add an extra reduction step to RSAZ mod_exp implementations

Inspired by BoringSSL fix by David Benjamin.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18510)

(cherry picked from commit 6d702cebfce3ffd9d8c0cb2af80a987d3288e7a3)

23 months agoAlways end BN_mod_exp_mont_consttime with normal Montgomery reduction.
Tomas Mraz [Thu, 9 Jun 2022 10:34:55 +0000 (12:34 +0200)]
Always end BN_mod_exp_mont_consttime with normal Montgomery reduction.

This partially fixes a bug where, on x86_64, BN_mod_exp_mont_consttime
would sometimes return m, the modulus, when it should have returned
zero. Thanks to Guido Vranken for reporting it. It is only a partial fix
because the same bug also exists in the "rsaz" codepath.

The bug only affects zero outputs (with non-zero inputs), so we believe
it has no security impact on our cryptographic functions.

The fx is to delete lowercase bn_from_montgomery altogether, and have the
mont5 path use the same BN_from_montgomery ending as the non-mont5 path.
This only impacts the final step of the whole exponentiation and has no
measurable perf impact.

See the original BoringSSL commit
https://boringssl.googlesource.com/boringssl/+/13c9d5c69d04485a7a8840c12185c832026c8315
for further analysis.

Original-author: David Benjamin <davidben@google.com>

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18510)

(cherry picked from commit 0ae365e1f80648f4c52aa3ac9bbc279b6192b23e)

23 months agotest/ssl_old_test.c: Add check for OPENSSL_malloc
Jiasheng Jiang [Tue, 14 Jun 2022 09:15:05 +0000 (17:15 +0800)]
test/ssl_old_test.c: Add check for OPENSSL_malloc

As the potential failure of the OPENSSL_malloc(),
it should be better to add the check and return
error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18555)

(cherry picked from commit b2feb9f0e394da6570346598837f1b01eb58c028)

23 months agoAdd sensitive memory clean in priv encode
Kan [Sun, 12 Jun 2022 13:11:01 +0000 (21:11 +0800)]
Add sensitive memory clean in priv encode

Fixes #18540

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18541)

(cherry picked from commit 16249341bb64329c2542c3d1e23b97ed3c44fad3)

23 months agotest/ssl_old_test.c: Add check for OPENSSL_zalloc
Jiasheng Jiang [Tue, 14 Jun 2022 07:06:23 +0000 (15:06 +0800)]
test/ssl_old_test.c: Add check for OPENSSL_zalloc

As the potential failure of the OPENSSL_zalloc(),
it should be better to add the check and return
error if fails.

Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18552)

(cherry picked from commit 4f4942a133bd57c4940fb1bc6ed7c8b67da4d8f0)

23 months agoFix a mem leak in evp_pkey_export_to_provider
K1 [Wed, 8 Jun 2022 08:41:16 +0000 (16:41 +0800)]
Fix a mem leak in evp_pkey_export_to_provider

If keymgmt is NULL, tmp_keymgmt is allocated and will not be freed.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18499)

(cherry picked from commit 115eb945acd9a27bf81c6c8923f43768f9e487a8)

23 months agoFix a crash in X509v3_asid_subset()
Matt Caswell [Thu, 9 Jun 2022 15:57:30 +0000 (16:57 +0100)]
Fix a crash in X509v3_asid_subset()

If the asnum or rdi fields are NULL and the ASIdentifiers are otherwise
subsets then this will result in a crash. Of note is that rdi will usually
be NULL.

Reported by Theo Buehler (@botovq)

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Yang <kaishen.yy@antfin.com>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18514)

(cherry picked from commit 01fc9b6bce82f0534d6673659a0e59a71f57ee82)

23 months agoproviders/implementations/exchange/kdf_exch.c: Fix kdf_derive()
Richard Levitte [Sat, 11 Jun 2022 05:40:40 +0000 (07:40 +0200)]
providers/implementations/exchange/kdf_exch.c: Fix kdf_derive()

kdf_derive() calls EVP_KDF_derive(), but didn't do enough to adapt its input
buffer length arguments to fit the requirements to call EVP_KDF_derive().

Fixes #18517

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18533)

23 months agotest/evp_test.c: Check too big output buffer sizes in PKEYKDF tests
Richard Levitte [Sun, 12 Jun 2022 04:03:50 +0000 (06:03 +0200)]
test/evp_test.c: Check too big output buffer sizes in PKEYKDF tests

EVP_PKEY_derive() should be able to cope with a too big buffer for fixed
size outputs.  However, we don't test that.

This change modifies the PKEYKDF tests to ask EVP_PKEY_derive() what the
desired output buffer size is, and as long as the returned value isn't
absurd (indicating that anything goes), the output buffer is made to be
twice as big as what is expected.

Tests #18517

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18533)

23 months agoFix the export routines to not return success if param alloc failed
Matt Caswell [Thu, 9 Jun 2022 11:02:37 +0000 (12:02 +0100)]
Fix the export routines to not return success if param alloc failed

We fix the dsa, dh, ec and rsa export routines so that they are
consistent with each other and do not report success if the allocation
of parameters failed.

This is essentially the same fix as applied in #18483 but applied to all
relevant key types.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18507)

(cherry picked from commit 46c1c2d7fa9153da4eb5e1aefd7b0139dc507c00)

23 months agotest_pkey_check: Positive testcase for private key with unknown parameters
Tomas Mraz [Wed, 13 Apr 2022 10:44:34 +0000 (12:44 +0200)]
test_pkey_check: Positive testcase for private key with unknown parameters

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18099)

(cherry picked from commit 08e0aad293f1c283dccf7e9065ec28af5e143304)

23 months agoossl_dh_check_priv_key: Do not fail on private keys without q
Tomas Mraz [Tue, 12 Apr 2022 13:36:05 +0000 (15:36 +0200)]
ossl_dh_check_priv_key: Do not fail on private keys without q

Fixes #18098

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18099)

(cherry picked from commit 0615cedecda7ed18300db48b0bb56cec6d3527bd)

23 months agoTestcase for regression by PPC64 fixed length montgomery multiplication
Tomas Mraz [Fri, 10 Jun 2022 12:41:27 +0000 (14:41 +0200)]
Testcase for regression by PPC64 fixed length montgomery multiplication

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18512)

(cherry picked from commit 14f95126c098358c434d59835834f9f0be7ea498)

23 months agoRevert "bn: Add fixed length (n=6), unrolled PPC Montgomery Multiplication"
Tomas Mraz [Thu, 9 Jun 2022 14:42:37 +0000 (16:42 +0200)]
Revert "bn: Add fixed length (n=6), unrolled PPC Montgomery Multiplication"

This reverts commit 0d40ca47bd86e74a95c3a2f5fb6c67cdbee93c79.

It was found that the computation produces incorrect results in some
cases.

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18512)

(cherry picked from commit 712d9cc90e355b2c98a959d4e9398610d2269c9e)

23 months agoAvoid reusing the init_lock for a different purpose
Tomas Mraz [Mon, 13 Jun 2022 13:50:18 +0000 (15:50 +0200)]
Avoid reusing the init_lock for a different purpose

Otherwise we might cause a recursive locking.

Fixes #18535

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18545)

(cherry picked from commit e9a806b2c265da3a4ca472acb4a4286d9c1b5c9d)

23 months agoRSA keygen update: Raise an error if no prime candidate q is found.
slontis [Mon, 30 May 2022 08:07:40 +0000 (18:07 +1000)]
RSA keygen update: Raise an error if no prime candidate q is found.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18429)

(cherry picked from commit d2399d8cd29f56e6614f0b3db4e7e563a745902a)

23 months agoRSA Keygen update - When using the default provider fallback to default multiprime...
slontis [Mon, 30 May 2022 08:03:11 +0000 (18:03 +1000)]
RSA Keygen update - When using the default provider fallback to default multiprime keygen if e is < 65537

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18429)

(cherry picked from commit 27c1cfd7653b7204af3301f93ccd2a3decfc309b)

23 months agoRSA keygen fixes
slontis [Mon, 30 May 2022 07:56:53 +0000 (17:56 +1000)]
RSA keygen fixes

Fixes #18321

Increase the iteration factor used when 'Computing a Probable Prime Factor Based on Auxiliary Primes' from 5 to 20.
This matches the algorithm update made in FIPS 186-5.

Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18429)

(cherry picked from commit ad7e0fd550a9eb2946edf38003ebc6d5b988dac7)

23 months agoInclude the modules directory in openssl.pc
Richard Levitte [Fri, 10 Jun 2022 06:36:42 +0000 (08:36 +0200)]
Include the modules directory in openssl.pc

Affected file: Configurations/unix-Makefile.tmpl

Fixes #18516

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18520)

23 months agosm2_dupctx: Avoid potential use after free of the md
Tomas Mraz [Wed, 8 Jun 2022 15:48:39 +0000 (17:48 +0200)]
sm2_dupctx: Avoid potential use after free of the md

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18494)

(cherry picked from commit 926c698c6f0a197e0322d4617db0ecd0d40f6e06)

23 months agoCheck return of BIO_new() and always free pkey from evp_pkey_copy_downgraded()
Tomas Mraz [Tue, 7 Jun 2022 16:49:29 +0000 (18:49 +0200)]
Check return of BIO_new() and always free pkey from evp_pkey_copy_downgraded()

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18494)

(cherry picked from commit d8732803c493cba7a863c5c16da62ee9d611c5ca)

23 months agoadd_provider_groups: Clean up algorithm pointer on failure
Tomas Mraz [Tue, 7 Jun 2022 12:17:32 +0000 (14:17 +0200)]
add_provider_groups: Clean up algorithm pointer on failure

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18494)

(cherry picked from commit a7863f994955c45fb7ce29e30b81a6206994c3dd)

23 months agoparse_unquoted: Check returned value from ossl_property_value()
Tomas Mraz [Tue, 7 Jun 2022 12:16:30 +0000 (14:16 +0200)]
parse_unquoted: Check returned value from ossl_property_value()

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18494)

(cherry picked from commit f91568eb50e847d0db2441fd9b9c5ffc8c4fe934)

23 months agoFix a use after free in error handling of hmac_dup
Bernd Edlinger [Wed, 8 Jun 2022 15:36:52 +0000 (17:36 +0200)]
Fix a use after free in error handling of hmac_dup

dst->digest needs to be zeroized in case HMAC_CTX_copy
or ossl_prov_digest_copy return failure.

Fixes #18493

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18502)

(cherry picked from commit cec1699f1f54ba8b87f055776dc77b48dd37d5fa)

23 months agoAssert that a property definition cache entry is the first
Matt Caswell [Mon, 6 Jun 2022 09:06:57 +0000 (10:06 +0100)]
Assert that a property definition cache entry is the first

When adding a property definition cache entry for a given property query
string we add an assert that we are not replacing an existing entry. If we
are then that indicates a bug in the caller.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18458)

(cherry picked from commit 5f4b3db624a83b812f23412e698ffd9c4284f87a)

23 months agoFix a memory leak in ossl_method_store_add()
Matt Caswell [Thu, 2 Jun 2022 10:14:32 +0000 (11:14 +0100)]
Fix a memory leak in ossl_method_store_add()

If the call to ossl_prop_defn_set() fails then the OSSL_PROPERTY_LIST
we just created will leak.

Found as a result of:
https://github.com/openssl/openssl/pull/18355#issuecomment-1139499881

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18458)

(cherry picked from commit fed8dbea27b7e01ee934951b25c6ffd40ad1d5c3)

23 months agoUpdate SIV mode documentation
Todd Short [Mon, 6 Jun 2022 15:46:36 +0000 (11:46 -0400)]
Update SIV mode documentation

Fixes #18440

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18485)

(cherry picked from commit 9cef2a70b151b6a92eb1770ceb5fa90331305934)

23 months agoDon't report success from ec_export if OSSL_PARAM_BLD_to_param failed
Matt Caswell [Mon, 6 Jun 2022 09:32:49 +0000 (10:32 +0100)]
Don't report success from ec_export if OSSL_PARAM_BLD_to_param failed

If the call to OSSL_PARAM_BLD_to_param() failed then ec_export was
reporting success, even though it has never called the param_cb.

Found due to:
https://github.com/openssl/openssl/pull/18355#issuecomment-1145993650

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18483)

(cherry picked from commit 7d6aad832b4cebb181c53ab80a3f61dc8549be08)

23 months agoFix a mem leak in evp_pkey_copy_downgraded()
Matt Caswell [Fri, 3 Jun 2022 13:01:22 +0000 (14:01 +0100)]
Fix a mem leak in evp_pkey_copy_downgraded()

If we get a failure during evp_pkey_copy_downgraded() and on entry *dest
was NULL then we leak the EVP_PKEY that was automatically allocated and
stored in *dest.

Found due to this comment:
https://github.com/openssl/openssl/pull/18355#issuecomment-1145028315

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18470)

23 months agoCheck return value of ossl_parse_property()
Tomas Mraz [Thu, 2 Jun 2022 14:50:15 +0000 (16:50 +0200)]
Check return value of ossl_parse_property()

Also check if we have d2i_public_key() function pointer.

Fixes https://github.com/openssl/openssl/pull/18355#issuecomment-1144893289

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18462)

(cherry picked from commit 4fa5ed5ce5c345eaeaec8b86eda265add467f941)

23 months agoCONF_modules_unload should fail if CONF_modules_finish fails
Matt Caswell [Thu, 2 Jun 2022 12:54:45 +0000 (13:54 +0100)]
CONF_modules_unload should fail if CONF_modules_finish fails

The module_list_lock is used by CONF_modules_unload(). That function relies
on the RUN_ONCE in CONF_modules_finish() to initialise that lock. However
if the RUN_ONCE fails that failure is not propagated to
CONF_modules_unload() and so it erroneously tries to use the lock anyway.

Found due to:
https://github.com/openssl/openssl/pull/18355#issuecomment-1144734604

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18460)

(cherry picked from commit 697d0b5ba146c232f5b2aa87f4e847a5495c1735)

23 months agoFix inadvertent NULL assignments in ternary ops
Clemens Lang [Fri, 3 Jun 2022 11:23:36 +0000 (13:23 +0200)]
Fix inadvertent NULL assignments in ternary ops

As identified by both clang with a warning and
$> git grep -P '(?<![!=])= NULL \?'

Signed-off-by: Clemens Lang <cllang@redhat.com>
CLA: trivial

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18469)

(cherry picked from commit 1a01e5c29dfaf09af3960b4c8e6ec0f8171eda80)

23 months agoUpdate further expiring certificates that affect tests
Tomas Mraz [Thu, 2 Jun 2022 16:12:05 +0000 (18:12 +0200)]
Update further expiring certificates that affect tests

Namely the smime certificates used in test_cms and the
SM2 certificates will expire soon and affect tests.

Fixes #15179

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18467)

(cherry picked from commit 5d219937d067a761fb871483369a6020c60a3cb8)

23 months agoChange the SCT issuer key to RSA 2048
Bernd Edlinger [Wed, 1 Jun 2022 14:37:05 +0000 (16:37 +0200)]
Change the SCT issuer key to RSA 2048

This avoids the need to use SECLEVEL=1 in 12-ct.cnf.in.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18450)

(cherry picked from commit 479b9adb88b9050186c1e9fc94879906f378b14b)

23 months agoFix strict client chain check with TLS-1.3
Tomas Mraz [Tue, 29 Mar 2022 11:31:34 +0000 (13:31 +0200)]
Fix strict client chain check with TLS-1.3

When TLS-1.3 is used and the server does not send any CA names
the ca_dn will be NULL. sk_X509_NAME_num() returns -1 on null
argument.

Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17986)

(cherry picked from commit 89dd85430770d39cbfb15eb586c921958ca7687f)

23 months agoAdd VERSIONINFO resource to legacy provider if it is not builtin
slontis [Tue, 31 May 2022 23:28:55 +0000 (09:28 +1000)]
Add VERSIONINFO resource to legacy provider if it is not builtin

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18416)

(cherry picked from commit 9510661400470d357c74c5c4d0ff01c7b813b974)

23 months agoAdd Windows VERSIONINFO resource to fips provider dll.
slontis [Fri, 27 May 2022 04:40:18 +0000 (14:40 +1000)]
Add Windows VERSIONINFO resource to fips provider dll.

Fixes #18388

This just looks like an omission, as this is added to libcrypto and libssl

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18416)

(cherry picked from commit 18f0870d39eb055c8c67af8025fd1b9e01ce6a43)

23 months agoFix the checks of BIO_get_cipher_status
Peiwei Hu [Sat, 28 May 2022 16:07:04 +0000 (00:07 +0800)]
Fix the checks of BIO_get_cipher_status

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit 48b571fe771f283d547ca2a5999ce5dd9a5509d0)

23 months agoFix the checks of EVP_PKEY_param_check
Peiwei Hu [Sat, 28 May 2022 16:05:28 +0000 (00:05 +0800)]
Fix the checks of EVP_PKEY_param_check

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit e85bef981c037a6ebc0ca39f61c11bd79ed89fb3)

23 months agoFix the checks of UI_add_input_string
Peiwei Hu [Sat, 28 May 2022 16:02:37 +0000 (00:02 +0800)]
Fix the checks of UI_add_input_string

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit 5755c11fd6e50028946e6e17c835afcd56995699)

23 months agoFix the checks of EVP_PKEY_private_check
Peiwei Hu [Sat, 28 May 2022 15:59:36 +0000 (23:59 +0800)]
Fix the checks of EVP_PKEY_private_check

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit babc818c3f669214fa192229003953e3dead1926)

23 months agoFix the checks of EVP_PKEY_public_check
Peiwei Hu [Sat, 28 May 2022 15:56:02 +0000 (23:56 +0800)]
Fix the checks of EVP_PKEY_public_check

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit bba14c6e28e9519b2d40fc5c551893996f2db246)

23 months agoFix the checks of EVP_PKEY_pairwise_check
Peiwei Hu [Sat, 28 May 2022 15:53:19 +0000 (23:53 +0800)]
Fix the checks of EVP_PKEY_pairwise_check

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit d016758706d0a7a104ff09db94448aeec1b38193)

23 months agoFix the checks of EVP_PKEY_check
Peiwei Hu [Sat, 28 May 2022 15:51:32 +0000 (23:51 +0800)]
Fix the checks of EVP_PKEY_check

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit 92d0d7ea9be40909ee79fb8861641a61eead2431)

23 months agoFix the checks of RAND_bytes
Peiwei Hu [Sat, 28 May 2022 15:46:33 +0000 (23:46 +0800)]
Fix the checks of RAND_bytes

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
(Merged from https://github.com/openssl/openssl/pull/18424)

(cherry picked from commit c2f7614fb7b93fe3792068077ff01384f42f39bc)

23 months agoCTLOG_new_ex: Fix copy&paste error when setting propq
Tomas Mraz [Mon, 30 May 2022 15:02:03 +0000 (17:02 +0200)]
CTLOG_new_ex: Fix copy&paste error when setting propq

Fixes #18431

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18432)

(cherry picked from commit 163bf682fd93971d07e66e3da339c229b86dc849)

23 months agoFix possible null pointer dereference of evp_pkey_get_legacy()
Zhou Qingyang [Fri, 25 Mar 2022 12:28:32 +0000 (20:28 +0800)]
Fix possible null pointer dereference of evp_pkey_get_legacy()

evp_pkey_get_legacy() will return NULL on failure, however several
uses of it or its wrappers does not check the return value of
evp_pkey_get_legacy(), which could lead to NULL pointer dereference.

Fix those possible bugs by adding NULL checking.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17967)

(cherry picked from commit b9a86d5dd8b5bd33be42390bcbb5121fe0ae71a1)

23 months agoDon't call ossl_provider_free() without first setting refcnt
Matt Caswell [Fri, 27 May 2022 10:07:37 +0000 (11:07 +0100)]
Don't call ossl_provider_free() without first setting refcnt

The function ossl_provider_free() decrements the refcnt of the
provider and frees it if it has reached 0. This only works if the
refcnt has already been initialised. We must only call
ossl_provider_free() after this initialisation - otherwise it will fail
to free the provider correctly.

Addresses the issue mentioned here:
https://github.com/openssl/openssl/pull/18355#issuecomment-1138741857

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18417)

(cherry picked from commit c4ed6f6f0ee700e0473def049659061dd52fd3fc)

23 months agoFix a memory leak is ossl_provider_doall_activated
Matt Caswell [Thu, 26 May 2022 14:34:38 +0000 (15:34 +0100)]
Fix a memory leak is ossl_provider_doall_activated

If the callback fails then we don't correctly free providers that were
already in our stack and that we up-refed earlier.

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18413)

(cherry picked from commit b4be10dfcd370960cecfda9773e1bfcc568a7390)

23 months agoFix another decoder mem leak on an error path
Matt Caswell [Thu, 26 May 2022 10:30:09 +0000 (11:30 +0100)]
Fix another decoder mem leak on an error path

If pushing the decoder onto a stack fails then we should free the ref
we just created.

Found due to the error report here:
https://github.com/openssl/openssl/pull/18355#issuecomment-1138205688

Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18411)

(cherry picked from commit da3193976380b8bd697a472025ff9f384cbca7af)

23 months agoFix a decoder mem leak on an error path
Matt Caswell [Thu, 26 May 2022 10:09:58 +0000 (11:09 +0100)]
Fix a decoder mem leak on an error path

If an error condition occurs then the the decoder that was up-refed in
ossl_decoder_instance_new can be leaked.

Found due to the error report here:
https://github.com/openssl/openssl/pull/18355#issuecomment-1138205688

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/18410)

(cherry picked from commit 9ec9b968f93e4a8e7c90eb1e717f0d7cd4ab722d)

23 months agothreadstest: Add missing framework for multithread tests
Tomas Mraz [Wed, 1 Jun 2022 15:08:55 +0000 (17:08 +0200)]
threadstest: Add missing framework for multithread tests

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18451)

23 months agoFix the checks of EVP_PKEY_CTX_set/get_* functions
Peiwei Hu [Tue, 24 May 2022 15:57:33 +0000 (23:57 +0800)]
Fix the checks of EVP_PKEY_CTX_set/get_* functions

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18399)

(cherry picked from commit 2cba2e160d5b028e4a777e8038744a8bc4280629)

23 months agoFix the check of evp_pkey_ctx_set_params_strict
Peiwei Hu [Tue, 24 May 2022 15:40:12 +0000 (23:40 +0800)]
Fix the check of evp_pkey_ctx_set_params_strict

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18399)

(cherry picked from commit 00d5193b688019a85d1bd0196f2837a4476394bb)

23 months agoFix the checks of EVP_PKEY_CTX_get/set_rsa_pss_saltlen
Peiwei Hu [Tue, 24 May 2022 15:38:39 +0000 (23:38 +0800)]
Fix the checks of EVP_PKEY_CTX_get/set_rsa_pss_saltlen

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18399)

(cherry picked from commit 7263a7fc3d0c0c17616c2e5309e0fd52ed654ecc)

23 months agoFix the erroneous checks of EVP_PKEY_CTX_set_group_name
Peiwei Hu [Tue, 24 May 2022 15:27:49 +0000 (23:27 +0800)]
Fix the erroneous checks of EVP_PKEY_CTX_set_group_name

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18399)

(cherry picked from commit 56876ae952b96b4a83266f6b2ec1393f599015d6)

2 years agodoc: Fix keymgmt functions parameters
Ladislav Marko [Sat, 28 May 2022 10:59:34 +0000 (12:59 +0200)]
doc: Fix keymgmt functions parameters

CLA: trivial

Make OSSL_FUNC_keymgmt_import and OSSL_FUNC_keymgmt_export documentation correspond to core_dispatch.h signatures

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18423)

(cherry picked from commit 70ed3046c5f156cab45a2bb2c8e36ab5d29a45ca)

2 years agoUpdate expired SCT issuer certificate
Tomas Mraz [Wed, 1 Jun 2022 10:06:33 +0000 (12:06 +0200)]
Update expired SCT issuer certificate

Fixes #15179

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/18444)

(cherry picked from commit 770aea88c3888cc5cb3ebc94ffcef706c68bc1d2)

2 years agoMake OSSL_LIB_CTX_load_config thread safe
Hugo Landau [Tue, 17 May 2022 12:47:57 +0000 (13:47 +0100)]
Make OSSL_LIB_CTX_load_config thread safe

Fixes #18226.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18331)

(cherry picked from commit ef7a9b44f04ef18b652cb47cd9eb3826301cca9e)

2 years agochanges: add note saying the locale based strcasecmp has been replaced
Pauli [Tue, 24 May 2022 07:31:06 +0000 (17:31 +1000)]
changes: add note saying the locale based strcasecmp has been replaced

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/18390)

2 years agoCheck that UnsafeLegacyServerConnect option exists
Tomas Mraz [Thu, 12 May 2022 10:11:08 +0000 (12:11 +0200)]
Check that UnsafeLegacyServerConnect option exists

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/18296)

(cherry picked from commit abe90105ba0908d5a2f500997f2bf2fceb263acd)

2 years agoThe -no_legacy_server_connect option applies to client
Tomas Mraz [Thu, 12 May 2022 09:53:27 +0000 (11:53 +0200)]
The -no_legacy_server_connect option applies to client

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/18296)

(cherry picked from commit d1b3b6741380a1d7607da671b97f3fe5f54fa657)