Received: by 2002:ab2:23c8:0:b0:1f2:fdbc:cb93 with SMTP id a8csp151544lqe; Wed, 27 Mar 2024 01:26:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWgY4HhuVA5tNC7AD7rLuNMM/t6ocOuBaakmJkwEJ0A0eqPi/0HVLz/9JSK3XT2Aud2gGjX6pUVfQRXQp75CamnZQFZEufgYLg2XJkZXA== X-Google-Smtp-Source: AGHT+IFLJXYI7vva+Obz8f4D1HOSL7ufLpyZjFEelhkQqI9Inb6JPdrzfIZf5srpx+AsUdnsizzV X-Received: by 2002:a17:906:410d:b0:a47:29ef:f3ca with SMTP id j13-20020a170906410d00b00a4729eff3camr2542903ejk.31.1711527977069; Wed, 27 Mar 2024 01:26:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711527977; cv=pass; d=google.com; s=arc-20160816; b=RZE55wg1F8Tlsb/42XbmhTnxOmdh7IIdSOefvVS34bkrXXexZBeZ/6gL9LHC3ESXXN fdY1NTOdYAxv5k1mWXRhob2O+cwpL0b+YM4USn4T7aW0XwTVElji77jb0XgKTmXT/hDG qsjIFBT1EReE2cbTMrzAchBxHWSC9ci4vmTVFX0pXNELFGFqsJN44XsAYJ2G3GeGh1eb MYQeUhtV9Jg4D7g7FwpaOA96VEWIAM9N2T8bDGS+RTlWl3nF72drsBVHHFawTm8o8Uqr 0E9B/Nz7kXLPBBLKGVJzLA31iOvqTsT3ey4E4v3Ob3fyaYutR3zil0N+KdkhF3oi0Hma DQ/g== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=jXnPhQZ/7MwqBVH7e72M3iqDK5PHqiK3NcW8fk9T+qY=; fh=qJeEKiZNKg3EU4OUWhZbWiYfpRypVL2Wdl6KK2TMoqI=; b=P1OMj4ZJ6Rhj/5m8x5s3RL24cAxaORc/DWBztBz1XoqgYH79gY5nkr3mBtJ0YUHdSc d7el3tTwjS9Lq8Sp42r2jlWsc6T8eNlEZoVc65TcGPGP0+leRpQL/bYnC5ACjhksBsus FprSWJ78B9BKCys5JPbG4fdqcdovqDTX7yJ44SoXZjWGKxY+jcUEWiVHqRqQebXqenyA 20s226gb4DA2djDOmj/EQOVrFqSnKkYEKvbFmpJZOa2Zg7brBUaemmRrFI2/KMbIMIZQ XwVBnd4UH4XOs58YPtGfW2ODeEtH4nYV5SUvvobMNWt35Qn+zIJRhJ+ONCvaTd22T/Q7 yPmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sigma-star.at header.s=google header.b=gZiImaV+; 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-2929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2929-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 a24-20020a1709064a5800b00a4dcdb26f8csi1873150ejv.394.2024.03.27.01.26.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 01:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-2929-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=gZiImaV+; 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-2929-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-crypto+bounces-2929-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 A28DF1F2B863 for ; Wed, 27 Mar 2024 08:26:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 811BD2E644; Wed, 27 Mar 2024 08:25:09 +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="gZiImaV+" X-Original-To: linux-crypto@vger.kernel.org Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 25E8A2D60B for ; Wed, 27 Mar 2024 08:25:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711527909; cv=none; b=ZI5shFwvW9T69wSXxXd5U4J80e7YPoaOZqiBHsp8S9vctHPDVdIp+SGg0kMrJyMzKI1FTfakbRIdRXC94yvLc22MS8PZMmWEZQeoOIhgUKI9ohihXM5f0PIdrF2NJ8R17q3h9Vs+gxKRPvzv0eJvNclK5gMknEPGxqNIszwABiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711527909; c=relaxed/simple; bh=Ze8zK2HY9+0PRvVXT50gi5jYVTJlg7k/wpO4RIzfls4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nQFxN5LsJVSPe2hWBR5T06K7rzKK77EYaD2B2l0GcU1J8HQW2VYuNiT0tuacCR44PEwhAnsgVJXSxFAme263ulJqUzN4r5mRWYuLJzImNk7txFxyTxtV1bi1G1WkQoQSMRbUPHa34vjI0Fzy7czckM1D88OtXSfVaLrOd+o2FUw= 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=gZiImaV+; arc=none smtp.client-ip=209.85.208.170 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-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d46dd5f222so76036461fa.1 for ; Wed, 27 Mar 2024 01:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sigma-star.at; s=google; t=1711527904; x=1712132704; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jXnPhQZ/7MwqBVH7e72M3iqDK5PHqiK3NcW8fk9T+qY=; b=gZiImaV+WStIGoHn7lC47kIhZg4G3h+FDJrdHrnaQjDzOWa4Fd+HQAQSiWjfA7aNi/ teQOtXTFUeTcCQEGDDr0Q6PCZGG+18Szom39b0TfzdEIt5lwFmoweaRENqDpG2nTM81v XaKZMTl+w4VNa99Cpgbokm9OFRpgUA1FhpL5rugcOMwDTLSmwl0X8kFy+aQ1uOtfat/3 3cEuDqdIVpVUvCS2alftIm4wERpMh3JuKVZwt37buiqa7SvFuQ5yHHUHkMk2OfJwjE/S x9nuy1l370P8A2uUj6NpBBXXcQj5ydR9yiL2HwXwuHV9P2L6w042mot2x9DHk3oiquQI dmiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711527904; x=1712132704; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jXnPhQZ/7MwqBVH7e72M3iqDK5PHqiK3NcW8fk9T+qY=; b=cuQlr8IRy8dSFvwjEIYErQAcVKL0aZeG0baGzXBTpQk8WxuHLsmB5uAbcu/aeh0xel tlsQAfBlGKd93OPCt5ghITvED8v/rSNp5HBvB9qOiZ1U9hLdMevALHE9uupJ4N4+Fgki H9Sk8hdTgNcvnJS2WJFlI7bUa98sGTPUO18EOskrHYUcNtB1Bvu/SlPMlAOa+NyfTF82 /XxFq7BXj6msJVzZ1nNsN9BibhtGdZUgF4z6MLvN0z/LUZ4ACSd+pgMpn3B7fED4qaYZ zwR5pqXT9VzXAlKLVbjps8M0FGJIgbWQcbRlVaIhHf5Brq43MMxgHFUUT5zALTS8utV+ AQ6A== X-Forwarded-Encrypted: i=1; AJvYcCVAo8lhaELVC8ZgIjPrp/TW0nqwIa8gdkGlosrHGj7LhtEOQjog5o89l1/4avXewHHZWGL8KFZ7lAABR5y4Ol02bQYFuO3e/ijZ/b5Y X-Gm-Message-State: AOJu0Yw/Vuusy98SgsfuDm7Hm40+/TruByqNR1ph0eM9p/gSv+GFI/Rg VD8jyIAbg8Rdn8Wgt2KkdQbDa1k/AYkQnkwP9Or3O8ww1bkdQ074zW44khwfyCA= X-Received: by 2002:a2e:a984:0:b0:2d4:170d:245f with SMTP id x4-20020a2ea984000000b002d4170d245fmr2716878ljq.12.1711527904204; Wed, 27 Mar 2024 01:25:04 -0700 (PDT) Received: from localhost ([82.150.214.1]) by smtp.gmail.com with UTF8SMTPSA id ch9-20020a5d5d09000000b00341c6778171sm9880373wrb.83.2024.03.27.01.25.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Mar 2024 01:25:04 -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 Subject: [PATCH v7 0/6] DCP as trusted keys backend Date: Wed, 27 Mar 2024 09:24:46 +0100 Message-ID: <20240327082454.13729-1-david@sigma-star.at> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This is a revival of the previous patch set submitted by Richard Weinberger: https://lore.kernel.org/linux-integrity/20210614201620.30451-1-richard@nod.at/ After having been thoroughly reviewed by Jarkko, it would be great if this could go into 6.10. :-) v6 is here (please ignore the incorrect version number in the cover letter): https://lore.kernel.org/keyrings/20240307153842.80033-1-david@sigma-star.at/ v6 -> v7: - Add Reviewed-by from Jarkko Sakkinen for patches #1 and #3 - Improved commit messages - Changed log level for non-trusted/secure mode check from error to warning v5 -> v6: - Cleaned up coding style and commit messages to make the whole series more coherent as suggested by Jarkko Sakkinen - Added Acked-By from Jarkko Sakkinen to patch #4 - thanks! - Rebased against next-20240307 v4 -> v5: - Make Kconfig for trust source check scalable as suggested by Jarkko Sakkinen - Add Acked-By from Herbert Xu to patch #1 - thanks! v3 -> v4: - Split changes on MAINTAINERS and documentation into dedicated patches - Use more concise wording in commit messages as suggested by Jarkko Sakkinen v2 -> v3: - Addressed review comments from Jarkko Sakkinen v1 -> v2: - Revive and rebase to latest version - Include review comments from Ahmad Fatoum The Data Co-Processor (DCP) is an IP core built into many NXP SoCs such as i.mx6ull. Similar to the CAAM engine used in more powerful SoCs, DCP can AES- encrypt/decrypt user data using a unique, never-disclosed, device-specific key. Unlike CAAM though, it cannot directly wrap and unwrap blobs in hardware. As DCP offers only the bare minimum feature set and a blob mechanism needs aid from software. A blob in this case is a piece of sensitive data (e.g. a key) that is encrypted and authenticated using the device-specific key so that unwrapping can only be done on the hardware where the blob was wrapped. This patch series adds a DCP based, trusted-key backend and is similar in spirit to the one by Ahmad Fatoum [0] that does the same for CAAM. It is of interest for similar use cases as the CAAM patch set, but for lower end devices, where CAAM is not available. Because constructing and parsing the blob has to happen in software, we needed to decide on a blob format and chose the following: struct dcp_blob_fmt { __u8 fmt_version; __u8 blob_key[AES_KEYSIZE_128]; __u8 nonce[AES_KEYSIZE_128]; __le32 payload_len; __u8 payload[]; } __packed; The `fmt_version` is currently 1. The encrypted key is stored in the payload area. It is AES-128-GCM encrypted using `blob_key` and `nonce`, GCM auth tag is attached at the end of the payload (`payload_len` does not include the size of the auth tag). The `blob_key` itself is encrypted in AES-128-ECB mode by DCP using the OTP or UNIQUE device key. A new `blob_key` and `nonce` are generated randomly, when sealing/exporting the DCP blob. This patchset was tested with dm-crypt on an i.MX6ULL board. [0] https://lore.kernel.org/keyrings/20220513145705.2080323-1-a.fatoum@pengutronix.de/ David Gstir (6): crypto: mxs-dcp: Add support for hardware-bound keys KEYS: trusted: improve scalability of trust source config KEYS: trusted: Introduce NXP DCP-backed trusted keys MAINTAINERS: add entry for DCP-based trusted keys docs: document DCP-backed trusted keys kernel params docs: trusted-encrypted: add DCP as new trust source .../admin-guide/kernel-parameters.txt | 13 + .../security/keys/trusted-encrypted.rst | 85 +++++ MAINTAINERS | 9 + drivers/crypto/mxs-dcp.c | 104 +++++- include/keys/trusted_dcp.h | 11 + include/soc/fsl/dcp.h | 20 ++ security/keys/trusted-keys/Kconfig | 18 +- security/keys/trusted-keys/Makefile | 2 + security/keys/trusted-keys/trusted_core.c | 6 +- security/keys/trusted-keys/trusted_dcp.c | 313 ++++++++++++++++++ 10 files changed, 567 insertions(+), 14 deletions(-) create mode 100644 include/keys/trusted_dcp.h create mode 100644 include/soc/fsl/dcp.h create mode 100644 security/keys/trusted-keys/trusted_dcp.c -- 2.35.3