Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp675648lqp; Sat, 13 Apr 2024 14:25:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX3AdwtTpPn65zIwhztOB0lguiNsKD2OC2uEWRMR+MTXnN8RBJ8MsQe58M0NsGW8pnqQQ+HfqQsq4BUOBjAQvaT8mYBvz1PTz2FbmwspQ== X-Google-Smtp-Source: AGHT+IFsA7YEuKEEf2XlpZ0a6oOeoSkPJjl0/lsqf36VT1gDWDQ/rID6liOmD52S7iVP8owZjWj+ X-Received: by 2002:a05:6808:1801:b0:3c7:615:6fc7 with SMTP id bh1-20020a056808180100b003c706156fc7mr2217293oib.43.1713043515759; Sat, 13 Apr 2024 14:25:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713043515; cv=pass; d=google.com; s=arc-20160816; b=a9n5hECGrfW+coUApCtSVIaICNYkc3+FhbBgsrg6LYu5oZOVuGJyxepT1QCLlHlMv1 UKPBTr/e/4o/jQMSu6jzgy8RDCFXKmtfrPpWF8vI6zk8xrft2w3PBGGG+g56tP5/2Sst NNe8ED+8gCjU2QYhHnzIF8b929mlFXrw7mQFWn1BfR4xWqjwhekICOt09tXSWRVQw72M 7x0iPhYsJfRHjAqeOoYhqJ2dwFqNpvu2/f21bGaaRm7RPMCzFAb2IPBlTrKMWWJ6SFu3 /iWahIkJ/Ao0uXTCF8Q8+Ff8U64JWlDND5/BFxeOsCgqaNva8Zx4oI3H7eKaROHvDymM ZcQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:cc:to:from:subject:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=wJWn+FNjNSBYFmF1rSOYK4YiECE1TKpzU37Zq0b9m/s=; fh=bnU1n+wq9jZQOclAx3yutQ8l+Zt6yvVIISRPbk8EaZQ=; b=yat3H/ErWYYSfIKzy81lXSM/gRqtiz1z7nR/AI/TXfoMMadDN8Z2CnrvbF8BCVeJNc GO611Chfi6Hz/lwVPOhMYm/RwjDurc6DEsvI9m5EJNHJYZr+qD0WZb4S+y8ExPxnHeec qst6gj/m1WgUlgkPbYM28RiyMdS40iZ13OPusfAziKhlY1RgPwTZRBd1PEudFbS2deZS pv7edmJhQLf67KFDT6vQc1e4ux7VQBXxM7WMKKNvyGgUPwvYFhm/X6d3LRd9qFv1dj58 OjZ9tSI0OlCnlSK+gFOkOAkNOce7fyGKWkEqzL+gB6sh6ni3xRf8NFLg0pKA90lPFVb5 lndg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ht8VVQRf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-3530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id j16-20020a05620a147000b0078d5fdebd6fsi6548965qkl.205.2024.04.13.14.25.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Apr 2024 14:25:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ht8VVQRf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-3530-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 65CF81C20AC8 for ; Sat, 13 Apr 2024 21:25:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D7E2955E72; Sat, 13 Apr 2024 21:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ht8VVQRf" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75FA71865; Sat, 13 Apr 2024 21:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713043508; cv=none; b=XsC1bNVr5MBVWp90hJ3hFld6MUObeeAlhRE2PXheR6KYskPziOA4ntFYT89Pqeit0O6cJMk67kOo/8WhUWs+SEwczHEq2pAns7AiKd5VwPYVAxyMksEyaESdUAEKIbAS+2a2+OsiZnWdfVSj7BJKfcLGR5H9sCBKlw6vg9z3uKo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713043508; c=relaxed/simple; bh=fWaZr02lXTk8vECphDiwIWtfs63IwnIajLCUTzl+yQQ=; h=Mime-Version:Content-Type:Date:Message-Id:Subject:From:To:Cc: References:In-Reply-To; b=EixbdTSu8yeQoKebQYDU1jwONCVe1rNuIk5tSv2C+IP37TbW2yURTtjz+6EIMy367XI87253qpErcJxp7ktLvEp2lEmWXGltoWMnk6hQ7YBR5d/KtdfsahAJ9SoCEYTYAfF3+iQ+UqR+P0XiAnJUxNG75ScPfQmp+DxNIgtXXvw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ht8VVQRf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C01F6C113CD; Sat, 13 Apr 2024 21:25:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713043507; bh=fWaZr02lXTk8vECphDiwIWtfs63IwnIajLCUTzl+yQQ=; h=Date:Subject:From:To:Cc:References:In-Reply-To:From; b=ht8VVQRfKStNVTDput5TStcrXO3vCmLyURXGRHMiofLuo0f5aDqTg5dTSM4Mf69nt 6zfN0dvorP9u2CFFnEId/THX8jb1kX7N6b9aEI7V8NbtR+TZkuWRPYDqKiHqUEpreF 8AVtDndGvq6jZAsyE4zYAMorJJXbrWPrnE2Fxq9Mu744XPfxsg6MFAsla8Tg1IyL/Z v8wYxt7hz4jw772i0JwSsIpTFyhSXT1DcMdicllbj44CdE0qWgPRy9Xhp8CeYV1Rha KvJsJLZSZ91rvXzoNgNuH/B/DrSw6Fki5hexSzFHx7DMhYRVdwIMI9aF2jJkA7F8WC DoTBJvleCViMQ== Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Sun, 14 Apr 2024 00:24:58 +0300 Message-Id: Subject: Re: [EXT] Re: [PATCH v8 6/6] docs: trusted-encrypted: add DCP as new trust source From: "Jarkko Sakkinen" To: "Kshitiz Varshney" , "David Gstir" , "Mimi Zohar" , "James Bottomley" , "Herbert Xu" , "David S. Miller" Cc: "Shawn Guo" , "Jonathan Corbet" , "Sascha Hauer" , "Pengutronix Kernel Team" , "Fabio Estevam" , "dl-linux-imx" , "Ahmad Fatoum" , "sigma star Kernel Team" , "David Howells" , "Li Yang" , "Paul Moore" , "James Morris" , "Serge E. Hallyn" , "Paul E. McKenney" , "Randy Dunlap" , "Catalin Marinas" , "Rafael J. Wysocki" , "Tejun Heo" , "Steven Rostedt (Google)" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-integrity@vger.kernel.org" , "keyrings@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-security-module@vger.kernel.org" , "Richard Weinberger" , "David Oberhollenzer" , "Varun Sethi" , "Gaurav Jain" , "Pankaj Gupta" X-Mailer: aerc 0.17.0 References: <20240403072131.54935-1-david@sigma-star.at> <20240403072131.54935-7-david@sigma-star.at> In-Reply-To: < On Tue Apr 9, 2024 at 12:48 PM EEST, Kshitiz Varshney wrote: > Hi Jarkko, > > > > -----Original Message----- > > From: Jarkko Sakkinen > > Sent: Wednesday, April 3, 2024 9:18 PM > > To: David Gstir ; Mimi Zohar = ; > > James Bottomley ; Herbert Xu > > ; David S. Miller > > Cc: Shawn Guo ; Jonathan Corbet > > ; Sascha Hauer ; Pengutronix > > Kernel Team ; Fabio Estevam > > ; dl-linux-imx ; Ahmad Fatoum > > ; sigma star Kernel Team > > ; David Howells ; Li > > Yang ; Paul Moore ; James > > Morris ; Serge E. Hallyn ; Paul E. > > McKenney ; Randy Dunlap ; > > Catalin Marinas ; Rafael J. Wysocki > > ; Tejun Heo ; Steven Rostedt > > (Google) ; linux-doc@vger.kernel.org; linux- > > kernel@vger.kernel.org; linux-integrity@vger.kernel.org; > > keyrings@vger.kernel.org; linux-crypto@vger.kernel.org; linux-arm- > > kernel@lists.infradead.org; linuxppc-dev@lists.ozlabs.org; linux-securi= ty- > > module@vger.kernel.org; Richard Weinberger ; David > > Oberhollenzer > > Subject: [EXT] Re: [PATCH v8 6/6] docs: trusted-encrypted: add DCP as n= ew > > trust source > >=20 > > Caution: This is an external email. Please take care when clicking link= s or > > opening attachments. When in doubt, report the message using the 'Repor= t > > this email' button > >=20 > >=20 > > On Wed Apr 3, 2024 at 10:21 AM EEST, David Gstir wrote: > > > 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 > > > > > > Co-developed-by: Richard Weinberger > > > Signed-off-by: Richard Weinberger > > > Co-developed-by: David Oberhollenzer > > > > > > Signed-off-by: David Oberhollenzer > > > Signed-off-by: David Gstir > > > --- > > > .../security/keys/trusted-encrypted.rst | 53 +++++++++++++++++= ++ > > > security/keys/trusted-keys/trusted_dcp.c | 19 +++++++ > > > 2 files changed, 72 insertions(+) > > > > > > diff --git a/Documentation/security/keys/trusted-encrypted.rst > > > b/Documentation/security/keys/trusted-encrypted.rst > > > index e989b9802f92..f4d7e162d5e4 100644 > > > --- a/Documentation/security/keys/trusted-encrypted.rst > > > +++ b/Documentation/security/keys/trusted-encrypted.rst > > > @@ -42,6 +42,14 @@ safe. > > > randomly generated and fused into each SoC at manufacturing= time. > > > Otherwise, a common fixed test key is used instead. > > > > > > + (4) DCP (Data Co-Processor: crypto accelerator of various i.MX > > > + SoCs) > > > + > > > + Rooted to a one-time programmable key (OTP) that is general= ly > > burnt > > > + in the on-chip fuses and is accessible to the DCP encryptio= n engine > > only. > > > + DCP provides two keys that can be used as root of trust: th= e OTP > > key > > > + and the UNIQUE key. Default is to use the UNIQUE key, but s= electing > > > + the OTP key can be done via a module parameter > > (dcp_use_otp_key). > > > + > > > * Execution isolation > > > > > > (1) TPM > > > @@ -57,6 +65,12 @@ safe. > > > > > > Fixed set of operations running in isolated execution envir= onment. > > > > > > + (4) DCP > > > + > > > + Fixed set of cryptographic operations running in isolated e= xecution > > > + environment. Only basic blob key encryption is executed the= re. > > > + The actual key sealing/unsealing is done on main processor/= kernel > > space. > > > + > > > * Optional binding to platform integrity state > > > > > > (1) TPM > > > @@ -79,6 +93,11 @@ safe. > > > Relies on the High Assurance Boot (HAB) mechanism of NXP So= Cs > > > for platform integrity. > > > > > > + (4) DCP > > > + > > > + Relies on Secure/Trusted boot process (called HAB by vendor= ) for > > > + platform integrity. > > > + > > > * Interfaces and APIs > > > > > > (1) TPM > > > @@ -94,6 +113,11 @@ safe. > > > > > > Interface is specific to silicon vendor. > > > > > > + (4) DCP > > > + > > > + Vendor-specific API that is implemented as part of the DCP = crypto > > driver in > > > + ``drivers/crypto/mxs-dcp.c``. > > > + > > > * Threat model > > > > > > The strength and appropriateness of a particular trust source > > > for a given @@ -129,6 +153,13 @@ selected trust source: > > > CAAM HWRNG, enable CRYPTO_DEV_FSL_CAAM_RNG_API and ensure > > the device > > > is probed. > > > > > > + * DCP (Data Co-Processor: crypto accelerator of various i.MX SoCs= ) > > > + > > > + The DCP hardware device itself does not provide a dedicated RNG > > interface, > > > + so the kernel default RNG is used. SoCs with DCP like the i.MX6= ULL do > > have > > > + a dedicated hardware RNG that is independent from DCP which can= be > > enabled > > > + to back the kernel RNG. > > > + > > > Users may override this by specifying ``trusted.rng=3Dkernel`` on th= e > > > kernel command-line to override the used RNG with the kernel's rando= m > > number pool. > > > > > > @@ -231,6 +262,19 @@ Usage:: > > > CAAM-specific format. The key length for new keys is always in byte= s. > > > Trusted Keys can be 32 - 128 bytes (256 - 1024 bits). > > > > > > +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 keys is always in bytes. Trusted Keys can be 32 - 128= bytes > > (256 - 1024 bits). > > > + > > > Encrypted Keys usage > > > -------------------- > > > > > > @@ -426,3 +470,12 @@ 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 > > > +--------------- > > > + > > > +.. kernel-doc:: security/keys/trusted-keys/trusted_dcp.c > > > + :doc: dcp blob format > > > + > > > +.. kernel-doc:: security/keys/trusted-keys/trusted_dcp.c > > > + :identifiers: struct dcp_blob_fmt > > > diff --git a/security/keys/trusted-keys/trusted_dcp.c > > > b/security/keys/trusted-keys/trusted_dcp.c > > > index 16c44aafeab3..b5f81a05be36 100644 > > > --- a/security/keys/trusted-keys/trusted_dcp.c > > > +++ b/security/keys/trusted-keys/trusted_dcp.c > > > @@ -19,6 +19,25 @@ > > > #define DCP_BLOB_VERSION 1 > > > #define DCP_BLOB_AUTHLEN 16 > > > > > > +/** > > > + * DOC: dcp blob format > > > + * > > > + * The Data Co-Processor (DCP) provides hardware-bound AES keys usin= g > > > +its > > > + * AES encryption engine only. It does not provide direct key > > sealing/unsealing. > > > + * To make DCP hardware encryption keys usable as trust source, we > > > +define > > > + * our own custom format that uses a hardware-bound key to secure th= e > > > +sealing > > > + * key stored in the key blob. > > > + * > > > + * Whenever a new trusted key using DCP is generated, we generate a > > > +random 128-bit > > > + * blob encryption key (BEK) and 128-bit nonce. The BEK and nonce ar= e > > > +used to > > > + * encrypt the trusted key payload using AES-128-GCM. > > > + * > > > + * The BEK itself is encrypted using the hardware-bound key using th= e > > > +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 together > > > + * with a version number, payload length and authentication tag. > > > + */ > > > + > > > /** > > > * struct dcp_blob_fmt - DCP BLOB format. > > > * > >=20 > > Reviewed-by: Jarkko Sakkinen > >=20 > > I can only test that this does not break a machine without the hardware > > feature. > >=20 > > Is there anyone who could possibly peer test these patches? > I am already working on testing this patchset on i.MX6 platform. > Regards, > Kshitiz OK great. BR, Jarkko