From patchwork Tue Jan 28 08:25:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1230211 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=HpCPw3bL; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 486KWc3JLwz9sP6 for ; Tue, 28 Jan 2020 19:28:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6E9B381A42; Tue, 28 Jan 2020 09:27:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="HpCPw3bL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2C46681A02; Tue, 28 Jan 2020 09:26:55 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 61B7481A10 for ; Tue, 28 Jan 2020 09:26:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pg1-x542.google.com with SMTP id b9so6567908pgk.12 for ; Tue, 28 Jan 2020 00:26:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7NnQ4scfGaB0+MbEXK3RzIJ7PfVEr7Wa7A51zEDPSaE=; b=HpCPw3bLDrdxDc4Y6mcuCZzbILwdB+BI/q/POCimw3bSiJqu4RkU/esU4N+AD0DQnS 2YyVr0M7OYMQUSvuobDkzZAom+5w2QNqY1vwZUbR/sx44er6x5Ff4EAwnmE8XE/YoBBL 7yACxnQBYRXrfckHTvKvE+WgfjLR80naC0So+sEZySZTnu4meozty9ozbvlucI+hJ5Hr DMm02tHQbG3MXqoRgR0aZiR40Q/S2euTGhZbKsesUY61KtgzbHDY/YtV+2gXdEbxMlxS 67OJsR7Shpi8q8LgCPjb2lEURc4UYVcQsv6OgM7jWKlEfMZY/fSRD0XdCyU4+q/1xT/F WMfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7NnQ4scfGaB0+MbEXK3RzIJ7PfVEr7Wa7A51zEDPSaE=; b=IONQ1QBzk6HAedtWfflvGi2TqsRYlselTBUyLt6qrJ6ASJofX/mUYMKAT8iSXQ9Cw1 xB0XyAymGlhQtwr8JR4tVwkwSpoRNam1IpqcxyUK5hdK9xKLN23coEuOU96lDmtwVowK OgGhjHYQ8G+RBvk/EYEAZxn0+WuWzAHlUUkElAB7Uc+sU7CGw7zdRW4yr1ahFOhYd5B5 ix/d3J6g+CSkZM2feuuUExIBtvWUA2aq2bC119vuygCWdU0avw/u9uJfAMT83bCV5lS1 GSFRaZ6fwfNEaBtlBn1IdjsyB9A89k/f38Vn26zy9L9UQiHVt259jPGn2x2Bp1JAZMG4 N0jg== X-Gm-Message-State: APjAAAU8fFJqLHJNWbycDdruNMjUZn05I0Fj7J/351OY5nkM3iaCxj2D I4QucYVD2piNaSlqfgt6fcdOGw== X-Google-Smtp-Source: APXvYqwE90BHOT0zZHmTIsNnrHnWUbtLkh+JKzWzmTcNZ/ORxCawG/Ehm9DjfGTMctUav3CjDpGAuQ== X-Received: by 2002:a63:ed4a:: with SMTP id m10mr21021900pgk.99.1580200009379; Tue, 28 Jan 2020 00:26:49 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id z4sm18590781pfn.42.2020.01.28.00.26.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jan 2020 00:26:48 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Subject: [PATCH v5 09/16] cmd: env: use appropriate guid for authenticated UEFI variable Date: Tue, 28 Jan 2020 17:25:25 +0900 Message-Id: <20200128082532.15943-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200128082532.15943-1-takahiro.akashi@linaro.org> References: <20200128082532.15943-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean A signature database variable is associated with a specific guid. For convenience, if user doesn't supply any guid info, "env set|print -e" should complement it. Signed-off-by: AKASHI Takahiro --- cmd/nvedit_efi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 8ea0da01283f..579cf430593c 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -41,6 +41,11 @@ static const struct { } efi_guid_text[] = { /* signature database */ {EFI_GLOBAL_VARIABLE_GUID, "EFI_GLOBAL_VARIABLE_GUID"}, + {EFI_IMAGE_SECURITY_DATABASE_GUID, "EFI_IMAGE_SECURITY_DATABASE_GUID"}, + /* certificate type */ + {EFI_CERT_SHA256_GUID, "EFI_CERT_SHA256_GUID"}, + {EFI_CERT_X509_GUID, "EFI_CERT_X509_GUID"}, + {EFI_CERT_TYPE_PKCS7_GUID, "EFI_CERT_TYPE_PKCS7_GUID"}, }; /* "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" */ @@ -525,9 +530,9 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (*ep != ',') return CMD_RET_USAGE; + /* 0 should be allowed for delete */ size = simple_strtoul(++ep, NULL, 16); - if (!size) - return CMD_RET_FAILURE; + value_on_memory = true; } else if (!strcmp(argv[0], "-v")) { verbose = true; @@ -539,8 +544,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_USAGE; var_name = argv[0]; - if (default_guid) - guid = efi_global_variable_guid; + if (default_guid) { + if (!strcmp(var_name, "db") || !strcmp(var_name, "dbx") || + !strcmp(var_name, "dbt")) + guid = efi_guid_image_security_database; + else + guid = efi_global_variable_guid; + } if (verbose) { printf("GUID: %s\n", efi_guid_to_str((const efi_guid_t *)