Re: [PATCH v2 8/8] state: backend_raw: add hamc support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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: signature.asc
Description: OpenPGP digital signature

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

[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux