What changed, and why it matters
This commit adds a feature that shuffles the on-screen numeric keypad layout each time the device lock screen appears. The goal is to make it harder for someone watching or recording your screen to figure out your PIN based on where your fingers tap. The change itself is a security improvement, not a vulnerability fix, but the commit message is vague and gives no explanation.
Treat as a benign hardening change. Review the randomness source used by ShuffleNumKeyBoardMap() to ensure it is cryptographically secure or at least unpredictable, and verify that the shuffle does not introduce accessibility or usability regressions.
Security signals we found
New shuffle/scramble routine invoked at lock-screen activation
Numeric keypad layout randomized per lock-screen invocation
No input validation, bounds checking, or memory safety changes present
Commit title/message provide no security context
Evidence from the diff
The patch exposes a previously internal ShuffleNumKeyBoardMap() routine through new public functions GuiUpdateNumKeyBoardMap() and GuiShuffleNumKeyBoardMap(), and calls it from GuiLockScreenTurnOn() so the numeric button matrix is randomized every time the lock screen is displayed. No bug is fixed; this is a defense-in-depth enhancement against shoulder-surfing / side-channel attacks on PIN entry.
Changed components
src/ui/gui_components/gui_keyboard.csrc/ui/gui_components/gui_keyboard.hsrc/ui/gui_widgets/gui_enter_passcode.csrc/ui/gui_widgets/gui_enter_passcode.hsrc/ui/gui_widgets/gui_lock_widgets.cInspect captured patch +14 / −0
diff --git a/src/ui/gui_components/gui_keyboard.c b/src/ui/gui_components/gui_keyboard.c
index 74bf3be..900e5bf 100644
--- a/src/ui/gui_components/gui_keyboard.c
+++ b/src/ui/gui_components/gui_keyboard.c
@@ -488,6 +488,12 @@ static void ShuffleNumKeyBoardMap(const char **map)
for (int i = 0; i < n; i++) map[digitIdx[i]] = digits[i];
}
+void GuiUpdateNumKeyBoardMap(lv_obj_t *btnm)
+{
+ ShuffleNumKeyBoardMap((const char **)g_numBtnmMap);
+ lv_btnmatrix_set_map(btnm, (const char **)g_numBtnmMap);
+}
+
void *GuiCreateNumKeyboard(lv_obj_t *parent, lv_event_cb_t cb, NUM_KEYBOARD_ENUM numMode, void *param)
{
uint16_t kbHeight = 310;
diff --git a/src/ui/gui_components/gui_keyboard.h b/src/ui/gui_components/gui_keyboard.h
index dbbaaf6..e464418 100644
--- a/src/ui/gui_components/gui_keyboard.h
+++ b/src/ui/gui_components/gui_keyboard.h
@@ -61,6 +61,7 @@ void GuiDeleteKeyBoard(KeyBoard_t *kb);
void GuiKeyBoardRestoreDefault(KeyBoard_t *keyBoard);
void *GuiCreateNumKeyboard(lv_obj_t *parent, lv_event_cb_t cb, NUM_KEYBOARD_ENUM numMode, void *param);
void GuiUpdateSsbKeyBoard(lv_obj_t *btnm, uint8_t memberCnt);
+void GuiUpdateNumKeyBoardMap(lv_obj_t *btnm);
// full keyboard
void *GuiCreateFullKeyBoard(lv_obj_t *parent, lv_event_cb_t kbCb, lv_keyboard_user_mode_t keyMode, void *param);
diff --git a/src/ui/gui_widgets/gui_enter_passcode.c b/src/ui/gui_widgets/gui_enter_passcode.c
index 8aaaa22..f6d784a 100644
--- a/src/ui/gui_widgets/gui_enter_passcode.c
+++ b/src/ui/gui_widgets/gui_enter_passcode.c
@@ -336,6 +336,11 @@ static void PassWordPinSwitchHandler(lv_event_t *e)
PassWordPinSwitch(item);
}
+void GuiShuffleNumKeyBoardMap(GuiEnterPasscodeItem_t *item)
+{
+ GuiUpdateNumKeyBoardMap(item->btnm);
+}
+
void GuiCreateEnterVerify(GuiEnterPasscodeItem_t *item, EnterPassCodeParam_t *passCodeParam)
{
lv_obj_t *pinCont = item->pinCont;
diff --git a/src/ui/gui_widgets/gui_enter_passcode.h b/src/ui/gui_widgets/gui_enter_passcode.h
index bad8fed..77a9781 100644
--- a/src/ui/gui_widgets/gui_enter_passcode.h
+++ b/src/ui/gui_widgets/gui_enter_passcode.h
@@ -50,6 +50,7 @@ uint8_t GetPassWordStrength(const char *password, uint8_t len);
void GuiFingerPrintStatus(GuiEnterPasscodeItem_t *item, bool en, uint8_t errCnt);
void PassWordPinSwitch(GuiEnterPasscodeItem_t *item);
void GuiEnterPassLabelRefresh(void);
+void GuiShuffleNumKeyBoardMap(GuiEnterPasscodeItem_t *item);
#endif /* _GUI_ENTER_PASSCODE_H */
diff --git a/src/ui/gui_widgets/gui_lock_widgets.c b/src/ui/gui_widgets/gui_lock_widgets.c
index 8a46ef9..13277b9 100644
--- a/src/ui/gui_widgets/gui_lock_widgets.c
+++ b/src/ui/gui_widgets/gui_lock_widgets.c
@@ -218,6 +218,7 @@ void GuiLockScreenTurnOn(void *param)
if (GetKeyboardWidgetMode() != g_verifyLock->mode % 2) {
PassWordPinSwitch(g_verifyLock);
}
+ GuiShuffleNumKeyBoardMap(g_verifyLock);
GuiUpdateEnterPasscodeParam(g_verifyLock, single);
GuilockScreenRefresh();
}
Why this scored 50/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.