From 9970af8320879b88b8a372f0f2c923e882c4fb81 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 07:56:28 +0000 Subject: [PATCH 01/17] Bump actions/checkout from 2 to 4 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] CLA: trivial Reviewed-by: Hugo Landau Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21953) (cherry picked from commit d4231af60a8d04196b3b873c2fa8638daff36173) Signed-off-by: Huiyue Xu --- .github/workflows/ci.yml | 40 ++++++++++++------------- .github/workflows/compiler-zoo.yml | 2 +- .github/workflows/coveralls.yml | 2 +- .github/workflows/cross-compiles.yml | 2 +- .github/workflows/fips-checksums.yml | 4 +-- .github/workflows/fips-old.yml | 2 +- .github/workflows/fuzz-checker.yml | 2 +- .github/workflows/run-checker-ci.yml | 2 +- .github/workflows/run-checker-daily.yml | 2 +- .github/workflows/run-checker-merge.yml | 2 +- .github/workflows/windows.yml | 6 ++-- 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd419303c3..2f1564b379 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,7 @@ jobs: run: | sudo apt-get update sudo apt-get -yq --no-install-suggests --no-install-recommends --force-yes install unifdef - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: config @@ -44,7 +44,7 @@ jobs: check_docs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured --strict-warnings enable-fips && perl configdata.pm --dump - name: make build_generated @@ -62,7 +62,7 @@ jobs: check-ansi: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: CPPFLAGS=-ansi ./config --banner=Configured no-asm no-makedepend enable-buildtest-c++ enable-fips --strict-warnings -D_DEFAULT_SOURCE && perl configdata.pm --dump - name: make @@ -71,7 +71,7 @@ jobs: basic_gcc: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: localegen run: sudo locale-gen tr_TR.UTF-8 - name: config @@ -84,7 +84,7 @@ jobs: basic_clang: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: CC=clang ./config --banner=Configured no-fips --strict-warnings && perl configdata.pm --dump - name: make @@ -95,7 +95,7 @@ jobs: minimal: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured --strict-warnings no-bulk no-pic no-asm -DOPENSSL_NO_SECURE_MEMORY -DOPENSSL_SMALL_FOOTPRINT && perl configdata.pm --dump - name: make @@ -106,7 +106,7 @@ jobs: no-deprecated: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured --strict-warnings no-deprecated enable-fips && perl configdata.pm --dump - name: make @@ -120,7 +120,7 @@ jobs: os: [ ubuntu-latest, macos-latest ] runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured --strict-warnings no-shared no-fips && perl configdata.pm --dump - name: make @@ -131,7 +131,7 @@ jobs: non-caching: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured --debug enable-asan enable-ubsan no-cached-fetch no-fips no-dtls no-tls1 no-tls1-method no-tls1_1 no-tls1_1-method no-async && perl configdata.pm --dump - name: make @@ -142,7 +142,7 @@ jobs: address_ub_sanitizer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured --debug enable-asan enable-ubsan enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-fips -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION && perl configdata.pm --dump - name: make @@ -153,7 +153,7 @@ jobs: memory_sanitizer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config # --debug -O1 is to produce a debug build that runs in a reasonable amount of time run: CC=clang ./config --banner=Configured --debug -O1 -fsanitize=memory -DOSSL_SANITIZE_MEMORY -fno-optimize-sibling-calls enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-fips && perl configdata.pm --dump @@ -165,7 +165,7 @@ jobs: threads_sanitizer: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: CC=clang ./config --banner=Configured no-fips --strict-warnings -fsanitize=thread && perl configdata.pm --dump - name: make @@ -176,7 +176,7 @@ jobs: enable_non-default_options: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: modprobe tls run: sudo modprobe tls - name: config @@ -189,7 +189,7 @@ jobs: fips_and_ktls: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: modprobe tls run: sudo modprobe tls - name: config @@ -202,7 +202,7 @@ jobs: no-legacy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured --strict-warnings no-legacy enable-fips && perl configdata.pm --dump - name: make @@ -213,7 +213,7 @@ jobs: legacy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured -Werror --debug no-afalgeng no-shared enable-crypto-mdebug enable-rc5 enable-md2 enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers enable-zlib enable-ec_nistp_64_gcc_128 no-fips && perl configdata.pm --dump - name: make @@ -224,7 +224,7 @@ jobs: buildtest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: ./config --banner=Configured no-asm no-makedepend enable-buildtest-c++ enable-fips --strict-warnings -D_DEFAULT_SOURCE && perl configdata.pm --dump - name: make @@ -238,7 +238,7 @@ jobs: os: [ubuntu-latest, macos-latest ] runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: extra preparations run: | mkdir ./build @@ -259,7 +259,7 @@ jobs: external-tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive - name: package installs @@ -290,7 +290,7 @@ jobs: PYTHON: - 3.9 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive - name: Configure OpenSSL diff --git a/.github/workflows/compiler-zoo.yml b/.github/workflows/compiler-zoo.yml index a20a84cffe..4f17322ec5 100644 --- a/.github/workflows/compiler-zoo.yml +++ b/.github/workflows/compiler-zoo.yml @@ -99,7 +99,7 @@ jobs: sudo apt-get update sudo apt-get -y install ${{ matrix.zoo.cc }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: | diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 3d7800a894..5aa595ce8d 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -22,7 +22,7 @@ jobs: contents: read # for actions/checkout to fetch code runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: package installs run: | sudo apt-get -yq install lcov diff --git a/.github/workflows/cross-compiles.yml b/.github/workflows/cross-compiles.yml index 31b6cbd3f1..65bb9cbce4 100644 --- a/.github/workflows/cross-compiles.yml +++ b/.github/workflows/cross-compiles.yml @@ -137,7 +137,7 @@ jobs: sudo apt-get -yq --force-yes install \ gcc-${{ matrix.platform.arch }} \ ${{ matrix.platform.libs }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config with FIPS if: matrix.platform.fips != 'no' diff --git a/.github/workflows/fips-checksums.yml b/.github/workflows/fips-checksums.yml index 1f62ed45b3..002494f58c 100644 --- a/.github/workflows/fips-checksums.yml +++ b/.github/workflows/fips-checksums.yml @@ -26,7 +26,7 @@ jobs: mkdir ./build mkdir ./source mkdir ./artifact - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: ${{ github.event.pull_request.base.repo.full_name }} ref: ${{ github.event.pull_request.base.ref }} @@ -43,7 +43,7 @@ jobs: - name: make fips-checksums pristine run: make fips-checksums working-directory: ./build-pristine - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: source - name: config diff --git a/.github/workflows/fips-old.yml b/.github/workflows/fips-old.yml index 8ff4d850d2..3589c83266 100644 --- a/.github/workflows/fips-old.yml +++ b/.github/workflows/fips-old.yml @@ -26,7 +26,7 @@ jobs: steps: - name: create directory run: mkdir ./current - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: path: current - name: download module source diff --git a/.github/workflows/fuzz-checker.yml b/.github/workflows/fuzz-checker.yml index 247389e518..ce6d894a98 100644 --- a/.github/workflows/fuzz-checker.yml +++ b/.github/workflows/fuzz-checker.yml @@ -48,7 +48,7 @@ jobs: run: | sudo apt-get update sudo apt-get -yq --force-yes install ${{ matrix.fuzzy.install }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: | diff --git a/.github/workflows/run-checker-ci.yml b/.github/workflows/run-checker-ci.yml index 05d1426a39..73ee5f1f80 100644 --- a/.github/workflows/run-checker-ci.yml +++ b/.github/workflows/run-checker-ci.yml @@ -40,7 +40,7 @@ jobs: ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: CC=clang ./config --banner=Configured --strict-warnings ${{ matrix.opt }} - name: config dump diff --git a/.github/workflows/run-checker-daily.yml b/.github/workflows/run-checker-daily.yml index 3303ca0d83..8b7252b128 100644 --- a/.github/workflows/run-checker-daily.yml +++ b/.github/workflows/run-checker-daily.yml @@ -133,7 +133,7 @@ jobs: ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: CC=clang ./config --banner=Configured --strict-warnings ${{ matrix.opt }} - name: config dump diff --git a/.github/workflows/run-checker-merge.yml b/.github/workflows/run-checker-merge.yml index 456477b8c8..14dfa7c2d4 100644 --- a/.github/workflows/run-checker-merge.yml +++ b/.github/workflows/run-checker-merge.yml @@ -32,7 +32,7 @@ jobs: ] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: config run: CC=clang ./config --banner=Configured --strict-warnings ${{ matrix.opt }} - name: config dump diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2d61ef8d24..8c518d17d9 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -27,7 +27,7 @@ jobs: config: --strict-warnings no-fips runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ilammy/msvc-dev-cmd@v1 with: arch: ${{ matrix.platform.arch }} @@ -63,7 +63,7 @@ jobs: - windows-2022 runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ilammy/msvc-dev-cmd@v1 - uses: shogo82148/actions-setup-perl@v1 - name: prepare the build directory @@ -87,7 +87,7 @@ jobs: - windows-2022 runs-on: ${{matrix.os}} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: ilammy/msvc-dev-cmd@v1 - uses: shogo82148/actions-setup-perl@v1 - name: prepare the build directory -- Gitee From 3c73a2dd1eef029770b2f310093b1bc1feb9d086 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 4 Sep 2023 09:40:28 +0200 Subject: [PATCH 02/17] Fix internal memory leaks from OPENSSL_MALLOC_FAILURES There is a rarely used feature that can be enabled with `./config enable-crypto-mdebug` when additionally the environment variable OPENSSL_MALLOC_FAILURES is used. It turns out to be possible that CRYPTO_zalloc may create a leak when the memory is allocated and then the shouldfail happens, then the memory is lost. Likewise when OPENSSL_realloc is used with size=0, then the memory is to be free'd but here the shouldfail check is too early, and the failure may prevent the memory to be freed thus creating a bogus memory leak. Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/21944) (cherry picked from commit e2cf38d5751d6b48c8625b622c3765d0a39958d7) Signed-off-by: Huiyue Xu --- crypto/mem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crypto/mem.c b/crypto/mem.c index f6cdcf5a42..d575dcdc13 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -195,7 +195,6 @@ void *CRYPTO_zalloc(size_t num, const char *file, int line) void *ret; ret = CRYPTO_malloc(num, file, line); - FAILTEST(); if (ret != NULL) memset(ret, 0, num); @@ -208,7 +207,6 @@ void *CRYPTO_realloc(void *str, size_t num, const char *file, int line) if (realloc_impl != CRYPTO_realloc) return realloc_impl(str, num, file, line); - FAILTEST(); if (str == NULL) return CRYPTO_malloc(num, file, line); @@ -217,6 +215,7 @@ void *CRYPTO_realloc(void *str, size_t num, const char *file, int line) return NULL; } + FAILTEST(); return realloc(str, num); } -- Gitee From 053b6618faffc6407ee7c8048026ae5ee66d787b Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Thu, 3 Aug 2023 16:52:49 +0200 Subject: [PATCH 03/17] apps.c: fix error messages (newline and needless text) in load_key_certs_crls() Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/21659) (cherry picked from commit 81d037b8adb0232c8a4d4654f79c883dafb102bc) Signed-off-by: Huiyue Xu --- apps/lib/apps.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 4baeb352fe..04425ea1d7 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -944,7 +944,7 @@ int load_key_certs_crls_suppress(const char *uri, int format, int maybe_stdin, BIO *bio; if (!maybe_stdin) { - BIO_printf(bio_err, "No filename or uri specified for loading"); + BIO_printf(bio_err, "No filename or uri specified for loading\n"); goto end; } uri = ""; @@ -960,10 +960,8 @@ int load_key_certs_crls_suppress(const char *uri, int format, int maybe_stdin, ctx = OSSL_STORE_open_ex(uri, libctx, propq, get_ui_method(), &uidata, params, NULL, NULL); } - if (ctx == NULL) { - BIO_printf(bio_err, "Could not open file or uri for loading"); + if (ctx == NULL) goto end; - } if (expect > 0 && !OSSL_STORE_expect(ctx, expect)) goto end; -- Gitee From 9379adaea2ee7905afbe4f2d87d1328218226dd3 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Fri, 4 Aug 2023 08:23:58 +0200 Subject: [PATCH 04/17] apps.c: improve warning texts of parse_name() when skipping RDN input Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/21659) (cherry picked from commit 49e097344ba51a8b25016794d482813b9c1e137f) Signed-off-by: Huiyue Xu --- apps/lib/apps.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 04425ea1d7..572f6a3f8f 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -1946,16 +1946,17 @@ X509_NAME *parse_name(const char *cp, int chtype, int canmulti, nid = OBJ_txt2nid(typestr); if (nid == NID_undef) { BIO_printf(bio_err, - "%s: Skipping unknown %s name attribute \"%s\"\n", + "%s warning: Skipping unknown %s name attribute \"%s\"\n", opt_getprog(), desc, typestr); if (ismulti) BIO_printf(bio_err, - "Hint: a '+' in a value string needs be escaped using '\\' else a new member of a multi-valued RDN is expected\n"); + "%s hint: a '+' in a value string needs be escaped using '\\' else a new member of a multi-valued RDN is expected\n", + opt_getprog()); continue; } if (*valstr == '\0') { BIO_printf(bio_err, - "%s: No value provided for %s name attribute \"%s\", skipped\n", + "%s warning: No value provided for %s name attribute \"%s\", skipped\n", opt_getprog(), desc, typestr); continue; } -- Gitee From 7b5318c19ea39f0b0b519fc9e52fda822ff764a5 Mon Sep 17 00:00:00 2001 From: "Dr. David von Oheimb" Date: Fri, 4 Aug 2023 19:02:28 +0200 Subject: [PATCH 05/17] apps/cmp.c: fix bug not allowing to reset -csr and -serial option values Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/21659) (cherry picked from commit 374945a9aa545d4d6f015de0b48cbed6a90258e0) Signed-off-by: Huiyue Xu --- apps/cmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/cmp.c b/apps/cmp.c index a317fdb0bf..c479b15496 100644 --- a/apps/cmp.c +++ b/apps/cmp.c @@ -2512,7 +2512,7 @@ static int get_opts(int argc, char **argv) } break; case OPT_CSR: - opt_csr = opt_arg(); + opt_csr = opt_str(); break; case OPT_OUT_TRUSTED: opt_out_trusted = opt_str(); -- Gitee From 933990995dbfacfecf617fad6e4b4be9bd9ebcf7 Mon Sep 17 00:00:00 2001 From: Min Zhou Date: Wed, 6 Sep 2023 11:52:26 +0800 Subject: [PATCH 06/17] test/chacha: replace CPUID_OBJ with OPENSSL_CPUID_OBJ Fixes #21977 Signed-off-by: Min Zhou Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21978) (cherry picked from commit e6b6b18af3e85a6b5f0d8ea1070f7070557d6357) Signed-off-by: Huiyue Xu --- test/chacha_internal_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/chacha_internal_test.c b/test/chacha_internal_test.c index 878bd752e0..d52479b658 100644 --- a/test/chacha_internal_test.c +++ b/test/chacha_internal_test.c @@ -181,7 +181,7 @@ static int test_cha_cha_internal(int n) int setup_tests(void) { -#ifdef CPUID_OBJ +#ifdef OPENSSL_CPUID_OBJ OPENSSL_cpuid_setup(); #endif -- Gitee From 43da26c5a075c4273ecb4f672e1848d7a683f227 Mon Sep 17 00:00:00 2001 From: wangcheng Date: Wed, 6 Sep 2023 21:29:38 +0800 Subject: [PATCH 07/17] Modify the dkeyform type to support engine The valtype value of dkeyform defined in the s_server_options structure is F, which leads to the judgment that the engine is not supported when processing parameters in the opt_next function. This the valtype value of dkeyform should be changed to "f". CLA: trivial Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/21982) (cherry picked from commit b9a189ce87fde1de4bf691031624538262f005c5) Signed-off-by: Huiyue Xu --- apps/s_server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/s_server.c b/apps/s_server.c index a203d6a091..c8ccdfd03c 100644 --- a/apps/s_server.c +++ b/apps/s_server.c @@ -789,7 +789,7 @@ const OPTIONS s_server_options[] = { "second server certificate chain file in PEM format"}, {"dkey", OPT_DKEY, '<', "Second private key file to use (usually for DSA)"}, - {"dkeyform", OPT_DKEYFORM, 'F', + {"dkeyform", OPT_DKEYFORM, 'f', "Second key file format (ENGINE, other values ignored)"}, {"dpass", OPT_DPASS, 's', "Second private key and cert file pass phrase source"}, -- Gitee From 46eb254c423f9ffe4faa4f33d979425ebbfa1a15 Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 7 Sep 2023 09:27:37 +1000 Subject: [PATCH 08/17] Check error return from cms_sd_asn1_ctrl() correctly. Fixes #21986 Reviewed-by: Tomas Mraz Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/21988) (cherry picked from commit 00a413e2483257a17239cef5dde52df14926284c) Signed-off-by: Huiyue Xu --- crypto/cms/cms_sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/cms/cms_sd.c b/crypto/cms/cms_sd.c index 34c021bba6..626401add4 100644 --- a/crypto/cms/cms_sd.c +++ b/crypto/cms/cms_sd.c @@ -233,9 +233,9 @@ static int cms_sd_asn1_ctrl(CMS_SignerInfo *si, int cmd) int i; if (EVP_PKEY_is_a(pkey, "DSA") || EVP_PKEY_is_a(pkey, "EC")) - return ossl_cms_ecdsa_dsa_sign(si, cmd); + return ossl_cms_ecdsa_dsa_sign(si, cmd) > 0; else if (EVP_PKEY_is_a(pkey, "RSA") || EVP_PKEY_is_a(pkey, "RSA-PSS")) - return ossl_cms_rsa_sign(si, cmd); + return ossl_cms_rsa_sign(si, cmd) > 0; /* Something else? We'll give engines etc a chance to handle this */ if (pkey->ameth == NULL || pkey->ameth->pkey_ctrl == NULL) -- Gitee From 09a11b65967b645c734332f59f7512caab12ab2a Mon Sep 17 00:00:00 2001 From: Pauli Date: Thu, 7 Sep 2023 12:35:10 +1000 Subject: [PATCH 09/17] Add test case for #21986 Reviewed-by: Tomas Mraz Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/21988) (cherry picked from commit c870a465864259f0bdec0953ad085da31941bc27) Signed-off-by: Huiyue Xu --- test/recipes/80-test_cms.t | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/recipes/80-test_cms.t b/test/recipes/80-test_cms.t index cabbe3ecdf..9759483979 100644 --- a/test/recipes/80-test_cms.t +++ b/test/recipes/80-test_cms.t @@ -50,7 +50,7 @@ my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib) $no_rc2 = 1 if disabled("legacy"); -plan tests => 16; +plan tests => 17 ok(run(test(["pkcs7_test"])), "test pkcs7"); @@ -994,3 +994,13 @@ with({ exit_checker => sub { return shift == 6; } }, ])), "Check failure during BIO setup with -stream is handled correctly"); }); + +# Test case for return value mis-check reported in #21986 +with({ exit_checker => sub { return shift == 3; } }, + sub { + ok(run(app(['openssl', 'cms', '-sign', + '-in', srctop_file("test", "smcont.txt"), + '-signer', srctop_file("test/smime-certs", "smdsa1.pem"), + '-md', 'SHAKE256'])), + "issue#21986"); + }); -- Gitee From ce87a77e755b6c6e531dce0344d2a9f0125f08a1 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 6 Sep 2023 07:13:26 +0200 Subject: [PATCH 10/17] OSSL_STORE: Fix error flag clearing and setting (provider path only) When the provider's load function returned with an error, the libcrypto error flag was only set if EOF hadn't been reached. This is troublesome, as an error can very well occur during the last load before EOF is reached! Also, the error flag was never reset, even though documentation specifies that it should indicate an error in the last load (i.e. not the one before that). Fixes #21968 Reviewed-by: Dmitry Belyavskiy Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/21976) (cherry picked from commit 17dd9a2c6262c00800301fddd9441a9c590a630e) Signed-off-by: Huiyue Xu --- crypto/store/store_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/store/store_lib.c b/crypto/store/store_lib.c index 5ff9278629..60a6aded05 100644 --- a/crypto/store/store_lib.c +++ b/crypto/store/store_lib.c @@ -424,14 +424,14 @@ OSSL_STORE_INFO *OSSL_STORE_load(OSSL_STORE_CTX *ctx) load_data.v = NULL; load_data.ctx = ctx; + ctx->error_flag = 0; if (!ctx->fetched_loader->p_load(ctx->loader_ctx, ossl_store_handle_load_result, &load_data, ossl_pw_passphrase_callback_dec, &ctx->pwdata)) { - if (!OSSL_STORE_eof(ctx)) - ctx->error_flag = 1; + ctx->error_flag = 1; return NULL; } v = load_data.v; -- Gitee From f683881d88b09141a64b1cc7d8863fc48364e980 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Wed, 6 Sep 2023 14:06:52 +0200 Subject: [PATCH 11/17] Fix a possible memleak in SRP_VBASE_new In the error handling case the memory in vb->users_pwd was accidentally not released. Reviewed-by: Paul Dale Reviewed-by: Matt Caswell Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21981) (cherry picked from commit 68e95f7840d0d8ac4e5e03381cf9d305578dd1c7) Signed-off-by: Huiyue Xu --- crypto/srp/srp_vfy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/crypto/srp/srp_vfy.c b/crypto/srp/srp_vfy.c index e8beb60d27..edcfb0c76e 100644 --- a/crypto/srp/srp_vfy.c +++ b/crypto/srp/srp_vfy.c @@ -283,6 +283,7 @@ SRP_VBASE *SRP_VBASE_new(char *seed_key) return NULL; if ((vb->users_pwd = sk_SRP_user_pwd_new_null()) == NULL || (vb->gN_cache = sk_SRP_gN_cache_new_null()) == NULL) { + sk_SRP_user_pwd_free(vb->users_pwd); OPENSSL_free(vb); return NULL; } -- Gitee From baccb5cad0d31c995b00738164be1c244e58b691 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Fri, 8 Sep 2023 10:33:24 +0200 Subject: [PATCH 12/17] Fix output corruption in req command when used in conjunction with -out and -modulus options. Fixes #21403 Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22026) (cherry picked from commit d2873946dfaff5537ea3d1adf3890e33a3f276ff) Signed-off-by: Huiyue Xu --- apps/req.c | 8 ++++---- test/recipes/25-test_req.t | 13 ++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/req.c b/apps/req.c index 73b320a709..926f0796bc 100644 --- a/apps/req.c +++ b/apps/req.c @@ -990,10 +990,10 @@ int req_main(int argc, char **argv) else tpubkey = X509_REQ_get0_pubkey(req); if (tpubkey == NULL) { - fprintf(stdout, "Modulus is unavailable\n"); + BIO_puts(bio_err, "Modulus is unavailable\n"); goto end; } - fprintf(stdout, "Modulus="); + BIO_puts(out, "Modulus="); if (EVP_PKEY_is_a(tpubkey, "RSA") || EVP_PKEY_is_a(tpubkey, "RSA-PSS")) { BIGNUM *n = NULL; @@ -1002,9 +1002,9 @@ int req_main(int argc, char **argv) BN_print(out, n); BN_free(n); } else { - fprintf(stdout, "Wrong Algorithm type"); + BIO_puts(out, "Wrong Algorithm type"); } - fprintf(stdout, "\n"); + BIO_puts(out, "\n"); } if (!noout && !gen_x509) { diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t index e615f1b338..f4526f3669 100644 --- a/test/recipes/25-test_req.t +++ b/test/recipes/25-test_req.t @@ -15,7 +15,7 @@ use OpenSSL::Test qw/:DEFAULT srctop_file/; setup("test_req"); -plan tests => 44; +plan tests => 46; require_ok(srctop_file('test', 'recipes', 'tconversion.pl')); @@ -473,3 +473,14 @@ my $cert = "self-signed_CA_with_keyUsages.pem"; generate_cert($cert, "-in", srctop_file(@certs, "ext-check.csr"), "-copy_extensions", "copy"); has_keyUsage($cert, 1); + +# Generate cert using req with '-modulus' +ok(run(app(["openssl", "req", "-x509", "-new", "-days", "365", + "-key", srctop_file("test", "testrsa.pem"), + "-config", srctop_file('test', 'test.cnf'), + "-out", "testreq-cert.pem", + "-modulus"])), "cert req creation - with -modulus"); + +# Verify cert +ok(run(app(["openssl", "x509", "-in", "testreq-cert.pem", + "-noout", "-text"])), "cert verification"); -- Gitee From 36c42c37b837d6e392ce70bb1531aaee4827875f Mon Sep 17 00:00:00 2001 From: "Randall S. Becker" Date: Sat, 9 Sep 2023 21:18:04 +0100 Subject: [PATCH 13/17] Fix typographical error in 80-test_cms.t (missing ;) Fixes: #22045 Signed-off-by: Randall S. Becker Reviewed-by: Tom Cosgrove Reviewed-by: Dmitry Belyavskiy (Merged from https://github.com/openssl/openssl/pull/22046) Signed-off-by: Huiyue Xu --- test/recipes/80-test_cms.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/recipes/80-test_cms.t b/test/recipes/80-test_cms.t index 9759483979..8dbec71212 100644 --- a/test/recipes/80-test_cms.t +++ b/test/recipes/80-test_cms.t @@ -50,7 +50,7 @@ my ($no_des, $no_dh, $no_dsa, $no_ec, $no_ec2m, $no_rc2, $no_zlib) $no_rc2 = 1 if disabled("legacy"); -plan tests => 17 +plan tests => 17; ok(run(test(["pkcs7_test"])), "test pkcs7"); -- Gitee From 5529f60d45a272cecf58b1474edcde2f9a19cd7f Mon Sep 17 00:00:00 2001 From: Dmitry Misharov Date: Thu, 7 Sep 2023 13:52:46 +0200 Subject: [PATCH 14/17] remove unused Appveyour config Reviewed-by: Hugo Landau Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22000) (cherry picked from commit 8ac32e1e1b1a786366333acf897d332339610e6b) Signed-off-by: Huiyue Xu --- appveyor.yml | 82 ---------------------------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 9bb6f04e0a..0000000000 --- a/appveyor.yml +++ /dev/null @@ -1,82 +0,0 @@ -image: - - Visual Studio 2017 - -platform: - - x64 - - x86 - -environment: - fast_finish: true - matrix: - - VSVER: 15 - -configuration: - - shared - - minimal - -for: - - - branches: - only: - - master - configuration: - - shared - - plain - - minimal - -before_build: - - ps: >- - Install-Module VSSetup -Scope CurrentUser - - ps: >- - Get-VSSetupInstance -All - - ps: >- - If ($env:Platform -Match "x86") { - $env:VCVARS_PLATFORM="x86" - $env:TARGET="VC-WIN32 no-asm --strict-warnings" - } Else { - $env:VCVARS_PLATFORM="amd64" - $env:TARGET="VC-WIN64A-masm" - } - - ps: >- - If ($env:Configuration -Match "shared") { - $env:CONFIG_OPTS="enable-fips" - } ElseIf ($env:Configuration -Match "minimal") { - $env:CONFIG_OPTS="no-bulk no-asm -DOPENSSL_SMALL_FOOTPRINT" - } Else { - $env:CONFIG_OPTS="no-fips no-shared" - } - - call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %VCVARS_PLATFORM% - - mkdir _build - - cd _build - - perl ..\Configure %TARGET% no-makedepend %CONFIG_OPTS% - - perl configdata.pm --dump - - cd .. - - ps: >- - If ($env:BUILDONLY -or $env:MAKEVERBOSE) { - $env:NMAKE="nmake" - } Else { - $env:NMAKE="nmake /S" - } - - ps: >- - gci env:* | sort-object name - -build_script: - - cd _build - - "%NMAKE% build_all_generated" - - "%NMAKE% PERL=no-perl" - - cd .. - -test_script: - - cd _build - - ps: >- - if ($env:Configuration -Match "plain") { - cmd /c "%NMAKE% test VERBOSE_FAILURE=yes 2>&1" - } Else { - cmd /c "%NMAKE% test VERBOSE_FAILURE=yes TESTS=-test_fuzz 2>&1" - } - - ps: >- - if ($env:Configuration -Match "shared") { - mkdir ..\_install - cmd /c "%NMAKE% install DESTDIR=..\_install 2>&1" - } - - cd .. -- Gitee From 045e3c1466d40f1504869a19c9acf098699cc1eb Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Thu, 7 Sep 2023 19:22:25 +0200 Subject: [PATCH 15/17] Fix a possible memleak in rsa_pub_encode That seems to be only an issue for RSA-PSS with parameters. Spotted by code review, so it looks like there is no test coverage for this. Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22032) (cherry picked from commit 285eb1688f05ad477fefc681bf05d0afedc46d40) Signed-off-by: Huiyue Xu --- crypto/rsa/rsa_ameth.c | 5 ++++- test/recipes/15-test_rsapss.t | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index e819780e7d..07734077e3 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c @@ -60,13 +60,16 @@ static int rsa_pub_encode(X509_PUBKEY *pk, const EVP_PKEY *pkey) if (!rsa_param_encode(pkey, &str, &strtype)) return 0; penclen = i2d_RSAPublicKey(pkey->pkey.rsa, &penc); - if (penclen <= 0) + if (penclen <= 0) { + ASN1_STRING_free(str); return 0; + } if (X509_PUBKEY_set0_param(pk, OBJ_nid2obj(pkey->ameth->pkey_id), strtype, str, penc, penclen)) return 1; OPENSSL_free(penc); + ASN1_STRING_free(str); return 0; } diff --git a/test/recipes/15-test_rsapss.t b/test/recipes/15-test_rsapss.t index ea1d9aceae..4773252185 100644 --- a/test/recipes/15-test_rsapss.t +++ b/test/recipes/15-test_rsapss.t @@ -16,7 +16,7 @@ use OpenSSL::Test::Utils; setup("test_rsapss"); -plan tests => 11; +plan tests => 13; #using test/testrsa.pem which happens to be a 512 bit RSA ok(run(app(['openssl', 'dgst', '-sign', srctop_file('test', 'testrsa.pem'), '-sha1', @@ -89,3 +89,11 @@ ok(run(app(['openssl', 'dgst', '-prverify', srctop_file('test', 'testrsa.pem'), ok(!run(app([ 'openssl', 'rsa', '-in' => data_file('negativesaltlen.pem')], '-out' => 'badout'))); + +ok(run(app(['openssl', 'genpkey', '-algorithm', 'RSA-PSS', '-pkeyopt', 'rsa_keygen_bits:1024', + '-pkeyopt', 'rsa_pss_keygen_md:SHA256', '-pkeyopt', 'rsa_pss_keygen_saltlen:10', + '-out', 'testrsapss.pem'])), + "openssl genpkey RSA-PSS with pss parameters"); +ok(run(app(['openssl', 'pkey', '-in', 'testrsapss.pem', '-pubout', '-text'])), + "openssl pkey, execute rsa_pub_encode with pss parameters"); +unlink 'testrsapss.pem'; -- Gitee From cca469ae7be6d5b6c9d0599c942dcf7346dbbc1c Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Fri, 8 Sep 2023 15:28:45 +0200 Subject: [PATCH 16/17] Add CVE-2023-4807 fix to CHANGES.md and NEWS.md Reviewed-by: Matt Caswell Reviewed-by: Hugo Landau Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/22033) (cherry picked from commit 0be7510f49e498532708fd03628fc3fc62ee7875) Signed-off-by: Huiyue Xu --- CHANGES.md | 23 ++++++++++++++++++++++- NEWS.md | 4 +++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6c39212ecf..e519978842 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,7 +30,27 @@ breaking changes, and mappings for the large list of deprecated functions. ### Changes between 3.0.10 and 3.0.11 [xx XXX xxxx] - * none yet + * Fix POLY1305 MAC implementation corrupting XMM registers on Windows. + + The POLY1305 MAC (message authentication code) implementation in OpenSSL + does not save the contents of non-volatile XMM registers on Windows 64 + platform when calculating the MAC of data larger than 64 bytes. Before + returning to the caller all the XMM registers are set to zero rather than + restoring their previous content. The vulnerable code is used only on newer + x86_64 processors supporting the AVX512-IFMA instructions. + + The consequences of this kind of internal application state corruption can + be various - from no consequences, if the calling application does not + depend on the contents of non-volatile XMM registers at all, to the worst + consequences, where the attacker could get complete control of the + application process. However given the contents of the registers are just + zeroized so the attacker cannot put arbitrary values inside, the most likely + consequence, if any, would be an incorrect result of some application + dependent calculations or a crash leading to a denial of service. + + ([CVE-2023-4807]) + + *Bernd Edlinger* ### Changes between 3.0.9 and 3.0.10 [1 Aug 2023] @@ -19712,6 +19732,7 @@ ndif +[CVE-2023-4807]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-4807 [CVE-2023-3817]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-3817 [CVE-2023-3446]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-3446 [CVE-2023-2975]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-2975 diff --git a/NEWS.md b/NEWS.md index 068def4ae1..1b8ec67442 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,7 +20,8 @@ OpenSSL 3.0 ### Major changes between OpenSSL 3.0.10 and OpenSSL 3.0.11 [under development] - * none + * Fix POLY1305 MAC implementation corrupting XMM registers on Windows + ([CVE-2023-4807]) ### Major changes between OpenSSL 3.0.9 and OpenSSL 3.0.10 [1 Aug 2023] @@ -1452,6 +1453,7 @@ OpenSSL 0.9.x +[CVE-2023-4807]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-4807 [CVE-2023-3817]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-3817 [CVE-2023-3446]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-3446 [CVE-2023-2975]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-2975 -- Gitee From 957a2a3a2033dff468e8fd43e69933749053a891 Mon Sep 17 00:00:00 2001 From: Vladimir Kotal Date: Tue, 5 Sep 2023 11:13:47 +0200 Subject: [PATCH 17/17] augment man pages with information about PKCS12KDF in FIPS mode Reviewed-by: Paul Dale Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/21965) (cherry picked from commit 4ee8c1fb51687ea811fc2abf87e173c70d018bc2) Signed-off-by: Huiyue Xu --- doc/man3/PKCS12_create.pod | 7 ++++++- doc/man3/PKCS12_gen_mac.pod | 2 ++ doc/man7/EVP_KDF-PKCS12KDF.pod | 6 +++++- doc/man7/migration_guide.pod | 9 +++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/man3/PKCS12_create.pod b/doc/man3/PKCS12_create.pod index dc0f06d9d3..f528330c04 100644 --- a/doc/man3/PKCS12_create.pod +++ b/doc/man3/PKCS12_create.pod @@ -42,7 +42,8 @@ can all be set to zero and sensible defaults will be used. These defaults are: AES password based encryption (PBES2 with PBKDF2 and AES-256-CBC) for private keys and certificates, the PBKDF2 and MAC key derivation iteration count of B (currently 2048), and -MAC algorithm HMAC with SHA2-256. +MAC algorithm HMAC with SHA2-256. The MAC key derivation algorithm used +for the outer PKCS#12 structure is PKCS12KDF. The default MAC iteration count is 1 in order to retain compatibility with old software which did not interpret MAC iteration counts. If such compatibility @@ -68,6 +69,8 @@ I or I can be set to -1 indicating that no encryption should be used. I can be set to -1 and the MAC will then be omitted entirely. +This can be useful when running with the FIPS provider as the PKCS12KDF +is not a FIPS approvable algorithm. PKCS12_create() makes assumptions regarding the encoding of the given pass phrase. @@ -83,7 +86,9 @@ IETF RFC 7292 (L) =head1 SEE ALSO +L, L, +L, L =head1 HISTORY diff --git a/doc/man3/PKCS12_gen_mac.pod b/doc/man3/PKCS12_gen_mac.pod index 37bcd572d8..a72df145fe 100644 --- a/doc/man3/PKCS12_gen_mac.pod +++ b/doc/man3/PKCS12_gen_mac.pod @@ -22,6 +22,7 @@ PKCS12_verify_mac - Functions to create and manipulate a PKCS#12 structure PKCS12_gen_mac() generates an HMAC over the entire PKCS#12 object using the supplied password along with a set of already configured parameters. +The default key generation mechanism used is PKCS12KDF. PKCS12_verify_mac() verifies the PKCS#12 object's HMAC using the supplied password. @@ -57,6 +58,7 @@ IETF RFC 7292 (L) =head1 SEE ALSO L, +L, L, L diff --git a/doc/man7/EVP_KDF-PKCS12KDF.pod b/doc/man7/EVP_KDF-PKCS12KDF.pod index 7edde1dc9b..05d4e902bd 100644 --- a/doc/man7/EVP_KDF-PKCS12KDF.pod +++ b/doc/man7/EVP_KDF-PKCS12KDF.pod @@ -46,6 +46,9 @@ RFC 7292 section B.3. =head1 NOTES +This algorithm is not available in the FIPS provider as it is not FIPS +approvable. + A typical application of this algorithm is to derive keying material for an encryption algorithm from a password in the "pass", a salt in "salt", and an iteration count. @@ -68,7 +71,8 @@ L, L, L, L, -L +L, +L =head1 HISTORY diff --git a/doc/man7/migration_guide.pod b/doc/man7/migration_guide.pod index 1847e9813c..61641324a7 100644 --- a/doc/man7/migration_guide.pod +++ b/doc/man7/migration_guide.pod @@ -306,6 +306,15 @@ context and property query and will call an extended version of the key/IV derivation function which supports these parameters. This includes L, L and L. +=head4 PKCS#12 KDF versus FIPS + +Unlike in 1.x.y, the PKCS12KDF algorithm used when a PKCS#12 structure +is created with a MAC that does not work with the FIPS provider as the PKCS12KDF +is not a FIPS approvable mechanism. + +See L, L, L, +L. + =head4 Windows thread synchronization changes Windows thread synchronization uses read/write primitives (SRWLock) when -- Gitee