List Archive


Thread Index


From: Thomas Klausner <>
To: Andreas Falkenhahn <>
Subject: Re: Porting zip_random() to non-Unix platform
Date: Mon, 13 Nov 2017 11:42:09 +0100

On Thu, Nov 09, 2017 at 04:11:22PM +0100, Andreas Falkenhahn wrote:
> I don't know anything about cryptography so I'm not sure if this is a
> good idea:
>     bool zip_random(zip_uint8_t *buffer, zip_uint16_t length)
>     {
>        srand(time(NULL));
>       while(length--) *buffer++ = rand() % 256;
>        return true;
>     }
> If this is not a good idea, does anybody have an idea on a
> good way of porting zip_random() to a platform that only has
> the ANSI C runtime plus a few POSIX functions?

This is fallback code. You'll have to take a close look at your
platform to find a source of real random data. I'm not aware of ANSI C
nor POSIX C providing such a thing portably.

Made by MHonArc.