From: Simon Glass <simon.glass@canonical.com> Provide fields to show that a disk is locked and allow the user to enter a passphrase to unlock it. Co-developed-by: Claude <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- boot/bootflow_internal.h | 11 +++++++++++ boot/bootflow_menu.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/boot/bootflow_internal.h b/boot/bootflow_internal.h index 519c3ee782a..b35700ba38f 100644 --- a/boot/bootflow_internal.h +++ b/boot/bootflow_internal.h @@ -26,6 +26,11 @@ * @ITEM_VERSION_NAME: Distro's name for the version, e.g. 'Noble Numbat' * @ITEM_BOX: Box around the item (normally hidden) * @ITEM_VERIFIED: Indicates that the item is verified by the vendor + * @ITEM_LOCKED: Indicates that the partition is encrypted (e.g., LUKS) + * @ITEM_PASS: Textline object for passphrase entry + * @ITEM_PASS_LABEL: Label text for the passphrase field (e.g., "Passphrase:") + * @ITEM_PASS_EDIT: Edit field for entering the passphrase + * @ITEM_PASS_MSG: Message text for displaying success/error feedback */ enum boomenu_id_t { START, @@ -37,6 +42,7 @@ enum boomenu_id_t { STR_AUTOBOOT, STR_MENU_TITLE, STR_POINTER, + STR_PASS_MSG, /* scene */ MAIN, @@ -70,6 +76,11 @@ enum boomenu_id_t { ITEM_VERSION_NAME = 1100, ITEM_BOX = 1200, ITEM_VERIFIED = 1300, + ITEM_LOCKED = 1400, + ITEM_PASS = 1500, + ITEM_PASS_LABEL = 1600, + ITEM_PASS_EDIT = 1700, + ITEM_PASS_MSG = 1800, /* left margin for the main menu */ MARGIN_LEFT = 100, diff --git a/boot/bootflow_menu.c b/boot/bootflow_menu.c index eda95428bf4..17fab284ef7 100644 --- a/boot/bootflow_menu.c +++ b/boot/bootflow_menu.c @@ -44,6 +44,9 @@ static int bootflow_menu_set_item_props(struct scene *scn, ret |= scene_obj_set_hide(scn, ITEM_VERSION_NAME + i, true); scene_obj_set_hide(scn, ITEM_VERIFIED + i, true); ret |= scene_obj_set_hide(scn, ITEM_KEY + i, false); + scene_obj_set_hide(scn, ITEM_LOCKED + i, true); + scene_obj_set_hide(scn, ITEM_PASS_LABEL + i, true); + scene_obj_set_hide(scn, ITEM_PASS_EDIT + i, true); if (ret) return log_msg_ret("msp", ret); @@ -229,6 +232,7 @@ int bootflow_menu_add(struct expo *exp, struct bootflow *bflow, int seq, struct scene **scnp) { struct menu_priv *priv = exp->priv; + struct scene_obj_textline *tline; char str[2], *key; struct scene *scn; uint preview_id; @@ -279,6 +283,33 @@ int bootflow_menu_add(struct expo *exp, struct bootflow *bflow, int seq, if (ret < 0) return log_msg_ret("itm", -EINVAL); + /* + * Create passphrase textline with label and edit field (12 chars). Show + * characters as asterisks + */ + ret = scene_textline(scn, "passphrase", ITEM_PASS + seq, 12, &tline); + if (ret < 0) + return log_msg_ret("itp", -EINVAL); + tline->obj.flags |= SCENEOF_PASSWORD; + ret = scene_txt_str(scn, "pass_label", ITEM_PASS_LABEL + seq, 0, + "Passphrase:", NULL); + if (ret < 0) + return log_msg_ret("itl", -EINVAL); + tline->label_id = ret; + + ret = scene_txt_str(scn, "pass_edit", ITEM_PASS_EDIT + seq, 0, + "", NULL); + if (ret < 0) + return log_msg_ret("ite", -EINVAL); + tline->edit_id = ret; + + /* Create message text (hidden by default) for success/error feedback */ + ret = scene_txt_str(scn, "pass_msg", ITEM_PASS_MSG + seq, + STR_PASS_MSG + seq, "", NULL); + if (ret < 0) + return log_msg_ret("ipm", -EINVAL); + scene_obj_set_hide(scn, ITEM_PASS_MSG + seq, true); + ret = bootflow_menu_set_item_props(scn, seq, bflow); if (ret) return log_msg_ret("itp", -EINVAL); -- 2.43.0