qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Geert Martin Ijewski <gm.ijewski@web.de>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org, eblake@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] crypto_gen_random() now also works on windows
Date: Tue, 25 Apr 2017 19:11:40 +0200	[thread overview]
Message-ID: <004c87ba-5fd7-9d45-71a3-4435bb2927f2@web.de> (raw)
In-Reply-To: <20170425134259.GH21129@redhat.com>

Am 25.04.2017 um 15:42 schrieb Daniel P. Berrange:
> On Mon, Apr 24, 2017 at 07:51:49PM +0200, Geert Martin Ijewski wrote:
>> +#ifdef _WIN32
>> +#include <Wincrypt.h>
>> +HCRYPTPROV hCryptProv;
>> +#else
>> +int fd; /* a file handle to either /dev/urandom or /dev/random */
>> +#endif
>
>
> Lets mark both these vars 'static'

Ah yes, of course - that was a stupid error.

>>
>> +int qcrypto_random_init(Error **errp)
>> +{
>> +#ifdef _WIN32
>> +    if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,
>> +                             CRYPT_SILENT | CRYPT_VERIFYCONTEXT)) {
>> +        error_setg_errno(errp, GetLastError(),
>> +                         "Unable to create cryptographic provider");
>
> Unfortunately the return value of 'GetLastError()' isn't an errno
> so we can't use error_setg_errno here.
>
> Just use error_setg, and report the error value with a '(code=%u)'
> substitution at the end of the error message.
>
>

I'll use Eric's suggestion here, thanks to the both of you.

>> +/**
>> + * qcrypto_random_init:
>> + * @errp: pointer to a NULL-initialized error object
>> + *
>> + * Initalizes the handles used by qcrypto_random_bytes
>> + *
>> + * Returns 0 on success, -1 on error
>> + */
>> +int qcrypto_random_init(Error **errp);
>
> We need to add a stub
>
>   int qcrypto_random_init(Error **errp G_GNUC_UNUSED) { return 0; }
>
> in the random-gcrypt.c and random-gnutls.c files

Oh, I didn't think to look into the makefile... Yes, sure I'll do that too

      parent reply	other threads:[~2017-04-25 17:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 17:51 [Qemu-devel] [PATCH v2] crypto_gen_random() now also works on windows Geert Martin Ijewski
2017-04-25 13:42 ` Daniel P. Berrange
2017-04-25 13:52   ` Eric Blake
2017-04-25 13:54     ` Daniel P. Berrange
2017-04-25 17:11   ` Geert Martin Ijewski [this message]

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=004c87ba-5fd7-9d45-71a3-4435bb2927f2@web.de \
    --to=gm.ijewski@web.de \
    --cc=berrange@redhat.com \
    --cc=eblake@redhat.com \
    --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).