Re: [PATCH 05/16] crypto: skcipher - add helper for simple block cipher modes

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

 



Am Freitag, 4. Januar 2019, 05:16:14 CET schrieb Eric Biggers:

Hi Eric,

> From: Eric Biggers <ebiggers@xxxxxxxxxx>
> 
> The majority of skcipher templates (including both the existing ones and
> the ones remaining to be converted from the "blkcipher" API) just wrap a
> single block cipher algorithm.  This includes cbc, cfb, ctr, ecb, kw,
> ofb, and pcbc.  Add a helper function skcipher_alloc_instance_simple()
> that handles allocating an skcipher instance for this common case.
> 
> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>

Apart from the comment below:

Reviewed-by: Stephan Mueller <smueller@xxxxxxxxxx>

> +struct skcipher_instance *
> +skcipher_alloc_instance_simple(struct crypto_template *tmpl, struct rtattr
> **tb, +			       struct crypto_alg **cipher_alg_ret)
> +{
> +	struct crypto_attr_type *algt;
> +	struct crypto_alg *cipher_alg;
> +	struct skcipher_instance *inst;
> +	struct crypto_spawn *spawn;
> +	u32 mask;
> +	int err;
> +
> +	algt = crypto_get_attr_type(tb);
> +	if (IS_ERR(algt))
> +		return ERR_CAST(algt);
> +
> +	if ((algt->type ^ CRYPTO_ALG_TYPE_SKCIPHER) & algt->mask)
> +		return ERR_PTR(-EINVAL);

Why not using crypto_check_attr_type? I understand that it does not return 
algt for the next check, but maybe we can consolidate the code a bit here?

> +
> +	mask = CRYPTO_ALG_TYPE_MASK |
> +		crypto_requires_off(algt->type, algt->mask,
> +				    CRYPTO_ALG_NEED_FALLBACK);


Ciao
Stephan





[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux