From: Michal Privoznik Date: Tue, 29 May 2018 08:01:38 +0000 (+0200) Subject: vircrypto: Drop virCryptoGenerateRandom X-Git-Tag: v4.5.0-rc1~260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f785aa6c2bd8814ee4282d6ac990b7d7650dfa40;p=thirdparty%2Flibvirt.git vircrypto: Drop virCryptoGenerateRandom Now that virCryptoGenerateRandom() is plain wrapper over virRandomBytes() we can drop it in favour of the latter. Signed-off-by: Michal Privoznik --- diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 206107befd..5540391fe8 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1653,7 +1653,6 @@ virConfWriteMem; # util/vircrypto.h virCryptoEncryptData; -virCryptoGenerateRandom; virCryptoHashBuf; virCryptoHashString; virCryptoHaveCipher; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index c4c25e95d0..2dd4e5ef5f 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -51,6 +51,7 @@ #include "viratomic.h" #include "virprocess.h" #include "vircrypto.h" +#include "virrandom.h" #include "virsystemd.h" #include "secret_util.h" #include "logging/log_manager.h" @@ -934,7 +935,7 @@ qemuDomainMasterKeyCreate(virDomainObjPtr vm) return -1; priv->masterKeyLen = QEMU_DOMAIN_MASTER_KEY_LEN; - if (virCryptoGenerateRandom(priv->masterKey, priv->masterKeyLen) < 0) { + if (virRandomBytes(priv->masterKey, priv->masterKeyLen) < 0) { VIR_DISPOSE_N(priv->masterKey, priv->masterKeyLen); return -1; } @@ -1288,7 +1289,7 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv, goto cleanup; /* Create a random initialization vector */ - if (virCryptoGenerateRandom(raw_iv, ivlen) < 0) + if (virRandomBytes(raw_iv, ivlen) < 0) goto cleanup; /* Encode the IV and save that since qemu will need it */ diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index 3f3ba0267a..d734ce6ad7 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -314,21 +314,3 @@ virCryptoEncryptData(virCryptoCipher algorithm, return -1; } #endif - -/* virCryptoGenerateRandom: - * @buf: Pointer to location to store bytes - * @buflen: Number of bytes to store - * - * Generate a random stream of @buflen length and store it into @buf. - * - * Since the gnutls_rnd could be missing, provide an alternate less - * secure mechanism to at least have something. - * - * Returns 0 on success or -1 on failure (with error reported) - */ -int -virCryptoGenerateRandom(unsigned char *buf, - size_t buflen) -{ - return virRandomBytes(buf, buflen); -} diff --git a/src/util/vircrypto.h b/src/util/vircrypto.h index 649ceff1a1..e3c70d7d9a 100644 --- a/src/util/vircrypto.h +++ b/src/util/vircrypto.h @@ -65,7 +65,4 @@ int virCryptoEncryptData(virCryptoCipher algorithm, ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(6) ATTRIBUTE_NONNULL(8) ATTRIBUTE_NONNULL(9) ATTRIBUTE_RETURN_CHECK; -int virCryptoGenerateRandom(unsigned char *buf, - size_t buflen) ATTRIBUTE_NOINLINE; - #endif /* __VIR_CRYPTO_H__ */ diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index cc3bf2095c..a4de7f0c46 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -190,13 +190,6 @@ virCommandPassFD(virCommandPtr cmd ATTRIBUTE_UNUSED, /* nada */ } -int -virCryptoGenerateRandom(unsigned char *buf, - size_t buflen) -{ - return virRandomBytes(buf, buflen); -} - int virNetDevOpenvswitchGetVhostuserIfname(const char *path ATTRIBUTE_UNUSED, char **ifname)