Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3054913pxj; Mon, 14 Jun 2021 13:18:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2OAPyikNAq9/r9hexRA7h/RKY8w9XS6ZDvcozzPJDdkxiUuoD24dT09bckCarmNUq1uEb X-Received: by 2002:a05:6402:2689:: with SMTP id w9mr18440969edd.375.1623701932320; Mon, 14 Jun 2021 13:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623701932; cv=none; d=google.com; s=arc-20160816; b=nizx7UyjSiMwZwdAPZq8yo9MtdnOAxzFstxQSGYJ4j85FG40ckeJat0PyYEFg+xrop 4GN1eB2PenX9ZfMv/3IGaDLhmCnaVTgXb4DImV9ZfgA3CI13e0OnvBngM8kAFEhvD6Xp RCzDQ/m3FZ4/IM3iNoO9TQlBF2EP802VQ27nxKskXkqB8lg9Wxp+fdUhMZTCP9XvMMaq 5xGrJFe5NqQx3r8HmdjY97uvRp8CDA9x57jxZP/s1phL4ETcRB9XB1A3jbTeXT8oCOYk RD21GTEhVoSDiuQIkrf3uHiiO/9j//Aem2pkxNrsQSZm5Boc+qCAmTeUEqVQlrcLg88d sr5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kOaRLd/xeYij+87ZdWZgr1+qeuyNqQDRrYoezy2NP/s=; b=fHVuogdjimEBcUhOmnHb06CxVpIIdc6BaK9CG5hqWiZzylzHmpQHNw/tTbSdMGgArI +vqWFi0tsNl077SSCejBOrLbOWKuWv1hajQ++MMRLlSBmOz/4iOGGzlB/kvex59Kqe4c k1bPhYe5vF/hmeaSHatCnRXPeY7uJ//okFbAlESAG46HeQcAeEARlrpbu2nB8KBRO2kh WKAohzUnWSyXDBj4oi4ZtImbpl9mYcZgGvnsO7rDeZzc7lpwSGGiTtpJap8MATv4m0vJ GKXJozd9ZxFGbeH8ZC1tHu+47XGBf9gLjK2RDhkmbS+NM7eynYPIn6f1TyUMjubeVDOP qjkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si12827449ejk.80.2021.06.14.13.18.28; Mon, 14 Jun 2021 13:18:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234656AbhFNUS5 (ORCPT + 99 others); Mon, 14 Jun 2021 16:18:57 -0400 Received: from lilium.sigma-star.at ([109.75.188.150]:59192 "EHLO lilium.sigma-star.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234444AbhFNUSo (ORCPT ); Mon, 14 Jun 2021 16:18:44 -0400 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 7C89818190E4A; Mon, 14 Jun 2021 22:16:38 +0200 (CEST) Received: from lilium.sigma-star.at ([127.0.0.1]) by localhost (lilium.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id EytU5U21JfDt; Mon, 14 Jun 2021 22:16:37 +0200 (CEST) Received: from lilium.sigma-star.at ([127.0.0.1]) by localhost (lilium.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Yxr3TtJK9DNP; Mon, 14 Jun 2021 22:16:37 +0200 (CEST) From: Richard Weinberger To: keyrings@vger.kernel.org Cc: David Gstir , Ahmad Fatoum , David Howells , "David S. Miller" , Fabio Estevam , Herbert Xu , James Bottomley , James Morris , Jarkko Sakkinen , Jonathan Corbet , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Mimi Zohar , NXP Linux Team , Pengutronix Kernel Team , Richard Weinberger , Sascha Hauer , "Serge E. Hallyn" , Shawn Guo Subject: [PATCH 3/3] doc: trusted-encrypted: add DCP as new trust source Date: Mon, 14 Jun 2021 22:16:20 +0200 Message-Id: <20210614201620.30451-4-richard@nod.at> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210614201620.30451-1-richard@nod.at> References: <20210614201620.30451-1-richard@nod.at> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Gstir Update the documentation for trusted and encrypted KEYS with DCP as new trust source: - Describe security properties of DCP trust source - Describe key usage - Document blob format Cc: Ahmad Fatoum Cc: David Gstir Cc: David Howells Cc: "David S. Miller" Cc: Fabio Estevam Cc: Herbert Xu Cc: James Bottomley Cc: James Morris Cc: Jarkko Sakkinen Cc: Jonathan Corbet Cc: keyrings@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-crypto@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-integrity@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: linux-security-module@vger.kernel.org Cc: Mimi Zohar Cc: NXP Linux Team Cc: Pengutronix Kernel Team Cc: Richard Weinberger Cc: Sascha Hauer Cc: "Serge E. Hallyn" Cc: Shawn Guo Co-developed-by: Richard Weinberger Signed-off-by: David Gstir --- .../security/keys/trusted-encrypted.rst | 84 ++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/Documentation/security/keys/trusted-encrypted.rst b/Document= ation/security/keys/trusted-encrypted.rst index 80d5a5af62a1..e8413122e4bc 100644 --- a/Documentation/security/keys/trusted-encrypted.rst +++ b/Documentation/security/keys/trusted-encrypted.rst @@ -35,6 +35,11 @@ safe. Rooted to Hardware Unique Key (HUK) which is generally burnt in= on-chip fuses and is accessible to TEE only. =20 + (3) DCP (Data Co-Processor: crypto accelerator of various i.MX SoCs= ) + + Rooted to a one-time programmable key (OTP) that is generally b= urnt in + the on-chip fuses and is accessbile to the DCP encryption engin= e only. + * Execution isolation =20 (1) TPM @@ -46,6 +51,12 @@ safe. Customizable set of operations running in isolated execution environment verified via Secure/Trusted boot process. =20 + (3) DCP + + Fixed set of cryptographic operations running in isolated execu= tion + environment. Only basic blob key encryption is executed there. + The actual key sealing/unsealing is done on main processor/kern= el space. + * Optional binding to platform integrity state =20 (1) TPM @@ -63,6 +74,11 @@ safe. Relies on Secure/Trusted boot process for platform integrity. I= t can be extended with TEE based measured boot process. =20 + (3) DCP + + Relies on Secure/Trusted boot process (called HAB by vendor) fo= r + platform integrity. + * Interfaces and APIs =20 (1) TPM @@ -74,10 +90,14 @@ safe. TEEs have well-documented, standardized client interface and AP= Is. For more details refer to ``Documentation/staging/tee.rst``. =20 + (3) DCP + + Vendor-specific API that is implemented as part of the DCP cryp= to driver in + ``drivers/crypto/mxs-dcp.c``. =20 * Threat model =20 - The strength and appropriateness of a particular TPM or TEE for a g= iven + The strength and appropriateness of a particular TPM, TEE or DCP fo= r a given purpose must be assessed when using them to protect security-releva= nt data. =20 =20 @@ -103,6 +123,14 @@ access control policy within the trust source. from platform specific hardware RNG or a software based Fortuna CSP= RNG which can be seeded via multiple entropy sources. =20 + * DCP (Data Co-Processor: crypto accelerator of various i.MX SoCs) + + The DCP hardware device itself does not provide a dedicated RNG int= erface, + so the kernel default RNG is used. SoCs with DCP like the i.MX6ULL = do have + a dedicated hardware RNG that is independent from DCP which can be = enabled + to back the kernel RNG. + + Encrypted Keys -------------- =20 @@ -188,6 +216,19 @@ Usage:: specific to TEE device implementation. The key length for new keys is a= lways in bytes. Trusted Keys can be 32 - 128 bytes (256 - 1024 bits). =20 +Trusted Keys usage: DCP +----------------------- + +Usage:: + + keyctl add trusted name "new keylen" ring + keyctl add trusted name "load hex_blob" ring + keyctl print keyid + +"keyctl print" returns an ASCII hex copy of the sealed key, which is in = format +specific to this DCP key-blob implementation. The key length for new ke= ys is +always in bytes. Trusted Keys can be 32 - 128 bytes (256 - 1024 bits). + Encrypted Keys usage -------------------- =20 @@ -370,3 +411,44 @@ string length. privkey is the binary representation of TPM2B_PUBLIC excluding the initial TPM2B header which can be reconstructed from the ASN.1 octed string length. + +DCP Blob Format +--------------- + +The Data Co-Processor (DCP) provides hardware-bound AES keys using its +AES encryption engine only. It does not provide direct key sealing/unsea= ling. +To make DCP hardware encryption keys usable as trust source, we define +our own custom format that uses a hardware-bound key to secure the seali= ng +key stored in the key blob. + +Whenever a new tusted key using DCP is generated, we generate a random 1= 28-bit +blob encryption key (BEK) and 128-bit nonce. The BEK and nonce are used = to +encrypt the trusted key payload using AES-128-GCM. + +The BEK itself is encrypted using the hardware-bound key using the DCP's= AES +encryption engine with AES-128-ECB. The encrypted BEK, generated nonce, +BEK-encrypted payload and authentication tag make up the blob format tog= ether +with a version number, payload length and authentication tag:: + + /* + * struct dcp_blob_fmt - DCP BLOB format. + * + * @fmt_version: Format version, currently being %1 + * @blob_key: Random AES 128 key which is used to encrypt @payload, + * @blob_key itself is encrypted with OTP or UNIQUE devic= e key in + * AES-128-ECB mode by DCP. + * @nonce: Random nonce used for @payload encryption. + * @payload_len: Length of the plain text @payload. + * @payload: The payload itself, encrypted using AES-128-GCM and @bl= ob_key, + * GCM auth tag of size AES_BLOCK_SIZE is attached at the = end of it. + * + * The total size of a DCP BLOB is sizeof(struct dcp_blob_fmt) + @pa= yload_len + + * AES_BLOCK_SIZE. + */ + struct dcp_blob_fmt { + __u8 fmt_version; + __u8 blob_key[AES_KEYSIZE_128]; + __u8 nonce[AES_KEYSIZE_128]; + __le32 payload_len; + __u8 payload[0]; + } __packed; --=20 2.26.2