All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jarkko Sakkinen" <jarkko@kernel.org>
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
	"Herbert Xu" <herbert@gondor.apana.org.au>
Cc: <linux-integrity@vger.kernel.org>, <keyrings@vger.kernel.org>,
	<Andreas.Fuchs@infineon.com>,
	"James Prestwood" <prestwoj@gmail.com>,
	"David Woodhouse" <dwmw2@infradead.org>,
	"Eric Biggers" <ebiggers@kernel.org>,
	"James Bottomley" <James.Bottomley@hansenpartnership.com>,
	<linux-crypto@vger.kernel.org>,
	"Stefan Berger" <stefanb@linux.ibm.com>,
	"Lennart Poettering" <lennart@poettering.net>,
	"David S. Miller" <davem@davemloft.net>,
	"open list" <linux-kernel@vger.kernel.org>,
	"David Howells" <dhowells@redhat.com>,
	"Peter Huewe" <peterhuewe@gmx.de>,
	"Jason Gunthorpe" <jgg@ziepe.ca>,
	"James Bottomley" <James.Bottomley@HansenPartnership.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Mario Limonciello" <mario.limonciello@amd.com>
Subject: Re: [PATCH v7 5/5] keys: asymmetric: Add tpm2_key_ecdsa
Date: Wed, 29 May 2024 00:42:08 +0300	[thread overview]
Message-ID: <D1LLSAS0YN47.18EIHL1KRF2UR@kernel.org> (raw)
In-Reply-To: <20240528210823.28798-6-jarkko@kernel.org>

On Wed May 29, 2024 at 12:08 AM EEST, Jarkko Sakkinen wrote:
> +	/* Encode the ASN.1 signature: */
> +#define TPM2_KEY_ECDSA_SIG_SIZE		(2 + 2 * (2 + SHA256_DIGEST_SIZE) + r_0 + s_0)
> +	pr_info("sig_size=%d\n", TPM2_KEY_ECDSA_SIG_SIZE);
> +	ptr[0] = 0x30; /* SEQUENCE */
> +	ptr[1] = TPM2_KEY_ECDSA_SIG_SIZE - 2;
> +#define TPM2_KEY_ECDSA_SIG_R_TAG	2
> +#define TPM2_KEY_ECDSA_SIG_R_SIZE	3
> +#define TPM2_KEY_ECDSA_SIG_R_BODY	4
> +	ptr[TPM2_KEY_ECDSA_SIG_R_TAG] = 0x02; /* INTEGER */
> +	ptr[TPM2_KEY_ECDSA_SIG_R_SIZE] = SHA256_DIGEST_SIZE + r_0;
> +	ptr[TPM2_KEY_ECDSA_SIG_R_BODY] = 0x00; /* maybe dummy write */
> +	memcpy(&ptr[TPM2_KEY_ECDSA_SIG_R_BODY + r_0], r, SHA256_DIGEST_SIZE);
> +#define TPM2_KEY_ECDSA_SIG_S_TAG	(4 + r_0 + SHA256_DIGEST_SIZE)
> +#define TPM2_KEY_ECDSA_SIG_S_SIZE	(5 + r_0 + SHA256_DIGEST_SIZE)
> +#define TPM2_KEY_ECDSA_SIG_S_BODY	(6 + r_0 + SHA256_DIGEST_SIZE)
> +	ptr[TPM2_KEY_ECDSA_SIG_S_TAG] = 0x02; /* INTEGER */
> +	ptr[TPM2_KEY_ECDSA_SIG_S_SIZE] = SHA256_DIGEST_SIZE + s_0;
> +	ptr[TPM2_KEY_ECDSA_SIG_S_BODY] = 0x00; /* maybe dummy write */
> +	memcpy(&ptr[TPM2_KEY_ECDSA_SIG_S_BODY + s_0], s, SHA256_DIGEST_SIZE);
> +	ret = TPM2_KEY_ECDSA_SIG_SIZE;

Stefan, so this how I realized the signature encoding, thanks to
your earlier remarks [1]! I found out based on that a few glitches
and ended up with this better structured ECDSA signature encoder,
so thank you for doing that.

[1] https://lore.kernel.org/linux-crypto/b5ff9003-065f-437f-bf6b-7f1ae0a0364a@linux.ibm.com/

BR, Jarkko

  reply	other threads:[~2024-05-28 21:42 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-28 21:08 [PATCH v7 0/5] KEYS: asymmetric: tpm2_key_{rsa,ecdsa} Jarkko Sakkinen
2024-05-28 21:08 ` [PATCH v7 1/5] crypto: rsa-pkcs1pad: export rsa1_asn_lookup() Jarkko Sakkinen
2024-05-28 23:20   ` Stefan Berger
2024-05-29  1:25     ` Jarkko Sakkinen
2024-05-28 21:08 ` [PATCH v7 2/5] KEYS: trusted: Change -EINVAL to -E2BIG Jarkko Sakkinen
2024-05-29  1:50   ` Stefan Berger
2024-05-29 12:20     ` Jarkko Sakkinen
2024-05-28 21:08 ` [PATCH v7 3/5] crypto: tpm2_key: Introduce a TPM2 key type Jarkko Sakkinen
2024-05-31  0:35   ` Stefan Berger
2024-06-04 17:23     ` Jarkko Sakkinen
2024-06-04 18:41       ` Stefan Berger
2024-06-04 22:33         ` Jarkko Sakkinen
2024-05-28 21:08 ` [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa Jarkko Sakkinen
2024-05-29 16:07   ` Jarkko Sakkinen
2024-05-31  1:10   ` Stefan Berger
2024-06-04 20:29     ` Jarkko Sakkinen
2024-06-07 10:58   ` Herbert Xu
2024-06-20  0:23     ` Jarkko Sakkinen
2025-08-26  8:25       ` Jarkko Sakkinen
2025-09-18  5:03         ` Jarkko Sakkinen
2024-05-28 21:08 ` [PATCH v7 5/5] keys: asymmetric: Add tpm2_key_ecdsa Jarkko Sakkinen
2024-05-28 21:42   ` Jarkko Sakkinen [this message]
2024-05-28 23:09     ` Jarkko Sakkinen
2024-05-28 23:15   ` Stefan Berger
2024-05-29  1:14     ` Jarkko Sakkinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D1LLSAS0YN47.18EIHL1KRF2UR@kernel.org \
    --to=jarkko@kernel.org \
    --cc=Andreas.Fuchs@infineon.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=ardb@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=ebiggers@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=jgg@ziepe.ca \
    --cc=keyrings@vger.kernel.org \
    --cc=lennart@poettering.net \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=peterhuewe@gmx.de \
    --cc=prestwoj@gmail.com \
    --cc=stefanb@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.