Skip to contentSkip to conversation

cryptodev: setiv only when really need

PATCH In review Longpeng(Mike) 2 participants 2 messages Jan 14, 2017 – Jan 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 backends/cryptodev-builtin.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
backends/cryptodev-builtin.c +6 -4
index 82a068e..b24a299 100644
@@ -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) {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 7 lines

From: longpeng
Sent: Saturday, January 14, 2017 2:28 PM
To: Gonglei (Arei)
Cc: Wubin (H); Zhoujian (jay, Euler); [email protected]; longpeng
Subject: [PATCH] cryptodev: setiv only when really need

Quoted 9 lines

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.

---
 backends/cryptodev-builtin.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Queued.

Thanks,
-Gonglei