From patchwork Wed Dec 18 00:45:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1211843 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=85.214.62.61; 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.b="iulZ0U1t"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 47cxC009Y3z9sRl for ; Wed, 18 Dec 2019 11:46:03 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0570C816CC; Wed, 18 Dec 2019 01:44:42 +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="iulZ0U1t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AEA04816A5; Wed, 18 Dec 2019 01:44:34 +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-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (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 41DBA8168D for ; Wed, 18 Dec 2019 01:44:31 +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-pj1-x1042.google.com with SMTP id n67so35653pjb.5 for ; Tue, 17 Dec 2019 16:44:31 -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=iulZ0U1tuI1BXTJmSAe0NduFD0su/uAscj1B6+hGP2PEh7qJl6PrwCBtE6hp5THC2m dZCeFEjmOFjZl2eNzWS+9Q3neRXTcHRwj/rPKh9hfCIA8Uu9m8gIMb8oDzbGBz3fZXgs +8CsKQSpsVngRaVvTWDrvk9tgHSklfNbr9gYy2wb0KojMmB9vWRZP9slX6o3yoUd7MjR cA9yWsWZ/NONv0bEx9yya7SrBIcvH6dtUSBvTLQEUPuXdS/+DrPL3i2Hr7PtagyrmYl4 MMz24HN8NXz5hYNnge/XhdeY5J2dNbqQTvgpe+4pm3A7KoBTeRnH4SQdwwJSsUDqTBF1 wDFw== 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=IhH97QySb5m1bedqB5pKRmxyYoEqLuPCAtO5e/2Cw2Ua0mtMqr5bEKcOPZoE7KjXUw 9V8Pko4JQRa2WUlG6khHAMFGjQcXnF1AkZ3PdHwUWbbVChL97/iKZaM/A9EmXQnpuJah qDyD3sLD/fVeYHnVWk1KWMZcM/PgMsqlKAy/jfDCZKBxziK8Revav81Pie+aufOlrF1p Hsu/nUTBPaTvhSSNSCksK8cgfGZ8lD5sNS2rPuAEj4f58NHYLY7/SniKjSWVg6c3TYOK yA7qcC134DSlGNFJaopAQz0vbmlzvFOq1Kae7lFcoZ4Z8RO2HkJg4gSMtQXFPFf/ZlEb lNgA== X-Gm-Message-State: APjAAAVFDiBM6PTeeFA5Ywa3snMpJn6BLFwrbTsKvZ9FnMpNJwrr17/q +fAdHvmcVxSkhDRWl/Zoe4UGag== X-Google-Smtp-Source: APXvYqyqFGrT6Fe3C++S1hWz2QhvGjtc6kea+41+lK2lh9SlcBoOb39/YMw9ifXZvLRfktnwbBvF5w== X-Received: by 2002:a17:902:7c83:: with SMTP id y3mr1095447pll.34.1576629869758; Tue, 17 Dec 2019 16:44:29 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 189sm258025pfw.73.2019.12.17.16.44.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 16:44:29 -0800 (PST) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Subject: [PATCH v4 10/16] cmd: env: use appropriate guid for authenticated UEFI variable Date: Wed, 18 Dec 2019 09:45:06 +0900 Message-Id: <20191218004512.24939-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191218004512.24939-1-takahiro.akashi@linaro.org> References: <20191218004512.24939-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 *)