From: Paul Louvel <paul.louvel@bootlin.com>
To: linux-crypto@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>, Jian Pan <jian.pan@se.com>
Subject: Re: ECDSA key parsing in crypto drivers
Date: Mon, 31 Aug 2026 14:08:02 +0200 [thread overview]
Message-ID: <41bb0b65-3a30-4922-9aef-10f73c654852@bootlin.com> (raw)
In-Reply-To: <34094aaa-da49-4203-b176-ed3faa4b8692@bootlin.com>
Adding Herbert Xu and David S. Miller as recipient.
On 8/31/26 11:09 AM, Paul Louvel wrote:
> Hi,
>
> I am currently working on upstreaming the ECDSA part of a Public Key
> Accelerator.
> I have a question regarding which ASN.1 schema should I use when decoding the
> buffer passed by the .set_pub_key() and .set_priv_key() callbacks in struct
> sig_alg.
> The documentation only mentions that the callbacks should "know how to decode
> and interpret the BER encoded public key and parameters."
>
> The kernel software implementation of ECDSA only supports verifying signatures,
> and thus only implements the .set_pub_key() callback. In this callback, the
> buffer should contain an ECC key as defined by RFC5480 section 2.2 [1].
>
> In the downstream driver I am currently upstreaming, it expects a BER encoded
> ASN.1 schema of SubjectPublicKeyInfo as defined in RFC5480 section 2 [2]. The
> driver defines its own .asn1 file containing the ASN.1 schema of this sequence,
> and uses the kernel's ASN.1 compiler/decoder to decode the buffer.
>
> Because the PKA can be used to sign messages, there is a .set_priv_key()
> callback that expects a BER encoded ASN.1 schema as defined in RFC5915 section
> 3 [3]. The same remark applies to the public key: a .asn1 file is present and
> defines the ASN.1 schema described by the RFC.
>
> My question is: which ASN.1 schema should be used? Should a client of the
> crypto API know in advance which format the driver expects? Also, for RSA,
> there are helpers for parsing private and public keys: rsa_parse_priv_key() and
> rsa_parse_pub_key(). These helpers use the kernel's ASN.1 decoder. Would it
> make sense to have such helpers for ECDSA?
>
> Thank you,
>
> [1] RFC5480 Section 2.2 - ECC Key Format
> https://tools.ietf.org/html/rfc5480#section-2.2
>
> [2] RFC5480 Section 2 - SubjectPublicKeyInfo
> https://tools.ietf.org/html/rfc5480#section-2
>
> [3] RFC5915 Section 3 - Private Key Format
> https://tools.ietf.org/html/rfc5915#section-3
>
--
Paul Louvel, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2026-08-31 12:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 9:09 ECDSA key parsing in crypto drivers Paul Louvel
2026-08-31 12:08 ` Paul Louvel [this message]
2026-09-02 8:35 ` Herbert Xu
2026-09-02 11:58 ` Paul Louvel
2026-09-03 3:50 ` Herbert Xu
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=41bb0b65-3a30-4922-9aef-10f73c654852@bootlin.com \
--to=paul.louvel@bootlin.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jian.pan@se.com \
--cc=linux-crypto@vger.kernel.org \
--cc=miquel.raynal@bootlin.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.