linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andy@kernel.org>
Cc: "Gregory CLEMENT" <gregory.clement@bootlin.com>,
	"Arnd Bergmann" <arnd@arndb.de>,
	soc@kernel.org, arm@kernel.org,
	"Hans de Goede" <hdegoede@redhat.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	linux-crypto@vger.kernel.org,
	"Dan Carpenter" <dan.carpenter@linaro.org>
Subject: Re: [PATCH v9 7/9] platform: cznic: turris-omnia-mcu: Add support for digital message signing via debugfs
Date: Thu, 9 May 2024 20:57:29 +0200	[thread overview]
Message-ID: <20240509205729.09728cbb@thinkpad> (raw)
In-Reply-To: <Zjti-FkUCAQzMmrQ@smile.fi.intel.com>

On Wed, 8 May 2024 14:33:12 +0300
Andy Shevchenko <andy@kernel.org> wrote:

> On Wed, May 08, 2024 at 12:31:16PM +0200, Marek Behún wrote:

...

> > +static irqreturn_t omnia_msg_signed_irq_handler(int irq, void *dev_id)
> > +{
> > +	u8 reply[1 + OMNIA_MCU_CRYPTO_SIGNATURE_LEN];
> > +	struct omnia_mcu *mcu = dev_id;
> > +	int err;
> > +
> > +	err = omnia_cmd_read(mcu->client, OMNIA_CMD_CRYPTO_COLLECT_SIGNATURE,
> > +			     reply, sizeof(reply));
> > +	if (!err && reply[0] != OMNIA_MCU_CRYPTO_SIGNATURE_LEN)
> > +		err = -EIO;
> > +
> > +	guard(mutex)(&mcu->sign_lock);
> > +
> > +	if (mcu->sign_state == SIGN_STATE_REQUESTED) {
> > +		mcu->sign_err = err;
> > +		if (!err)
> > +			memcpy(mcu->signature, &reply[1],
> > +			       OMNIA_MCU_CRYPTO_SIGNATURE_LEN);  
> 
> > +		mcu->sign_state = SIGN_STATE_COLLECTED;  
> 
> Even for an error case?

Yes, the pair (errno, signature) is collected.

> > +		complete(&mcu->msg_signed_completion);
> > +	}
> > +
> > +	return IRQ_HANDLED;
> > +}  
> 
> ...
> 
> > +	scoped_guard(mutex, &mcu->sign_lock)
> > +		if (mcu->sign_state != SIGN_STATE_REQUESTED &&
> > +		    mcu->sign_state != SIGN_STATE_COLLECTED)
> > +			return -ENODATA;  
> 
> {}
> 
> Don't you want interruptible mutex? In such case you might need to return
> -ERESTARTSYS. OTOH, this is debugfs, we don't much care.

Indeed I shall use
  scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &mcu->sign_lock) {
    ...
  }

And -ERESTARTSYS instead of -EINTR also for the subsequent
wait_for_completion_interruptible(), and also in trng from patch 6/9.

> ...
> 
> > +#define OMNIA_MCU_CRYPTO_PUBLIC_KEY_LEN	33  
> 
> 33? Hmm... does it mean (32 + 1)?

Rather (1 + 32), the first byte is 0x02 or 0x03, determining whether
the y coordinate of the public key elliptic curve point is positive or
negative, and the rest 32 bytes are the x coordinate.

Marek


  reply	other threads:[~2024-05-09 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08 10:31 [PATCH v9 0/9] Turris Omnia MCU driver Marek Behún
2024-05-08 10:31 ` [PATCH v9 6/9] platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG Marek Behún
2024-05-08 10:31 ` [PATCH v9 7/9] platform: cznic: turris-omnia-mcu: Add support for digital message signing via debugfs Marek Behún
2024-05-08 11:33   ` Andy Shevchenko
2024-05-09 18:57     ` Marek Behún [this message]
2024-05-10 13:19       ` Andy Shevchenko
2024-05-08 11:17 ` [PATCH v9 0/9] Turris Omnia MCU driver Andy Shevchenko
2024-05-08 17:50   ` Marek Behún

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=20240509205729.09728cbb@thinkpad \
    --to=kabel@kernel.org \
    --cc=andy@kernel.org \
    --cc=arm@kernel.org \
    --cc=arnd@arndb.de \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=gregory.clement@bootlin.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=soc@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).