From patchwork Mon Dec 8 02:32:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 842 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765161211; bh=IU/PLJWwtPaNdLZkZo9LY1/ES8w7dRBSrjfgPpmokqc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=R9D+ad0Q82K3ybPezm5FNdI16YmZU2BMN2l5iRK8qxSKJujfmNKkVMVORXNbduVxq YSgo6KAHkDrgfJx3KnOiu8daGm8vhxx7s5eOxJP03CGrxeKrPWWfODCRE64eWQIbfC iOjSOHioA9mZojU5uA2W1nTkrJugWzw+XxzOPwhW7Do4rp/Qb63e47QxM7REQmqyrC RoTrUainVgfBArw+hUH9CYmwRSOT1x1UJdcCYxSqDvVfrLwexR2evsBt1rKUgkhykV zXUAdin2Ftf/DZwtYhwncboyWLyNuuBLgAKjYtfs/eGZQNKFaOpOXO3VHFtGlXI5a8 gkJ8qBfaJGF6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EBF79689C2 for ; Sun, 7 Dec 2025 19:33:31 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Jntd1TbW4A8i for ; Sun, 7 Dec 2025 19:33:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765161211; bh=IU/PLJWwtPaNdLZkZo9LY1/ES8w7dRBSrjfgPpmokqc=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=R9D+ad0Q82K3ybPezm5FNdI16YmZU2BMN2l5iRK8qxSKJujfmNKkVMVORXNbduVxq YSgo6KAHkDrgfJx3KnOiu8daGm8vhxx7s5eOxJP03CGrxeKrPWWfODCRE64eWQIbfC iOjSOHioA9mZojU5uA2W1nTkrJugWzw+XxzOPwhW7Do4rp/Qb63e47QxM7REQmqyrC RoTrUainVgfBArw+hUH9CYmwRSOT1x1UJdcCYxSqDvVfrLwexR2evsBt1rKUgkhykV zXUAdin2Ftf/DZwtYhwncboyWLyNuuBLgAKjYtfs/eGZQNKFaOpOXO3VHFtGlXI5a8 gkJ8qBfaJGF6A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D9CE268900 for ; Sun, 7 Dec 2025 19:33:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765161210; bh=eXFefSYzCRlbHDTqA9qnVhPKY+fGbCpfQzwgbYZk1jU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8HQJQcTQeY9FllCXRMyWHt4if8IbMEbDg/Wcs0keDbui9IUniJXLNI4ouQtddTVA KXuhfYeROzMd0GTTTs5JKq45PklOjAItZ7PCV3fBkYc1Nz5cB3NREv23PtTlc+7RXH qOW2+SZrzM+3iOzAGxWK/vBst2PAHnPP4yYYktyI3u6bltUsRVfTHVYEY0Qj9LWwmm wKSA/uPF+LTmkLfNJ9FY8E5K2WHWjYMiBahWBBrZ1LLQjf8WYDE69pkKiID7hsHcRM MOnPiyj1yuWA96ZyU9uuP8Vv2XSkXZ4YMS3QuRGT8Kfa24JWTmbmVZmoRkeVnyPDhm lMOjME1TPs9sA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F0266883E; Sun, 7 Dec 2025 19:33:30 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id HtyM4pvDW3-g; Sun, 7 Dec 2025 19:33:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765161206; bh=M3pvqGC0q27TbS41vEqMDrejTmWbZLS+RU3mvboq0w4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Add3QL8VjcqZRdY9kQ+axhAwzMyMUoZKNSGh5NA7+SvrJSkNTtF1UcKRL5NotFhhv Lwi/ttGpGt6cLYbZUJNjXY1hv3bYBqi2oifzLPmlrcFBvzVHxDjdccvuNYVHYiw6iw 40nGu3lD40Uf+UIfF05T+E2KF/Ed1KkXXIDrxV4vmOGpcb1/Ge48Yfc3n3xuVvuaXa vKK4mrSZXPCy8QGp0J8WfcQJ8ds7pyJhU+vjrtCdLvUIckREX9/c4ZolKkZ7hGYH2o /oW6FCtfimMl0LAfstHDi8g7SzNvIDIC6tA9CgEwNXBLdHLX8Hfo9zD6yjOkaVHkTT DObr+z/4fRlxw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 14BD668900; Sun, 7 Dec 2025 19:33:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 7 Dec 2025 19:32:12 -0700 Message-ID: <20251208023229.3929910-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251208023229.3929910-1-sjg@u-boot.org> References: <20251208023229.3929910-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: EQUKZ7HDYOOFG5I6PRHTNDLFAAFH52TV X-Message-ID-Hash: EQUKZ7HDYOOFG5I6PRHTNDLFAAFH52TV X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/19] bootctl: Enhance the UI to support a TKey List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass When unlocking an encrypted disk with a TKey we need a few more UI operations: - allow the password-entry textline to be shown/hidden - allow showing instructions to the user, as well as unlock result - obtain the password entered by the user Add these to the API and implement them in the multi UI. Signed-off-by: Simon Glass --- boot/bootctl/multi_ui.c | 84 +++++++++++++++++++++++++++++++++++++++++ boot/bootctl/util.c | 60 +++++++++++++++++++++++++++++ include/bootctl/ui.h | 80 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 224 insertions(+) diff --git a/boot/bootctl/multi_ui.c b/boot/bootctl/multi_ui.c index f4f0bd281fe..5145e4357cb 100644 --- a/boot/bootctl/multi_ui.c +++ b/boot/bootctl/multi_ui.c @@ -577,6 +577,86 @@ static int multiboot_ui_of_to_plat(struct udevice *dev) return 0; } +static int multiboot_ui_show_pass(struct udevice *dev, int seq, bool show) +{ + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + struct scene *scn = upriv->scn; + int ret; + + scene_obj_set_hide(scn, ITEM_PASS + seq, !show); + scene_obj_set_hide(scn, ITEM_PASS_LABEL + seq, !show); + scene_obj_set_hide(scn, ITEM_PASS_EDIT + seq, !show); + + if (show) { + struct scene_obj_textline *tline; + char *buf; + + /* Clear the passphrase buffer for retry */ + tline = scene_obj_find(scn, ITEM_PASS + seq, + SCENEOBJT_TEXTLINE); + if (!tline) + return log_msg_ret("tln", -ENOENT); + buf = abuf_data(&tline->buf); + *buf = '\0'; + + /* Set highlight and open the textline for editing */ + scene_set_highlight_id(scn, ITEM_PASS + seq); + ret = scene_set_open(scn, ITEM_PASS + seq, true); + if (ret) + return log_msg_ret("sop", ret); + } else { + /* Close the textline */ + ret = scene_set_open(scn, ITEM_PASS + seq, false); + if (ret) + return log_msg_ret("sop", ret); + } + + return 0; +} + +static int multiboot_ui_get_pass(struct udevice *dev, int seq, + const char **passp) +{ + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + struct scene *scn = upriv->scn; + struct scene_obj_textline *tline; + + tline = scene_obj_find(scn, ITEM_PASS + seq, SCENEOBJT_TEXTLINE); + if (!tline) + return log_msg_ret("tln", -ENOENT); + + *passp = abuf_data(&tline->buf); + + return 0; +} + +static int multiboot_ui_show_pass_msg(struct udevice *dev, int seq, bool show) +{ + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + struct scene *scn = upriv->scn; + + scene_obj_set_hide(scn, ITEM_PASS_MSG + seq, !show); + + return 0; +} + +static int multiboot_ui_set_pass_msg(struct udevice *dev, int seq, + const char *msg) +{ + struct bc_ui_priv *upriv = dev_get_uclass_priv(dev); + struct expo *exp = upriv->expo; + struct abuf *buf; + int ret; + + ret = expo_edit_str(exp, STR_PASS_MSG + seq, NULL, &buf); + if (ret) + return log_msg_ret("spm", ret); + + abuf_set(buf, (void *)msg, strlen(msg) + 1); + + return 0; +} + static struct bc_ui_ops ops = { .print = multiboot_ui_print, .show = multiboot_ui_show, @@ -584,6 +664,10 @@ static struct bc_ui_ops ops = { .render = multiboot_ui_render, .poll = multiboot_ui_poll, .switch_layout = multiboot_ui_switch_layout, + .show_pass = multiboot_ui_show_pass, + .get_pass = multiboot_ui_get_pass, + .show_pass_msg = multiboot_ui_show_pass_msg, + .set_pass_msg = multiboot_ui_set_pass_msg, }; static const struct udevice_id multiboot_ui_ids[] = { diff --git a/boot/bootctl/util.c b/boot/bootctl/util.c index 48912c67f21..790489ca937 100644 --- a/boot/bootctl/util.c +++ b/boot/bootctl/util.c @@ -110,6 +110,66 @@ int bc_ui_switch_layout(struct udevice *dev) return 0; } +int bc_ui_show_pass(struct udevice *dev, int seq, bool show) +{ + struct bc_ui_ops *ops = bc_ui_get_ops(dev); + int ret; + + if (!ops->show_pass) + return -ENOSYS; + + ret = ops->show_pass(dev, seq, show); + if (ret) + return log_msg_ret("bsp", ret); + + return 0; +} + +int bc_ui_get_pass(struct udevice *dev, int seq, const char **passp) +{ + struct bc_ui_ops *ops = bc_ui_get_ops(dev); + int ret; + + if (!ops->get_pass) + return -ENOSYS; + + ret = ops->get_pass(dev, seq, passp); + if (ret) + return log_msg_ret("bgp", ret); + + return 0; +} + +int bc_ui_show_pass_msg(struct udevice *dev, int seq, bool show) +{ + struct bc_ui_ops *ops = bc_ui_get_ops(dev); + int ret; + + if (!ops->show_pass_msg) + return -ENOSYS; + + ret = ops->show_pass_msg(dev, seq, show); + if (ret) + return log_msg_ret("bse", ret); + + return 0; +} + +int bc_ui_set_pass_msg(struct udevice *dev, int seq, const char *msg) +{ + struct bc_ui_ops *ops = bc_ui_get_ops(dev); + int ret; + + if (!ops->set_pass_msg) + return -ENOSYS; + + ret = ops->set_pass_msg(dev, seq, msg); + if (ret) + return log_msg_ret("bsm", ret); + + return 0; +} + void bc_oslist_setup_iter(struct oslist_iter *iter) { memset(iter, '\0', sizeof(struct oslist_iter)); diff --git a/include/bootctl/ui.h b/include/bootctl/ui.h index 4f8e08a00c2..5e592e3dce2 100644 --- a/include/bootctl/ui.h +++ b/include/bootctl/ui.h @@ -99,6 +99,46 @@ struct bc_ui_ops { * Return 0 if OK, -ve on error */ int (*switch_layout)(struct udevice *dev); + + /** + * show_pass() - Show or hide the passphrase input field + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @show: true to show the pass field, false to hide it + * Return 0 if OK, -ve on error + */ + int (*show_pass)(struct udevice *dev, int seq, bool show); + + /** + * get_pass() - Get the passphrase entered by the user + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @passp: Returns pointer to the passphrase string + * Return 0 if OK, -ve on error + */ + int (*get_pass)(struct udevice *dev, int seq, const char **passp); + + /** + * show_pass_msg() - Show or hide the pass message + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @show: true to show the message, false to hide it + * Return 0 if OK, -ve on error + */ + int (*show_pass_msg)(struct udevice *dev, int seq, bool show); + + /** + * set_pass_msg() - Set the pass message text + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @msg: Message text to display + * Return 0 if OK, -ve on error + */ + int (*set_pass_msg)(struct udevice *dev, int seq, const char *msg); }; #define bc_ui_get_ops(dev) ((struct bc_ui_ops *)(dev)->driver->ops) @@ -148,4 +188,44 @@ int bc_ui_poll(struct udevice *dev, int *seqp, bool *selectedp); */ int bc_ui_switch_layout(struct udevice *dev); +/** + * bc_ui_show_pass() - Show or hide the pass input field + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @show: true to show the pass field, false to hide it + * Return 0 if OK, -ve on error + */ +int bc_ui_show_pass(struct udevice *dev, int seq, bool show); + +/** + * bc_ui_get_pass() - Get the pass entered by the user + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @passp: Returns pointer to the pass string + * Return 0 if OK, -ve on error + */ +int bc_ui_get_pass(struct udevice *dev, int seq, const char **passp); + +/** + * bc_ui_show_pass_msg() - Show or hide the pass message + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @show: true to show the message, false to hide it + * Return 0 if OK, -ve on error + */ +int bc_ui_show_pass_msg(struct udevice *dev, int seq, bool show); + +/** + * bc_ui_set_pass_msg() - Set the pass message text + * + * @dev: Display device + * @seq: Sequence number of the bootflow item + * @msg: Message text to display + * Return 0 if OK, -ve on error + */ +int bc_ui_set_pass_msg(struct udevice *dev, int seq, const char *msg); + #endif