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 <mprivozn@redhat.com>
This commit is contained in:
Michal Privoznik 2018-05-29 10:01:38 +02:00
parent 620a1c6a2a
commit f785aa6c2b
5 changed files with 3 additions and 31 deletions

View File

@ -1653,7 +1653,6 @@ virConfWriteMem;
# util/vircrypto.h
virCryptoEncryptData;
virCryptoGenerateRandom;
virCryptoHashBuf;
virCryptoHashString;
virCryptoHaveCipher;

View File

@ -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 */

View File

@ -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);
}

View File

@ -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__ */

View File

@ -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)