Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6593082rdb; Fri, 15 Dec 2023 03:09:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjrGo/8govRX4/TbcNIDKy+8la03f0UZK6tDm4HBvBI4NGK/MNeqmozBvXgg3SYBd6FHJY X-Received: by 2002:a05:6214:1bcd:b0:67f:14b9:a166 with SMTP id m13-20020a0562141bcd00b0067f14b9a166mr2307824qvc.31.1702638543623; Fri, 15 Dec 2023 03:09:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702638543; cv=none; d=google.com; s=arc-20160816; b=baQ+9LvzY3XzdIs1yexz5OZA4nsUtVDmvTUtSShWl8j2vI36bqkoMnROWcAznmLt3C rIwlfj6KENEH9up33vDKRlgktc1QVfbQ0J8gzXYuAdSMtkHXf1FhRTQnix+3KlZzXYQp KRWSDXpF1fX+a1bvnmReEfA+m8eVvNpwFygEq7JnZ4+EF5N1ZeEjQpZ2+uFv4pTa9KGr 56i+JCqsIQiwWWPCtayNQoocbPfuS4qGVeRV9vV4/EN9dGeOUyyF1pcAVAIZG6CKpDiW Wov7FH6jjT6wvjmpOdnPFxiMRfjK2nd0lWyfCYUQJq0LonlfFg5jduDLUnyCwcWfkE3e D+Ug== ARC-Message-Signature: i=1; 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=+qntkmutwprS+2oQeQzgmaP97TAaIsTbzLeg5qvDo3I=; fh=fqqaJGcTW3YJBUZ5ogs0l28P+DdVWFvboOwwsmcz240=; b=yk3q0OLLYwdT4L53Tvyx99QLQoqMQ95gQEUHwAIDGVWfnmqgNKgrehit+JZoz43DbK BdqqqBtxUWjps0rI7KV/OEiyfu5nvMCnAI2yorAYKBJac6HLdEZuaJfIBgmyTD287Y1W QfpZSmfilQXXymq9Ml6uf8vC3BrBQ7H5G9gPoYxjkZLspg6qrmg0ZlLZKWNFlvW/iWBj LxOGnFuDxYK+97HVZg6hMGa0ImS3oDh6fZt3YRtqT5QYr59TRUtDaSwhdCPmtyFOwPDP 9LLRaF52hXF5ZBctI3Tpf1h4/J80No58O9nigQw0C69p7N7OxorGSpVgK63+uSgcQezR EgxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sigma-star.at header.s=google header.b="pOH/51at"; spf=pass (google.com: domain of linux-crypto+bounces-870-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-870-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 ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id y9-20020a0cf149000000b0067ef41587a6si2204534qvl.393.2023.12.15.03.09.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 03:09:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-870-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@sigma-star.at header.s=google header.b="pOH/51at"; spf=pass (google.com: domain of linux-crypto+bounces-870-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-crypto+bounces-870-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id D3FB11C2347F for ; Fri, 15 Dec 2023 11:09:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B05A2DB88; Fri, 15 Dec 2023 11:07:22 +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="pOH/51at" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 7256A2D791 for ; Fri, 15 Dec 2023 11:07:20 +0000 (UTC) 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-wr1-f50.google.com with SMTP id ffacd0b85a97d-32f8441dfb5so421525f8f.0 for ; Fri, 15 Dec 2023 03:07:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sigma-star.at; s=google; t=1702638439; x=1703243239; 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=+qntkmutwprS+2oQeQzgmaP97TAaIsTbzLeg5qvDo3I=; b=pOH/51atVr7BH/rvGzASIsdokLdrAh2KwL9LKfemqSGyhegKt84LLc2UQhHeBIXUzr 8gBYidiYO3kRkSpcxsP9v4H7JK0VVzhbfOf9CDWg+nsRjP5BV+k/TQmXKUnEFDEeG3X1 SRV98hI1ayMXWeSD0Cob33njgMyP4vNEAREaAovbmG3/Nm/RjHkjXvf2ckfgSZIcZf2+ Gbj2MR1DgFqd3S07LV4KJ+MOqfxGZQQHmhKdEvCS8W7Sn8bnDlBNn7kFEpJkUDSnQRBD oc58EBbgVcklglvPtrXeEL+F9t7wMxkTN5ZDH0Oxnlfr5ZNc5Lg5O/GfyLgxTS/ByOC1 sOfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702638439; x=1703243239; 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=+qntkmutwprS+2oQeQzgmaP97TAaIsTbzLeg5qvDo3I=; b=HQBQWLEnVKV/LEskYT0ApQRjKmEW8lqEmlZzZSuIXy3vafr57vilBKkv6PAf4d9wgc ucnaDSkZePaAW7ajwWxcq5FvS6SmsvgQMwnEIqwiJ0bJoxmuXuhrvTB1yGQFuLZbD/Vc uzfYyBXbb1LKbZWBG0xnwOiQf/MHa69EiV2rYhxI9svozAg+moL+eAHAJjdxDyOQl8ro egZjelOhZjB4MhEKaiD5Oyo2Aa8iKosYwB2Q7JupUutOc78ucsEkxjie0lJxoPPQ/gL/ NzNTrMtH6PNp1tNxI1/00o56cbNEGJvsNODKlUJB/oyxIp987FQ+XzJ9/CxkXibXUVCd B6mA== X-Gm-Message-State: AOJu0YxZNf8CK8NZ1xsOd7xpIKQdW4kIMKhVDFa6PPPE7ZBT1hTt/wUL HtDyeYZC/8tggBmy3TKtNkv1cg== X-Received: by 2002:a5d:4590:0:b0:336:4bac:f9a5 with SMTP id p16-20020a5d4590000000b003364bacf9a5mr978164wrq.64.1702638438773; Fri, 15 Dec 2023 03:07:18 -0800 (PST) Received: from localhost (clnet-p106-198.ikbnet.co.at. [83.175.106.198]) by smtp.gmail.com with UTF8SMTPSA id e18-20020a056000121200b00333404e9935sm18384464wrx.54.2023.12.15.03.07.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Dec 2023 03:07:18 -0800 (PST) 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 v5 6/6] docs: trusted-encrypted: add DCP as new trust source Date: Fri, 15 Dec 2023 12:06:33 +0100 Message-ID: <20231215110639.45522-7-david@sigma-star.at> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231215110639.45522-1-david@sigma-star.at> References: <20231215110639.45522-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 | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/Documentation/security/keys/trusted-encrypted.rst b/Documentation/security/keys/trusted-encrypted.rst index 9bc9db8ec651..4452070afbe9 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,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/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. + * + * @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 device 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 @blob_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) + @payload_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[]; + } __packed; -- 2.35.3