From patchwork Tue Nov 26 00:51:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1200688 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 (no SPF record) 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="PNz1Lwa7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47MQPj4czqz9s3Z for ; Tue, 26 Nov 2019 11:53:29 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3DF35C21ECF; Tue, 26 Nov 2019 00:52:02 +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 BE4F8C21E2C; Tue, 26 Nov 2019 00:51:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3958CC21E5B; Tue, 26 Nov 2019 00:51:05 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by lists.denx.de (Postfix) with ESMTPS id 6DC6FC21D56 for ; Tue, 26 Nov 2019 00:51:02 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id z4so8259290pfn.12 for ; Mon, 25 Nov 2019 16:51:02 -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=PNz1Lwa7C9WWl7RwL/+VHWA4oYxHMe7b9N5rRirIJ59uFxeuKwn+D34mZn/cQwD5cg 81D6FdSu3iCxApbS3SXZu5TdMGgv67gNTY9FqxfUjNJ5c1a6+HjhiLpjG+7eOWm901yt p1tSrFS6N5ROd7S7QpFyUBiG+WYVEBsMjGb+evX2wFzerb9VMnrzqhdcBR+lNE6ozfcN FQTbq4wr+s1SvgSYKqa+3K4Vhf1kzRO68UamKLdz1vxfhft50ApwQzYHOkd/BYVi9JJz zSS992sMLIkowSfaiHxC3Y6jkhEJczYkYVlOfBLUNOa8cBOB/0TblDpYQH3Up9BYHx74 utow== 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=QmwOwClWFRRJnnt9pC+vOByHLRTddT2m5TV+OGpDdT1OvCCr/ItdRjQBQ6jYrrn4DW PULSVLlLMPjTA12bc9bOvU0eSkQDfcF0XdXzifhTU4lotqh8s7K2npCw0yahY8K8XinL sSFIphh2DksKwu3rkHVPPFGY3gwHLZueQFleT2pQsyr2k9d32kCBwQ3u8o50Z56+VELx 4n/tdBkdG/xS0Gm5yCnvUUQt9xmg1XCDIsx+nT7sOr1zTy9HnMrjZKcIWW5hsoCrd4EL 1mtlNYNtQ5XbAYdKTypvZsMFUXR0Wj3XUuH1YSI+KD0hz6d+r3kL4dM8acdcxc3tWCyy QUvw== X-Gm-Message-State: APjAAAVqZyYs/4qCraaEVjAcyNd1AHmpn14n4WkpALalg9usBCfGMMvX PZ/h8qrNNQlAfq+3ObMfGu9H5w== X-Google-Smtp-Source: APXvYqxOxqjcoT8k7YQ5gpj5OO9xMUNuiyhlgdZUBGZbKzIl6rEc869/fJdCJOPI86UuGl9fShI5tw== X-Received: by 2002:a65:628f:: with SMTP id f15mr35913393pgv.91.1574729461020; Mon, 25 Nov 2019 16:51:01 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id o14sm10380452pfp.5.2019.11.25.16.51.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Nov 2019 16:51:00 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Date: Tue, 26 Nov 2019 09:51:14 +0900 Message-Id: <20191126005120.31156-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191126005120.31156-1-takahiro.akashi@linaro.org> References: <20191126005120.31156-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Subject: [U-Boot] [PATCH v2 10/16] cmd: env: use appropriate guid for authenticated UEFI 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" 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 *)