提交 896c4862 编写于 作者: J John Ferlan

util: Alter virCryptoEncryptData for non GNUTLS builds

Rather than intermixing the ATTRIBUTE_UNUSED - use HAVE_GNUTLS_CIPHER_ENCRYPT
for the whole function instead.
上级 1fd8fc8f
...@@ -200,7 +200,6 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg, ...@@ -200,7 +200,6 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg,
memset(&iv_buf, 0, sizeof(gnutls_datum_t)); memset(&iv_buf, 0, sizeof(gnutls_datum_t));
return -1; return -1;
} }
#endif
/* virCryptoEncryptData: /* virCryptoEncryptData:
...@@ -221,14 +220,14 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg, ...@@ -221,14 +220,14 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg,
*/ */
int int
virCryptoEncryptData(virCryptoCipher algorithm, virCryptoEncryptData(virCryptoCipher algorithm,
uint8_t *enckey ATTRIBUTE_UNUSED, uint8_t *enckey,
size_t enckeylen, size_t enckeylen,
uint8_t *iv ATTRIBUTE_UNUSED, uint8_t *iv,
size_t ivlen, size_t ivlen,
uint8_t *data ATTRIBUTE_UNUSED, uint8_t *data,
size_t datalen ATTRIBUTE_UNUSED, size_t datalen,
uint8_t **ciphertext ATTRIBUTE_UNUSED, uint8_t **ciphertext,
size_t *ciphertextlen ATTRIBUTE_UNUSED) size_t *ciphertextlen)
{ {
switch (algorithm) { switch (algorithm) {
case VIR_CRYPTO_CIPHER_AES256CBC: case VIR_CRYPTO_CIPHER_AES256CBC:
...@@ -246,7 +245,6 @@ virCryptoEncryptData(virCryptoCipher algorithm, ...@@ -246,7 +245,6 @@ virCryptoEncryptData(virCryptoCipher algorithm,
return -1; return -1;
} }
#ifdef HAVE_GNUTLS_CIPHER_ENCRYPT
/* /*
* Encrypt the data buffer using an encryption key and * Encrypt the data buffer using an encryption key and
* initialization vector via the gnutls_cipher_encrypt API * initialization vector via the gnutls_cipher_encrypt API
...@@ -256,9 +254,6 @@ virCryptoEncryptData(virCryptoCipher algorithm, ...@@ -256,9 +254,6 @@ virCryptoEncryptData(virCryptoCipher algorithm,
enckey, enckeylen, iv, ivlen, enckey, enckeylen, iv, ivlen,
data, datalen, data, datalen,
ciphertext, ciphertextlen); ciphertext, ciphertextlen);
#else
break;
#endif
case VIR_CRYPTO_CIPHER_NONE: case VIR_CRYPTO_CIPHER_NONE:
case VIR_CRYPTO_CIPHER_LAST: case VIR_CRYPTO_CIPHER_LAST:
...@@ -270,6 +265,25 @@ virCryptoEncryptData(virCryptoCipher algorithm, ...@@ -270,6 +265,25 @@ virCryptoEncryptData(virCryptoCipher algorithm,
return -1; 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: /* virCryptoGenerateRandom:
* @nbytes: Size in bytes of random byte stream to generate * @nbytes: Size in bytes of random byte stream to generate
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册