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]
Message-ID: <CANc+2y60cCtDwBi1jaV=eMtTwoihRf2WiKW7Zo3iC9ALv2OVSw@mail.gmail.com>
Date:   Wed, 12 Feb 2020 21:54:51 +0530
From:   PrasannaKumar Muralidharan <prasannatsmkumar@...il.com>
To:     Martin Kaiser <martin@...ser.cx>
Cc:     Herbert Xu <herbert@...dor.apana.org.au>,
        NXP Linux Team <linux-imx@....com>,
        "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" 
        <linux-crypto@...r.kernel.org>,
        linux-arm-kernel@...ts.infradead.org,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/6] hwrng: imx-rngc - use automatic seeding

On Tue, 28 Jan 2020 at 16:31, Martin Kaiser <martin@...ser.cx> wrote:
>
> The rngc requires a new seed for its prng after generating 2^20 160-bit
> words of random data. At the moment, we seed the prng only once during
> initalisation.
>
> Set the rngc to auto seed mode so that it kicks off the internal
> reseeding operation when a new seed is required.
>
> Keep the manual calculation of the initial seed when the device is
> probed and switch to automatic seeding afterwards.
>
> Signed-off-by: Martin Kaiser <martin@...ser.cx>
> ---
>  drivers/char/hw_random/imx-rngc.c | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/hw_random/imx-rngc.c b/drivers/char/hw_random/imx-rngc.c
> index 0576801944fd..903894518c8d 100644
> --- a/drivers/char/hw_random/imx-rngc.c
> +++ b/drivers/char/hw_random/imx-rngc.c
> @@ -31,6 +31,7 @@
>
>  #define RNGC_CTRL_MASK_ERROR           0x00000040
>  #define RNGC_CTRL_MASK_DONE            0x00000020
> +#define RNGC_CTRL_AUTO_SEED            0x00000010
>
>  #define RNGC_STATUS_ERROR              0x00010000
>  #define RNGC_STATUS_FIFO_LEVEL_MASK    0x00000f00
> @@ -167,7 +168,7 @@ static irqreturn_t imx_rngc_irq(int irq, void *priv)
>  static int imx_rngc_init(struct hwrng *rng)
>  {
>         struct imx_rngc *rngc = container_of(rng, struct imx_rngc, rng);
> -       u32 cmd;
> +       u32 cmd, ctrl;
>         int ret;
>
>         /* clear error */
> @@ -192,7 +193,18 @@ static int imx_rngc_init(struct hwrng *rng)
>
>         } while (rngc->err_reg == RNGC_ERROR_STATUS_STAT_ERR);
>
> -       return rngc->err_reg ? -EIO : 0;
> +       if (rngc->err_reg)
> +               return -EIO;
> +
> +       /*
> +        * enable automatic seeding, the rngc creates a new seed automatically
> +        * after serving 2^20 random 160-bit words
> +        */
> +       ctrl = readl(rngc->base + RNGC_CONTROL);
> +       ctrl |= RNGC_CTRL_AUTO_SEED;
> +       writel(ctrl, rngc->base + RNGC_CONTROL);
> +
> +       return 0;
>  }
>
>  static int imx_rngc_probe(struct platform_device *pdev)
> --
> 2.20.1
>

Reviewed-by: PrasannaKumar Muralidharan <prasannatsmkumar@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ