[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: Geert Martin Ijewski
Subject: Re: [Qemu-devel] [PATCH v2] crypto_gen_random() now also works on windows
Date: Tue, 25 Apr 2017 19:11:40 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

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>
+int fd; /* a file handle to either /dev/urandom or /dev/random */

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

reply via email to

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