From: "Horia Geantă" <horia.geanta@nxp.com>
To: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,
Pankaj Gupta <pankaj.gupta@nxp.com>,
Gaurav Jain <gaurav.jain@nxp.com>, Varun Sethi <V.Sethi@nxp.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S . Miller" <davem@davemloft.net>
Cc: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH v4 1/1] crypto: caam/rng: Add support for PRNG
Date: Fri, 29 Apr 2022 14:01:33 +0300 [thread overview]
Message-ID: <8878ca42-6660-2d02-5bcd-2b4be4373914@nxp.com> (raw)
In-Reply-To: <20220429084527.2069402-2-meenakshi.aggarwal@nxp.com>
On 4/29/2022 11:45 AM, Meenakshi Aggarwal wrote:
> From: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
>
> Add support for random number generation using PRNG
> mode of CAAM and expose the interface through crypto API.
>
> According to the RM, the HW implementation of the DRBG follows
> NIST SP 800-90A specification for DRBG_Hash SHA-256 function
>
> Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
There are a few nitpicks below, if you can address them great,
either way here's my
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
> + * Length of used descriptors, see caam_init_desc()
caam_init_desc() does not exist in this file.
> + */
> +#define CAAM_PRNG_DESC_LEN (CAAM_CMD_SZ + \
> + CAAM_CMD_SZ + \
> + CAAM_CMD_SZ + CAAM_PTR_SZ_MAX)
The reseed descriptor length is now smaller.
Memmory allocated by kmalloc() will probably be the same,
but code would be more readable.
If you want to use the same length for both descriptors,
I suggest renaming the define to CAAM_PRNG_MAX_DESC_LEN.
> +static u32 *caam_init_reseed_desc(u32 *desc)
> +{
> + init_job_desc(desc, 0); /* + 1 cmd_sz */
> + /* Generate random bytes: + 1 cmd_sz */
This is a "reseed" operation, not "generate".
> + append_operation(desc, OP_TYPE_CLASS1_ALG | OP_ALG_ALGSEL_RNG |
> + OP_ALG_AS_FINALIZE);
> +
[...]
> +static int caam_prng_generate(struct crypto_rng *tfm,
> + const u8 *src, unsigned int slen,
> + u8 *dst, unsigned int dlen)
> +{
[...]
> + ret = caam_jr_enqueue(jrdev,
> + caam_init_prng_desc(desc, dst_dma, dlen),
> + caam_prng_done, &ctx);
> +
> + if (ret == -EINPROGRESS) {
> + wait_for_completion(&ctx.done);
> + ret = ctx.err;
> + }
> +
> + dma_unmap_single(jrdev, dst_dma, dlen, DMA_FROM_DEVICE);
> +
> + memcpy(dst, buf, dlen);
memcpy() should be performed only when the HW executed the operation
successfully.
Thanks,
Horia
next prev parent reply other threads:[~2022-04-29 11:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 11:41 [PATCH] " meenakshi.aggarwal
2022-03-08 22:49 ` kernel test robot
2022-03-16 18:01 ` [PATCH v2 0/1] " meenakshi.aggarwal
2022-03-16 18:01 ` [PATCH v2 1/1] " meenakshi.aggarwal
2022-04-05 12:31 ` Horia Geantă
2022-04-20 5:57 ` Meenakshi Aggarwal
2022-04-20 6:38 ` [PATCH v3 0/1] " meenakshi.aggarwal
2022-04-20 6:38 ` [PATCH v3 1/1] " meenakshi.aggarwal
2022-04-27 11:48 ` Horia Geantă
2022-04-29 8:45 ` [PATCH v4 0/1] " meenakshi.aggarwal
2022-04-29 8:45 ` [PATCH v4 1/1] " meenakshi.aggarwal
2022-04-29 11:01 ` Horia Geantă [this message]
2022-04-29 11:48 ` [PATCH v5 0/1] " meenakshi.aggarwal
2022-04-29 11:48 ` [PATCH v5 1/1] " meenakshi.aggarwal
2022-05-06 10:22 ` Herbert Xu
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=8878ca42-6660-2d02-5bcd-2b4be4373914@nxp.com \
--to=horia.geanta@nxp.com \
--cc=V.Sethi@nxp.com \
--cc=davem@davemloft.net \
--cc=gaurav.jain@nxp.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=meenakshi.aggarwal@nxp.com \
--cc=pankaj.gupta@nxp.com \
/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
all inboxes | Powered by JetHome®