Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2538388lqz; Wed, 3 Apr 2024 00:24:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJBN+hlk3asDDnyKT39pkgqJjuXey8NfR2On7u4PU6klvHjR9KoL1LSxn/IYAgYfRDPbgM2Gdzul6oCB4iLWcNmcnRjgrrATkmQvZXdw== X-Google-Smtp-Source: AGHT+IECFLrwe400DodixwQiLYD2KG4EUHGgdNtUkF9IwrcFK3hdoFzBQunfTekt8/YIZjxCyI3z X-Received: by 2002:a19:c209:0:b0:513:a6a7:ac88 with SMTP id l9-20020a19c209000000b00513a6a7ac88mr3235180lfc.14.1712129075240; Wed, 03 Apr 2024 00:24:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712129075; cv=pass; d=google.com; s=arc-20160816; b=p/YbBGMILiNP0k40eUO3Qy3UPQNli1eIkiUmwmECuMpN5EwxbEkOalxGDpB57fkcxw xtAMaoQssMA5MmCz1dfiGavR/lqzxebKklaPy9qUnd5yRhUxjKIjshB+QnAwoswesWi6 AAKJKUGLAuU5TnFcK9kBOH4wZtCX+fFsssHH5iY1GEYs5APerAZXN5+KuQZJuKNlcJ8y rFyHOeEqwOmsD2bv8nFfBsAMXeZgvuH7Qo8oOb6mUvyWsCPiQi3oLjfpx0dk9eby4ytg YMS5lazdFFQmoyIP19fsBzXTnfZ6IzCwBd3ycLPkodYdAB7t5lDP02cKmEOrJYr+J8Gn yadA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ht1KLnNvKBCCICp+Y6JpKOSNrIWAe17k5/lz/+k/t0k=; fh=msDHI3r7VkjAIXuqILYGGRzlIPUp7g/n+ctAG/V0SIE=; b=dSk5d/09XjAOlATd5NYc9V/3mlOv+Xxz43hjfNNtUnvK6CSolCBa7bAsOqjnIz4NF+ iOLD6WHDu9tWuLu2BjDkhYw7NEJnilAUr4Mg50MN/Yj0UEL8XJxBbBd0nltWyZPKBntT X2X+0EgzDHYOwPzvU4AoiuneX1pVyAxirI3taUrZbgDbHYIieiYiaAfzabhO88Lik9o8 FsQT6qYnGZdD7n7wS05fpbF2VFmv4OXUG1mDJxqWl4lhJcCooscWEM31bIhiM/mo3BE/ KO4GjNGMKgLkUYWeS0qQ89qeMIjwjnbfMW3XdTO/o6UJY29fEwcKMuGh5c38HewvUYPY WBKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sigma-star.at header.s=google header.b=uW854BK8; arc=pass (i=1 spf=pass spfdomain=sigma-star.at dkim=pass dkdomain=sigma-star.at dmarc=pass fromdomain=sigma-star.at); spf=pass (google.com: domain of linux-crypto+bounces-3277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sigma-star.at Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id lc12-20020a170906f90c00b00a46e2b74eabsi6598484ejb.58.2024.04.03.00.24.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 00:24:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@sigma-star.at header.s=google header.b=uW854BK8; arc=pass (i=1 spf=pass spfdomain=sigma-star.at dkim=pass dkdomain=sigma-star.at dmarc=pass fromdomain=sigma-star.at); spf=pass (google.com: domain of linux-crypto+bounces-3277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sigma-star.at 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 141301F212DA for ; Wed, 3 Apr 2024 07:23:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F76A6F523; Wed, 3 Apr 2024 07:21:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sigma-star.at header.i=@sigma-star.at header.b="uW854BK8" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81AFF6DCF5 for ; Wed, 3 Apr 2024 07:21:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712128916; cv=none; b=BUIoLvSGbBk70yZzE6F0FAP3p4bLysojDWmhJVbYpjMct6/4+tm3vUP5ES5gzHg6umTRuydBEUYeaQqNN91dGMFgeLkVO9F7MLuydEcimRxXmQmPod1koxj6IwVtM0YDPkWjBS2HKfwAhdWujFpVwsHitHROydG0FU1aLSCRBp0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712128916; c=relaxed/simple; bh=YwCTtSxtOVaFrBMehGFPkK05qlCv/3lFORgK1gDJgN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EVVeDdHryK6Jsl8hqkwhsC1Vz6CeoqE91mwDfy8C28wGwvENYaXC/QWTZF+uXOMIpM/TUCrbAfLZITJ35DFbfElUp/z8VslNZA9ExdsThdtcA5U0c9vJJocVTxG92fi97rDacVOb8Aaw6G3wBkBdQ+mWtbNGXjJQzCW5Uwox7Jc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sigma-star.at; spf=pass smtp.mailfrom=sigma-star.at; dkim=pass (2048-bit key) header.d=sigma-star.at header.i=@sigma-star.at header.b=uW854BK8; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sigma-star.at Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sigma-star.at Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-41624c40b44so897775e9.0 for ; Wed, 03 Apr 2024 00:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sigma-star.at; s=google; t=1712128912; x=1712733712; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ht1KLnNvKBCCICp+Y6JpKOSNrIWAe17k5/lz/+k/t0k=; b=uW854BK8iRab+dLisa+IbHPHJgwWKAKDISQ819SOYm1n3kgAF7WCNlqinyILIpJ2hI TGaQsz83vXduS0LjJAvE/5vDlZjmpGnTcq2/i2obKcAXtecd5iyzhn/HVL0v9CuaIoR+ NIgoZQGNZZ6aYzLBkQNOtUajyD5C57G3czNHbSAtIKou8RtsxCbESzp8/Fkm4uPr1h/Q SHfuuM62iVAxN0aybNchd0oj8lS+U3QV9m2sQrQjrDP+VVZJhmR13Fk4FMPhqkHayZUP SXlWNSI6VrBviYkHIBADSh+q2qzJPbK+fVi7zA82Otz95blwYrofBZUHW1ma6NCe7mfC 8diA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712128912; x=1712733712; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ht1KLnNvKBCCICp+Y6JpKOSNrIWAe17k5/lz/+k/t0k=; b=Hk52lal5yMc/7gNnodrVi9OBtHmfEJm0HjHIjKxS0MLY2lDLHBCyeGVe3UeKQllqxr GAIRKWpr3fQoBjDWgGQ1/UVcj3uJ3KZ0Is8+wwT3+g7rd0Hq8UXcPJBnFt94BHc6HspA 6LV7aMaMv/2/1vl2H3WsmueFr2yFkZV8pbA+2iDsD5bKPfW8cBDhc9kmrofH3+iIlyRL OFTWExqraWlH1YuZyPtnubbGojF/MaVhM4Py7k2truDdHaoE9nGSzKFkIamkKVPTezdl 964Ane/pW3OMjhwkggbFA1IotLk0o/BpDoY5T33qO0292Mh4EgnS6RlRV+zX5Ie9po4K ZUSA== X-Forwarded-Encrypted: i=1; AJvYcCWN6tdV8uSp9KlrgUmkHGVTkZqIJ54sEVoJmsLuz/zbqzDTr2yNX+bvqlmt2DMsWreoQO36uUlIa7J6Cd7y0wwPg0KHt+UMBFaUTE/+ X-Gm-Message-State: AOJu0Yy8ObVtHcV+l8k6koKTbTI80AuVw+ZXtBm2jpX62hRIXi3M5yrm /ow1vlFcgFYRom/mpkE8aEQCAYAMdZhAeJb454ZI4lsRtJ3KjNXHbLpsFShgyek= X-Received: by 2002:a05:600c:2d06:b0:413:e19:337f with SMTP id x6-20020a05600c2d0600b004130e19337fmr3324441wmf.22.1712128912023; Wed, 03 Apr 2024 00:21:52 -0700 (PDT) Received: from localhost ([82.150.214.1]) by smtp.gmail.com with UTF8SMTPSA id f11-20020a05600c4e8b00b004154e48bcdesm17187826wmq.14.2024.04.03.00.21.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 03 Apr 2024 00:21:51 -0700 (PDT) From: David Gstir To: Mimi Zohar , James Bottomley , Jarkko Sakkinen , Herbert Xu , "David S. Miller" Cc: David Gstir , Shawn Guo , Jonathan Corbet , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , 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 Subject: [PATCH v8 6/6] docs: trusted-encrypted: add DCP as new trust source Date: Wed, 3 Apr 2024 09:21:22 +0200 Message-ID: <20240403072131.54935-7-david@sigma-star.at> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240403072131.54935-1-david@sigma-star.at> References: <20240403072131.54935-1-david@sigma-star.at> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 generally burnt + in the on-chip fuses and is accessible to the DCP encryption engine only. + DCP provides two keys that can be used as root of trust: the OTP key + and the UNIQUE key. Default is to use the UNIQUE key, but selecting + 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 environment. + (4) DCP + + Fixed set of cryptographic operations running in isolated execution + environment. Only basic blob key encryption is executed there. + 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 SoCs 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.MX6ULL 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=kernel`` on the kernel command-line to override the used RNG with the kernel's random number pool. @@ -231,6 +262,19 @@ Usage:: CAAM-specific format. The key length for new keys is always in bytes. 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 using 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 the 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 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 together + * with a version number, payload length and authentication tag. + */ + /** * struct dcp_blob_fmt - DCP BLOB format. * -- 2.35.3