From patchwork Sat Jan 14 06:28:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Longpeng (Mike, Cloud Infrastructure Service Product Dept.)" X-Patchwork-Id: 715321 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v0qNM1d0dz9t1C for ; Sat, 14 Jan 2017 17:29:38 +1100 (AEDT) Received: from localhost ([::1]:46628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSHqF-0006SC-UJ for incoming@patchwork.ozlabs.org; Sat, 14 Jan 2017 01:29:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSHpc-0006BF-Mw for qemu-devel@nongnu.org; Sat, 14 Jan 2017 01:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cSHpX-0006fJ-Uj for qemu-devel@nongnu.org; Sat, 14 Jan 2017 01:28:52 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:57143) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cSHpX-0006e1-FX for qemu-devel@nongnu.org; Sat, 14 Jan 2017 01:28:47 -0500 Received: from 172.24.1.137 (EHLO szxeml433-hub.china.huawei.com) ([172.24.1.137]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DXU71168; Sat, 14 Jan 2017 14:28:34 +0800 (CST) Received: from localhost (10.177.246.209) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.235.1; Sat, 14 Jan 2017 14:28:25 +0800 From: "Longpeng(Mike)" To: Date: Sat, 14 Jan 2017 14:28:21 +0800 Message-ID: <1484375301-159804-1-git-send-email-longpeng2@huawei.com> X-Mailer: git-send-email 1.8.4.msysgit.0 MIME-Version: 1.0 X-Originating-IP: [10.177.246.209] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.5879C512.0226, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1bbf1ceda02e05a25a9d21f7905942bd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 58.251.152.64 Subject: [Qemu-devel] [PATCH] cryptodev: setiv only when really need X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Longpeng\(Mike\)" , qemu-devel@nongnu.org, wu.wubin@huawei.com, jianjay.zhou@huawei.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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) --- 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) {