All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cryptodev: setiv only when really need
@ 2017-01-14  6:28 Longpeng(Mike)
  2017-01-16  6:32 ` Gonglei (Arei)
  0 siblings, 1 reply; 2+ messages in thread
From: Longpeng(Mike) @ 2017-01-14  6:28 UTC (permalink / raw)
  To: arei.gonglei; +Cc: wu.wubin, jianjay.zhou, qemu-devel, Longpeng(Mike)

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>
---
 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 82a068e..b24a299 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) {
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH] cryptodev: setiv only when really need
  2017-01-14  6:28 [Qemu-devel] [PATCH] cryptodev: setiv only when really need Longpeng(Mike)
@ 2017-01-16  6:32 ` Gonglei (Arei)
  0 siblings, 0 replies; 2+ messages in thread
From: Gonglei (Arei) @ 2017-01-16  6:32 UTC (permalink / raw)
  To: longpeng; +Cc: Wubin (H), Zhoujian (jay, Euler), qemu-devel

>
> From: longpeng
> Sent: Saturday, January 14, 2017 2:28 PM
> To: Gonglei (Arei)
> Cc: Wubin (H); Zhoujian (jay, Euler); qemu-devel@nongnu.org; longpeng
> Subject: [PATCH] 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) <longpeng2@huawei.com>
> ---
>  backends/cryptodev-builtin.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
Queued.

Thanks,
-Gonglei

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

end of thread, other threads:[~2017-01-16  6:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-14  6:28 [Qemu-devel] [PATCH] cryptodev: setiv only when really need Longpeng(Mike)
2017-01-16  6:32 ` Gonglei (Arei)

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.