From patchwork Wed Sep 18 01:26:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1163648 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.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.b="UeW7uGrC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Y2TJ6Bkkz9s4Y for ; Wed, 18 Sep 2019 11:29:40 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9984AC2209D; Wed, 18 Sep 2019 01:28:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 737FEC21E1E; Wed, 18 Sep 2019 01:27:55 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 14476C21DAF; Wed, 18 Sep 2019 01:24:10 +0000 (UTC) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by lists.denx.de (Postfix) with ESMTPS id 13472C21D72 for ; Wed, 18 Sep 2019 01:24:08 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id 205so3266030pfw.2 for ; Tue, 17 Sep 2019 18:24:08 -0700 (PDT) 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=lpT0i+omjdd1fCw1v5ryFUmN/toLIUPG52wfp5+OhmM=; b=UeW7uGrCroQINMd6dUMCSf7EAkUs6gMOkvAJ8RXZK+/E/M/rA5L9j54rBzysZ6isi2 tv002kQvf77gsj63NYs+OUIN7KmUkRgh9f/3Wo/HrrnrS7GI3dGmvhFoYVfYB5T4MlQw Am0KTTeryeOJ5mp1cssH5iLhQaB8Osoe8ACViWvfCBdDkWMX8ow61oqgutVB4g2FYimk tjlLr8JPXCXPWYEv5nIt9H46XXCK+PIR+DWBOdqxQceV4/chL4xNauybEcsb3L5uO2n7 QRhkAjjP+TAhfoGAMEUR1Q00qzE4qPTZI40g6Qfgb7Ni+RBrArbZ5vrkP9yz3Uh3aXZb oBYA== 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=lpT0i+omjdd1fCw1v5ryFUmN/toLIUPG52wfp5+OhmM=; b=tTGxxJSEVYdma7qw/K+x/TIDN1nEM9ipfnzJwNL5eYOROXpX1TSg+wCO/ZRBeVgaq7 q3bJes5EC5nfrHS9eCetmwCDxbqQTUFH+3+jfF/NNY0ozeQ5qnuvuIJ8+wSn/nxozgpZ 6VMLoARdJYTdT9EJOPunUcGV3ROMIFksDYGo/BdAQSHxbZie8YnYBipwiqpYHRCeERfU IwBoA9b8J633XdjfGZs9Zm4j2k340Rzls82G0PVEb0MuffU6Ab51t+8X5LXDjceGHDlr 7/ungsVcsxjRK0Vk7XN6wpu7rrr0ar6PJgvsaFJBHJFJiHX6cSkXOfutjQ9BM7HGBxN0 Zb2Q== X-Gm-Message-State: APjAAAWKoDRRQl1NjuJO/j7XJzeAvQC/hw/ajyhgQlWyCmWMDk9QjyRo 6NCssScWKG+gZ1UlLFpuTei4cg== X-Google-Smtp-Source: APXvYqwqhDeCfOSdFVxSdHsAgcXv4aj9wEwYQ02hz/ekAm/DAz8CMTbf2WTwwkJsVrc5/OW1pmORng== X-Received: by 2002:a65:6259:: with SMTP id q25mr1622395pgv.145.1568769846653; Tue, 17 Sep 2019 18:24:06 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j1sm399894pjs.28.2019.09.17.18.24.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Sep 2019 18:24:06 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Date: Wed, 18 Sep 2019 10:26:41 +0900 Message-Id: <20190918012643.25192-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190918012643.25192-1-takahiro.akashi@linaro.org> References: <20190918012643.25192-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [RFC 13/15] cmd: env: provide appropriate guid for well-defined variable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Any 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 | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 4532124c33d0..a4dbf37f3f2e 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" */ @@ -135,6 +140,7 @@ static int efi_dump_vars(int argc, char * const argv[], bool verbose) { u16 *var_name16, *p; efi_uintn_t buf_size, size; + efi_guid_t *guid; buf_size = 128; var_name16 = malloc(buf_size); @@ -156,9 +162,13 @@ static int efi_dump_vars(int argc, char * const argv[], bool verbose) p = var_name16; utf8_utf16_strcpy(&p, argv[0]); - efi_dump_single_var(var_name16, - (efi_guid_t *)&efi_global_variable_guid, - verbose); + if (!strcmp(argv[0], "db") || !strcmp(argv[0], "dbx") || + !strcmp(argv[0], "dbt")) + guid = (efi_guid_t *)&efi_guid_image_security_database; + else + guid = (efi_guid_t *)&efi_global_variable_guid; + + efi_dump_single_var(var_name16, guid, verbose); } free(var_name16); @@ -167,7 +177,7 @@ static int efi_dump_vars(int argc, char * const argv[], bool verbose) } /** - * efi_dump_vars() - show information about all the UEFI variables + * efi_dump_var_all() - show information about all the UEFI variables * * @verbose: if true, dump data * Return: CMD_RET_SUCCESS on success, or CMD_RET_RET_FAILURE @@ -463,9 +473,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; @@ -477,8 +487,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(&guid));