On 04/25/2017 12:28 PM, 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
s/openeing/opening/ s/opening neither file worked/opening both files failed/ > errored out. > > Those files obviously do not exist on windows, so there the code uses > CryptGenRandom(). > > Furthermore there was some refactoring and a new function > qcrypto_random_init() was introduced. If a proper crypto library (gnutls > or libgcrypt) is included in the build, this function does nothing. If > neither is included it initalizes the (platform specific) handles that s/initalizes/initializes/ > are used by qcrypto_random_bytes(). > Either: > * a handle to /dev/urandom | /dev/random on unix like systems > * a handle to a cryptographic service provider on windows > > Signed-off-by: Geert Martin Ijewski <[email protected]> > --- > +int qcrypto_random_init(Error **errp) > +{ > +#ifdef _WIN32 Weird that you use #ifdef _WIN32 here... > +int qcrypto_random_bytes(uint8_t *buf G_GNUC_UNUSED, > + size_t buflen G_GNUC_UNUSED, > + Error **errp) > +{ > +#ifndef _WIN32 ...but #ifndef here. It would be more consistent if all dual-implemented functions have the #ifdefs in the same order, so that I can focus on first or second half without having to check sense. > +++ b/include/crypto/random.h > @@ -40,5 +40,14 @@ int qcrypto_random_bytes(uint8_t *buf, > size_t buflen, > Error **errp); > > +/** > + * qcrypto_random_init: > + * @errp: pointer to a NULL-initialized error object > + * > + * Initalizes the handles used by qcrypto_random_bytes s/Initalizes/Initializes/ > + * > + * Returns 0 on success, -1 on error > + */ > +int qcrypto_random_init(Error **errp); > > #endif /* QCRYPTO_RANDOM_H */ -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
