Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3263648lqo; Tue, 21 May 2024 11:19:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+ugVvj+/LhfwjxLcxdH3818FtCAibT7jX11Gc64XJOwET+KW8FnLqGJGLDEkWZlG1T4hBueBCTwFdUvQbC8npy9mnLDKrM4JgYGgw/g== X-Google-Smtp-Source: AGHT+IFqjIDmnW7VrmXyU5GyNpnmJKnqUSOASyeES1XVqSAZ9w0+TWuZvz6wLxsZwjOFn8hanVa4 X-Received: by 2002:a05:6a00:3c89:b0:6f4:d5d8:e0a3 with SMTP id d2e1a72fcca58-6f69fbe0465mr14488662b3a.9.1716315541024; Tue, 21 May 2024 11:19:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716315541; cv=pass; d=google.com; s=arc-20160816; b=vlbYCilx6liWZEVazsH/s/eTpl5zH+e4ncsbA89AYyX7ahw58SaOcVhOeLXn6fG+Y/ ILKtkQucqtCUFrscyu4O7VQFDkPCpPgPNL46t1AM+Rdfjaf1Y8wEBgqM6JmzsP2w1n7L k+O6cf9dkdBlXdmjnZmHUDP3cwyeePOGHwsQhvvXj00ujL4ZUMyXXoTzD7e0cO4rDXy1 NKxVwdv+5BchiTYsasopGQaXXsWSMrhGIlBXAKmLAP8fAbZ1wgXEzwYzjAWOK3D5Ii/P zsZJmrjGOrvB0Pme34GTb0or5NbcSoMDROknuHHLrh25Vft+d/XJQa6qArYZAqr4noIk nSUA== 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:user-agent:references:in-reply-to :date:cc:to:from:subject:message-id:dkim-signature:dkim-signature; bh=YgO3F8PskvqTSaDEkT3nTbJhKIKBPni9ERW3lCqcTy4=; fh=J3YbtBF1YalbLOB2yFx/7Cp3RCJuzJ4sxY2b1tLEuFU=; b=t76I+bteDodz4msVwB9RZVXrEp+mwioU0zXQL3S9mYurPOCbMIcT5A0J6CGkLcPQUS xeCBAXpkxk7b99bYhr6f7LHJT9NfPvlyzoTdnDGKopJLOrko3ztv+QhUyo9ATFJATL5A ic8AlN4cQYZnIMJjreZrJOgWGz0mmI8jzADquFKKhW9bpiJFB2SOtjItrGAVRBH0ekIs oTUwpSUdlu4srrf6HQJN9dAkn6VcYOyaowewdbJj/Yqmp9r5Hp3NX07tcQhR1nDQV5CS 2F4zX+grqZ1QzFQPnY6/CPT1RWN4jURRUE6CSMp5eGMiwT8ITxjRu74sRN6g6XqMC6aE 8T5g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=okvqzxgp; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=okvqzxgp; arc=pass (i=1 spf=pass spfdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dmarc=pass fromdomain=hansenpartnership.com); spf=pass (google.com: domain of linux-crypto+bounces-4309-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f50533c827si4501429b3a.233.2024.05.21.11.19.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 11:19:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4309-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=okvqzxgp; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=okvqzxgp; arc=pass (i=1 spf=pass spfdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dkim=pass dkdomain=hansenpartnership.com dmarc=pass fromdomain=hansenpartnership.com); spf=pass (google.com: domain of linux-crypto+bounces-4309-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4309-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2CF78B22572 for ; Tue, 21 May 2024 18:18:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A7FF1442F6; Tue, 21 May 2024 18:18:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="okvqzxgp"; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b="okvqzxgp" X-Original-To: linux-crypto@vger.kernel.org Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [96.44.175.130]) (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 4CB3F3D982; Tue, 21 May 2024 18:18:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=96.44.175.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716315533; cv=none; b=mtMQFo6nbXzrXRPHbCit8oxyfbybC4MMV9JIEHxo/BXVjNJWmZqWxyJo/4cTIV0kF3uymLUiQiY6tuOyQbPfqUlilaw4DclQaV8derfmITmUAKoNjJdk76+YBM1su4ttKyiNcH0UvCXxcbkl66vWqRwEgSt6IqtqdhsOErHJ+g0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716315533; c=relaxed/simple; bh=2/WNvNUaxZWBWFghnTzz7COI4nb5mN2JEaGF6GoBrSg=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=ENw5Z1qCprjaqFu8l/O2VLE9PCXLg1/iIaKKCnSSudnRQLq2Dtmg8RNqaC3znQMj+tLilWfJg5PRuhcNa8W0LwvWXcPPh4Xzd3BDAORRYKc711DPEp+a/0QJ65H0hHL03hatcWYlfvnE/8Yp37l1iT7uzJRONsa5X/PFQKxheyU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=HansenPartnership.com; spf=pass smtp.mailfrom=HansenPartnership.com; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b=okvqzxgp; dkim=pass (1024-bit key) header.d=hansenpartnership.com header.i=@hansenpartnership.com header.b=okvqzxgp; arc=none smtp.client-ip=96.44.175.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=HansenPartnership.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=HansenPartnership.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1716315529; bh=2/WNvNUaxZWBWFghnTzz7COI4nb5mN2JEaGF6GoBrSg=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=okvqzxgpTRIrIDxwVOWW9RZLReb/uwFXXxGhf6NhiUFe5cd2R2pAvrywW4gN1QBJG GBilIfhWNh1rPu6RHKi88EY+5VrHB5atLe3SPchZiFN0RngFBaGRDfjkunvWK1/oFl I8ho0o3LMZMWxf1NzcocsSDud8C2Ty/Yk6jDBDLk= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 8D54A1286DC8; Tue, 21 May 2024 14:18:49 -0400 (EDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavis, port 10024) with ESMTP id JesuGFsTjEfu; Tue, 21 May 2024 14:18:49 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1716315529; bh=2/WNvNUaxZWBWFghnTzz7COI4nb5mN2JEaGF6GoBrSg=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=okvqzxgpTRIrIDxwVOWW9RZLReb/uwFXXxGhf6NhiUFe5cd2R2pAvrywW4gN1QBJG GBilIfhWNh1rPu6RHKi88EY+5VrHB5atLe3SPchZiFN0RngFBaGRDfjkunvWK1/oFl I8ho0o3LMZMWxf1NzcocsSDud8C2Ty/Yk6jDBDLk= Received: from lingrow.int.hansenpartnership.com (unknown [IPv6:2601:5c4:4302:c21::a774]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id BD1251286DBE; Tue, 21 May 2024 14:18:47 -0400 (EDT) Message-ID: Subject: Re: [PATCH v2 4/6] KEYS: trusted: Move tpm2_key_decode() to the TPM driver From: James Bottomley To: Jarkko Sakkinen , Herbert Xu Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, Andreas.Fuchs@infineon.com, James Prestwood , David Woodhouse , Eric Biggers , "David S. Miller" , "open list:CRYPTO API" , open list , Peter Huewe , Jason Gunthorpe , Mimi Zohar , David Howells , Paul Moore , James Morris , "Serge E. Hallyn" , "open list:SECURITY SUBSYSTEM" Date: Tue, 21 May 2024 14:18:45 -0400 In-Reply-To: <20240521031645.17008-5-jarkko@kernel.org> References: <20240521031645.17008-1-jarkko@kernel.org> <20240521031645.17008-5-jarkko@kernel.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, 2024-05-21 at 06:16 +0300, Jarkko Sakkinen wrote: [...] > diff --git a/include/crypto/tpm2_key.h b/include/crypto/tpm2_key.h > new file mode 100644 > index 000000000000..acf41b2e0c92 > --- /dev/null > +++ b/include/crypto/tpm2_key.h > @@ -0,0 +1,33 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +#ifndef __LINUX_TPM2_KEY_H__ > +#define __LINUX_TPM2_KEY_H__ > + > +#include > + > +/* > + * TPM2 ASN.1 key > + */ > +struct tpm2_key { > +       u32 parent; > +       const u8 *blob; > +       u32 blob_len; > +       const u8 *pub; > +       u32 pub_len; > +       const u8 *priv; > +       u32 priv_len; > +}; > + > +int tpm2_key_decode(const u8 *src, u32 src_len, struct tpm2_key > *key, > +                   u32 max_key_len); I don't think this is a good idea. Trusted keys already have a pre- defined max payload size (MAX_BLOB_SIZE in include/keys/trusted-type.h) and I've already had to increase this several times because once you get policy attached to a key, it can get pretty big (over a page). Exactly the same thing will happen to asymmetric keys as well, so it does make sense that they share the same maximum (probably in a more generic header, though). Since the code already right sizes the allocation and all we check with this is whether it's over a pre-defined maximum, it's way easier if that maximum is defined in a header rather than passed in in several places making increasing the maximum really hard because you have to chase all the threading. James