From: Peter Krempa Date: Tue, 2 Feb 2021 14:44:55 +0000 (+0100) Subject: virCryptoEncryptDataAESgnutls: Use virSecureErase instead of memset X-Git-Tag: v7.1.0-rc1~316 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=91858434b4c9008719fc582455845aa1c8673491;p=thirdparty%2Flibvirt.git virCryptoEncryptDataAESgnutls: Use virSecureErase instead of memset Clear the key and IV structs using virSecureErase. Signed-off-by: Peter Krempa Reviewed-by: Daniel P. Berrangé --- diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c index d2a42d83e2..78689721c3 100644 --- a/src/util/vircrypto.c +++ b/src/util/vircrypto.c @@ -193,8 +193,8 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg, /* Encrypt the data and free the memory for cipher operations */ rc = gnutls_cipher_encrypt(handle, ciphertext, ciphertextlen); gnutls_cipher_deinit(handle); - memset(&enc_key, 0, sizeof(gnutls_datum_t)); - memset(&iv_buf, 0, sizeof(gnutls_datum_t)); + virSecureErase(&enc_key, sizeof(gnutls_datum_t)); + virSecureErase(&iv_buf, sizeof(gnutls_datum_t)); if (rc < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to encrypt the data: '%s'"), @@ -209,8 +209,8 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg, error: virSecureErase(ciphertext, ciphertextlen); g_free(ciphertext); - memset(&enc_key, 0, sizeof(gnutls_datum_t)); - memset(&iv_buf, 0, sizeof(gnutls_datum_t)); + virSecureErase(&enc_key, sizeof(gnutls_datum_t)); + virSecureErase(&iv_buf, sizeof(gnutls_datum_t)); return -1; }