Now that virCryptoGenerateRandom() is plain wrapper over
virRandomBytes() we can drop it in favour of the latter.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libvirt_private.syms | 1 -
src/qemu/qemu_domain.c | 5 +++--
src/util/vircrypto.c | 18 ------------------
src/util/vircrypto.h | 3 ---
tests/qemuxml2argvmock.c | 7 -------
5 files changed, 3 insertions(+), 31 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 8d381ee11b..18c0c3e954 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1649,7 +1649,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 2d13a03344..e49398432f 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, QEMU_DOMAIN_MASTER_KEY_LEN) < 0)
+ if (virRandomBytes(priv->masterKey, QEMU_DOMAIN_MASTER_KEY_LEN) < 0)
return -1;
return 0;
@@ -1219,7 +1220,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 44b6504de9..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)
--
2.16.1