i18n: add missing passphrase on host translations
What changed, and why it matters
This commit is a localization (translation) fix. It adds missing translated text strings for the 'passphrase on host' feature and makes the unlock code use those translated strings instead of hard-coded English text. There is no evidence of a security vulnerability being fixed; it is a user-interface completeness and internationalization improvement.
No security action required. Treat as a normal UI/translation fix. If auditing, verify that all new translation keys have matching entries in other supported locales to avoid runtime fallback issues.
Security signals we found
No security-relevant code logic changed
No bounds checks, cryptographic operations, or access controls modified
Change only affects displayed user-facing strings and their translation lookup
Evidence from the diff
The change adds i18n keys (confirmHost, enterOnHost, tooLong, unsupportedCharacters) to German and English firmware translation files. In unlock.rs, hard-coded English strings used in UI prompts/statuses are replaced with calls to the translation macro crate::tr!(hal, …). An enum HostPassphraseError is introduced so error messages can be resolved via i18n rather than returning raw string literals. A previously bypassed translation for ‘Please try again’ is also wired through i18n.
Changed components
src/i18n/locales/de/firmware.jsonsrc/i18n/locales/en/firmware.jsonsrc/rust/bitbox02-rust/src/hww/api/unlock.rsInspect captured patch +33 / −10
### src/i18n/locales/de/firmware.json
@@ -328,9 +328,13 @@
"passphrase": {
"confirm": "Bestätigen",
"confirmEmpty": "Leere Passphrase\nverwenden?",
+ "confirmHost": "Passphrase auf\nHost eingeben?",
"doubleCheck": "Bitte prüfe gleich\ndie angezeigte\nPassphrase erneut.",
+ "enterOnHost": "Passphrase auf\nHost eingeben",
"title": "Optionale Passphrase",
- "tryAgain": "Bitte erneut\nversuchen"
+ "tooLong": "Passphrase\nzu lang",
+ "tryAgain": "Bitte erneut\nversuchen",
+ "unsupportedCharacters": "Ungültige\nZeichen"
},
"remainingAttempts": {
"last": "LETZTER Versuch.\nBei falschem\nPasswort wird das\nGerät zurückgesetzt.",
### src/i18n/locales/en/firmware.json
@@ -328,9 +328,13 @@
"passphrase": {
"confirm": "Confirm",
"confirmEmpty": "Use empty\npassphrase?",
+ "confirmHost": "Enter passphrase\non host?",
"doubleCheck": "You will be asked to\nvisually confirm your\npassphrase now.",
+ "enterOnHost": "Enter passphrase\non host",
"title": "Optional passphrase",
- "tryAgain": "Please try again"
+ "tooLong": "Passphrase too\nlong",
+ "tryAgain": "Please try again",
+ "unsupportedCharacters": "Unsupported\ncharacters"
},
"remainingAttempts": {
"last": "This is your LAST\npassword attempt.\nDevice will reset\nif password is wrong.",
### src/rust/bitbox02-rust/src/hww/api/unlock.rs
@@ -3,6 +3,7 @@
use super::error::Error;
use crate::hal::ui::ConfirmParams;
use crate::hal::{Memory, Ui};
+use crate::i18n::I18n as _;
use crate::pb;
use crate::pb::request::Request;
use crate::pb::response::Response;
@@ -64,16 +65,21 @@ async fn device_entry(hal: &mut impl crate::hal::Hal) -> Result<Option<Zeroizing
}
}
-fn validate_host_passphrase(passphrase: &str) -> Result<(), &'static str> {
+enum HostPassphraseError {
+ TooLong,
+ UnsupportedCharacters,
+}
+
+fn validate_host_passphrase(passphrase: &str) -> Result<(), HostPassphraseError> {
// Restrict host input to values that can also be entered again on the device.
if passphrase.len() > MAX_PASSPHRASE_LEN {
- return Err("Passphrase too\nlong");
+ return Err(HostPassphraseError::TooLong);
}
if !passphrase
.bytes()
.all(|c| c.is_ascii_alphanumeric() || SPECIAL.contains(&c))
{
- return Err("Unsupported\ncharacters");
+ return Err(HostPassphraseError::UnsupportedCharacters);
}
Ok(())
}
@@ -94,11 +100,12 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result<Zeroizing<String>,
None => {
// Entry was interrupted by the host button. Rejection/cancellation always starts a
// fresh device-entry screen, without preserving a partially entered passphrase.
+ let body = crate::tr!(hal, "Enter passphrase\non host?");
if hal
.ui()
.confirm(&ConfirmParams {
title: "",
- body: "Enter passphrase\non host?",
+ body: &body,
..Default::default()
})
.await
@@ -109,7 +116,8 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result<Zeroizing<String>,
let request = {
let waiting = async {
- hal.ui().waiting("Enter passphrase\non host").await;
+ let message = crate::tr!(hal, "Enter passphrase\non host");
+ hal.ui().waiting(&message).await;
unreachable!()
};
// Poll the waiting screen first so it is visible before HOST_ENTRY_READY. This
@@ -126,10 +134,16 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result<Zeroizing<String>,
let Some(passphrase) = request.passphrase.take().map(Zeroizing::new) else {
continue;
};
- if let Err(message) = validate_host_passphrase(&passphrase) {
+ if let Err(error) = validate_host_passphrase(&passphrase) {
// Invalid user input restarts entry just like rejection; malformed protocol
// messages still fail in next_request.
- hal.ui().status(message, false).await;
+ let message = match error {
+ HostPassphraseError::TooLong => crate::tr!(hal, "Passphrase too\nlong"),
+ HostPassphraseError::UnsupportedCharacters => {
+ crate::tr!(hal, "Unsupported\ncharacters")
+ }
+ };
+ hal.ui().status(&message, false).await;
continue;
}
(passphrase, true)
@@ -141,7 +155,8 @@ async fn passphrase(hal: &mut impl crate::hal::Hal) -> Result<Zeroizing<String>,
{
return Ok(passphrase);
}
- hal.ui().status("Please try again", false).await;
+ let status = crate::tr!(hal, "Please try again");
+ hal.ui().status(&status, false).await;
}
}
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.