From 50d19cf3681059efc8d2efcc585d2a19b9ab37c3 Mon Sep 17 00:00:00 2001 From: "Longpeng(Mike)" Date: Sat, 14 Jan 2017 14:14:27 +0800 Subject: cryptodev: setiv only when really need ECB mode cipher doesn't need IV, if we setiv for it then qemu crypto API would report "Expected IV size 0 not **", so we should setiv only when the cipher algos really need. Signed-off-by: Longpeng(Mike) Signed-off-by: Gonglei --- backends/cryptodev-builtin.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index 82a068e792..b24a299d9e 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -320,10 +320,12 @@ static int cryptodev_builtin_sym_operation( sess = builtin->sessions[op_info->session_id]; - ret = qcrypto_cipher_setiv(sess->cipher, op_info->iv, - op_info->iv_len, errp); - if (ret < 0) { - return -VIRTIO_CRYPTO_ERR; + if (op_info->iv_len > 0) { + ret = qcrypto_cipher_setiv(sess->cipher, op_info->iv, + op_info->iv_len, errp); + if (ret < 0) { + return -VIRTIO_CRYPTO_ERR; + } } if (sess->direction == VIRTIO_CRYPTO_OP_ENCRYPT) { -- cgit v1.2.3 From b7bad50ae81efeb180609eeecdb086ebc7536ed7 Mon Sep 17 00:00:00 2001 From: Halil Pasic Date: Wed, 22 Mar 2017 13:36:55 +0100 Subject: cryptodev: fix asserting single queue We already check for queues == 1 in cryptodev_builtin_init and when that is not true raise an error. But before that error is reported the assertion in cryptodev_builtin_cleanup kicks in (because object is being finalized and freed). Let's remove assert(queues == 1) form cryptodev_builtin_cleanup as it does only harm and no good. Reported-by: Boris Fiuczynski Signed-off-by: Halil Pasic Reviewed-by: Eric Blake Signed-off-by: Gonglei --- backends/cryptodev-builtin.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/backends/cryptodev-builtin.c b/backends/cryptodev-builtin.c index b24a299d9e..657c0ba2f3 100644 --- a/backends/cryptodev-builtin.c +++ b/backends/cryptodev-builtin.c @@ -361,8 +361,6 @@ static void cryptodev_builtin_cleanup( } } - assert(queues == 1); - for (i = 0; i < queues; i++) { cc = backend->conf.peers.ccs[i]; if (cc) { -- cgit v1.2.3