All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gaurav Jain <gaurav.jain@nxp.com>
To: Michael Walle <michael@walle.cc>
Cc: Shengzhou Liu <shengzhou.liu@nxp.com>,
	Varun Sethi <V.Sethi@nxp.com>,
	Adrian Alonso <adrian.alonso@nxp.com>,
	Alison Wang <alison.wang@nxp.com>, Andy Tang <andy.tang@nxp.com>,
	"festevam@gmail.com" <festevam@gmail.com>,
	Franck Lenormand <franck.lenormand@nxp.com>,
	Horia Geanta <horia.geanta@nxp.com>, Ji Luo <ji.luo@nxp.com>,
	Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,
	Mingkai Hu <mingkai.hu@nxp.com>,
	"olteanv@gmail.com" <olteanv@gmail.com>,
	Pankaj Gupta <pankaj.gupta@nxp.com>,  Peng Fan <peng.fan@nxp.com>,
	Pramod Kumar <pramod.kumar_1@nxp.com>,
	Priyanka Jain <priyanka.jain@nxp.com>,
	Rajesh Bhagat <rajesh.bhagat@nxp.com>,
	Sahil Malhotra <sahil.malhotra@nxp.com>,
	"sbabic@denx.de" <sbabic@denx.de>,
	Silvano Di Ninno <silvano.dininno@nxp.com>,
	"sjg@chromium.org" <sjg@chromium.org>,
	"u-boot@lists.denx.de" <u-boot@lists.denx.de>,
	dl-uboot-imx <uboot-imx@nxp.com>, Wasim Khan <wasim.khan@nxp.com>,
	Ye Li <ye.li@nxp.com>
Subject: RE: [EXT] Re: [PATCH v5 02/16] crypto/fsl: Add CAAM support for bkek,  random number generation
Date: Tue, 16 Nov 2021 11:57:58 +0000	[thread overview]
Message-ID: <VI1PR04MB53426B406BCDF5A262954D88E7999@VI1PR04MB5342.eurprd04.prod.outlook.com> (raw)
In-Reply-To: <29891f7b0c6b990e3af1a2a7f28b28ad@walle.cc>

Hi

> -----Original Message-----
> From: Michael Walle <michael@walle.cc>
> Sent: Tuesday, November 16, 2021 4:53 PM
> To: Gaurav Jain <gaurav.jain@nxp.com>
> Cc: Shengzhou Liu <shengzhou.liu@nxp.com>; Varun Sethi
> <V.Sethi@nxp.com>; Adrian Alonso <adrian.alonso@nxp.com>; Alison Wang
> <alison.wang@nxp.com>; Andy Tang <andy.tang@nxp.com>;
> festevam@gmail.com; Franck Lenormand <franck.lenormand@nxp.com>;
> Horia Geanta <horia.geanta@nxp.com>; Ji Luo <ji.luo@nxp.com>;
> Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>; Mingkai Hu
> <mingkai.hu@nxp.com>; olteanv@gmail.com; Pankaj Gupta
> <pankaj.gupta@nxp.com>; Peng Fan <peng.fan@nxp.com>; Pramod Kumar
> <pramod.kumar_1@nxp.com>; Priyanka Jain <priyanka.jain@nxp.com>;
> Rajesh Bhagat <rajesh.bhagat@nxp.com>; Sahil Malhotra
> <sahil.malhotra@nxp.com>; sbabic@denx.de; Silvano Di Ninno
> <silvano.dininno@nxp.com>; sjg@chromium.org; u-boot@lists.denx.de; dl-
> uboot-imx <uboot-imx@nxp.com>; Wasim Khan <wasim.khan@nxp.com>;
> Ye Li <ye.li@nxp.com>
> Subject: Re: [EXT] Re: [PATCH v5 02/16] crypto/fsl: Add CAAM support for
> bkek, random number generation
> 
> Caution: EXT Email
> 
> Hi,
> 
> Am 2021-11-16 12:09, schrieb Gaurav Jain:
> >> > --- a/drivers/crypto/fsl/fsl_blob.c
> >> > +++ b/drivers/crypto/fsl/fsl_blob.c
> >> > @@ -1,6 +1,7 @@
> >> >  // SPDX-License-Identifier: GPL-2.0+
> >> >  /*
> >> >   * Copyright 2014 Freescale Semiconductor, Inc.
> >> > + * Copyright 2021 NXP
> >> >   *
> >> >   */
> >> >
> >> > @@ -152,6 +153,87 @@ int blob_encap(u8 *key_mod, u8 *src, u8 *dst,
> >> u32 len)
> >> >       return ret;
> >> >  }
> >> >
> >> > +int derive_blob_kek(u8 *bkek_buf, u8 *key_mod, u32 key_sz)
> >>
> >> where is this function actually used? looks like dead code to me.
> >
> > I was thinking to add the command for this function later.
> > But will remove this patch from this series and send this later with
> > derive blob kek cmd implementation.
> 
> ok, but you've missed the question below.
> 
> >>
> >> > +{
> >> > +     int ret, size;
> >> > +     u32 *desc;
> >> > +
> >> > +     if (!IS_ALIGNED((uintptr_t)bkek_buf, ARCH_DMA_MINALIGN) ||
> >> > +         !IS_ALIGNED((uintptr_t)key_mod, ARCH_DMA_MINALIGN)) {
> >> > +             puts("Error: derive_bkek: Address arguments are not
> aligned!\n");
> >> > +             return -EINVAL;
> >> > +     }
> >> > +
> >> > +     printf("\nBlob key encryption key(bkek)\n");
> >> > +     desc = malloc_cache_aligned(sizeof(int) * MAX_CAAM_DESCSIZE);
> >> > +     if (!desc) {
> >> > +             printf("Not enough memory for descriptor allocation\n");
> >> > +             return -ENOMEM;
> >> > +     }
> >> > +
> >> > +     size = ALIGN(key_sz, ARCH_DMA_MINALIGN);
> >> > +     flush_dcache_range((unsigned long)key_mod, (unsigned
> >> > + long)key_mod + size);
> >> > +
> >> > +     /* construct blob key encryption key(bkek) derive descriptor */
> >> > +     inline_cnstr_jobdesc_derive_bkek(desc, bkek_buf, key_mod,
> >> > + key_sz);
> >> > +
> >> > +     size = ALIGN(sizeof(int) * MAX_CAAM_DESCSIZE,
> >> ARCH_DMA_MINALIGN);
> >> > +     flush_dcache_range((unsigned long)desc, (unsigned long)desc +
> size);
> >> > +     size = ALIGN(BKEK_SIZE, ARCH_DMA_MINALIGN);
> >> > +     invalidate_dcache_range((unsigned long)bkek_buf,
> >> > +                             (unsigned long)bkek_buf + size);
> >> > +
> >> > +     /* run descriptor */
> >> > +     ret = run_descriptor_jr(desc);
> >> > +     if (ret < 0) {
> >> > +             printf("Error: %s failed 0x%x\n", __func__, ret);
> >> > +     } else {
> >> > +             invalidate_dcache_range((unsigned long)bkek_buf,
> >> > +                                     (unsigned long)bkek_buf + size);
> >> > +             puts("derive bkek successful.\n");
> >> > +     }
> >> > +
> >> > +     free(desc);
> >> > +     return ret;
> >> > +}
> >> > +
> >> > +int hwrng_generate(u8 *dst, u32 len)
> >>
> >> likewise.
> >> But more important what is the difference to drivers/crypto/fsl/rng.c?
> >> Why
> >> do you need a new function here?
> 
> This one. Why can't you reuse the code which is already there?

I might have missed to update this.
dm_rng_read() can be used. Will remove hwrng_generate().

Regards
Gaurav Jain
> 
> -michael

  reply	other threads:[~2021-11-16 11:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15  6:59 [PATCH v5 00/16] Add CAAM driver model support Gaurav Jain
2021-11-15  6:59 ` [PATCH v5 01/16] crypto/fsl: Add support for CAAM Job ring driver model Gaurav Jain
2021-11-16 11:01   ` Michael Walle
2021-11-30 10:07     ` [EXT] " Gaurav Jain
2021-11-16 15:54   ` ZHIZHIKIN Andrey
2021-11-17 11:25     ` [EXT] " Gaurav Jain
2021-11-17 13:02       ` ZHIZHIKIN Andrey
2021-11-17 20:19         ` ZHIZHIKIN Andrey
2021-11-22  7:29         ` Gaurav Jain
2021-11-22 17:20           ` ZHIZHIKIN Andrey
2021-11-23  7:22             ` Gaurav Jain
2021-11-23  9:11               ` ZHIZHIKIN Andrey
2021-11-15  7:00 ` [PATCH v5 02/16] crypto/fsl: Add CAAM support for bkek, random number generation Gaurav Jain
2021-11-16 10:45   ` Michael Walle
2021-11-16 11:09     ` [EXT] " Gaurav Jain
2021-11-16 11:23       ` Michael Walle
2021-11-16 11:57         ` Gaurav Jain [this message]
2021-11-16 12:03           ` Michael Walle
2021-11-15  7:00 ` [PATCH v5 03/16] i.MX8M: crypto: updated device tree for supporting DM in SPL Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 04/16] crypto/fsl: i.MX8M: Enable Job ring driver model in SPL and U-Boot Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 05/16] mx6sabre: Remove unnecessary SPL configs Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 06/16] i.MX6: Enable Job ring driver model in U-Boot Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 07/16] i.MX7: " Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 08/16] i.MX7ULP: " Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 09/16] i.MX8: Add crypto node in device tree Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 10/16] crypto/fsl: i.MX8: Enable Job ring driver model in SPL and U-Boot Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 11/16] crypto/fsl: Fix kick_trng Gaurav Jain
2021-11-22 19:45   ` ZHIZHIKIN Andrey
2021-11-23 10:44     ` [EXT] " Gaurav Jain
2021-11-23 10:52       ` Michael Walle
2021-11-23 13:13         ` Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 12/16] Layerscape: Add crypto node in device tree Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 13/16] Layerscape: Enable Job ring driver model in U-Boot Gaurav Jain
2021-11-16 11:20   ` Michael Walle
2021-11-30 10:09     ` [EXT] " Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 14/16] PPC: Add crypto node in device tree Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 15/16] PPC: Enable Job ring driver model in U-Boot Gaurav Jain
2021-11-15  7:00 ` [PATCH v5 16/16] update CAAM MAINTAINER Gaurav Jain

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=VI1PR04MB53426B406BCDF5A262954D88E7999@VI1PR04MB5342.eurprd04.prod.outlook.com \
    --to=gaurav.jain@nxp.com \
    --cc=V.Sethi@nxp.com \
    --cc=adrian.alonso@nxp.com \
    --cc=alison.wang@nxp.com \
    --cc=andy.tang@nxp.com \
    --cc=festevam@gmail.com \
    --cc=franck.lenormand@nxp.com \
    --cc=horia.geanta@nxp.com \
    --cc=ji.luo@nxp.com \
    --cc=meenakshi.aggarwal@nxp.com \
    --cc=michael@walle.cc \
    --cc=mingkai.hu@nxp.com \
    --cc=olteanv@gmail.com \
    --cc=pankaj.gupta@nxp.com \
    --cc=peng.fan@nxp.com \
    --cc=pramod.kumar_1@nxp.com \
    --cc=priyanka.jain@nxp.com \
    --cc=rajesh.bhagat@nxp.com \
    --cc=sahil.malhotra@nxp.com \
    --cc=sbabic@denx.de \
    --cc=shengzhou.liu@nxp.com \
    --cc=silvano.dininno@nxp.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.com \
    --cc=wasim.khan@nxp.com \
    --cc=ye.li@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 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.