[PATCH REPOST 3/4] util: Alter virCryptoEncryptData for non GNUTLS builds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rather than intermixing the ATTRIBUTE_UNUSED - use HAVE_GNUTLS_CIPHER_ENCRYPT
for the whole function instead.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/vircrypto.c | 36 +++++++++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 11 deletions(-)

diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c
index 4125230..27a3d1d 100644
--- a/src/util/vircrypto.c
+++ b/src/util/vircrypto.c
@@ -200,7 +200,6 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg,
     memset(&iv_buf, 0, sizeof(gnutls_datum_t));
     return -1;
 }
-#endif
 
 
 /* virCryptoEncryptData:
@@ -221,14 +220,14 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg,
  */
 int
 virCryptoEncryptData(virCryptoCipher algorithm,
-                     uint8_t *enckey ATTRIBUTE_UNUSED,
+                     uint8_t *enckey,
                      size_t enckeylen,
-                     uint8_t *iv ATTRIBUTE_UNUSED,
+                     uint8_t *iv,
                      size_t ivlen,
-                     uint8_t *data ATTRIBUTE_UNUSED,
-                     size_t datalen ATTRIBUTE_UNUSED,
-                     uint8_t **ciphertext ATTRIBUTE_UNUSED,
-                     size_t *ciphertextlen ATTRIBUTE_UNUSED)
+                     uint8_t *data,
+                     size_t datalen,
+                     uint8_t **ciphertext,
+                     size_t *ciphertextlen)
 {
     switch (algorithm) {
     case VIR_CRYPTO_CIPHER_AES256CBC:
@@ -246,7 +245,6 @@ virCryptoEncryptData(virCryptoCipher algorithm,
             return -1;
         }
 
-#ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
         /*
          * Encrypt the data buffer using an encryption key and
          * initialization vector via the gnutls_cipher_encrypt API
@@ -256,9 +254,6 @@ virCryptoEncryptData(virCryptoCipher algorithm,
                                              enckey, enckeylen, iv, ivlen,
                                              data, datalen,
                                              ciphertext, ciphertextlen);
-#else
-        break;
-#endif
 
     case VIR_CRYPTO_CIPHER_NONE:
     case VIR_CRYPTO_CIPHER_LAST:
@@ -270,6 +265,25 @@ virCryptoEncryptData(virCryptoCipher algorithm,
     return -1;
 }
 
+#else
+
+int
+virCryptoEncryptData(virCryptoCipher algorithm,
+                     uint8_t *enckey ATTRIBUTE_UNUSED,
+                     size_t enckeylen ATTRIBUTE_UNUSED,
+                     uint8_t *iv ATTRIBUTE_UNUSED,
+                     size_t ivlen ATTRIBUTE_UNUSED,
+                     uint8_t *data ATTRIBUTE_UNUSED,
+                     size_t datalen ATTRIBUTE_UNUSED,
+                     uint8_t **ciphertext ATTRIBUTE_UNUSED,
+                     size_t *ciphertextlen ATTRIBUTE_UNUSED)
+{
+    virReportError(VIR_ERR_INVALID_ARG,
+                   _("algorithm=%d is not supported"), algorithm);
+    return -1;
+}
+#endif
+
 /* virCryptoGenerateRandom:
  * @nbytes: Size in bytes of random byte stream to generate
  *
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]