chore(core/rust): update bindgen to 0.72.1
What changed, and why it matters
This is a routine dependency update for the Rust build tool bindgen inside Trezor firmware. It bumps bindgen from version 0.62.0 to 0.72.1 and adjusts the code to match the newer API. The change removes a small workaround that forced a function signature to be read as non-const pointers, because the newer bindgen now generates the correct const pointers. There is no direct security fix here, but keeping build tools current reduces the chance of future bugs or build issues.
Treat as routine maintenance. Verify CI builds pass and generated bindings remain const-correct. No security response required unless additional context emerges showing the bindgen update fixes a known vulnerability.
Security signals we found
Dependency update of bindgen (build-time code generator)
Removal of FFI signature workaround for ed25519_sign_open const-correctness
No changelog entry ([no changelog])
No mention of CVE, advisory, or security bug in commit message or diff
Evidence from the diff
The commit updates bindgen 0.62.0 -> 0.72.1 in core/embed/rust/Cargo.toml and Cargo.lock. API changes are addressed: bindgen::CargoCallbacks now requires ::new(), bitflags and rustc-hash are updated, and the ed25519_sign_open allowlist is re-enabled because bindgen now correctly emits *const for pk and RS parameters. The manual ffi_override module in ed25519.rs is removed and the generated ffi::ed25519_sign_open is used directly. A clippy allow is added for ptr_offset_with_cast generated by bindgen. This is a maintenance/chore commit with no runtime vulnerability patch visible in the diff.
Changed components
core/embed/rust build.rscore/embed/rust/src/crypto/ed25519.rscore/embed/rust/Cargo.tomlcore/embed/rust/Cargo.lockcore/embed/rust/src/lib.rsInspect captured patch +29 / −47
diff --git a/core/embed/rust/Cargo.lock b/core/embed/rust/Cargo.lock
index a6db4668..179e0a83 100644
--- a/core/embed/rust/Cargo.lock
+++ b/core/embed/rust/Cargo.lock
@@ -16,29 +16,27 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bindgen"
-version = "0.62.0"
+version = "0.72.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6720a8b7b2d39dd533285ed438d458f65b31b5c257e6ac7bb3d7e82844dd722"
+checksum = "993776b509cfb49c750f11b8f07a46fa23e0a1386ffc01fb1e7d343efc387895"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
- "lazy_static",
- "lazycell",
- "peeking_take_while",
+ "itertools",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
- "syn 1.0.109",
+ "syn 2.0.65",
]
[[package]]
name = "bitflags"
-version = "1.3.2"
+version = "2.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
[[package]]
name = "byteorder"
@@ -93,6 +91,12 @@ dependencies = [
"num-traits",
]
+[[package]]
+name = "either"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
+
[[package]]
name = "glob"
version = "0.3.0"
@@ -120,22 +124,19 @@ dependencies = [
]
[[package]]
-name = "itoa"
-version = "1.0.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
-
-[[package]]
-name = "lazy_static"
-version = "1.4.0"
+name = "itertools"
+version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
+checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186"
+dependencies = [
+ "either",
+]
[[package]]
-name = "lazycell"
-version = "1.3.0"
+name = "itoa"
+version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
+checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6"
[[package]]
name = "libc"
@@ -216,12 +217,6 @@ dependencies = [
"num-traits",
]
-[[package]]
-name = "peeking_take_while"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
-
[[package]]
name = "proc-macro2"
version = "1.0.81"
@@ -261,9 +256,9 @@ checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
[[package]]
name = "rustc-hash"
-version = "1.1.0"
+version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
+checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
[[package]]
name = "ryu"
diff --git a/core/embed/rust/Cargo.toml b/core/embed/rust/Cargo.toml
index 0730fad2..9614ae7f 100644
--- a/core/embed/rust/Cargo.toml
+++ b/core/embed/rust/Cargo.toml
@@ -159,7 +159,7 @@ default-features = false
# Build dependencies
[build-dependencies.bindgen]
-version = "0.62.0"
+version = "0.72.1"
default-features = false
features = ["runtime"]
diff --git a/core/embed/rust/build.rs b/core/embed/rust/build.rs
index 2d26f667..85c5f576 100644
--- a/core/embed/rust/build.rs
+++ b/core/embed/rust/build.rs
@@ -122,7 +122,7 @@ fn generate_qstr_bindings() {
.size_t_is_usize(true)
// Tell cargo to invalidate the built crate whenever any of the
// included header files change.
- .parse_callbacks(Box::new(bindgen::CargoCallbacks))
+ .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.expect("Unable to generate Rust QSTR bindings")
.write_to_file(&dest_file)
@@ -201,7 +201,7 @@ fn prepare_bindings() -> bindgen::Builder {
.layout_tests(false)
// Tell cargo to invalidate the built crate whenever any of the
// included header files change.
- .parse_callbacks(Box::new(bindgen::CargoCallbacks))
+ .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
}
#[cfg(feature = "micropython")]
@@ -506,8 +506,7 @@ fn generate_crypto_bindings() {
.allowlist_type("ed25519_signature")
.allowlist_type("ed25519_public_key")
.allowlist_function("ed25519_cosi_combine_publickeys")
- // incorrect signature from bindgen, see crypto::ed25519:ffi_override
- //.allowlist_function("ed25519_sign_open")
+ .allowlist_function("ed25519_sign_open")
// sha256
.allowlist_var("SHA256_DIGEST_LENGTH")
.allowlist_type("SHA256_CTX")
diff --git a/core/embed/rust/src/crypto/ed25519.rs b/core/embed/rust/src/crypto/ed25519.rs
index 338051c3..03873578 100644
--- a/core/embed/rust/src/crypto/ed25519.rs
+++ b/core/embed/rust/src/crypto/ed25519.rs
@@ -6,22 +6,9 @@ pub const SIGNATURE_SIZE: usize = core::mem::size_of::<Signature>();
pub type PublicKey = ffi::ed25519_public_key;
pub const PUBLIC_KEY_SIZE: usize = core::mem::size_of::<PublicKey>();
-mod ffi_override {
- // bindgen incorrectly generates pk and RS as *mut instead of *const
- // https://github.com/rust-lang/rust-bindgen/pull/2684
- extern "C" {
- pub fn ed25519_sign_open(
- m: *const cty::c_uchar,
- mlen: usize,
- pk: *const cty::c_uchar,
- RS: *const cty::c_uchar,
- ) -> cty::c_int;
- }
-}
-
pub fn verify(message: &[u8], public_key: &PublicKey, signature: &Signature) -> Result<(), Error> {
let res = unsafe {
- ffi_override::ed25519_sign_open(
+ ffi::ed25519_sign_open(
message.as_ptr(),
message.len(),
public_key.as_ptr(),
diff --git a/core/embed/rust/src/lib.rs b/core/embed/rust/src/lib.rs
index 38ecb375..6704c98d 100644
--- a/core/embed/rust/src/lib.rs
+++ b/core/embed/rust/src/lib.rs
@@ -1,6 +1,7 @@
#![cfg_attr(not(test), no_std)]
#![deny(clippy::all)]
#![allow(clippy::new_without_default)]
+#![allow(clippy::ptr_offset_with_cast)] // workaround https://github.com/rust-lang/rust-bindgen/issues/3053
#![deny(unsafe_op_in_unsafe_fn)]
#![allow(internal_features)]
// Allowing dead code not to cause a lot of warnings when building for a specific target
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.