All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 8/8] state: backend_raw: add hamc support
Date: Wed, 21 Oct 2015 10:56:01 +0200	[thread overview]
Message-ID: <56275321.40107@pengutronix.de> (raw)
In-Reply-To: <20151021071314.GZ14476@pengutronix.de>


[-- Attachment #1.1: Type: text/plain, Size: 2341 bytes --]

On 10/21/2015 09:13 AM, Sascha Hauer wrote:
>> +static int state_backend_raw_file_init_digest(struct state *state, struct state_backend_raw *backend_raw)
>> +{
>> +	struct digest *digest;
>> +	const char *algo;
>> +	const unsigned char *key;
>> +	int key_len, ret;
>> +
>> +	ret = of_property_read_string(state->root, "algo", &algo);
> 
> This needs an update to Documentation/devicetree/bindings/barebox/barebox,state.rst

ok

>> +	if (ret == -EINVAL)	/* -EINVAL == does not exist */
>> +		return 0;
> 
> -EINVAL is such a widespread error value. Maybe better explicitly test
> for existence with of_find_property?

ok

>> +	else if (ret)
>> +		return ret;
>> +
>> +	ret = keystore_get_secret(state->name, &key, &key_len);
>> +	if (ret == -ENOENT)	/* -ENOENT == does not exist */
>> +		return -EPROBE_DEFER;
>> +	else if (ret)
>> +		return ret;
>> +
>> +	digest = digest_alloc(algo);
>> +	if (!digest) {
>> +		dev_info(&state->dev, "algo %s not found - probe deferred\n", algo);
>> +		return -EPROBE_DEFER;
>> +	}
>> +
>> +	ret = digest_set_key(digest, key, key_len);
>> +	if (ret) {
>> +		digest_free(digest);
>> +		return ret;
>> +	}
>> +
>> +	backend_raw->backend.digest = digest;
>> +	backend_raw->size_full = digest_length(digest);
>> +
>> +	return 0;
>> +}
>> +
>>  /*
>>   * state_backend_raw_file - create a raw file backend store for a state instance
>>   *
>> @@ -1534,8 +1627,14 @@ int state_backend_raw_file(struct state *state, const char *of_path,
>>  		return -EINVAL;
>>  
>>  	backend_raw = xzalloc(sizeof(*backend_raw));
>> -	backend = &backend_raw->backend;
>>  
>> +	ret = state_backend_raw_file_init_digest(state, backend_raw);
>> +	if (ret) {
>> +		free(backend_raw);
>> +		return ret;
>> +	}
> 
> Maybe better make this configurable with correct dependencies
> (CONFIG_CRYPTO_KEYSTORE, CONFIG_DIGEST) rather than depending on the
> user selecting the implicit dependencies manually?

There are noops so that it compile even if KEYSTORE and DIGEST is not
selected.

Marc
-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-10-21  8:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-20  8:39 [PATCH v2 1/8] state framework enhancements Marc Kleine-Budde
2015-10-20  8:39 ` [PATCH v2 1/8] of_path: of_find_path() factor out device detection logic into separate function Marc Kleine-Budde
2015-10-21  6:24   ` Sascha Hauer
2015-12-10 22:38   ` Trent Piepho
2015-12-11  0:07     ` [PATCH] of_path: Fix bug with partitions, simply code Trent Piepho
2015-12-11  9:35       ` Sascha Hauer
2015-12-11 18:51         ` Trent Piepho
2015-12-16 10:43       ` Sascha Hauer
2015-10-20  8:39 ` [PATCH v2 2/8] of_path: add of_find_path_by_phandle() Marc Kleine-Budde
2015-10-20  8:39 ` [PATCH v2 3/8] state: make use of of_find_path_by_phandle() and add return -EPROBE_DEFER if device is not available Marc Kleine-Budde
2015-10-20  8:39 ` [PATCH v2 4/8] state: use name of device node as name if alias " Marc Kleine-Budde
2015-10-20  8:39 ` [PATCH v2 5/8] state: disable load command Marc Kleine-Budde
2015-10-20  8:39 ` [PATCH v2 6/8] crypto: add simple keystore Marc Kleine-Budde
2015-10-20  8:39 ` [PATCH v2 7/8] state: prepare raw backend for hmac support Marc Kleine-Budde
2015-10-20  8:39 ` [PATCH v2 8/8] state: backend_raw: add hamc support Marc Kleine-Budde
2015-10-20  9:49   ` Jan Lübbe
2015-10-21  7:13   ` Sascha Hauer
2015-10-21  8:56     ` Marc Kleine-Budde [this message]
2015-10-21  9:12       ` Sascha Hauer

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=56275321.40107@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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.