lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 21 Sep 2020 14:46:10 +0300
From:   Horia Geantă <horia.geanta@....com>
To:     "Andrei Botila (OSS)" <andrei.botila@....nxp.com>,
        Aymen Sghaier <aymen.sghaier@....com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>
Cc:     "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 01/12] crypto: caam/jr - add fallback for XTS with more
 than 8B IV

On 9/21/2020 10:32 AM, Andrei Botila (OSS) wrote:
> +static bool xts_skcipher_ivsize(struct skcipher_request *req)
> +{
> +	struct crypto_skcipher *skcipher = crypto_skcipher_reqtfm(req);
> +	unsigned int ivsize = crypto_skcipher_ivsize(skcipher);
> +	u64 size = 0;
> +
> +	size = get_unaligned((u64 *)(req->iv + (ivsize / 2)));
> +
> +	return !!size;
Just get rid of the "size" local variable and return !!get_unaligned(...).
Also the function should be inline.

> @@ -3344,13 +3379,30 @@ static int caam_cra_init(struct crypto_skcipher *tfm)
>  	struct caam_skcipher_alg *caam_alg =
>  		container_of(alg, typeof(*caam_alg), skcipher);
>  	struct caam_ctx *ctx = crypto_skcipher_ctx(tfm);
> -
> -	crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx));
> +	u32 alg_aai = caam_alg->caam.class1_alg_type & OP_ALG_AAI_MASK;
>  
>  	ctx->enginectx.op.do_one_request = skcipher_do_one_req;
>  
> -	return caam_init_common(crypto_skcipher_ctx(tfm), &caam_alg->caam,
> -				false);
> +	if (alg_aai == OP_ALG_AAI_XTS) {
> +		const char *tfm_name = crypto_tfm_alg_name(&tfm->base);
> +		struct crypto_skcipher *fallback;
> +
> +		fallback = crypto_alloc_skcipher(tfm_name, 0,
> +						 CRYPTO_ALG_NEED_FALLBACK);
> +		if (IS_ERR(fallback)) {
> +			dev_err(ctx->jrdev, "Failed to allocate %s fallback: %ld\n",
> +				tfm_name, PTR_ERR(fallback));
> +			return PTR_ERR(fallback);
> +		}
> +
> +		ctx->fallback = fallback;
> +		crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx) +
> +					    crypto_skcipher_reqsize(fallback));
> +	} else {
> +		crypto_skcipher_set_reqsize(tfm, sizeof(struct caam_skcipher_req_ctx));
> +	}
> +
> +	return caam_init_common(ctx, &caam_alg->caam, false);
In case caam_init_common() fails, fallback should be freed for XTS path.

Horia

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ