All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukas Wunner <lukas@wunner.de>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org,
	linuxarm@huawei.com,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Chris Browy <cbrowy@avery-design.com>,
	keyrings@vger.kernel.org, Bjorn Helgaas <bjorn@helgaas.com>,
	"David E . Box" <david.e.box@linux.intel.com>,
	dan.j.williams@intel.com
Subject: Re: [RFC PATCH v2 12/14] spdm: Introduce a library for DMTF SPDM
Date: Mon, 9 May 2022 20:07:17 +0200	[thread overview]
Message-ID: <20220509180717.GA7015@wunner.de> (raw)
In-Reply-To: <20220303135905.10420-13-Jonathan.Cameron@huawei.com>

On Thu, Mar 03, 2022 at 01:59:03PM +0000, Jonathan Cameron wrote:
> --- /dev/null
> +++ b/include/linux/spdm.h
> @@ -0,0 +1,104 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/*
> + * DMTF Security Protocol and Data Model
> + *

Please amend this comment at the top of both spdm.h and spdm.c
with a link to https://www.dmtf.org/dsp/DSP0274
so the casual reader knows the document number and
knows where to find the spec.


> +struct spdm_header {
> +	u8 version;
> +	u8 code;  /* requestresponsecode */
> +	u8 param1;
> +	u8 param2;
> +};

I think you need to add __packed to all of the message structs
to ensure the compiler doesn't add padding anywhere.


> +struct spdm_exchange {
> +	struct spdm_header *request_pl;
> +	size_t request_pl_sz;
> +	struct spdm_header *response_pl;
> +	size_t response_pl_sz;

I assume "pl" means payload.  This isn't accurate as the spec defines
payload as the message body only (i.e. sans header).
I'd just omit the "_pl" suffix.


> +int spdm_measurements_get(struct spdm_state *spdm_state);

That function is declared in spdm.h but there's no implementation
provided in this patch.  Probably a leftover from an older iteration?


> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -289,6 +289,8 @@ obj-$(CONFIG_PERCPU_TEST) += percpu_test.o
>  obj-$(CONFIG_ASN1) += asn1_decoder.o
>  obj-$(CONFIG_ASN1_ENCODER) += asn1_encoder.o
>  
> +obj-$(CONFIG_SPDM) += spdm.o

It certainly seems wise to put this in lib/ so that it can be used by
other buses as well once they add encryption/authentication.
It's clearly not a PCIe-only feature.

I'm thinking of USB specifically since the USB Authentication Spec
seems to have served as a blueprint for SPDM.

I'd suggest to only include a forward declaration of struct spdm_state
in spdm.h to avoid exposing internals.  I'd further suggest to expose
one function to allocate & initialize an spdm_state.  By initialize I mean
that a transport function pointer is passed in which is stored in
struct spdm_state.  The transport function performs one request/response
transaction.  I think you should not mark the dev pointer in struct
spdm_state as "For error reporting only", rather that's the device with
which an SPDM exchange is performed.  The transport function should use
that dev pointer instead of duplicating the pointer in transport_priv.

Authenticating a device would thus encompass two function calls,
one to allocate & initialize spdm_state, another one to perform
SPDM session setup (which does authentication).

Encryption would encompass a third function call to set up IDE.


> +	spdm_state->measurement_hash_alg = __ffs(le16_to_cpu(rsp->measurement_hash_algo));
> +	spdm_state->base_asym_alg = __ffs(le16_to_cpu(rsp->base_asym_sel));
> +	spdm_state->base_hash_alg = __ffs(le16_to_cpu(rsp->base_hash_sel));

The weaker algorithms are represented by lower bits, so this selects
the weakest supported algorithm.  Wouldn't we want the opposite?
I guess that's a policy decision that user space should decide...

Thanks,

Lukas

  reply	other threads:[~2022-05-09 18:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 13:58 [RFC PATCH v2 00/14] PCI/CMA and SPDM Library Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 01/14] PCI: Add vendor ID for the PCI SIG Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 02/14] PCI: Replace magic constant for PCI Sig Vendor ID Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 03/14] PCI/DOE: Add Data Object Exchange Aux Driver Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 04/14] PCI/DOE: Introduce pci_doe_create_doe_devices Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 05/14] cxl/pci: Create DOE auxiliary devices Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 06/14] cxl/pci: Find the DOE mailbox which supports CDAT Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 07/14] cxl/mem: Read CDAT table Jonathan Cameron
2022-03-03 13:58 ` [RFC PATCH v2 08/14] cxl/cdat: Introduce cdat_hdr_valid() Jonathan Cameron
2022-03-03 13:59 ` [RFC PATCH v2 09/14] cxl/mem: Retry reading CDAT on failure Jonathan Cameron
2022-03-03 13:59 ` [RFC PATCH v2 10/14] cxl/cdat: Parse out DSMAS data from CDAT table Jonathan Cameron
2022-03-03 13:59 ` [RFC PATCH v2 11/14] lib/asn1_encoder: Add a function to encode many byte integer values Jonathan Cameron
2022-03-03 13:59 ` [RFC PATCH v2 12/14] spdm: Introduce a library for DMTF SPDM Jonathan Cameron
2022-05-09 18:07   ` Lukas Wunner [this message]
2022-03-03 13:59 ` [RFC PATCH v2 13/14] PCI/CMA: Initial support for Component Measurement and Authentication ECN Jonathan Cameron
2022-03-03 13:59 ` [RFC PATCH v2 14/14] cxl/pci: Add really basic CMA authentication support Jonathan Cameron

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=20220509180717.GA7015@wunner.de \
    --to=lukas@wunner.de \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=bjorn@helgaas.com \
    --cc=cbrowy@avery-design.com \
    --cc=dan.j.williams@intel.com \
    --cc=david.e.box@linux.intel.com \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=lorenzo.pieralisi@arm.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.