Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete mbedtls backend coding #519

Closed
wants to merge 15 commits into from
Closed

Complete mbedtls backend coding #519

wants to merge 15 commits into from

Conversation

huitema
Copy link
Collaborator

@huitema huitema commented Apr 10, 2024

Develop a static function to load file content in memory, as a replacement for the API mbedtls_pk_load_file issue() that is not available in recent versions of MbedTLS.

Also fix missing parentheses in cmake/FindMbedTLS.cmake

Edited on May 16, 2024: the PR now includes the complete code needed for using MbedTLS as a back end.

lib/mbedtls_sign.c Outdated Show resolved Hide resolved
lib/mbedtls_sign.c Show resolved Hide resolved
@huitema
Copy link
Collaborator Author

huitema commented Apr 11, 2024

The last failure is in the linker:

/usr/bin/cc -D_GNU_SOURCE -pthread -std=c99 -Wall -O2 -g   -DPICOTLS_USE_DTRACE=1 -DPICOTLS_USE_BROTLI=1 -DPTLS_HAVE_FUSION=1 -DPTLS_HAVE_MBEDTLS=1 -rdynamic CMakeFiles/test-mbedtls.t.dir/deps/picotest/picotest.c.o CMakeFiles/test-mbedtls.t.dir/t/hpke.c.o CMakeFiles/test-mbedtls.t.dir/t/picotls.c.o CMakeFiles/test-mbedtls.t.dir/t/mbedtls.c.o picotls-probes.o -o test-mbedtls.t   -L"/picotls/("  -L"/picotls/)"  -Wl,-rpath,"/picotls/(:/picotls/)" libpicotls-minicrypto.a libpicotls-mbedtls.a /usr/local/lib/libmbedtls.a /usr/local/lib/libmbedcrypto.a /usr/local/lib/libmbedx509.a libpicotls-core.a -lbrotlidec -lbrotlienc 
/usr/bin/ld: errno: TLS definition in /lib/x86_64-linux-gnu/libc.so.6 section .tbss mismatches non-TLS reference in libpicotls-mbedtls.a(mbedtls_sign.c.o)
/usr/bin/ld: /lib/x86_64-linux-gnu/libc.so.6: error adding symbols: bad value

The diagnostic error adding symbols: bad value supposedly happens because some function was present in multiple binaries, but these binaries were not compiled with exactly the same flags -- see this page on stack overflow.

The error only happens after we tried to use errno, so maybe removing that will solve the issue.

@huitema
Copy link
Collaborator Author

huitema commented Apr 12, 2024

@kazuho This is finally ready. I am sorry for the mess yesterday. I was down with a fever, trying to make it work and missing basic stuff. The latest fix was to add a final NULL byte to the returned buffer -- just copying the content of the file was not enough. Overall, a very small fix, and very contained.

@huitema
Copy link
Collaborator Author

huitema commented May 16, 2024

@kazuho Since this PR was not checked in, I am adding the missing pieces to fully support MbedTLS as a backend: loading of certificates, implementation of the sign certificate and verify certificates call back.

@huitema huitema changed the title Address mbedtls_pk_load_file issue Complete mbedtls backend coding May 16, 2024
@huitema
Copy link
Collaborator Author

huitema commented May 16, 2024

@kazuho The tests are failing because this branch somehow picked the wrong version of picotest, which does not support adding arguments to the "subtest" function. This is weird, because the test scripts supposedly load the latest version.

@huitema
Copy link
Collaborator Author

huitema commented May 16, 2024

The issue is probably happening when building the docker image in the github actions, but I don't know how to fix that.

@huitema huitema closed this by deleting the head repository May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants