summaryrefslogtreecommitdiffstats
path: root/qemu/include/crypto/cipher.h
diff options
context:
space:
mode:
authorJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:18:31 +0300
committerJosé Pekkarinen <jose.pekkarinen@nokia.com>2016-05-18 13:42:15 +0300
commit437fd90c0250dee670290f9b714253671a990160 (patch)
treeb871786c360704244a07411c69fb58da9ead4a06 /qemu/include/crypto/cipher.h
parent5bbd6fe9b8bab2a93e548c5a53b032d1939eec05 (diff)
These changes are the raw update to qemu-2.6.
Collission happened in the following patches: migration: do cleanup operation after completion(738df5b9) Bug fix.(1750c932f86) kvmclock: add a new function to update env->tsc.(b52baab2) The code provided by the patches was already in the upstreamed version. Change-Id: I3cc11841a6a76ae20887b2e245710199e1ea7f9a Signed-off-by: José Pekkarinen <jose.pekkarinen@nokia.com>
Diffstat (limited to 'qemu/include/crypto/cipher.h')
-rw-r--r--qemu/include/crypto/cipher.h65
1 files changed, 44 insertions, 21 deletions
diff --git a/qemu/include/crypto/cipher.h b/qemu/include/crypto/cipher.h
index b4d714f26..d770c4835 100644
--- a/qemu/include/crypto/cipher.h
+++ b/qemu/include/crypto/cipher.h
@@ -21,26 +21,12 @@
#ifndef QCRYPTO_CIPHER_H__
#define QCRYPTO_CIPHER_H__
-#include "qemu-common.h"
-#include "qapi/error.h"
+#include "qapi-types.h"
typedef struct QCryptoCipher QCryptoCipher;
-typedef enum {
- QCRYPTO_CIPHER_ALG_AES_128,
- QCRYPTO_CIPHER_ALG_AES_192,
- QCRYPTO_CIPHER_ALG_AES_256,
- QCRYPTO_CIPHER_ALG_DES_RFB, /* A stupid variant on DES for VNC */
-
- QCRYPTO_CIPHER_ALG_LAST
-} QCryptoCipherAlgorithm;
-
-typedef enum {
- QCRYPTO_CIPHER_MODE_ECB,
- QCRYPTO_CIPHER_MODE_CBC,
-
- QCRYPTO_CIPHER_MODE_LAST
-} QCryptoCipherMode;
+/* See also "QCryptoCipherAlgorithm" and "QCryptoCipherMode"
+ * enums defined in qapi/crypto.json */
/**
* QCryptoCipher:
@@ -107,6 +93,43 @@ struct QCryptoCipher {
*/
bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg);
+/**
+ * qcrypto_cipher_get_block_len:
+ * @alg: the cipher algorithm
+ *
+ * Get the required data block size in bytes. When
+ * encrypting data, it must be a multiple of the
+ * block size.
+ *
+ * Returns: the block size in bytes
+ */
+size_t qcrypto_cipher_get_block_len(QCryptoCipherAlgorithm alg);
+
+
+/**
+ * qcrypto_cipher_get_key_len:
+ * @alg: the cipher algorithm
+ *
+ * Get the required key size in bytes.
+ *
+ * Returns: the key size in bytes
+ */
+size_t qcrypto_cipher_get_key_len(QCryptoCipherAlgorithm alg);
+
+
+/**
+ * qcrypto_cipher_get_iv_len:
+ * @alg: the cipher algorithm
+ * @mode: the cipher mode
+ *
+ * Get the required initialization vector size
+ * in bytes, if one is required.
+ *
+ * Returns: the IV size in bytes, or 0 if no IV is permitted
+ */
+size_t qcrypto_cipher_get_iv_len(QCryptoCipherAlgorithm alg,
+ QCryptoCipherMode mode);
+
/**
* qcrypto_cipher_new:
@@ -114,7 +137,7 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg);
* @mode: the cipher usage mode
* @key: the private key bytes
* @nkey: the length of @key
- * @errp: pointer to an uninitialized error object
+ * @errp: pointer to a NULL-initialized error object
*
* Creates a new cipher object for encrypting/decrypting
* data with the algorithm @alg in the usage mode @mode.
@@ -150,7 +173,7 @@ void qcrypto_cipher_free(QCryptoCipher *cipher);
* @in: buffer holding the plain text input data
* @out: buffer to fill with the cipher text output data
* @len: the length of @in and @out buffers
- * @errp: pointer to an uninitialized error object
+ * @errp: pointer to a NULL-initialized error object
*
* Encrypts the plain text stored in @in, filling
* @out with the resulting ciphered text. Both the
@@ -172,7 +195,7 @@ int qcrypto_cipher_encrypt(QCryptoCipher *cipher,
* @in: buffer holding the cipher text input data
* @out: buffer to fill with the plain text output data
* @len: the length of @in and @out buffers
- * @errp: pointer to an uninitialized error object
+ * @errp: pointer to a NULL-initialized error object
*
* Decrypts the cipher text stored in @in, filling
* @out with the resulting plain text. Both the
@@ -192,7 +215,7 @@ int qcrypto_cipher_decrypt(QCryptoCipher *cipher,
* @cipher: the cipher object
* @iv: the initialization vector bytes
* @niv: the length of @iv
- * @errpr: pointer to an uninitialized error object
+ * @errpr: pointer to a NULL-initialized error object
*
* If the @cipher object is setup to use a mode that requires
* initialization vectors, this sets the initialization vector