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] [day] [month] [year] [list]
Date:   Wed, 24 May 2023 11:56:16 +0000
From:   Bharat Bhushan <bbhushan2@...vell.com>
To:     Herbert Xu <herbert@...dor.apana.org.au>
CC:     "olivia@...enic.com" <olivia@...enic.com>,
        "Jason@...c4.com" <Jason@...c4.com>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Sunil Kovvuri Goutham <sgoutham@...vell.com>
Subject: RE: [EXT] Re: [PATCH] hwrng: cn10k: Add extended trng register
 support



> -----Original Message-----
> From: Herbert Xu <herbert@...dor.apana.org.au>
> Sent: Wednesday, May 24, 2023 3:26 PM
> To: Bharat Bhushan <bbhushan2@...vell.com>
> Cc: olivia@...enic.com; Jason@...c4.com; linux-crypto@...r.kernel.org; linux-
> kernel@...r.kernel.org; Sunil Kovvuri Goutham <sgoutham@...vell.com>
> Subject: [EXT] Re: [PATCH] hwrng: cn10k: Add extended trng register support
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Thu, May 18, 2023 at 12:17:34PM +0530, Bharat Bhushan wrote:
> >
> > -static void cn10k_read_trng(struct cn10k_rng *rng, u64 *value)
> > +static size_t cn10k_read_trng(struct cn10k_rng *rng, u64 *value)
> 
> Since the return value is either 0 or 8, why did you pick size_t as the return value?

This function returns number of valid bytes available in "value". 0 means no valid data. size_t is definitely wrong.
I think I will make this function to return bool, true when data is valid and false when data is not valid.

Thanks
-Bharat

> 
> >  {
> > +	u16 retry_count = 0;
> >  	u64 upper, lower;
> > +	u64 status;
> > +
> > +	if (rng->extended_trng_regs) {
> > +		do {
> > +			*value = readq(rng->reg_base + RNM_PF_TRNG_DAT);
> > +			if (*value)
> > +				return 8;
> > +			status = readq(rng->reg_base + RNM_PF_TRNG_RES);
> > +			if (!status && (retry_count++ > 0x1000))
> > +				return 0;
> > +		} while (!status);
> > +	}
> >
> >  	*value = readq(rng->reg_base + RNM_PF_RANDOM);
> >
> > @@ -82,6 +130,7 @@ static void cn10k_read_trng(struct cn10k_rng *rng,
> > u64 *value)
> >
> >  		*value = (upper & 0xFFFFFFFF00000000) | (lower & 0xFFFFFFFF);
> >  	}
> > +	return 8;
> >  }
> >
> >  static int cn10k_rng_read(struct hwrng *hwrng, void *data, @@ -100,7
> > +149,9 @@ static int cn10k_rng_read(struct hwrng *hwrng, void *data,
> >  	size = max;
> >
> >  	while (size >= 8) {
> > -		cn10k_read_trng(rng, &value);
> > +		err = cn10k_read_trng(rng, &value);
> > +		if (!err)
> > +			goto out;
> 
> It appears that err is either 8 or 0, so it's not really an error.
> Could you plesae use a more meaningful name for this variable?
> 
> Cheers,
> --
> Email: Herbert Xu <herbert@...dor.apana.org.au> Home Page:
> https://urldefense.proofpoint.com/v2/url?u=http-3A__gondor.apana.org.au_-
> 7Eherbert_&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=PAAlWswPe7d8gHlGb
> CLmy2YezyK7O3Hv_t2heGnouBw&m=Ya8SJ6OhypttG2itpa39dd7kXwEXGgbUOJ2
> Hqi95w7MetfxqRKKFX7aluHaLZpoc&s=pnRAp3oSzsNrbEAHZdLM6Eb9M4tDMxEd
> WLzANKejHwU&e=
> PGP Key: https://urldefense.proofpoint.com/v2/url?u=http-
> 3A__gondor.apana.org.au_-
> 7Eherbert_pubkey.txt&d=DwIBAg&c=nKjWec2b6R0mOyPaz7xtfQ&r=PAAlWswP
> e7d8gHlGbCLmy2YezyK7O3Hv_t2heGnouBw&m=Ya8SJ6OhypttG2itpa39dd7kXwE
> XGgbUOJ2Hqi95w7MetfxqRKKFX7aluHaLZpoc&s=pLpT-
> xdKvVvCI4sp5r8r5qYoKeEx537Gnlkq1dpTrYY&e=

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ