All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
@ 2016-09-26  9:23 Gonglei
  2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 1/3] crypto: extend mode as a parameter in qcrypto_cipher_supports() Gonglei
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Gonglei @ 2016-09-26  9:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, wu.wubin, Gonglei

Please see the detailed description in each patch.

v3:
 - adjust the sequence of patch 1 and 2. (Daniel)
 - fix a mising 'break' in code logic. (Daniel)
v2:
 - fix qtest complaint in cipher-builtin backend.
 - introduce patch 2 and patch 3.

Gonglei (3):
  crypto: extend mode as a parameter in qcrypto_cipher_supports()
  crypto: add CTR mode support
  crypto: add mode check in qcrypto_cipher_new() for cipher-builtin

 block/qcow.c               |  3 ++-
 block/qcow2.c              |  3 ++-
 crypto/cipher-builtin.c    | 25 +++++++++++++++++++-
 crypto/cipher-gcrypt.c     | 38 +++++++++++++++++++++++++------
 crypto/cipher-nettle.c     | 28 +++++++++++++++++++++--
 crypto/cipher.c            |  1 +
 include/crypto/cipher.h    | 12 ++++++----
 qapi/crypto.json           |  3 ++-
 tests/test-crypto-cipher.c | 57 +++++++++++++++++++++++++++++++++++++++++++++-
 ui/vnc.c                   |  2 +-
 10 files changed, 152 insertions(+), 20 deletions(-)

-- 
1.7.12.4

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 1/3] crypto: extend mode as a parameter in qcrypto_cipher_supports()
  2016-09-26  9:23 [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei
@ 2016-09-26  9:23 ` Gonglei
  2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 2/3] crypto: add CTR mode support Gonglei
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Gonglei @ 2016-09-26  9:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, wu.wubin, Gonglei

It can't guarantee all cipher modes are supported
if one cipher algorithm is supported by a backend.
Let's extend qcrypto_cipher_supports() to take both
the algorithm and mode as parameters.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 block/qcow.c               |  3 ++-
 block/qcow2.c              |  3 ++-
 crypto/cipher-builtin.c    | 14 +++++++++++++-
 crypto/cipher-gcrypt.c     | 13 ++++++++++++-
 crypto/cipher-nettle.c     | 13 ++++++++++++-
 include/crypto/cipher.h    |  6 ++++--
 tests/test-crypto-cipher.c |  2 +-
 ui/vnc.c                   |  2 +-
 8 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index 94f01b3..7540f43 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -153,7 +153,8 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
         ret = -EINVAL;
         goto fail;
     }
-    if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128)) {
+    if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128,
+                                 QCRYPTO_CIPHER_MODE_CBC)) {
         error_setg(errp, "AES cipher not available");
         ret = -EINVAL;
         goto fail;
diff --git a/block/qcow2.c b/block/qcow2.c
index 0e53a4d..e11c7c9 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -959,7 +959,8 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
         ret = -EINVAL;
         goto fail;
     }
-    if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128)) {
+    if (!qcrypto_cipher_supports(QCRYPTO_CIPHER_ALG_AES_128,
+                                 QCRYPTO_CIPHER_MODE_CBC)) {
         error_setg(errp, "AES cipher not available");
         ret = -EINVAL;
         goto fail;
diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index 9d25842..fd59a9e 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -400,14 +400,26 @@ static int qcrypto_cipher_init_des_rfb(QCryptoCipher *cipher,
 }
 
 
-bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg)
+bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
+                             QCryptoCipherMode mode)
 {
     switch (alg) {
     case QCRYPTO_CIPHER_ALG_DES_RFB:
     case QCRYPTO_CIPHER_ALG_AES_128:
     case QCRYPTO_CIPHER_ALG_AES_192:
     case QCRYPTO_CIPHER_ALG_AES_256:
+        break;
+    default:
+        return false;
+    }
+
+    switch (mode) {
+    case QCRYPTO_CIPHER_MODE_ECB:
+    case QCRYPTO_CIPHER_MODE_CBC:
+    case QCRYPTO_CIPHER_MODE_XTS:
         return true;
+    case QCRYPTO_CIPHER_MODE_CTR:
+        return false;
     default:
         return false;
     }
diff --git a/crypto/cipher-gcrypt.c b/crypto/cipher-gcrypt.c
index da3f4c7..05026c0 100644
--- a/crypto/cipher-gcrypt.c
+++ b/crypto/cipher-gcrypt.c
@@ -24,7 +24,8 @@
 #include <gcrypt.h>
 
 
-bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg)
+bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
+                             QCryptoCipherMode mode)
 {
     switch (alg) {
     case QCRYPTO_CIPHER_ALG_DES_RFB:
@@ -37,6 +38,16 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg)
     case QCRYPTO_CIPHER_ALG_SERPENT_256:
     case QCRYPTO_CIPHER_ALG_TWOFISH_128:
     case QCRYPTO_CIPHER_ALG_TWOFISH_256:
+        break;
+    default:
+        return false;
+    }
+
+    switch (mode) {
+    case QCRYPTO_CIPHER_MODE_ECB:
+    case QCRYPTO_CIPHER_MODE_CBC:
+    case QCRYPTO_CIPHER_MODE_XTS:
+    case QCRYPTO_CIPHER_MODE_CTR:
         return true;
     default:
         return false;
diff --git a/crypto/cipher-nettle.c b/crypto/cipher-nettle.c
index 879d831..72d1069 100644
--- a/crypto/cipher-nettle.c
+++ b/crypto/cipher-nettle.c
@@ -191,7 +191,8 @@ struct QCryptoCipherNettle {
     size_t blocksize;
 };
 
-bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg)
+bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
+                             QCryptoCipherMode mode)
 {
     switch (alg) {
     case QCRYPTO_CIPHER_ALG_DES_RFB:
@@ -205,6 +206,16 @@ bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg)
     case QCRYPTO_CIPHER_ALG_TWOFISH_128:
     case QCRYPTO_CIPHER_ALG_TWOFISH_192:
     case QCRYPTO_CIPHER_ALG_TWOFISH_256:
+        break;
+    default:
+        return false;
+    }
+
+    switch (mode) {
+    case QCRYPTO_CIPHER_MODE_ECB:
+    case QCRYPTO_CIPHER_MODE_CBC:
+    case QCRYPTO_CIPHER_MODE_XTS:
+    case QCRYPTO_CIPHER_MODE_CTR:
         return true;
     default:
         return false;
diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h
index 376654d..97638e7 100644
--- a/include/crypto/cipher.h
+++ b/include/crypto/cipher.h
@@ -85,13 +85,15 @@ struct QCryptoCipher {
 /**
  * qcrypto_cipher_supports:
  * @alg: the cipher algorithm
+ * @mode: the cipher mode
  *
- * Determine if @alg cipher algorithm is supported by the
+ * Determine if @alg cipher algorithm in @mode is supported by the
  * current configured build
  *
  * Returns: true if the algorithm is supported, false otherwise
  */
-bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg);
+bool qcrypto_cipher_supports(QCryptoCipherAlgorithm alg,
+                             QCryptoCipherMode mode);
 
 /**
  * qcrypto_cipher_get_block_len:
diff --git a/tests/test-crypto-cipher.c b/tests/test-crypto-cipher.c
index b89dfa2..8492978 100644
--- a/tests/test-crypto-cipher.c
+++ b/tests/test-crypto-cipher.c
@@ -616,7 +616,7 @@ int main(int argc, char **argv)
     g_assert(qcrypto_init(NULL) == 0);
 
     for (i = 0; i < G_N_ELEMENTS(test_data); i++) {
-        if (qcrypto_cipher_supports(test_data[i].alg)) {
+        if (qcrypto_cipher_supports(test_data[i].alg, test_data[i].mode)) {
             g_test_add_data_func(test_data[i].path, &test_data[i], test_cipher);
         }
     }
diff --git a/ui/vnc.c b/ui/vnc.c
index 76a3273..a185d60 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3650,7 +3650,7 @@ void vnc_display_open(const char *id, Error **errp)
             goto fail;
         }
         if (!qcrypto_cipher_supports(
-                QCRYPTO_CIPHER_ALG_DES_RFB)) {
+                QCRYPTO_CIPHER_ALG_DES_RFB, QCRYPTO_CIPHER_MODE_ECB)) {
             error_setg(errp,
                        "Cipher backend does not support DES RFB algorithm");
             goto fail;
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 2/3] crypto: add CTR mode support
  2016-09-26  9:23 [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei
  2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 1/3] crypto: extend mode as a parameter in qcrypto_cipher_supports() Gonglei
@ 2016-09-26  9:23 ` Gonglei
  2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 3/3] crypto: add mode check in qcrypto_cipher_new() for cipher-builtin Gonglei
  2016-09-27  9:32 ` [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei (Arei)
  3 siblings, 0 replies; 9+ messages in thread
From: Gonglei @ 2016-09-26  9:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, wu.wubin, Gonglei

Introduce CTR mode support for the cipher APIs.
CTR mode uses a counter rather than a traditional IV.
The counter has additional properties, including a nonce
and initial counter block. We reuse the ctx->iv as
the counter for conveniences.

Both libgcrypt and nettle are support CTR mode, the
cipher-builtin doesn't support yet.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 crypto/cipher-gcrypt.c     | 25 ++++++++++++++++-----
 crypto/cipher-nettle.c     | 15 ++++++++++++-
 crypto/cipher.c            |  1 +
 include/crypto/cipher.h    |  6 ++---
 qapi/crypto.json           |  3 ++-
 tests/test-crypto-cipher.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 94 insertions(+), 11 deletions(-)

diff --git a/crypto/cipher-gcrypt.c b/crypto/cipher-gcrypt.c
index 05026c0..c550db9 100644
--- a/crypto/cipher-gcrypt.c
+++ b/crypto/cipher-gcrypt.c
@@ -59,6 +59,7 @@ struct QCryptoCipherGcrypt {
     gcry_cipher_hd_t handle;
     gcry_cipher_hd_t tweakhandle;
     size_t blocksize;
+    /* Initialization vector or Counter */
     uint8_t *iv;
 };
 
@@ -80,6 +81,9 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
     case QCRYPTO_CIPHER_MODE_CBC:
         gcrymode = GCRY_CIPHER_MODE_CBC;
         break;
+    case QCRYPTO_CIPHER_MODE_CTR:
+        gcrymode = GCRY_CIPHER_MODE_CTR;
+        break;
     default:
         error_setg(errp, "Unsupported cipher mode %s",
                    QCryptoCipherMode_lookup[mode]);
@@ -350,12 +354,21 @@ int qcrypto_cipher_setiv(QCryptoCipher *cipher,
     if (ctx->iv) {
         memcpy(ctx->iv, iv, niv);
     } else {
-        gcry_cipher_reset(ctx->handle);
-        err = gcry_cipher_setiv(ctx->handle, iv, niv);
-        if (err != 0) {
-            error_setg(errp, "Cannot set IV: %s",
-                   gcry_strerror(err));
-            return -1;
+        if (cipher->mode == QCRYPTO_CIPHER_MODE_CTR) {
+            err = gcry_cipher_setctr(ctx->handle, iv, niv);
+            if (err != 0) {
+                error_setg(errp, "Cannot set Counter: %s",
+                       gcry_strerror(err));
+                return -1;
+            }
+        } else {
+            gcry_cipher_reset(ctx->handle);
+            err = gcry_cipher_setiv(ctx->handle, iv, niv);
+            if (err != 0) {
+                error_setg(errp, "Cannot set IV: %s",
+                       gcry_strerror(err));
+                return -1;
+            }
         }
     }
 
diff --git a/crypto/cipher-nettle.c b/crypto/cipher-nettle.c
index 72d1069..cd094cd 100644
--- a/crypto/cipher-nettle.c
+++ b/crypto/cipher-nettle.c
@@ -28,6 +28,7 @@
 #include <nettle/cast128.h>
 #include <nettle/serpent.h>
 #include <nettle/twofish.h>
+#include <nettle/ctr.h>
 
 typedef void (*QCryptoCipherNettleFuncWrapper)(const void *ctx,
                                                size_t length,
@@ -186,7 +187,7 @@ struct QCryptoCipherNettle {
     QCryptoCipherNettleFuncNative alg_decrypt_native;
     QCryptoCipherNettleFuncWrapper alg_encrypt_wrapper;
     QCryptoCipherNettleFuncWrapper alg_decrypt_wrapper;
-
+    /* Initialization vector or Counter */
     uint8_t *iv;
     size_t blocksize;
 };
@@ -236,6 +237,7 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
     case QCRYPTO_CIPHER_MODE_ECB:
     case QCRYPTO_CIPHER_MODE_CBC:
     case QCRYPTO_CIPHER_MODE_XTS:
+    case QCRYPTO_CIPHER_MODE_CTR:
         break;
     default:
         error_setg(errp, "Unsupported cipher mode %s",
@@ -441,6 +443,12 @@ int qcrypto_cipher_encrypt(QCryptoCipher *cipher,
                     ctx->iv, len, out, in);
         break;
 
+    case QCRYPTO_CIPHER_MODE_CTR:
+        ctr_crypt(ctx->ctx, ctx->alg_encrypt_native,
+                    ctx->blocksize, ctx->iv,
+                    len, out, in);
+        break;
+
     default:
         error_setg(errp, "Unsupported cipher mode %s",
                    QCryptoCipherMode_lookup[cipher->mode]);
@@ -480,6 +488,11 @@ int qcrypto_cipher_decrypt(QCryptoCipher *cipher,
                     ctx->alg_encrypt_wrapper, ctx->alg_decrypt_wrapper,
                     ctx->iv, len, out, in);
         break;
+    case QCRYPTO_CIPHER_MODE_CTR:
+        ctr_crypt(ctx->ctx, ctx->alg_encrypt_native,
+                    ctx->blocksize, ctx->iv,
+                    len, out, in);
+        break;
 
     default:
         error_setg(errp, "Unsupported cipher mode %s",
diff --git a/crypto/cipher.c b/crypto/cipher.c
index cafb454..a9bca41 100644
--- a/crypto/cipher.c
+++ b/crypto/cipher.c
@@ -55,6 +55,7 @@ static bool mode_need_iv[QCRYPTO_CIPHER_MODE__MAX] = {
     [QCRYPTO_CIPHER_MODE_ECB] = false,
     [QCRYPTO_CIPHER_MODE_CBC] = true,
     [QCRYPTO_CIPHER_MODE_XTS] = true,
+    [QCRYPTO_CIPHER_MODE_CTR] = true,
 };
 
 
diff --git a/include/crypto/cipher.h b/include/crypto/cipher.h
index 97638e7..bec9f41 100644
--- a/include/crypto/cipher.h
+++ b/include/crypto/cipher.h
@@ -215,16 +215,16 @@ int qcrypto_cipher_decrypt(QCryptoCipher *cipher,
 /**
  * qcrypto_cipher_setiv:
  * @cipher: the cipher object
- * @iv: the initialization vector bytes
+ * @iv: the initialization vector or counter (CTR mode) bytes
  * @niv: the length of @iv
  * @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
+ * initialization vectors or counter, this sets the @niv
  * bytes. The @iv data should have the same length as the
  * cipher key used when originally constructing the cipher
  * object. It is an error to set an initialization vector
- * if the cipher mode does not require one.
+ * or counter if the cipher mode does not require one.
  *
  * Returns: 0 on success, -1 on error
  */
diff --git a/qapi/crypto.json b/qapi/crypto.json
index 34d2583..ca2b217 100644
--- a/qapi/crypto.json
+++ b/qapi/crypto.json
@@ -89,11 +89,12 @@
 # @ecb: Electronic Code Book
 # @cbc: Cipher Block Chaining
 # @xts: XEX with tweaked code book and ciphertext stealing
+# @ctr: Counter (Since 2.8)
 # Since: 2.6
 ##
 { 'enum': 'QCryptoCipherMode',
   'prefix': 'QCRYPTO_CIPHER_MODE',
-  'data': ['ecb', 'cbc', 'xts']}
+  'data': ['ecb', 'cbc', 'xts', 'ctr']}
 
 
 ##
diff --git a/tests/test-crypto-cipher.c b/tests/test-crypto-cipher.c
index 8492978..5d9e535 100644
--- a/tests/test-crypto-cipher.c
+++ b/tests/test-crypto-cipher.c
@@ -380,6 +380,61 @@ static QCryptoCipherTestData test_data[] = {
         .key =
             "27182818284590452353602874713526"
             "31415926535897932384626433832795",
+    },
+    {
+        /* NIST F.5.1 CTR-AES128.Encrypt */
+        .path = "/crypto/cipher/aes-ctr-128",
+        .alg = QCRYPTO_CIPHER_ALG_AES_128,
+        .mode = QCRYPTO_CIPHER_MODE_CTR,
+        .key = "2b7e151628aed2a6abf7158809cf4f3c",
+        .iv = "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
+        .plaintext  =
+            "6bc1bee22e409f96e93d7e117393172a"
+            "ae2d8a571e03ac9c9eb76fac45af8e51"
+            "30c81c46a35ce411e5fbc1191a0a52ef"
+            "f69f2445df4f9b17ad2b417be66c3710",
+        .ciphertext =
+            "874d6191b620e3261bef6864990db6ce"
+            "9806f66b7970fdff8617187bb9fffdff"
+            "5ae4df3edbd5d35e5b4f09020db03eab"
+            "1e031dda2fbe03d1792170a0f3009cee",
+    },
+    {
+        /* NIST F.5.3 CTR-AES192.Encrypt */
+        .path = "/crypto/cipher/aes-ctr-192",
+        .alg = QCRYPTO_CIPHER_ALG_AES_192,
+        .mode = QCRYPTO_CIPHER_MODE_CTR,
+        .key = "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b",
+        .iv = "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
+        .plaintext  =
+            "6bc1bee22e409f96e93d7e117393172a"
+            "ae2d8a571e03ac9c9eb76fac45af8e51"
+            "30c81c46a35ce411e5fbc1191a0a52ef"
+            "f69f2445df4f9b17ad2b417be66c3710",
+        .ciphertext =
+            "1abc932417521ca24f2b0459fe7e6e0b"
+            "090339ec0aa6faefd5ccc2c6f4ce8e94"
+            "1e36b26bd1ebc670d1bd1d665620abf7"
+            "4f78a7f6d29809585a97daec58c6b050",
+    },
+    {
+        /* NIST F.5.5 CTR-AES256.Encrypt */
+        .path = "/crypto/cipher/aes-ctr-256",
+        .alg = QCRYPTO_CIPHER_ALG_AES_256,
+        .mode = QCRYPTO_CIPHER_MODE_CTR,
+        .key = "603deb1015ca71be2b73aef0857d7781"
+               "1f352c073b6108d72d9810a30914dff4",
+        .iv = "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff",
+        .plaintext  =
+            "6bc1bee22e409f96e93d7e117393172a"
+            "ae2d8a571e03ac9c9eb76fac45af8e51"
+            "30c81c46a35ce411e5fbc1191a0a52ef"
+            "f69f2445df4f9b17ad2b417be66c3710",
+        .ciphertext =
+            "601ec313775789a5b7a7f504bbf3d228"
+            "f443e3ca4d62b59aca84e990cacaf5c5"
+            "2b0930daa23de94ce87017ba2d84988d"
+            "dfc9c58db67aada613c2dd08457941a6",
     }
 };
 
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v3 3/3] crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
  2016-09-26  9:23 [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei
  2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 1/3] crypto: extend mode as a parameter in qcrypto_cipher_supports() Gonglei
  2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 2/3] crypto: add CTR mode support Gonglei
@ 2016-09-26  9:23 ` Gonglei
  2016-09-27  9:32 ` [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei (Arei)
  3 siblings, 0 replies; 9+ messages in thread
From: Gonglei @ 2016-09-26  9:23 UTC (permalink / raw)
  To: qemu-devel; +Cc: berrange, wu.wubin, Gonglei

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 crypto/cipher-builtin.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index fd59a9e..b4bc2b9 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -433,6 +433,17 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg,
 {
     QCryptoCipher *cipher;
 
+    switch (mode) {
+    case QCRYPTO_CIPHER_MODE_ECB:
+    case QCRYPTO_CIPHER_MODE_CBC:
+    case QCRYPTO_CIPHER_MODE_XTS:
+        break;
+    default:
+        error_setg(errp, "Unsupported cipher mode %s",
+                   QCryptoCipherMode_lookup[mode]);
+        return NULL;
+    }
+
     cipher = g_new0(QCryptoCipher, 1);
     cipher->alg = alg;
     cipher->mode = mode;
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
  2016-09-26  9:23 [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei
                   ` (2 preceding siblings ...)
  2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 3/3] crypto: add mode check in qcrypto_cipher_new() for cipher-builtin Gonglei
@ 2016-09-27  9:32 ` Gonglei (Arei)
  2016-09-27 12:49   ` Daniel P. Berrange
  3 siblings, 1 reply; 9+ messages in thread
From: Gonglei (Arei) @ 2016-09-27  9:32 UTC (permalink / raw)
  To: Gonglei (Arei), qemu-devel@nongnu.org; +Cc: berrange@redhat.com, Wubin (H)

Hi Daniel,

I'll post virtio-crypto v4 based on this patch set. 
Would you please merge it if it's ok? Thanks.

Regards,
-Gonglei


> -----Original Message-----
> From: Gonglei (Arei)
> Sent: Monday, September 26, 2016 5:23 PM
> To: qemu-devel@nongnu.org
> Cc: berrange@redhat.com; Wubin (H); Gonglei (Arei)
> Subject: [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
> 
> Please see the detailed description in each patch.
> 
> v3:
>  - adjust the sequence of patch 1 and 2. (Daniel)
>  - fix a mising 'break' in code logic. (Daniel)
> v2:
>  - fix qtest complaint in cipher-builtin backend.
>  - introduce patch 2 and patch 3.
> 
> Gonglei (3):
>   crypto: extend mode as a parameter in qcrypto_cipher_supports()
>   crypto: add CTR mode support
>   crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
> 
>  block/qcow.c               |  3 ++-
>  block/qcow2.c              |  3 ++-
>  crypto/cipher-builtin.c    | 25 +++++++++++++++++++-
>  crypto/cipher-gcrypt.c     | 38 +++++++++++++++++++++++++------
>  crypto/cipher-nettle.c     | 28 +++++++++++++++++++++--
>  crypto/cipher.c            |  1 +
>  include/crypto/cipher.h    | 12 ++++++----
>  qapi/crypto.json           |  3 ++-
>  tests/test-crypto-cipher.c | 57
> +++++++++++++++++++++++++++++++++++++++++++++-
>  ui/vnc.c                   |  2 +-
>  10 files changed, 152 insertions(+), 20 deletions(-)
> 
> --
> 1.7.12.4
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
  2016-09-27  9:32 ` [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei (Arei)
@ 2016-09-27 12:49   ` Daniel P. Berrange
  2016-09-28  1:09     ` Gonglei (Arei)
  2016-10-19  7:52     ` Gonglei (Arei)
  0 siblings, 2 replies; 9+ messages in thread
From: Daniel P. Berrange @ 2016-09-27 12:49 UTC (permalink / raw)
  To: Gonglei (Arei); +Cc: qemu-devel@nongnu.org, Wubin (H)

On Tue, Sep 27, 2016 at 09:32:10AM +0000, Gonglei (Arei) wrote:
> Hi Daniel,
> 
> I'll post virtio-crypto v4 based on this patch set. 
> Would you please merge it if it's ok? Thanks.
> 
> Regards,
> -Gonglei
> 
> 
> > -----Original Message-----
> > From: Gonglei (Arei)
> > Sent: Monday, September 26, 2016 5:23 PM
> > To: qemu-devel@nongnu.org
> > Cc: berrange@redhat.com; Wubin (H); Gonglei (Arei)
> > Subject: [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
> > 
> > Please see the detailed description in each patch.
> > 
> > v3:
> >  - adjust the sequence of patch 1 and 2. (Daniel)
> >  - fix a mising 'break' in code logic. (Daniel)
> > v2:
> >  - fix qtest complaint in cipher-builtin backend.
> >  - introduce patch 2 and patch 3.
> > 
> > Gonglei (3):
> >   crypto: extend mode as a parameter in qcrypto_cipher_supports()
> >   crypto: add CTR mode support
> >   crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
> > 
> >  block/qcow.c               |  3 ++-
> >  block/qcow2.c              |  3 ++-
> >  crypto/cipher-builtin.c    | 25 +++++++++++++++++++-
> >  crypto/cipher-gcrypt.c     | 38 +++++++++++++++++++++++++------
> >  crypto/cipher-nettle.c     | 28 +++++++++++++++++++++--
> >  crypto/cipher.c            |  1 +
> >  include/crypto/cipher.h    | 12 ++++++----
> >  qapi/crypto.json           |  3 ++-
> >  tests/test-crypto-cipher.c | 57
> > +++++++++++++++++++++++++++++++++++++++++++++-
> >  ui/vnc.c                   |  2 +-
> >  10 files changed, 152 insertions(+), 20 deletions(-)

These 3 patches look good and pass my build tests, so I've added them
to my crypto queue.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
  2016-09-27 12:49   ` Daniel P. Berrange
@ 2016-09-28  1:09     ` Gonglei (Arei)
  2016-10-19  7:52     ` Gonglei (Arei)
  1 sibling, 0 replies; 9+ messages in thread
From: Gonglei (Arei) @ 2016-09-28  1:09 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel@nongnu.org, Wubin (H)



> -----Original Message-----
> From: Daniel P. Berrange [mailto:berrange@redhat.com]
> Sent: Tuesday, September 27, 2016 8:50 PM
> To: Gonglei (Arei)
> Cc: qemu-devel@nongnu.org; Wubin (H)
> Subject: Re: [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
> 
> On Tue, Sep 27, 2016 at 09:32:10AM +0000, Gonglei (Arei) wrote:
> > Hi Daniel,
> >
> > I'll post virtio-crypto v4 based on this patch set.
> > Would you please merge it if it's ok? Thanks.
> >
> > Regards,
> > -Gonglei
> >
> >
> > > -----Original Message-----
> > > From: Gonglei (Arei)
> > > Sent: Monday, September 26, 2016 5:23 PM
> > > To: qemu-devel@nongnu.org
> > > Cc: berrange@redhat.com; Wubin (H); Gonglei (Arei)
> > > Subject: [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
> > >
> > > Please see the detailed description in each patch.
> > >
> > > v3:
> > >  - adjust the sequence of patch 1 and 2. (Daniel)
> > >  - fix a mising 'break' in code logic. (Daniel)
> > > v2:
> > >  - fix qtest complaint in cipher-builtin backend.
> > >  - introduce patch 2 and patch 3.
> > >
> > > Gonglei (3):
> > >   crypto: extend mode as a parameter in qcrypto_cipher_supports()
> > >   crypto: add CTR mode support
> > >   crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
> > >
> > >  block/qcow.c               |  3 ++-
> > >  block/qcow2.c              |  3 ++-
> > >  crypto/cipher-builtin.c    | 25 +++++++++++++++++++-
> > >  crypto/cipher-gcrypt.c     | 38 +++++++++++++++++++++++++------
> > >  crypto/cipher-nettle.c     | 28 +++++++++++++++++++++--
> > >  crypto/cipher.c            |  1 +
> > >  include/crypto/cipher.h    | 12 ++++++----
> > >  qapi/crypto.json           |  3 ++-
> > >  tests/test-crypto-cipher.c | 57
> > > +++++++++++++++++++++++++++++++++++++++++++++-
> > >  ui/vnc.c                   |  2 +-
> > >  10 files changed, 152 insertions(+), 20 deletions(-)
> 
> These 3 patches look good and pass my build tests, so I've added them
> to my crypto queue.
> 
Cool. There is another patch need to be picked up:

[PATCH v3] qtest: fix make check complaint in crypto module

Thanks,
-Gonglei

> Regards,
> Daniel
> --
> |: http://berrange.com      -o-
> http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org              -o-
> http://virt-manager.org :|
> |: http://autobuild.org       -o-
> http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org       -o-
> http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
  2016-09-27 12:49   ` Daniel P. Berrange
  2016-09-28  1:09     ` Gonglei (Arei)
@ 2016-10-19  7:52     ` Gonglei (Arei)
  2016-10-19  9:20       ` Daniel P. Berrange
  1 sibling, 1 reply; 9+ messages in thread
From: Gonglei (Arei) @ 2016-10-19  7:52 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: qemu-devel@nongnu.org, Wubin (H)

Hi Daniel,

Do you have a plan to send a pull request ? 

My virtio-crypto patch series rely on this patch series.

Regards,
-Gonglei

> -----Original Message-----
> From: Daniel P. Berrange [mailto:berrange@redhat.com]
> Sent: Tuesday, September 27, 2016 8:50 PM
> To: Gonglei (Arei)
> Cc: qemu-devel@nongnu.org; Wubin (H)
> Subject: Re: [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
> 
> On Tue, Sep 27, 2016 at 09:32:10AM +0000, Gonglei (Arei) wrote:
> > Hi Daniel,
> >
> > I'll post virtio-crypto v4 based on this patch set.
> > Would you please merge it if it's ok? Thanks.
> >
> > Regards,
> > -Gonglei
> >
> >
> > > -----Original Message-----
> > > From: Gonglei (Arei)
> > > Sent: Monday, September 26, 2016 5:23 PM
> > > To: qemu-devel@nongnu.org
> > > Cc: berrange@redhat.com; Wubin (H); Gonglei (Arei)
> > > Subject: [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
> > >
> > > Please see the detailed description in each patch.
> > >
> > > v3:
> > >  - adjust the sequence of patch 1 and 2. (Daniel)
> > >  - fix a mising 'break' in code logic. (Daniel)
> > > v2:
> > >  - fix qtest complaint in cipher-builtin backend.
> > >  - introduce patch 2 and patch 3.
> > >
> > > Gonglei (3):
> > >   crypto: extend mode as a parameter in qcrypto_cipher_supports()
> > >   crypto: add CTR mode support
> > >   crypto: add mode check in qcrypto_cipher_new() for cipher-builtin
> > >
> > >  block/qcow.c               |  3 ++-
> > >  block/qcow2.c              |  3 ++-
> > >  crypto/cipher-builtin.c    | 25 +++++++++++++++++++-
> > >  crypto/cipher-gcrypt.c     | 38 +++++++++++++++++++++++++------
> > >  crypto/cipher-nettle.c     | 28 +++++++++++++++++++++--
> > >  crypto/cipher.c            |  1 +
> > >  include/crypto/cipher.h    | 12 ++++++----
> > >  qapi/crypto.json           |  3 ++-
> > >  tests/test-crypto-cipher.c | 57
> > > +++++++++++++++++++++++++++++++++++++++++++++-
> > >  ui/vnc.c                   |  2 +-
> > >  10 files changed, 152 insertions(+), 20 deletions(-)
> 
> These 3 patches look good and pass my build tests, so I've added them
> to my crypto queue.
> 
> Regards,
> Daniel
> --
> |: http://berrange.com      -o-
> http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org              -o-
> http://virt-manager.org :|
> |: http://autobuild.org       -o-
> http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org       -o-
> http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement
  2016-10-19  7:52     ` Gonglei (Arei)
@ 2016-10-19  9:20       ` Daniel P. Berrange
  0 siblings, 0 replies; 9+ messages in thread
From: Daniel P. Berrange @ 2016-10-19  9:20 UTC (permalink / raw)
  To: Gonglei (Arei); +Cc: qemu-devel@nongnu.org, Wubin (H)

On Wed, Oct 19, 2016 at 07:52:38AM +0000, Gonglei (Arei) wrote:
> Hi Daniel,
> 
> Do you have a plan to send a pull request ? 
> 
> My virtio-crypto patch series rely on this patch series.

I'll do it today.


Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://entangle-photo.org       -o-    http://search.cpan.org/~danberr/ :|

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-10-19  9:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-26  9:23 [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei
2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 1/3] crypto: extend mode as a parameter in qcrypto_cipher_supports() Gonglei
2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 2/3] crypto: add CTR mode support Gonglei
2016-09-26  9:23 ` [Qemu-devel] [PATCH v3 3/3] crypto: add mode check in qcrypto_cipher_new() for cipher-builtin Gonglei
2016-09-27  9:32 ` [Qemu-devel] [PATCH v3 0/3] crypto: add ctr mode support and little inprovement Gonglei (Arei)
2016-09-27 12:49   ` Daniel P. Berrange
2016-09-28  1:09     ` Gonglei (Arei)
2016-10-19  7:52     ` Gonglei (Arei)
2016-10-19  9:20       ` Daniel P. Berrange

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.