qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: GM.Ijewski@web.de, QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] error: qcrypto_random_bytes() tried to read from /dev/[u]random, even on windows
Date: Mon, 24 Apr 2017 14:36:24 +0100	[thread overview]
Message-ID: <20170424133624.GP20809@redhat.com> (raw)
In-Reply-To: <CAFEAcA_p7rWmuRZ20PHBPfXoKswz95PtOjG866kaC2ooKx70PQ@mail.gmail.com>

On Mon, Apr 24, 2017 at 02:30:25PM +0100, Peter Maydell wrote:
> On 24 April 2017 at 13:50, Daniel P. Berrange <berrange@redhat.com> wrote:
> > For subject line, better to describe the change made, rather than
> > the problem.
> >
> > On Mon, Apr 24, 2017 at 02:17:56PM +0200, GM.Ijewski@web.de wrote:
> >> Now it calls CryptGenRandom() if is it compiled for windows.
> >>
> >> It might be possible to save the cryptographic provider in between
> >> invocations, e.g. by making it static -- I have no idea how computationally
> >> intensive that operation actually is.
> >
> > I'd think most people should really just enable gnutls during build. This just
> > has to provide a fallback that's good enough to be functional. If someone really
> > cares about performance of this fallback, they can send patches later....
> 
> What I think is more worrying is the suggestion in the CryptAcquireContext
> docs that this might for instance prompt the user for a password to
> decrypt keys. We definitely don't want to do that every time. In
> fact we'd rather not do it at all.
> 
> Googling suggests that the approach used by web browsers is
> to use the not-very-documented RtlGenRandom function:
> https://dxr.mozilla.org/mozilla-central/source/security/nss/lib/freebl/win_rand.c#141
> https://chromium.googlesource.com/chromium/src.git/+/master/base/rand_util_win.cc
> 
> That looks much simpler than trying to use the official crypto
> APIs. (It's also what the MS C runtime library does to implement
> rand_s().)

FYI, both gnutls and openssl use these CryptAcquireContext/CryptGenRandom
methods, so I'd prefer to stick with that.

It seems we merely need to set CRYPT_SILENT in the flags to prevent any
chance of interactive prompts.

https://msdn.microsoft.com/en-us/library/windows/desktop/aa379886(v=vs.85).aspx

"CRYPT_SILENT is intended for use with applications for which the UI
 cannot be displayed by the CSP."

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

  reply	other threads:[~2017-04-24 13:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 12:17 [Qemu-devel] error: qcrypto_random_bytes() tried to read from /dev/[u]random, even on windows GM.Ijewski
2017-04-24 12:50 ` Daniel P. Berrange
2017-04-24 13:30   ` Peter Maydell
2017-04-24 13:36     ` Daniel P. Berrange [this message]
2017-04-24 13:52       ` Peter Maydell
2017-04-24 13:57         ` Daniel P. Berrange
2017-04-24 14:05           ` Peter Maydell
2017-04-24 15:41             ` Daniel P. Berrange
2017-04-24 15:42               ` Peter Maydell
2017-04-24 15:52                 ` Daniel P. Berrange
2017-04-24 16:33                   ` Geert Martin Ijewski
2017-04-24 16:39                     ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170424133624.GP20809@redhat.com \
    --to=berrange@redhat.com \
    --cc=GM.Ijewski@web.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).