This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

/dev/[u]random sources


>
>
>int
>fhandler_dev_random::write (const void *ptr, size_t len)
>{
>  if (!len)
>    return 0;
>  if (!ptr)
>    {
>      set_errno (EINVAL);
>      return -1;
>    }
>
>  /* Limit len to a value <= 512 since we don't want to overact.
>     Copy to local buffer because CryptGenRandom violates const. */
>  unsigned char buf[512];
>  size_t limited_len = len <= 512 ? len : 512;
>  memcpy (buf, ptr, limited_len);
>
>  /* Mess up system entropy source. Return error if device is /dev/random. */
>  if (!crypt_gen_random (buf, limited_len) && unit == RANDOM)
>    {
>      __seterrno ();
>      return -1;
>    }
>  /* Mess up the pseudo random number generator. */
>  pseudo_write (buf, limited_len);
>  return len;
>}
>
I think chaning the comment from

/* Mess up system entropy source. Return error if device is /dev/random. */

to

/* Mess up system entropy source. Return eventual error only if device is /dev/random. */

could clarify things a bit, at least for me it took a bit of time to 
notice that the Windows system call is used both for seeding and for 
retreiving and that that "if" does actually seed the buffer and returns 
error only if failed it (AND it is /dev/random).

Of course this is not an important/urgent issue at all.

Paranoic issue: how good is the default windows crypto provider? does it 
uses (at least on the NT series, I mean) latency from h/w and so on?
I can find no such infos on MSDN as they are provider-specific.

-- 
Lapo 'Raist' Luchini
lapo@lapo.it (PGP & X.509 keys available)
http://www.lapo.it (ICQ UIN: 529796)



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]