Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp1014314lqp; Thu, 23 May 2024 06:54:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyjInhgXu3rlUa13Lga/v34JP8odv+9PQSBJK/4K7oB+CqUeZD+x4Mp2UzQJeTv+COEgNQ8/5ygn8oH/f70h4rjq+cyBRN5J6i6QSo5Q== X-Google-Smtp-Source: AGHT+IFqdMGDyZtsfs+YtYvZYlYuE3rqkdGXXHrkRbNM2bHt0ACud7KtE1jRjsIlhj/j53ADCQmm X-Received: by 2002:a05:6102:3050:b0:47b:dcda:79df with SMTP id ada2fe7eead31-489077ce87amr5990703137.19.1716472454462; Thu, 23 May 2024 06:54:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716472454; cv=pass; d=google.com; s=arc-20160816; b=J+1z5bG/Rum8zJ5NOghrSHf0ItvRjnllw4OSUZGgk/Y6QSXzISdq3+/RBpuTBHqLB6 vBV/il+2d17Abx5XmHnTR7/0V16ptOUokoNeHUY6pyoc7JWR4O433ZmUbeR4NAHwGSNM kHPMmoM6x5NKM7YYYekG0t9RvrlTvxrIUwKyHK3+Beds7DrsKruG3lWtfttBMPeP3EDJ qI4RmoJ8P1I0oWmeh4oEeRi8UqUY9e8lKguA3b6Ltv/bovb1O6pycfcVu120vNgz8k2F lBCcTjTi+cD/6W8I4klzBUNxeID9flRQC9LzFPHFtyhk1XNhO2j/0zUx91BynOfPBKXl eIFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=GledI2PxU/rsQRWq2MyTsBSNUYjHAJ8ngpvBWzD+fV8=; fh=p0sipic1/7b/5jQzkvXQ8GRDx+h2PMYo+X/1WCR/KzQ=; b=WcX3+hIUrFoD2ea6Zl12cpPWlFDaJJHDvEPrRufeu58gRT9V8fmkFqkunSFGXRfHf6 ImplqHfNQXyUH5lTFC2JEjF/uEcclBc+TwFcDGZD0dNrHL0bOGreu5DX5em3z4GF1L5d uv+73TcnUPJnRnrECfABUIMkb/aSSfpxOwaskQ2j0Y1bgt2gIJmcGs98ahqToCOVKX09 YI3K5mSdzX6YsE3l7ZXq9MsqeRzDYuMSCiIVQYLzCoxAS8xyZka8UvKE5b4Q0F+SqmOu lQ6YYcmysEHLulrQY889fkV8mZe2uLjs8QWNsfx4IsF0nH93vwIM4lsb1fYKmwIJD8y9 q8XA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ayKX1bTr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4354-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 d75a77b69052e-43f945edae0si4661111cf.683.2024.05.23.06.54.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 06:54:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4354-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=ayKX1bTr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4354-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4354-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 33A7C1C22439 for ; Thu, 23 May 2024 13:54:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7319A14AD23; Thu, 23 May 2024 13:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ayKX1bTr" 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 1FD4614A623; Thu, 23 May 2024 13:54: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=1716472448; cv=none; b=vF2AXGfx2R2laVAWdKF4af38abTMnDVSkOKE7728hVEg/8NoHBpVqlw0EpA865SnS52kjwqIrUPAaG9gnF7KqKbQXBVKJtIg8XrbtZKSTsVSF9vSEqmp/8nuPlqC6VabUULJc5pPKVTHjaE9HYF8YT3oupYxJwgXlMLKQpHz9iA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716472448; c=relaxed/simple; bh=P+hLj/xeIZCtao3ZdxaW6Pa3wcEv0A+M9crGMZXsRZ4=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=msLhCMN70f9AC9UV1nucmM+5RV9erRWdSan3j6cXaiHwDtyPtrcZuagpYwc342TjX3MwRg+X9ng/9se3qU4NZ03M/RZfH3oCADijAiHE134+KntPOh2cMxTq+RWeSIDzItJY6a3Z6i5Vr3ubU/inNxV4kvYmooy9DS4MAtvg50A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ayKX1bTr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D114C2BD10; Thu, 23 May 2024 13:54:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716472447; bh=P+hLj/xeIZCtao3ZdxaW6Pa3wcEv0A+M9crGMZXsRZ4=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=ayKX1bTreCUTqoASDyJPYr6TE6auh/UCZhEgX9iyrQ048n9MrNmMqI8bnIkveOVc9 QaIhEo6wh7Y5FDsOhpCqmt2qOHIVoCgmWkAhsEzqlFZMCienHNRGAutLrxJH6hu3aY dJ36BDJY+07Q+4Gmw3lan86Zam2WO+X6JWltZ0N+8ZAVqaFZTAzI9July0mKXfSZG6 UL1fdhJa2vBqoR8rImFxT5c/gbiEJly4SpAeMAkfsn3HqSITRsC5IHYBNX+H6VStPp +1+WvFXKpQ+uB5oY0bGGsKUydK/tti03cklTBbUZGlHc8z2Oa1cegL+3yNfi9Tz8qd sNHXUH8+ytmxQ== 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: Thu, 23 May 2024 16:54:02 +0300 Message-Id: Cc: , "David Woodhouse" , "Eric Biggers" , "Herbert Xu" , "David S. Miller" , "Andrew Morton" , "Mimi Zohar" , "David Howells" , "Paul Moore" , "James Morris" , "Serge E. Hallyn" , "open list:CRYPTO API" , "open list" , "open list:SECURITY SUBSYSTEM" Subject: Re: [PATCH RESEND] KEYS: trusted: Use ASN.1 encoded OID From: "Jarkko Sakkinen" To: "James Bottomley" , X-Mailer: aerc 0.17.0 References: <20240523131931.22350-1-jarkko@kernel.org> <9c96f39ed2161dd7f0c3a7964cba2de3169fae3b.camel@HansenPartnership.com> In-Reply-To: <9c96f39ed2161dd7f0c3a7964cba2de3169fae3b.camel@HansenPartnership.com> On Thu May 23, 2024 at 4:38 PM EEST, James Bottomley wrote: > On Thu, 2024-05-23 at 16:19 +0300, Jarkko Sakkinen wrote: > > There's no reason to encode OID_TPMSealedData at run-time, as it > > never changes. > >=20 > > Replace it with the encoded version, which has exactly the same size: > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A067 81 05 0A 01 05 > >=20 > > Include OBJECT IDENTIFIER (0x06) tag and length as the epilogue so > > that the OID can be simply copied to the blob. > > This is true, but if we're going to do this, we should expand the OID > registry functions (in lib/oid_registry.c) to do something like > encode_OID. The registry already contains the hex above minus the two > prefixes (which are easy to add). Yes, I do agree with this idea, and I named variable the I named it to make it obvious that generation is possible. It would be best to have a single source, which could be just a CSV file with entries like: , And then in scripts/ there should be a script that takes this source and generates oid_registry.gen.{h,c}. The existing oid_registry.h should really just include oid_registry.gen.h then to make this transparent change. And then in the series where OID's are encoded per-subsystem patch that takes pre-encoded OID into use. Happy to review such patch set if it is pushed forward. > > @ -51,8 +52,8 @@ static int tpm2_key_encode(struct > > trusted_key_payload *payload, > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (!scratch) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0return -ENOMEM; > > =C2=A0 > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0work =3D asn1_encode_oid(wor= k, end_work, tpm2key_oid, > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 asn1_oid_len(tpm2key_oid)); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0work =3D memcpy(work, OID_TP= MSealedData_ASN1, > > sizeof(OID_TPMSealedData_ASN1)); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0work +=3D sizeof(OID_TPMSeal= edData_ASN1); > > You lost the actually fits check. This is somewhat irrelevant for TPM > keys because the OID is first in the structure and thus will never > overflow, but it might matter for other uses. Yep, it is irrelevant IMHO, there is 8 bytes, and also its location never changes. > James BR, Jarkko