[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] crypto_gen_random() now also works on window

From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2] crypto_gen_random() now also works on windows
Date: Tue, 25 Apr 2017 08:52:58 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0

On 04/25/2017 08:42 AM, Daniel P. Berrange wrote:
> On Mon, Apr 24, 2017 at 07:51:49PM +0200, Geert Martin Ijewski wrote:
>> If no crypto library is included in the build QEMU uses
>> qcrypto_random_bytes() to generate random data. That function tried to open
>> /dev/urandom or /dev/random and if openeing neither file worked it errored
>> out.

>> +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.

Or, use error_setg_win32(), which is designed for this purpose.

Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]