Add winsock2 header into build_info.h #262
Open
irwir wants to merge 3 commits from
irwir/winsock2 into development
pull from: irwir/winsock2
merge into: gh-Mbed-TLS:development
gh-Mbed-TLS:development
gh-Mbed-TLS:tf-psa-crypto-1.1
gh-Mbed-TLS:archive/20261005T153337Z-force/pull/927
gh-Mbed-TLS:archive/20261001T141055Z-force/pull/927
gh-Mbed-TLS:archive/20261005T153337Z-force/pull/931
gh-Mbed-TLS:archive/20261001T083616Z-force/pull/927
gh-Mbed-TLS:archive/20260930T232327Z-force/pull/927
gh-Mbed-TLS:archive/20260930T154618Z-force/pull/927
gh-Mbed-TLS:archive/20260929T231919Z-rescue/rohankl-arm/mldsa-pubkey-899
gh-Mbed-TLS:archive/20260929T231919Z-rescue/sigvartmh/pr/spake2p-9342-public-key-import-export
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ManoharPaturi/fix-pem-ct-padding
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ManoharPaturi/fix-asn1write-null-guard
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ManoharPaturi/fix-pbes2-params-validation
gh-Mbed-TLS:archive/20260929T231919Z-rescue/valeriosetti/blake2
gh-Mbed-TLS:archive/20260929T231919Z-rescue/jfdev001/v1.1.1_bump-cmake-minimum-version
gh-Mbed-TLS:archive/20260929T231919Z-rescue/jfdev001/bump-cmake-minimum-version
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ronald-cron-arm/sm3-base
gh-Mbed-TLS:archive/20260929T231919Z-rescue/valeriosetti/blake2-hmac
gh-Mbed-TLS:archive/20260929T231919Z-rescue/v1rtu3x/enforce-hash-length-sign-verify
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/file-backed-keystore-doc
gh-Mbed-TLS:archive/20260929T231919Z-rescue/sigvartmh/pr/spake2p-9344-set-context
gh-Mbed-TLS:archive/20260929T231919Z-rescue/sigvartmh/pr/spake2p-9343-key-pair-import-export-depends-on-9342
gh-Mbed-TLS:archive/20260929T231919Z-rescue/romart/development
gh-Mbed-TLS:archive/20260929T231919Z-rescue/sweetlilmre/constant-time-embedded-perf
gh-Mbed-TLS:archive/20260929T231919Z-rescue/JulioLoayzaM/add-wycheproof-rsa-pss
gh-Mbed-TLS:archive/20260929T231919Z-rescue/JulioLoayzaM/add-wycheproof-ecdsa
gh-Mbed-TLS:archive/20260929T231919Z-rescue/JulioLoayzaM/add-wycheproof-tests
gh-Mbed-TLS:archive/20260929T231919Z-rescue/oubaid-a/dev_psa_driver_wrapper
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/keystoreless-prototype-1
gh-Mbed-TLS:archive/20260929T231919Z-rescue/valeriosetti/issue9580
gh-Mbed-TLS:archive/20260929T231919Z-rescue/LeonieReichertABB/hpke-functionality
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/psa-hash-no-buffer-copy-1.1
gh-Mbed-TLS:archive/20260929T231919Z-rescue/vanhauser-thc/development
gh-Mbed-TLS:archive/20260929T231919Z-rescue/tpambor/key-wrap
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ruiliio/psa_xts
gh-Mbed-TLS:archive/20261011T063515Z-force/pull/538
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/fix-broken-links-1.1
gh-Mbed-TLS:archive/20260929T231919Z-rescue/valeriosetti/issue669
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/prepare-release-test
gh-Mbed-TLS:archive/20260929T231919Z-rescue/krish2718/wpa3-sae-design-note
gh-Mbed-TLS:archive/20260929T231919Z-rescue/nzzlinh/fix_iar_endianness_1.1
gh-Mbed-TLS:archive/20260929T231919Z-rescue/nzzlinh/fix-iar-endianness
gh-Mbed-TLS:archive/20260929T231919Z-rescue/abtom87/fix-pbkdf2-iter-count
gh-Mbed-TLS:archive/20260929T231919Z-rescue/minosgalanakis/tools/prepare_release_lite
gh-Mbed-TLS:archive/20260929T231919Z-rescue/Harshal5/fix/aes-xts-in-place-cts
gh-Mbed-TLS:archive/20260929T231919Z-rescue/sigvartmh/pr/spake2p-9347-prover-depends-on-9342-9343-9344
gh-Mbed-TLS:archive/20260929T231919Z-rescue/crabel99/async-hardware-support-c35df962
gh-Mbed-TLS:tf-psa-crypto-1.2.0_mergeback
gh-Mbed-TLS:tf-psa-crypto-1.1.1_mergeback
gh-Mbed-TLS:archive/20260929T231919Z-rescue/asmellby/feature/dispatch-library
gh-Mbed-TLS:tf-psa-crypto-release-sync
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ChakshuGupta13/fix/ecdsa-zeroize-stack-key
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/security-md-option-names
gh-Mbed-TLS:archive/20260929T231919Z-rescue/parmi93/patch-2
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/remove-mldsa-sign-from-build
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/tf-m-build-issues
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/test-context-population
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/iar-1.1.0
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/fork-helper-unit-tests-create-crypto
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/redundant-declarations
gh-Mbed-TLS:archive/20260929T231919Z-rescue/hasheddan/docs/fix-broken-links
gh-Mbed-TLS:main
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/reintroduce-dh
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/cipher-update-incorrect-error
gh-Mbed-TLS:archive/20260929T231919Z-rescue/Marandil/fix/mbedtls-4314-parse-explicit-curve
gh-Mbed-TLS:archive/20260929T231919Z-rescue/schneider-electric/dev/plaj-se/parse-rsassa-pss
gh-Mbed-TLS:archive/20260929T231919Z-rescue/minosgalanakis/bugfix/program-fuzz-mscv
gh-Mbed-TLS:archive/20260929T231919Z-rescue/daverodgman/aesgcm
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/sha3-coverity-20260224
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bensze01/undef
gh-Mbed-TLS:archive/20260929T231919Z-rescue/valeriosetti/issue523
gh-Mbed-TLS:archive/20260929T231919Z-rescue/dannytsen/ppc-dev
gh-Mbed-TLS:archive/20260929T231919Z-rescue/daverodgman/aes12
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/ascon-prototype
gh-Mbed-TLS:archive/20260929T231919Z-rescue/daverodgman/chacha10
gh-Mbed-TLS:archive/20260929T231919Z-rescue/kusumitg/implement_psa_pake_set_context_for_spake2p
gh-Mbed-TLS:archive/20260929T231919Z-rescue/davidhorstmann-arm/add-code-size-target
gh-Mbed-TLS:archive/20260929T231919Z-rescue/bjwtaylor/simplify-sign_func
gh-Mbed-TLS:archive/20260929T231919Z-rescue/mfil/feature/aes_ni_parallel
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ivv19041994/patch-1
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/psa-verify-policy-relax
gh-Mbed-TLS:public_2/main
gh-Mbed-TLS:archive/20260929T231919Z-rescue/mpg/pk-sign-proto
gh-Mbed-TLS:release/tf-psa-crypto1.0.0-documentation
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/0e-plans-july-updates
gh-Mbed-TLS:archive/20260929T231919Z-rescue/davidhorstmann-arm/guard-context-types-in-client-only
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/psa-driver-interface-spec-remove
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/ecp-self-test-race-crypto
gh-Mbed-TLS:archive/20260929T231919Z-rescue/KiruthikPrakash/feature/9342_add-support-for-spake2p-public-key-import-export
gh-Mbed-TLS:archive/20260929T231919Z-rescue/ruiliio/chacha20_16
gh-Mbed-TLS:archive/20260929T231919Z-rescue/irwir/winsock2
gh-Mbed-TLS:archive/20260929T231919Z-rescue/aphroteus/development
gh-Mbed-TLS:archive/20260929T231919Z-rescue/amjoul01/amjoul01/psa-mac-out-of-bound-fix
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/everest-submodule-crypto
gh-Mbed-TLS:archive/20260929T231919Z-rescue/yamt/xtensa-ccount
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/all.sh-generate-only-before-checks-crypto
gh-Mbed-TLS:archive/20260929T231919Z-rescue/Harshal5/feat/builtin_cmac_driver_use_psa_crypto_interface
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/test-data_t-empty_is_empty-crypto
gh-Mbed-TLS:archive/20260929T231919Z-rescue/jean-baptisteboric-eaton/oids-pkcs7-authenticated-attributes
gh-Mbed-TLS:dev/bensze01/public-only-commit
gh-Mbed-TLS:archive/20260929T231919Z-rescue/waleed-elmelegy-arm/psa-key-wrap-aes-kw
gh-Mbed-TLS:archive/20260929T231919Z-rescue/tfloch/psa_add_xts_algorithm
gh-Mbed-TLS:archive/20260929T231919Z-rescue/gilles-peskine-arm/msancf-clang16-crypto
gh-Mbed-TLS:archive/20260929T231919Z-rescue/DemiMarie/document-unexpected-tags
gh-Mbed-TLS:archive/20260929T231919Z-rescue/DemiMarie/strict-len
gh-Mbed-TLS:archive/20260929T231919Z-rescue/valeriosetti/issue9255-tfpsacrypto
gh-Mbed-TLS:archive/20260929T231919Z-rescue/daantimmer/use-compiler-frontend
gh-Mbed-TLS:archive/20260929T231919Z-rescue/benmcollins/enable-rsassa-pss-pkparse
gh-Mbed-TLS:dev/paul-elliott-arm/add_iop_key_agreement_negative_tests
gh-Mbed-TLS:add-iop-export-pub-key-get-num-ops
gh-Mbed-TLS:dev/rc/new-2-d635ea1
gh-Mbed-TLS:dev/bensze01/jenkins
No reviewers
Labels
Clear labels
api-break
This issue/PR breaks the API and must wait for a new major version
approved
Design and code approved - may be waiting for CI or backports
bug
Something isn't working
component-docs
Docs / website issues filed here for tracking
component-platform
Portability layer and build scripts
component-test
Test framework and CI scripts
dependencies
Pull requests that update a dependency file
deprecation
needs deprecation announcement
DO-NOT-MERGE
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
This issue is not being actively worked on, but PRs welcome.
needs-adoption
stalled PR that someone should pick up and complete
needs-backports
Backports are missing or are pending review and approval.
needs-ci
Needs to pass CI tests
needs-design-approval
Needs design discussion / approval
needs-info
An issue or PR which needs further info from the reporter / author
needs-preceding-pr
Requires another PR to be merged first
needs-review
Every commit must be reviewed by at least two team members
needs-reviewer
This PR needs someone to pick it up for review
needs-work
priority-high
High priority - will be reviewed soon
priority-low
Low priority - this may not receive review soon
priority-medium
Medium priority - this can be reviewed as time permits
priority-scheduled
This PR is big - it will require time to be scheduled for review
priority-very-high
Highest priority - prioritise this over other review work
resolved-after-1.1
The issue is resolved in development, but still present in 1.1 LTS.
single-reviewer
This PR qualifies for having only one reviewer
size-l
Estimated task size: large (2w+)
size-m
Estimated task size: medium (~1w)
size-optimisation
size-s
Estimated task size: small (~2d)
size-xs
Estimated task size: extra small (a few hours at most)
No labels
api-break
approved
bug
component-docs
component-platform
component-test
dependencies
deprecation
DO-NOT-MERGE
enhancement
good first issue
help wanted
needs-adoption
needs-backports
needs-ci
needs-design-approval
needs-info
needs-preceding-pr
needs-review
needs-reviewer
needs-work
priority-high
priority-low
priority-medium
priority-scheduled
priority-very-high
resolved-after-1.1
single-reviewer
size-l
size-m
size-optimisation
size-s
size-xs
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
gh-Mbed-TLS/TF-PSA-Crypto!262
Loading…
Reference in a new issue
No description provided.
Delete branch "irwir/winsock2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Ensures proper socket definitions on Windows (as a part of resolving mbedtls issue #10097).
PR checklist
TF-PSA-Crypto needs to build outside of Mbed TLS. So it doesn't seem right to me that the Windows build (with an unchanged mbedtls) is failing here.
This is odd if an additional standard header breaks things so badly.
How to parse this?
The C2143 error code from a compiler and the last word
vcxprojindicate a compilation error.But the source file is
test_suite_ecp.functionwhile make build usestf-psa-crypto/tests/test_suite_ecp.c?Numerous warnings in the log. Maybe VS 2013 did not have this option?
Unlike for
mbdetls, tests were never tried with later versions of Visual Studio.test_suite_xxx.cis generated fromtest_suite_xxx.functionusingframework/scripts/generate_test_code.py. It does a couple of substitutions and adds some boilerplate as well as code to prepare arguments to test functions.The offending line (more visible in the message from MinGW) is
It looks like the parser gets confused because it doesn't recognize
inlineas intended.We use the
inlinekeyword in our code base. For compilers such as MSVC that don't define it,tf-psa-crypto/build_info.hdefines it. This happens shortly before the inclusion ofwinsock2.h. I have no idea why includingwinsock2.hbreaks this.As for
/utf-8, the warning is annoying but harmless. It was added to fix a warning that does break the build in some environments (those using a non-UTF-8 multibyte encoding by default, if I understand correctly).The question was why
.functioninstead of the expected.cin the compiler diagnostics. This was explained by #line directive.It is difficult to guess without installed VS 2013 and the generated projects and sources.
A trivial inlined function after including
build_info.hcould be compiled even in VS 2012. The issue should be somewhere deeper.With VS 2022, I copied and renamed cert_app.vcxproj, changed the source file to test_suite_ecp.c. Some paths had to be added, but finally it compiled.
Available since VS 2015.
As far as I remember, a bug in VS 2015 increased the minimum required version for
mbedtlsto VS 2017, even though the official documentation still says VS 2013 (also in solution pathvisualc/VS2013/mbedTLS.sln).Quote from the current
README.mdinTF-PSA-Crypto:Yet there is nothing but VS 2013 in
TF OpenCI: PR tests.Should this have been changed in development branches?
Two questions.
Could TF OpenCI: PR tests be retried with VS 2017?
Would it be possible to get the failing generated projects and source files, as artifacts maybe?
At least one, like test_suite_ecp.c and test_suite_ecp.vcxproj for investigation in VS 2017.
Text search in TF-PSA-Crypto sources had found 51 files containing the
inlineword. A few tests had been built successfully before the failure.Sure. Since the last CI run, we've switched our CI from VS2013 to VS2017. I've kicked a new run.
Setting this up would require some Groovy code. But I don't really see the point: these files don't depend on the platform, on the library configuration or (in principle) on tool versions, you can generate them locally on any platform.
It could be generated provided everything is installed, configured and it is perfectly well known what commands to run.
But there is only VS 2017 for C/C++ builds. Nothing else, and nothing is planned to be added.
There is also Ubuntu 25.04 which is used for generating files with make.
So it was cheaper to manually create a VS project for the test code and then figure out what was wrong.
Build process now is working, but tests are failing.
With
make alltwo versions had been built - with included winsock2.h and without it.The only difference in the sources and generated files was
build_info.h.Knowing this, I locally created two builds of
test_suite_ssl- withwinsock2.hand with the#includecommented out.All compiled files were deleted before the rebuild.
The results are exactly the same, some of Session serialization tests had failed.
Every test in
test_suite_ssl.dataxthat contains path name of a certificate file - failed.Corrected path names had this outcome:
PASSED (854 / 854 tests (146 skipped))You need to run the tests suites from the
testsdirectory.There's code in
tests/suites/host_test.functionthat tries to automatically change into the directory containing the executable. This is relatively new but our scripts might have gotten used to that. But that code isn't implemented for Windows (patches welcome).github.com/Mbed-TLS/TF-PSA-Crypto@864dee0530/tests/suites/host_test.function (L446-L449)This code correctly changed directory for me; verified with
_getcwd().Certainly backslash for
argv[0]because the path was created by CRT.chdiris the same as_chdir; deprecation warnings have low level (ignored now, and could be disabled).strdup(or_strdup) and truncation with null character could give shorter code.But there is a catch.
Full path for a data file may be specified in command line; and the data may contain paths relative to the file's location.
Which means,
chdirshould be to the data file's path, not executable's path. Also (forward) slashes might be here.Unless this line
means "executable must be copied to
testsdirectory" - which is not always a great idea.Another trouble:
const char *default_filename = "./test_suite_ssl.datax";With the current code this path in command line means not what might be expected:
tests/test_suite_ssl ./test_suite_ssl.dataxTo verify that only tests were failing, one final check was attempted with the line
#include <winsock2.h>commented out. Build process would not start automatically, hence the commit was reverted.It is hard to provide useful patches without decent understanding of the testing structure and the future plans.
Currently this PR seems to be blocked by a flaw in test code.
If so, are there any plans to move on?
This pull request is blocked because it fails the CI. It's not a flaw in test code: the patch makes the existing code fail to compile. Since it only happens on Windows, which most of us are unfamiliar with, this is unlikely to progress unless a Windows expert can fix the problem.
Compilation had been fixed months ago (the second commit). Since then the
test_suite_sslfailed in every test that required to read a certificate file. With a bit of code tweakingtest_suite_sslpassed all 854 tests (VS 2017).The history is in the above conversation.
Outdated build logs had been deleted, but for verification you could run the process again.
Ok, I've kicked a new CI run.
New kind of errors in build (exception in compiler?).
Synced PR with
Mbed-TLS/TF-PSA-Crypto:developmentbranch.Rebased the PR and somehow all tests had passed.
It would be nice to add under the Windows condition this definition:
But the macro must be added into name checker's exclusion list.
That needs a patch to https://github.com/Mbed-TLS/mbedtls-framework/blob/main/scripts/check_names.py
At line 343 like this?
Yes, that looks right,
WIN32_LEAN_AND_MEANand_CRT_SECURE_NO_DEPRECATEhave very similar roles.If this was merged,
<windows.h>and<winsock2.h>could be removed from.cfiles inTF-PSA-Cryptoandmbedtls.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.