]> git.proxmox.com Git - mirror_qemu.git/commitdiff
cryptodev: setiv only when really need
authorLongpeng(Mike) <longpeng2@huawei.com>
Sat, 14 Jan 2017 06:14:27 +0000 (14:14 +0800)
committerGonglei <arei.gonglei@huawei.com>
Thu, 23 Mar 2017 09:22:01 +0000 (17:22 +0800)
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) <longpeng2@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
backends/cryptodev-builtin.c

index 82a068e79211b646ba4390a46226873c096b83ec..b24a299d9ea4d9087726dac2dd5941f4d4cc6887 100644 (file)
@@ -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) {