Re: [PATCH] crypto: virtio/akcipher - Move a pointer assignment in virtio_crypto_rsa_set_key()

2024-10-12 Thread zhenwei pi
On 10/12/24 16:06, Markus Elfring wrote: From: Markus Elfring Date: Sat, 12 Oct 2024 09:51:58 +0200 Move the reset of the data structure member “n” to a null pointer into an if branch so that this assignment will be performed only after a key parsing failure. Signed-off-by: Markus Elfring

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-10-07 Thread Jarkko Sakkinen
On Fri, 2024-09-27 at 08:42 +0800, Herbert Xu wrote: > On Tue, Sep 24, 2024 at 08:43:00PM +0300, Jarkko Sakkinen wrote: > > > > Without any traces that would provide more information I don't see > > the smoking gun. > > I haven't confirmed that it's definitely the tpm2 driver, it's just > based o

Re: [PATCH v2 00/19] Migrate to sig_alg and templatize ecdsa

2024-10-04 Thread Herbert Xu
On Tue, Sep 10, 2024 at 04:30:10PM +0200, Lukas Wunner wrote: > The original impetus of this series is to introduce P1363 signature > decoding for ecdsa (patch [18/19]), which is needed by the upcoming > SPDM library (Security Protocol and Data Model) for PCI device > authentication. > > To facili

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-10-04 Thread Roberto Sassu
On 9/26/2024 11:41 AM, Roberto Sassu wrote: On Sun, 2024-09-15 at 10:40 +0200, Linus Torvalds wrote: On Sun, 15 Sept 2024 at 10:08, Herbert Xu wrote: If the aformentioned EFI use-case is bogus, then distro package verification is going to be the only application for PGP keys in the kernel.

Re: [PATCH v2 00/19] Migrate to sig_alg and templatize ecdsa

2024-10-01 Thread Lukas Wunner
Hi Herbert, On Tue, Sep 10, 2024 at 04:30:10PM +0200, Lukas Wunner wrote: > The original impetus of this series is to introduce P1363 signature > decoding for ecdsa (patch [18/19]), which is needed by the upcoming > SPDM library (Security Protocol and Data Model) for PCI device > authentication. >

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-26 Thread Dr. Greg
On Thu, Sep 26, 2024 at 11:41:51AM +0200, Roberto Sassu wrote: Good evening, I hope the week has gone well for everyone. > On Sun, 2024-09-15 at 10:40 +0200, Linus Torvalds wrote: > > On Sun, 15 Sept 2024 at 10:08, Herbert Xu > > wrote: > > > > > > If the aformentioned EFI use-case is bogus, t

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-26 Thread Herbert Xu
On Tue, Sep 24, 2024 at 08:43:00PM +0300, Jarkko Sakkinen wrote: > > Without any traces that would provide more information I don't see > the smoking gun. I haven't confirmed that it's definitely the tpm2 driver, it's just based on the backtrace. Hopefully my patch will confirm it one way or the

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-26 Thread Roberto Sassu
On Sun, 2024-09-15 at 10:40 +0200, Linus Torvalds wrote: > On Sun, 15 Sept 2024 at 10:08, Herbert Xu wrote: > > > > If the aformentioned EFI use-case is bogus, then distro package > > verification is going to be the only application for PGP keys in > > the kernel. > > So I haven't actually seen

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-24 Thread Jarkko Sakkinen
On Tue Sep 24, 2024 at 7:05 PM EEST, Jarkko Sakkinen wrote: > On Tue Sep 24, 2024 at 1:32 AM EEST, Herbert Xu wrote: > > On Mon, Sep 23, 2024 at 04:48:27PM +0200, Greg KH wrote: > > > > > > Please see: > > > > > > https://www.kernel.org/doc/html/latest/process/deprecated.html#bug-and-bug-on > >

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-24 Thread Jarkko Sakkinen
On Tue Sep 24, 2024 at 1:32 AM EEST, Herbert Xu wrote: > On Mon, Sep 23, 2024 at 04:48:27PM +0200, Greg KH wrote: > > > > Please see: > > > > https://www.kernel.org/doc/html/latest/process/deprecated.html#bug-and-bug-on > > which describes that. We should make it more explicit that any WARN()

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Herbert Xu
On Mon, Sep 23, 2024 at 04:48:27PM +0200, Greg KH wrote: > > Please see: > > https://www.kernel.org/doc/html/latest/process/deprecated.html#bug-and-bug-on > which describes that. We should make it more explicit that any WARN() > or WARN_ON() calls that can be hit by user interactions someho

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Jarkko Sakkinen
On Mon Sep 23, 2024 at 5:48 PM EEST, Greg KH wrote: > On Mon, Sep 23, 2024 at 05:31:47PM +0300, Jarkko Sakkinen wrote: > > On Mon Sep 23, 2024 at 12:26 PM EEST, Herbert Xu wrote: > > > > + > > > > > + err = rng->read(rng, buffer, size, wait); > > > > > + if (WARN_ON_ONCE(er

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Greg KH
On Mon, Sep 23, 2024 at 05:31:47PM +0300, Jarkko Sakkinen wrote: > On Mon Sep 23, 2024 at 12:26 PM EEST, Herbert Xu wrote: > > > + > > > > + err = rng->read(rng, buffer, size, wait); > > > > + if (WARN_ON_ONCE(err > 0 && err > size)) > > > > > > Are you sure you want t

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Jarkko Sakkinen
On Mon Sep 23, 2024 at 5:31 PM EEST, Jarkko Sakkinen wrote: > Greg, did we have something under Documentation/ that would fully > address the use of WARN? ... personally I think that even if there was a separate document, this should be somehow addressed already in SubmittingPatches so that it can

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Jarkko Sakkinen
On Mon Sep 23, 2024 at 12:26 PM EEST, Herbert Xu wrote: > > + > > > + err = rng->read(rng, buffer, size, wait); > > > + if (WARN_ON_ONCE(err > 0 && err > size)) > > > > Are you sure you want to use WARN_ON_ONCE here instead of > > pr_warn_once()? I.e. is it worth of taking down th

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Herbert Xu
On Mon, Sep 23, 2024 at 10:52:49AM +0300, Jarkko Sakkinen wrote: > On Mon Sep 23, 2024 at 9:05 AM EEST, Herbert Xu wrote: > > Dear TPM maintainers: > > There's really only just me (for past 10 years). Maybe that should be > updatred. :) > > BUG_ON(!mutex_is_locked(&reading_mutex)); > > - i

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Jarkko Sakkinen
On Mon Sep 23, 2024 at 11:07 AM EEST, Jarkko Sakkinen wrote: > On Mon Sep 23, 2024 at 10:52 AM EEST, Jarkko Sakkinen wrote: > > On Mon Sep 23, 2024 at 9:05 AM EEST, Herbert Xu wrote: > > > Dear TPM maintainers: > > > > There's really only just me (for past 10 years). Maybe that should be > > updatr

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Jarkko Sakkinen
On Mon Sep 23, 2024 at 10:52 AM EEST, Jarkko Sakkinen wrote: > On Mon Sep 23, 2024 at 9:05 AM EEST, Herbert Xu wrote: > > Dear TPM maintainers: > > There's really only just me (for past 10 years). Maybe that should be > updatred. > > > > > Please have a look at the tpm hwrng driver because it appea

Re: [PATCH] hwrng: core - Add WARN_ON for buggy read return values

2024-09-23 Thread Jarkko Sakkinen
On Mon Sep 23, 2024 at 9:05 AM EEST, Herbert Xu wrote: > Dear TPM maintainers: There's really only just me (for past 10 years). Maybe that should be updatred. > > Please have a look at the tpm hwrng driver because it appears to > be returning a length longer than the buffer length that we gave >

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-17 Thread Dr. Greg
On Sun, Sep 15, 2024 at 07:52:13PM +0200, Roberto Sassu wrote: Good morning, I hope the day is starting well for everyone. > On 9/15/2024 11:31 AM, Herbert Xu wrote: > >On Sun, Sep 15, 2024 at 05:15:25PM +0800, Herbert Xu wrote: > >> > >>Roberto, correct me if I'm wrong but your intended use case

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-15 Thread Roberto Sassu
On 9/15/2024 11:31 AM, Herbert Xu wrote: On Sun, Sep 15, 2024 at 05:15:25PM +0800, Herbert Xu wrote: Roberto, correct me if I'm wrong but your intended use case is the following patch series, right? Actually the meat of the changes is in the following series: https://lore.kernel.org/linux-in

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-15 Thread Roberto Sassu
On 9/15/2024 9:11 AM, Linus Torvalds wrote: On Fri, 13 Sept 2024 at 10:30, Roberto Sassu [...] The objections I had were against the whole "start doing policy in kernel", with what sounded like actually parsing and unpacking rpm contents and verifying them with a pgp key. *That* still sounds

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-15 Thread Herbert Xu
On Sun, Sep 15, 2024 at 05:15:25PM +0800, Herbert Xu wrote: > > Roberto, correct me if I'm wrong but your intended use case is > the following patch series, right? Actually the meat of the changes is in the following series: https://lore.kernel.org/linux-integrity/20240905150543.3766895-1-roberto

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-15 Thread Herbert Xu
On Sun, Sep 15, 2024 at 10:40:15AM +0200, Linus Torvalds wrote: > > So I haven't actually seen _that_ series, but as mentioned it does > smell pretty conceptually broken to me. > > But hey, code talks, bullshit walks. People can most certainly try to > convince me. Roberto, correct me if I'm wro

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-15 Thread Linus Torvalds
On Sun, 15 Sept 2024 at 10:08, Herbert Xu wrote: > > If the aformentioned EFI use-case is bogus, then distro package > verification is going to be the only application for PGP keys in > the kernel. So I haven't actually seen _that_ series, but as mentioned it does smell pretty conceptually broken

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-15 Thread Herbert Xu
On Sun, Sep 15, 2024 at 09:11:04AM +0200, Linus Torvalds wrote: > > So honestly, just the series adding pgp key verification I have no > objection to. The use case where some firmware uses pgp to validate > allowed keys in EFI variables etc sounds like a "ok, then we need to > parse them". The use

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-15 Thread Linus Torvalds
On Fri, 13 Sept 2024 at 10:30, Roberto Sassu wrote: > > On Fri, 2024-09-13 at 12:45 +0800, Herbert Xu wrote: > > > > Does this address Linus's objections? If not then we cannot proceed. > > I hope to get an answer from him. So honestly, just the series adding pgp key verification I have no object

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-14 Thread Jarkko Sakkinen
On Fri Sep 13, 2024 at 7:45 AM EEST, Herbert Xu wrote: > Roberto Sassu wrote: > > > > For the envisioned use cases, PGP operations cannot be done in user space, > > since the consumers are in the kernel itself (Integrity Digest Cache and > > IMA). Also they cannot be done in a trusted initial ram

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-13 Thread Ard Biesheuvel
On Fri, 13 Sept 2024 at 11:32, David Howells wrote: > > Herbert Xu wrote: > > > Personally I don't think the argument above holds water. With > > IPsec we had a similar issue of authenticating untrusted peers > > using public key cryptography. In that case we successfully > > delegated the task

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-13 Thread David Howells
Herbert Xu wrote: > Personally I don't think the argument above holds water. With > IPsec we had a similar issue of authenticating untrusted peers > using public key cryptography. In that case we successfully > delegated the task to user-space and it is still how it works > to this day. It tra

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-13 Thread Herbert Xu
On Fri, Sep 13, 2024 at 10:30:11AM +0200, Roberto Sassu wrote: > > The second problem is, assuming that the task is verified through other > means other than PGP (but again, we are still relying on the public > crypto functionality to be performed by the kernel, for this to work), > that I didn't g

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-13 Thread Roberto Sassu
On Fri, 2024-09-13 at 12:45 +0800, Herbert Xu wrote: > Roberto Sassu wrote: + linux-security-module > > > > For the envisioned use cases, PGP operations cannot be done in user space, > > since the consumers are in the kernel itself (Integrity Digest Cache and > > IMA). Also they cannot be done

Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures

2024-09-12 Thread Herbert Xu
Roberto Sassu wrote: > > For the envisioned use cases, PGP operations cannot be done in user space, > since the consumers are in the kernel itself (Integrity Digest Cache and > IMA). Also they cannot be done in a trusted initial ram disk, since PGP > operations can occur also while the system is r

Re: [PATCH v3 05/14] PGPLIB: Signature parser

2024-09-12 Thread Jarkko Sakkinen
On Wed Sep 11, 2024 at 3:29 PM EEST, Roberto Sassu wrote: > From: David Howells > > Provide some PGP signature parsing helpers: > > (1) A function to parse V4 signature subpackets and pass the desired ones > to a processor function: > > int pgp_parse_sig_subpkts(const u8 *data, size_t

Re: [PATCH v3 04/14] PGPLIB: Basic packet parser

2024-09-12 Thread Jarkko Sakkinen
On Wed Sep 11, 2024 at 3:29 PM EEST, Roberto Sassu wrote: > From: David Howells > > Provide a simple parser that extracts the packets from a PGP packet blob > and passes the desirous ones to the given processor function: > > struct pgp_parse_context { > u64 types_of_interest; >

Re: [PATCH v3 03/14] PGPLIB: PGP definitions (RFC 9580)

2024-09-12 Thread Jarkko Sakkinen
On Wed Sep 11, 2024 at 3:29 PM EEST, Roberto Sassu wrote: > From: David Howells > > Provide some useful PGP definitions from RFC 9580. These describe details > of public key crypto as used by crypto keys for things like signature > verification. > > Signed-off-by: David Howells > Co-developed-by

Re: [PATCH v3 02/14] rsa: add parser of raw format

2024-09-12 Thread Jarkko Sakkinen
On Wed Sep 11, 2024 at 3:28 PM EEST, Roberto Sassu wrote: > From: Roberto Sassu > > Parse the RSA key with RAW format if the ASN.1 parser returns an error, to > avoid passing somehow the key format as parameter. > > Signed-off-by: Roberto Sassu > Signed-off-by: David Howells > --- > crypto/rsa.

Re: [PATCH v3 01/14] mpi: Introduce mpi_key_length()

2024-09-12 Thread Jarkko Sakkinen
On Wed Sep 11, 2024 at 3:28 PM EEST, Roberto Sassu wrote: > From: Roberto Sassu > > Introduce the new function to get the number of bits and bytes from an MPI. > > Signed-off-by: Roberto Sassu > Signed-off-by: David Howells > --- > include/linux/mpi.h | 2 ++ > lib/crypto/mpi/mpicoder.c

Re: [PATCH] integrity: prevent deadlock during digsig verification.

2024-09-11 Thread Lukas Wunner
On Wed, Jun 27, 2018 at 04:33:42PM +0300, Mikhail Kurinnoi wrote: > +int integrity_kernel_module_request(char *kmod_name) > +{ > + if (strncmp(kmod_name, "crypto-pkcs1pad(rsa,", 20) == 0) > + return -EINVAL; > + > + return 0; > +} Just a heads-up: The above was applied as comm

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-09-11 Thread Roberto Sassu
pport for v3 PGP signatures... but that broke openSUSE > > > Tumbleweed. > > Is this a signature from a v3 key, or a v3 signature? Unfortunately > there are implementations which will issue a v3 signature even from a v4 > key; IIRC this ambiguity has been cleared up in the upda

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-09-10 Thread Jonathan McDowell
On Tue, Sep 10, 2024 at 04:51:22PM +0200, Roberto Sassu wrote: > On Tue, 2024-09-10 at 16:36 +0200, Roberto Sassu wrote: > > On Tue, 2024-08-20 at 15:12 +0100, Jonathan McDowell wrote: > > > On Mon, Aug 19, 2024 at 05:15:02PM +0200, Roberto Sassu wrote: > > > > On Mon, 2024-08-19 at 16:08 +0100, Jo

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-09-10 Thread Roberto Sassu
On Tue, 2024-09-10 at 16:36 +0200, Roberto Sassu wrote: > On Tue, 2024-08-20 at 15:12 +0100, Jonathan McDowell wrote: > > On Mon, Aug 19, 2024 at 05:15:02PM +0200, Roberto Sassu wrote: > > > On Mon, 2024-08-19 at 16:08 +0100, Jonathan McDowell wrote: > > > > On Sun, Aug 18, 2024 at 06:57:42PM +0200

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-09-10 Thread Roberto Sassu
On Tue, 2024-08-20 at 15:12 +0100, Jonathan McDowell wrote: > On Mon, Aug 19, 2024 at 05:15:02PM +0200, Roberto Sassu wrote: > > On Mon, 2024-08-19 at 16:08 +0100, Jonathan McDowell wrote: > > > On Sun, Aug 18, 2024 at 06:57:42PM +0200, Roberto Sassu wrote: > > > > From: Roberto Sassu > > > > > >

Re: [PATCH] virtio-crypto: support crypto engine framework

2024-09-06 Thread Herbert Xu
On Fri, Aug 30, 2024 at 08:30:03AM +0200, Lukas Wunner wrote: > > I'm tempted to instead remove crypto_engine support from > virtio_crypto_core.c to ease migration to synchronous sign/verify. I would remove virtio akcipher support in its entirety. This API was never meant to be exposed outside of

Re: [PATCH] virtio-crypto: support crypto engine framework

2024-08-29 Thread Lukas Wunner
On Tue, Dec 27, 2016 at 02:49:07PM +0800, Gonglei wrote: > crypto engine was introduced since 'commit 735d37b5424b ("crypto: engine > - Introduce the block request crypto engine framework")' which uses work > queue to realize the asynchronous processing for ablk_cipher and ahash. > > For virtio-cr

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-08-20 Thread Roberto Sassu
On Tue, 2024-08-20 at 15:12 +0100, Jonathan McDowell wrote: > On Mon, Aug 19, 2024 at 05:15:02PM +0200, Roberto Sassu wrote: > > On Mon, 2024-08-19 at 16:08 +0100, Jonathan McDowell wrote: > > > On Sun, Aug 18, 2024 at 06:57:42PM +0200, Roberto Sassu wrote: > > > > From: Roberto Sassu > > > > > >

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-08-20 Thread Jonathan McDowell
On Mon, Aug 19, 2024 at 05:15:02PM +0200, Roberto Sassu wrote: > On Mon, 2024-08-19 at 16:08 +0100, Jonathan McDowell wrote: > > On Sun, Aug 18, 2024 at 06:57:42PM +0200, Roberto Sassu wrote: > > > From: Roberto Sassu > > > > > > Support for PGP keys and signatures was proposed by David long time

Re: [PATCH v2 02/14] rsa: add parser of raw format

2024-08-19 Thread Jarkko Sakkinen
On Sun Aug 18, 2024 at 7:57 PM EEST, Roberto Sassu wrote: > From: Roberto Sassu > > Parse the RSA key with RAW format if the ASN.1 parser returns an error. Why? Please finish the commit message properly. BR, Jarkko

Re: [PATCH v2 01/14] mpi: Introduce mpi_key_length()

2024-08-19 Thread Jarkko Sakkinen
On Sun Aug 18, 2024 at 7:57 PM EEST, Roberto Sassu wrote: > From: Roberto Sassu > > Introduce the new function to get the number of bits and bytes from an MPI. > > Signed-off-by: Roberto Sassu > Signed-off-by: David Howells > --- > include/linux/mpi.h | 2 ++ > lib/crypto/mpi/mpicoder.c

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-08-19 Thread Jarkko Sakkinen
On Sun Aug 18, 2024 at 7:57 PM EEST, Roberto Sassu wrote: > The patch set includes two preliminary patches: patch 1 introduces > mpi_key_length(), to get the number of bits and bytes of an MPI; patch 2 > introduces rsa_parse_priv_key_raw() and rsa_parse_pub_key_raw(), to parse > an RSA key in RAW f

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-08-19 Thread Roberto Sassu
On Sun, 2024-08-18 at 18:57 +0200, Roberto Sassu wrote: > From: Roberto Sassu > > Support for PGP keys and signatures was proposed by David long time ago, > before the decision of using PKCS#7 for kernel modules signatures > verification was made. After that, there has been not enough interest to

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-08-19 Thread Roberto Sassu
On Mon, 2024-08-19 at 16:08 +0100, Jonathan McDowell wrote: > On Sun, Aug 18, 2024 at 06:57:42PM +0200, Roberto Sassu wrote: > > From: Roberto Sassu > > > > Support for PGP keys and signatures was proposed by David long time ago, > > before the decision of using PKCS#7 for kernel modules signatur

Re: [PATCH v2 00/14] KEYS: Add support for PGP keys and signatures

2024-08-19 Thread Jonathan McDowell
On Sun, Aug 18, 2024 at 06:57:42PM +0200, Roberto Sassu wrote: > From: Roberto Sassu > > Support for PGP keys and signatures was proposed by David long time ago, > before the decision of using PKCS#7 for kernel modules signatures > verification was made. After that, there has been not enough inte

Re: [PATCH v2 04/14] PGPLIB: Basic packet parser

2024-08-19 Thread Roberto Sassu
On Mon, 2024-08-19 at 07:34 -0700, Jeff Johnson wrote: > On 8/18/24 09:57, Roberto Sassu wrote: > ... > > diff --git a/crypto/asymmetric_keys/pgp_library.c > > b/crypto/asymmetric_keys/pgp_library.c > > new file mode 100644 > > index ..33ed01f67654 > > --- /dev/null > > +++ b/crypto/as

Re: [PATCH v2 04/14] PGPLIB: Basic packet parser

2024-08-19 Thread Jeff Johnson
On 8/18/24 09:57, Roberto Sassu wrote: ... > diff --git a/crypto/asymmetric_keys/pgp_library.c > b/crypto/asymmetric_keys/pgp_library.c > new file mode 100644 > index ..33ed01f67654 > --- /dev/null > +++ b/crypto/asymmetric_keys/pgp_library.c > @@ -0,0 +1,272 @@ > +// SPDX-License-Iden

Re: [PATCH v2 06/14] KEYS: PGP data parser

2024-08-19 Thread Roberto Sassu
On Mon, 2024-08-19 at 07:36 -0700, Jeff Johnson wrote: > On 8/18/24 09:57, Roberto Sassu wrote: > ... > > diff --git a/crypto/asymmetric_keys/pgp_public_key.c > > b/crypto/asymmetric_keys/pgp_public_key.c > > new file mode 100644 > > index ..cb399f5cdd3e > > --- /dev/null > > +++ b/cry

Re: [PATCH v2 12/14] PGP: Provide a key type for testing PGP signatures

2024-08-19 Thread Jeff Johnson
On 8/18/24 09:57, Roberto Sassu wrote: ... > diff --git a/crypto/asymmetric_keys/pgp_test_key.c > b/crypto/asymmetric_keys/pgp_test_key.c > new file mode 100644 > index ..e067dedf6ca0 > --- /dev/null > +++ b/crypto/asymmetric_keys/pgp_test_key.c > @@ -0,0 +1,129 @@ > +// SPDX-License-I

Re: [PATCH v2 06/14] KEYS: PGP data parser

2024-08-19 Thread Jeff Johnson
On 8/18/24 09:57, Roberto Sassu wrote: ... > diff --git a/crypto/asymmetric_keys/pgp_public_key.c > b/crypto/asymmetric_keys/pgp_public_key.c > new file mode 100644 > index ..cb399f5cdd3e > --- /dev/null > +++ b/crypto/asymmetric_keys/pgp_public_key.c > @@ -0,0 +1,366 @@ > +// SPDX-Lic

Re: [PATCH][next] crypto: nx - Use static_assert() to check struct sizes

2024-08-17 Thread Herbert Xu
On Thu, Aug 08, 2024 at 04:09:06PM -0600, Gustavo A. R. Silva wrote: > Commit 1e6b251ce175 ("crypto: nx - Avoid -Wflex-array-member-not-at-end > warning") introduced tagged `struct nx842_crypto_header_hdr`. We want > to ensure that when new members need to be added to the flexible > structure, they

Re: [PATCH][next] crypto: qat - Use static_assert() to check struct sizes

2024-08-17 Thread Herbert Xu
On Thu, Aug 08, 2024 at 04:05:26PM -0600, Gustavo A. R. Silva wrote: > Commit 140e4c85d540 ("crypto: qat - Avoid -Wflex-array-member-not-at-end > warnings") introduced tagged `struct qat_alg_buf_list_hdr`. We want to > ensure that when new members need to be added to the flexible structure, > they

Re: [PATCH v2] crypto: chacha20poly1305 - Annotate struct chachapoly_ctx with __counted_by()

2024-08-17 Thread Herbert Xu
On Tue, Aug 06, 2024 at 12:11:30AM +0200, Thorsten Blum wrote: > Add the __counted_by compiler attribute to the flexible array member > salt to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and > CONFIG_FORTIFY_SOURCE. > > Reviewed-by: Kees Cook > Signed-off-by: Thorsten Blum > --- > Ch

Re: [PATCH][next] crypto: qat - Use static_assert() to check struct sizes

2024-08-15 Thread Cabiddu, Giovanni
On Thu, Aug 08, 2024 at 04:05:26PM -0600, Gustavo A. R. Silva wrote: > Commit 140e4c85d540 ("crypto: qat - Avoid -Wflex-array-member-not-at-end > warnings") introduced tagged `struct qat_alg_buf_list_hdr`. We want to > ensure that when new members need to be added to the flexible structure, > they

Re: [PATCH] crypto: chacha20poly1305 - Annotate struct chachapoly_ctx with __counted_by()

2024-08-05 Thread Thorsten Blum
On 5. Aug 2024, at 19:59, Eric Biggers wrote: > On Mon, Aug 05, 2024 at 07:52:38PM +0200, Thorsten Blum wrote: >> struct poly_req { >> @@ -611,8 +611,8 @@ static int chachapoly_create(struct crypto_template >> *tmpl, struct rtattr **tb, >> poly->base.cra_priority) / 2; >> inst->alg.base.cra

Re: [PATCH] crypto: chacha20poly1305 - Annotate struct chachapoly_ctx with __counted_by()

2024-08-05 Thread Eric Biggers
On Mon, Aug 05, 2024 at 07:52:38PM +0200, Thorsten Blum wrote: > struct poly_req { > @@ -611,8 +611,8 @@ static int chachapoly_create(struct crypto_template > *tmpl, struct rtattr **tb, > poly->base.cra_priority) / 2; > inst->alg.base.cra_blocksize = 1;

Re: [PATCH v12 02/10] crypto: Add support for ECDSA signature verification

2024-07-22 Thread Lukas Wunner
On Mon, Jul 22, 2024 at 08:19:41AM -0400, Stefan Berger wrote: > On 7/17/24 12:17, Lukas Wunner wrote: > > On Tue, Mar 16, 2021 at 05:07:32PM -0400, Stefan Berger wrote: > > > +/* > > > + * Get the r and s components of a signature from the X509 certificate. > > > + */ > > > +static int ecdsa_get_s

Re: [PATCH v12 02/10] crypto: Add support for ECDSA signature verification

2024-07-22 Thread Stefan Berger
On 7/17/24 12:17, Lukas Wunner wrote: Hi Stefan, On Tue, Mar 16, 2021 at 05:07:32PM -0400, Stefan Berger wrote: +/* + * Get the r and s components of a signature from the X509 certificate. + */ +static int ecdsa_get_signature_rs(u64 *dest, size_t hdrlen, unsigned char tag, +

Re: [PATCH v12 02/10] crypto: Add support for ECDSA signature verification

2024-07-17 Thread Lukas Wunner
Hi Stefan, On Tue, Mar 16, 2021 at 05:07:32PM -0400, Stefan Berger wrote: > +/* > + * Get the r and s components of a signature from the X509 certificate. > + */ > +static int ecdsa_get_signature_rs(u64 *dest, size_t hdrlen, unsigned char > tag, > + const void *value

Re: [PATCH] crypto: arm/crc32 - add kCFI annotations to asm routines

2024-06-21 Thread Herbert Xu
On Mon, Jun 10, 2024 at 05:26:39PM +0200, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > The crc32/crc32c implementations using the scalar CRC32 instructions are > accessed via indirect calls, and so they must be annotated with type ids > in order to execute correctly when kCFI is enabled. > >

Re: [RFC PATCH v2 0/8] Clavis LSM

2024-06-20 Thread Eric Snowberg
odules could be used for BPF verification. >> >> This new LSM adds the ability to do access control for all system keys. When >> enabled, only the .builtin_trusted_keys are available for loading kernel >> modules and doing a kexec. Until an ACL entry is add

Re: [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa

2024-06-19 Thread Jarkko Sakkinen
On Fri Jun 7, 2024 at 1:58 PM EEST, Herbert Xu wrote: > 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

Re: [RFC PATCH v2 0/8] Clavis LSM

2024-06-19 Thread Mimi Zohar
for any other purpose. Keys stored on the .builtin_trusted_keys keyring seem to always be permitted, independent of a Clavis rule, which is fine, but the above paragraph needs to be re-worded. > > Enabling the LSM is done during initial boot by passing in a single asymmetric > key id within

Re: is_module()

2024-06-14 Thread Lucas De Marchi
On Thu, May 23, 2024 at 06:01:49PM GMT, Jarkko Sakkinen wrote: Hi, I just put this here while I still have it on my mind. Possibly I'm ignoring something that already enables this but at least I learn something by doing this then. This came up in a recent discussion albeit for this crypto bug i

Re: [PATCH] crypto: arm/crc32 - add kCFI annotations to asm routines

2024-06-11 Thread Linus Walleij
On Mon, Jun 10, 2024 at 5:26 PM Ard Biesheuvel wrote: > From: Ard Biesheuvel > > The crc32/crc32c implementations using the scalar CRC32 instructions are > accessed via indirect calls, and so they must be annotated with type ids > in order to execute correctly when kCFI is enabled. > > Cc: Kees

Re: [RFC PATCH v2 8/8] clavis: Introduce new LSM called clavis

2024-06-11 Thread Eric Snowberg
> On Jun 10, 2024, at 8:33 PM, Randy Dunlap wrote: > > Hi Eric, > > On 5/30/24 5:39 PM, Eric Snowberg wrote: >> >> Signed-off-by: Eric Snowberg >> --- >> Documentation/admin-guide/LSM/clavis.rst | 198 +++ >> MAINTAINERS | 7 + >> crypto/asymm

Re: [RFC PATCH v2 8/8] clavis: Introduce new LSM called clavis

2024-06-10 Thread Randy Dunlap
Hi Eric, On 5/30/24 5:39 PM, Eric Snowberg wrote: > > Signed-off-by: Eric Snowberg > --- > Documentation/admin-guide/LSM/clavis.rst | 198 +++ > MAINTAINERS | 7 + > crypto/asymmetric_keys/signature.c | 4 + > include/linux/lsm_hook_def

Re: [PATCH] crypto: arm/crc32 - add kCFI annotations to asm routines

2024-06-10 Thread Kees Cook
On Mon, Jun 10, 2024 at 05:26:39PM +0200, Ard Biesheuvel wrote: > From: Ard Biesheuvel > > The crc32/crc32c implementations using the scalar CRC32 instructions are > accessed via indirect calls, and so they must be annotated with type ids > in order to execute correctly when kCFI is enabled. > >

Re: [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa

2024-06-07 Thread Herbert Xu
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

Re: [RFC PATCH v2 0/8] Clavis LSM

2024-06-05 Thread Eric Snowberg
> On Jun 4, 2024, at 11:59 AM, Jarkko Sakkinen wrote: > > On Fri May 31, 2024 at 3:39 AM EEST, Eric Snowberg wrote: >> Introduce a new LSM called Clavis (Latin word meaning key). The motivation >> behind this LSM is to provide access control for system keys. Before >> spending >> more time o

Re: [RFC PATCH v2 1/8] certs: Introduce ability to link to a system key

2024-06-05 Thread Eric Snowberg
> On Jun 4, 2024, at 12:08 PM, Jarkko Sakkinen wrote: > > On Fri May 31, 2024 at 3:39 AM EEST, Eric Snowberg wrote: >> Introduce a new function to allow a keyring to link to a key contained >> within one of the system keyrings (builtin, secondary, or platform). > > "Introduce system_key_link()

Re: [PATCH v7 3/5] crypto: tpm2_key: Introduce a TPM2 key type

2024-06-04 Thread Jarkko Sakkinen
On Tue Jun 4, 2024 at 9:41 PM EEST, Stefan Berger wrote: > > > On 6/4/24 13:23, Jarkko Sakkinen wrote: > > On Fri May 31, 2024 at 3:35 AM EEST, Stefan Berger wrote: > >> > > >>> > >>> - rc = tpm2_key_decode(payload, options, &blob); > >>> - if (rc) { > >>> - /* old form */ > >>> + key =

Re: [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa

2024-06-04 Thread Jarkko Sakkinen
On Fri May 31, 2024 at 4:10 AM EEST, Stefan Berger wrote: > > > On 5/28/24 17:08, Jarkko Sakkinen wrote: > > * Asymmetric TPM2 RSA key with signing and verification. > > * Encryption and decryption when pcks1 encoding is used. > > * Enabled with CONFIG_ASYMMETRIC_TPM2_KEY_ECDSA_SUBTYPE. > > s/ECDSA

Re: [PATCH v7 3/5] crypto: tpm2_key: Introduce a TPM2 key type

2024-06-04 Thread Stefan Berger
On 6/4/24 13:23, Jarkko Sakkinen wrote: On Fri May 31, 2024 at 3:35 AM EEST, Stefan Berger wrote: - rc = tpm2_key_decode(payload, options, &blob); - if (rc) { - /* old form */ + key = tpm2_key_decode(payload->blob, payload->blob_len); + if (IS_ERR(key))

Re: [RFC PATCH v2 1/8] certs: Introduce ability to link to a system key

2024-06-04 Thread Jarkko Sakkinen
On Fri May 31, 2024 at 3:39 AM EEST, Eric Snowberg wrote: > Introduce a new function to allow a keyring to link to a key contained > within one of the system keyrings (builtin, secondary, or platform). "Introduce system_key_link(), a new function..." I hate when the exact thing added is not immed

Re: [RFC PATCH v2 0/8] Clavis LSM

2024-06-04 Thread Jarkko Sakkinen
On Fri May 31, 2024 at 3:39 AM EEST, Eric Snowberg wrote: > Introduce a new LSM called Clavis (Latin word meaning key). The motivation > behind this LSM is to provide access control for system keys. Before spending > more time on this LSM, I am sending this as an RFC to start a discussion to > s

Re: [PATCH v7 3/5] crypto: tpm2_key: Introduce a TPM2 key type

2024-06-04 Thread Jarkko Sakkinen
On Fri May 31, 2024 at 3:35 AM EEST, Stefan Berger wrote: > > > On 5/28/24 17:08, Jarkko Sakkinen wrote: > > TPM2 ASN.1 format is required for trusted keys and asymmetric keys. Move it > > to crypto in order to make it available for both. Implement validation with > > coverage of all TPMT_PUBLIC sh

Re: [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa

2024-05-30 Thread Stefan Berger
On 5/28/24 17:08, Jarkko Sakkinen wrote: * Asymmetric TPM2 RSA key with signing and verification. * Encryption and decryption when pcks1 encoding is used. * Enabled with CONFIG_ASYMMETRIC_TPM2_KEY_ECDSA_SUBTYPE. s/ECDSA/RSA ! Signed-off-by: James Prestwood Co-developed-by: Jarkko Sakkine

Re: [PATCH v7 3/5] crypto: tpm2_key: Introduce a TPM2 key type

2024-05-30 Thread Stefan Berger
On 5/28/24 17:08, Jarkko Sakkinen wrote: TPM2 ASN.1 format is required for trusted keys and asymmetric keys. Move it to crypto in order to make it available for both. Implement validation with coverage of all TPMT_PUBLIC shared fields. Key type specific fields must be covered by the different

Re: [PATCH v7 4/5] keys: asymmetric: Add tpm2_key_rsa

2024-05-29 Thread Jarkko Sakkinen
On Wed May 29, 2024 at 12:08 AM EEST, Jarkko Sakkinen wrote: > * Asymmetric TPM2 RSA key with signing and verification. > * Encryption and decryption when pcks1 encoding is used. > * Enabled with CONFIG_ASYMMETRIC_TPM2_KEY_ECDSA_SUBTYPE. > > Signed-off-by: James Prestwood > Co-developed-by: Jarkko

Re: [PATCH v7 2/5] KEYS: trusted: Change -EINVAL to -E2BIG

2024-05-29 Thread Jarkko Sakkinen
On Wed May 29, 2024 at 4:50 AM EEST, Stefan Berger wrote: > > > On 5/28/24 17:08, Jarkko Sakkinen wrote: > > Report -E2BIG instead of -EINVAL when too large size for the key blob is > > requested. > > > > Signed-off-by: Jarkko Sakkinen > > Reviewed-by: Stefan Berger Thank you. Hmm... I'd like

Re: [PATCH v7 2/5] KEYS: trusted: Change -EINVAL to -E2BIG

2024-05-28 Thread Stefan Berger
On 5/28/24 17:08, Jarkko Sakkinen wrote: Report -E2BIG instead of -EINVAL when too large size for the key blob is requested. Signed-off-by: Jarkko Sakkinen Reviewed-by: Stefan Berger --- security/keys/trusted-keys/trusted_tpm2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)

Re: [PATCH v7 1/5] crypto: rsa-pkcs1pad: export rsa1_asn_lookup()

2024-05-28 Thread Jarkko Sakkinen
On Wed May 29, 2024 at 2:20 AM EEST, Stefan Berger wrote: > > > On 5/28/24 17:08, Jarkko Sakkinen wrote: > > ASN.1 template is required for TPM2 asymmetric keys, as it needs to be > > piggy-packed with the input data before applying TPM2_RSA_Decrypt. This > > piggy-backed Right! I consciously wrot

Re: [PATCH v7 5/5] keys: asymmetric: Add tpm2_key_ecdsa

2024-05-28 Thread Jarkko Sakkinen
On Wed May 29, 2024 at 2:15 AM EEST, Stefan Berger wrote: > > + ptr[TPM2_KEY_ECDSA_SIG_R_TAG] = 0x02; /* INTEGER */ > > + ptr[TPM2_KEY_ECDSA_SIG_R_SIZE] = SHA256_DIGEST_SIZE + r_0; > > The size of the signature has nothing to do with the size of the hash. > SHA256_DIGEST_SIZE (32) happens to m

Re: [PATCH v7 1/5] crypto: rsa-pkcs1pad: export rsa1_asn_lookup()

2024-05-28 Thread Stefan Berger
On 5/28/24 17:08, Jarkko Sakkinen wrote: ASN.1 template is required for TPM2 asymmetric keys, as it needs to be piggy-packed with the input data before applying TPM2_RSA_Decrypt. This piggy-backed patch prepares crypto subsystem for the addition of those keys. Signed-off-by: Jarkko Sakkin

Re: [PATCH v7 5/5] keys: asymmetric: Add tpm2_key_ecdsa

2024-05-28 Thread Stefan Berger
On 5/28/24 17:08, Jarkko Sakkinen wrote: * Asymmetric TPM2 ECDSA key with signing and verification. * Enabled with CONFIG_ASYMMETRIC_TPM2_KEY_ECDSA_SUBTYPE. Cc: Stefan Berger Signed-off-by: Jarkko Sakkinen --- v7: * Rewrote the signature encoder. * Added the missing sha256() call to the sig

Re: [PATCH v7 5/5] keys: asymmetric: Add tpm2_key_ecdsa

2024-05-28 Thread Jarkko Sakkinen
On Wed May 29, 2024 at 12:42 AM EEST, Jarkko Sakkinen wrote: > 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",

Re: [PATCH v7 5/5] keys: asymmetric: Add tpm2_key_ecdsa

2024-05-28 Thread Jarkko Sakkinen
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 */ >

Re: [PATCH v6 1/6] tpm: Open code tpm_buf_parameters()

2024-05-27 Thread Jarkko Sakkinen
On Tue May 28, 2024 at 6:51 AM EEST, Jarkko Sakkinen wrote: > With only single call site, this makes zero sense (slipped out of the > radar during the review). Open code and document the action directly > to the site, to make it more readable. > > Fixes: 1b6d7f9eb150 ("tpm: add session encryption p

Re: [PATCH v5 0/5] KEYS: asymmetric: tpm2_key_rsa

2024-05-24 Thread Jarkko Sakkinen
On Fri May 24, 2024 at 12:25 AM EEST, Jarkko Sakkinen wrote: > ## Overview > > Introduce tpm2_key_rsa module, which implements asymmetric TPM2 RSA key. > The feature can be enabled with the CONFIG_ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE > kconfig option. This feature allows the private key to be uploaded

Re: [PATCH v5 5/5] keys: asymmetric: ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE

2024-05-23 Thread Jarkko Sakkinen
On Fri May 24, 2024 at 12:52 AM EEST, Jarkko Sakkinen wrote: > On Fri May 24, 2024 at 12:39 AM EEST, Jarkko Sakkinen wrote: > > On Fri May 24, 2024 at 12:25 AM EEST, Jarkko Sakkinen wrote: > > > + /* > > > + * ABI requires this according include/crypto/akcipher.h, which says > > > + * that there

Re: [PATCH v5 5/5] keys: asymmetric: ASYMMETRIC_TPM2_KEY_RSA_SUBTYPE

2024-05-23 Thread Jarkko Sakkinen
On Fri May 24, 2024 at 12:39 AM EEST, Jarkko Sakkinen wrote: > On Fri May 24, 2024 at 12:25 AM EEST, Jarkko Sakkinen wrote: > > + /* > > +* ABI requires this according include/crypto/akcipher.h, which says > > +* that there is epilogue with algorithm OID and parameters length. > > +*

  1   2   3   4   5   6   7   8   9   10   >