Re: [RFC PATCH] crypto: make the seed() function optional

From: PrasannaKumar Muralidharan
Date: Sun Oct 08 2017 - 10:11:23 EST


Hi Herbert,

On 7 October 2017 at 09:03, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
> Mathieu Malaterre <malat@xxxxxxxxxx> wrote:
>> This makes it simplier for driver author to not provide the seed() function
>> in case of a pseudo RNG where the seed operation is a no-op.
>>
>> Document that the seed() function pointer is optional in header.
>>
>> Signed-off-by: Mathieu Malaterre <malat@xxxxxxxxxx>
>> ---
>> The PRNG as found on Ingenic JZ4780 is one such example. This is found on a
>> MIPS Creator CI20 SoC.
>
> So how does it seed itself? This also contradicts with the JZ4780
> driver that's currently in the patch queue as it does contain a
> seed function.

The current version of JZ4780 driver in the patch queue indeed has
seed function. But when Mathieu sent this email based on v2 of the
driver. V2 did not have seed callback. Using v2 resulted in a NULL
pointer in kernel. This patch prevents that NULL pointer access.

Regardless of what JZ4780 driver has this patch makes sense.

Currently crypto framework does not mandate seed callback's presence.
If mandatory, crypto framework should error out if seed is not
implemented while registering the PRNG.

Thanks,
PrasannaKumar