mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Bauckholt <florian.bauckholt@cispa.de>
To: Stefan Berger <stefanb@linux.ibm.com>,
	Lukas Wunner <lukas@wunner.de>, Ignat Korchagin <ignat@linux.win>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Jarkko Sakkinen <jarkko@kernel.org>
Cc: <linux-crypto@vger.kernel.org>, <keyrings@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] crypto: ecdsa - Reject non-DER X9.62 signatures
Date: Fri, 13 Nov 2026 10:58:44 +0100	[thread overview]
Message-ID: <473700a3-f5d7-4a7a-b89a-12c51adcc3df@cispa.de> (raw)
In-Reply-To: <d3a49bde-769f-48a9-ab1b-0374d3d4753e@linux.ibm.com>

Hi Stefan,

thanks for testing.

On 11/13/26 00:38, Stefan Berger wrote:
> On 11/12/26 12:06 PM, Stefan Berger wrote:
>> I have a user-space test suite here:
>> https://github.com/stefanberger/eckey-testing
>>
>> It tries to load openssl-generated self-signed certs into the kernel
>> and this fails now:
>>
>> $ ./test-ecc-kernel-keys.sh

I can reproduce this with your script. It fails without the
KEYCTL_PKEY_VERIFY patch and passes with it.

>>> This is a behaviour change for every user of the x962 template (X.509
> 
> I would say a 'potential but unlikely behaviour change' because if you
> signed with a tool (e.g., OpenSSL) that created properly (DER-)formatted
> signatures in X.509 certificates, then those signatures still verify
> with your patch applied. I would assume that most people signed with
> such a tool. In your patch you seem to add more tests for proper DER
> formatting that all existing x.509 certs and signatures should meet, right?
>

Yes, this only changes behaviour for non-conforming signatures. Anything
generated by OpenSSL behaves the same. I'll change the wording to be
explicit about this for v2.

The existing testmgr vectors covered only valid DER encodings and this
patch adds new ones for the BER edge cases.

>>> certificates, module and IMA signatures, KEYCTL_PKEY_VERIFY): signatures
>>> that are valid ECDSA signatures but are not DER-encoded used to verify
>>> and are now rejected with -EINVAL. The p1363 template is not affected.
> 
> What breaks the signature verification test in my test suite currently
> was pointed out by AI. For signature verifications using the
> KEYCTL_PKEY_VERIFY interface, it currently would pass along an input
> size of 72 bytes for a secp256r1 signature, which is the max. size, but
> this does not always correspond to the application provided signature
> size, which may for example be just 71 bytes.
> -               params->out_len = info.max_sig_size;
> +               params->in2_len = uparams.in2_len;

Yes, sorry, maybe I should have mentioned this in the commit message.
The notes below the --- link to this exact fix:

https://lore.kernel.org/r/20261111-keyctl-pkey-fixes-v1-1-934ebaa267a7@cispa.de

The AI review in the thread also ran the patch without the keyctl fix.

I'll move this dependency to the commit message for v2, or wait until
the keyctl fix is in mainline.

Thanks!
Florian

      reply	other threads:[~2026-11-13  9:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 10:47 Florian Bauckholt via B4 Relay
2026-11-12 17:06 ` Stefan Berger
2026-11-12 23:38   ` Stefan Berger
2026-11-13  9:58     ` Florian Bauckholt [this message]

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=473700a3-f5d7-4a7a-b89a-12c51adcc3df@cispa.de \
    --to=florian.bauckholt@cispa.de \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=ignat@linux.win \
    --cc=jarkko@kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas@wunner.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®