From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) (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 5FAE8186E26; Fri, 7 Jun 2024 10:58:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=144.6.53.87 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717757928; cv=none; b=k5MFWZFiDgf51ezNUTPW5TwTUfCgjZL6w16YARQQGY16XUkfMwFOJIKuZWYojopxi+09q/hZ1x8jyKwLlN7C+Vq41CZx4tqF+Y72oVBABy3TO7dxBPBS9bCgwwFea9CHP057oj9QAooLWvF1HCRSqTZWBDxsHy+8ajvep0bjBcw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717757928; c=relaxed/simple; bh=gj9rHGiqEtVhgMyKf1T0aWkSra6juadP60PhESLNEog=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Coovq8uTJOM+wj5yb3A8P1kfRzSEjOtt96yRcOYOqWnnVVQoDpN40w0WTwely4/x8w63epX9cUkcvuADOSU9dya656r/R94Irs0xN4SMDVHYDOv9kByfiGUGNeNxMK8gpdjaAjgq7m838VnOOdgU5/y/ShHb6lbJGGFf2IWEIzc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au; spf=pass smtp.mailfrom=gondor.apana.org.au; arc=none smtp.client-ip=144.6.53.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gondor.apana.org.au Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.96 #2 (Debian)) id 1sFXIW-006npX-0e; Fri, 07 Jun 2024 18:58:17 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Fri, 07 Jun 2024 18:58:18 +0800 Date: Fri, 7 Jun 2024 18:58:18 +0800 From: Herbert Xu To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, Andreas.Fuchs@infineon.com, James Prestwood , David Woodhouse , Eric Biggers , James Bottomley , linux-crypto@vger.kernel.org, Stefan Berger , Lennart Poettering , "David S. Miller" , open list , David Howells , Ard Biesheuvel , Mario Limonciello Subject: Re: [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa Message-ID: References: <20240528210823.28798-1-jarkko@kernel.org> <20240528210823.28798-5-jarkko@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240528210823.28798-5-jarkko@kernel.org> On Wed, May 29, 2024 at 12:08:09AM +0300, Jarkko Sakkinen wrote: > > +/* > + * Sign operation is an encryption using the TPM's private key. With RSA the > + * only difference between encryption and decryption is where the padding goes. > + * Since own padding can be used, TPM2_RSA_Decrypt can be repurposed to do > + * encryption. > + */ > +static int tpm2_key_rsa_sign(struct tpm_chip *chip, struct tpm2_key *key, > + struct kernel_pkey_params *params, > + const void *in, void *out) > +{ > + const off_t o = key->priv_len + 2 + sizeof(*key->desc); > + const struct tpm2_rsa_parms *p = > + (const struct tpm2_rsa_parms *)&key->data[o]; > + const u16 mod_size = be16_to_cpu(p->modulus_size); > + const struct rsa_asn1_template *asn1; > + u32 in_len = params->in_len; > + void *asn1_wrapped = NULL; > + u8 *padded; > + int ret; > + > + if (strcmp(params->encoding, "pkcs1") != 0) { > + ret = -ENOPKG; > + goto err; > + } > + > + if (params->hash_algo) { > + asn1 = rsa_lookup_asn1(params->hash_algo); Could you please explain why this can't be done through pkcs1pad instead of going to raw RSA? Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt