From: Stephan =?ISO-8859-1?Q?M=FCller?= Subject: Re: [PATCH v3 1/3] crypto: hw_random - Add new Exynos RNG driver Date: Mon, 27 Mar 2017 15:53:03 +0200 Message-ID: <1564458.pWTRdRYEuG@positron.chronox.de> References: <20170325162654.3827-1-krzk@kernel.org> <4479175.Jfq03yCxQW@tauon.atsec.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Cc: linux-samsung-soc@vger.kernel.org, Herbert Xu , Arnd Bergmann , Bartlomiej Zolnierkiewicz , linux-kernel@vger.kernel.org, Krzysztof Kozlowski , Javier Martinez Canillas , Kukjin Kim , linux-crypto@vger.kernel.org, Matt Mackall , Olof Johansson , "David S. Miller" , linux-arm-kernel@lists.infradead.org To: PrasannaKumar Muralidharan Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org List-Id: linux-crypto.vger.kernel.org Am Montag, 27. M=E4rz 2017, 06:23:11 CEST schrieb PrasannaKumar Muralidhara= n: Hi PrasannaKumar, > > Oh my, if you are right with your first guess, this is a bad DRNG desig= n. > > = > > Just out of curiousity: what happens if a caller invokes the seed funct= ion > > twice or more times (each time with the sufficient amount of bits)? What > > is > > your guess here? > = > Should the second seed use the random data generated by the device? A DRNG should be capable of processing an arbitrary amount of seed data. It = may be the case that the seed data must be processed in chunks though. That said, it may be the case that after injecting one chunk of seed the = currently discussed RNG simply needs to generate a random number to process = the input data before another seed can be added. But that is pure speculati= on. But I guess that can be easily tested: inject a known seed into the DRNG, = generate a random number, inject the same seed again and again generate a = random number. If both are identical (which I do not hope), then the intern= al = state is simply overwritten (strange DRNG design). A similar test can be made to see whether a larger set of seed simply = overwrites the state or is really processed. 1. seed 2. generate random data 3. reset 4. seed with anther seed 5. generate random data 6. reset 7. seed with same data from 1 8. seed with same data from 2 9. generate random data If data from 9 is identical to 2, then additional seed data is discarded -> = bad design. If data from 9 is identical to 5, then the additional data = overwrites the initial data -> bad DRNG design. If data from 9 neither matc= hes = 2 or 5, then all seed is taken -> good design. Ciao Stephan