From patchwork Sun Feb 7 18:26:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jorge Ramirez-Ortiz, Foundries" X-Patchwork-Id: 1437237 X-Patchwork-Delegate: trini@ti.com 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; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=VBZFO9vh; 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 4DYd0y1Jb8z9sVF for ; Mon, 8 Feb 2021 05:27:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7D6A9827C5; Sun, 7 Feb 2021 19:26:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="VBZFO9vh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24356826FC; Sun, 7 Feb 2021 19:26:49 +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=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) (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 E2234826FC for ; Sun, 7 Feb 2021 19:26:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge@foundries.io Received: by mail-wr1-x430.google.com with SMTP id n6so1792755wrv.8 for ; Sun, 07 Feb 2021 10:26:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W9xN9RLp99vGzLCMlL/huxCpVmL0MBe4gBZueqlPS5A=; b=VBZFO9vhZrR4sIGpydw24D8qRx6TfVqDIRB3ZXx51TOzMhjqZul1YzeSbacFDITm/2 HAjUbRjgLAoKIvyuAIFgxJgA2dP1+Y4jMsiXwwX89Rd6wIwXdoJvb4IQiRmvS/7VQ2oG hJeeIKFManD68BxzGyRvWy5pw4WNZi6dk2ph3M33Fen3l4p+f/2AnT2cbDd8Ix8fzff4 CSaHj7UhxMKQwovKt0NG7BTRxQuufvHgJooPIdhfN8eIWqc0kfDDZ/fVcQ45EFfh9jk4 rfsR7twT4PctIrRo2l/n9S4hxleycBT9Pp2OGcDoGMIPJBz56k/tguR13leSKtuKr/Zz x4NA== 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=W9xN9RLp99vGzLCMlL/huxCpVmL0MBe4gBZueqlPS5A=; b=oK9xqLF/z7ECiuhFFZdevB59V9t4jrBlPPDX0QV0+vkKjPBSGefupBUKqfRPpdHc4r VVk1juptSorxwUb4+6MJyZ1R+t4RxhuMot/x3YYcO36lQ8vIkVLnoOuq1vyOOmJJ1RAH P4C/0s+ZGbrE4ron23Mckifl9ZvjpzV4T+wN/caYtPsjM96j2NOlszLk7gIB164H4awf 7sbedFg0FSLDPOSpNHVKIZnR6/E2sGtG9yUKFamWIU3Gua1ItjeBiXsoqPSdPJWgPJX+ zyC0MmwaXu8wmWeZ2MnCJCQRt9TnvUTzC5cDkuhiQXrp267HRW/gnbCR1In2Nn+sPcs8 5i8w== X-Gm-Message-State: AOAM531SZyflpRiB94y6ajNs0QlavBVGj1do2PGdq/P/jpZMSd9s+MDm BRwBeq1vWZnYF1oEiSEbWlotkg== X-Google-Smtp-Source: ABdhPJwXHx774OWlz3h+iDR15okXz0eL2J8LiUSN9j0k69rtzJzKsSjkPT57VqDBmV0tmhR9J2WDcA== X-Received: by 2002:adf:f8c1:: with SMTP id f1mr16104719wrq.76.1612722404529; Sun, 07 Feb 2021 10:26:44 -0800 (PST) Received: from localhost.localdomain (182.red-79-146-86.dynamicip.rima-tde.net. [79.146.86.182]) by smtp.gmail.com with ESMTPSA id i3sm5173360wrr.19.2021.02.07.10.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Feb 2021 10:26:44 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge@foundries.io, sjg@chromium.org, jens.wiklander@linaro.org Cc: igor.opaniuk@foundries.io, u-boot@lists.denx.de Subject: [PATCHv3 2/4] cmd: SCP03: enable and provision command Date: Sun, 7 Feb 2021 19:26:30 +0100 Message-Id: <20210207182632.24252-3-jorge@foundries.io> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210207182632.24252-1-jorge@foundries.io> References: <20210207182632.24252-1-jorge@foundries.io> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Enable and provision the SCP03 keys on a TEE controlled secured elemt from the U-Boot shell. Executing this command will generate and program new SCP03 encryption keys on the secure element NVM. Depending on the TEE implementation, the keys would then be stored in some persistent storage or better derived from some platform secret (so they can't be lost). Signed-off-by: Jorge Ramirez-Ortiz Reviewed-by: Simon Glass --- cmd/Kconfig | 8 ++++++++ cmd/Makefile | 3 +++ cmd/scp03.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 cmd/scp03.c diff --git a/cmd/Kconfig b/cmd/Kconfig index 928a2a0a2d..6327374f2c 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2021,6 +2021,14 @@ config HASH_VERIFY help Add -v option to verify data against a hash. +config CMD_SCP03 + bool "scp03 - SCP03 enable and rotate/provision operations" + depends on SCP03 + help + This command provides access to a Trusted Application + running in a TEE to request Secure Channel Protocol 03 + (SCP03) enablement and/or rotation of its SCP03 keys. + config CMD_TPM_V1 bool diff --git a/cmd/Makefile b/cmd/Makefile index 176bf925fd..a7017e8452 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -193,6 +193,9 @@ obj-$(CONFIG_CMD_BLOB) += blob.o # Android Verified Boot 2.0 obj-$(CONFIG_CMD_AVB) += avb.o +# Foundries.IO SCP03 +obj-$(CONFIG_CMD_SCP03) += scp03.o + obj-$(CONFIG_ARM) += arm/ obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_SANDBOX) += sandbox/ diff --git a/cmd/scp03.c b/cmd/scp03.c new file mode 100644 index 0000000000..cc1a904923 --- /dev/null +++ b/cmd/scp03.c @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2021, Foundries.IO + * + */ + +#include +#include +#include +#include + +int do_scp03_enable(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + if (argc != 1) + return CMD_RET_USAGE; + + if (tee_enable_scp03()) { + printf("TEE failed to enable SCP03\n"); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + +int do_scp03_provision(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + if (argc != 1) + return CMD_RET_USAGE; + + if (tee_provision_scp03()) { + printf("TEE failed to provision SCP03 keys\n"); + return CMD_RET_FAILURE; + } + + return CMD_RET_SUCCESS; +} + +static char text[] = + "provides a command to enable SCP03 and provision the SCP03 keys\n" + " enable - enable SCP03 on the TEE\n" + " provision - provision SCP03 on the TEE\n"; + +U_BOOT_CMD_WITH_SUBCMDS(scp03, "Secure Channel Protocol 03 control", text, + U_BOOT_SUBCMD_MKENT(enable, 1, 1, do_scp03_enable), + U_BOOT_SUBCMD_MKENT(provision, 1, 1, do_scp03_provision)); +