Skip to content

Update libtropic and ts-tvl #5424

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

Closed
wants to merge 8 commits into from
Closed

Update libtropic and ts-tvl #5424

wants to merge 8 commits into from

Conversation

onvej-sl
Copy link
Contributor

This pull request builds on of #5416 (the oldest commit) and #5421 (the second oldest commit).

The pull request updates libtropic and ts-tvl to their latest stable releases.

As side effect, it removes the tropic.get_certificate() function, which I found no use for in the firmware and which depends on a libtropic function whose API has changed.

@trezor-bot trezor-bot bot added this to Firmware Jul 24, 2025
@github-project-automation github-project-automation bot moved this to 🔎 Needs review in Firmware Jul 24, 2025
Copy link

github-actions bot commented Jul 24, 2025

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)

Latest CI run: 16523575572

@onvej-sl onvej-sl force-pushed the onvej-sl/libtropic-update branch from d99c71c to e3fe064 Compare July 24, 2025 16:18
@onvej-sl onvej-sl force-pushed the onvej-sl/libtropic-update branch from e3fe064 to 3236769 Compare July 24, 2025 16:23
@@ -86,6 +88,8 @@ def configure(
paths += ["vendor/libtropic/src"]
defines += ["USE_TREZOR_CRYPTO"]
defines += [("LT_USE_TREZOR_CRYPTO", "1")]
# This is a workaround for an error caused by the redefinition of the macro `STATIC`, which is initially defined in `SConscript.unix` and later redefined in `libtropic_common.h`. As an adverse effect of defining `TEST`, all functions declared in `libtropic.c` become non-static, causing `lt_asn1_der.c` to be compiled even though it is not used.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to fix this issue properly. @cepetr Could you help me with that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STATIC is defined not only in SConscript.unix, but also in mpconfig.h, which is included (and heavily used) in many micropython C files, as well as in our modtrezorxxx files. Since we also include libtropic in these files, this causes a collision. Somebody needs to step aside... and it's probably not going to be MicroPython.

I believe no library should use the STATIC symbol in its public interface, as libtropic currently does. BTW, there's a similar potential issue with the UNUSED symbol, which need not (and should not) be defined in libtropic_common.h.

I think the easiest and the most correct solution is to rename STATIC to LT_STATIC (or something similar) on the libtropic side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the easiest and the most correct solution is to rename STATIC to LT_STATIC (or something similar) on the libtropic side.

Hmm, I was hoping we could find a more elegant solution. I opened tropicsquare/libtropic#177.

I believe no library should use the STATIC symbol in its public interface, as libtropic currently does. BTW, there's a similar potential issue with the UNUSED symbol, which need not (and should not) be defined in libtropic_common.h.

It seems to me that this should not be a problem, as UNUSED is used only within libtropic's *.c files, and these files do not include our header files.

Copy link
Contributor

@cepetr cepetr Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We include libtropic.h, that includes libtropic_common.h, so there's potential collision with our definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. I didn't realize that UNUSED is defined in libtropic.h, even though it doesn't need to be, since it is only used in *.c files.

@onvej-sl
Copy link
Contributor Author

Closing in favour of #5525.

@onvej-sl onvej-sl closed this Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🔎 Needs review
Development

Successfully merging this pull request may close these issues.

2 participants