From patchwork Sat Sep 24 02:10:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9349007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB78260B16 for ; Sat, 24 Sep 2016 02:10:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98C3B2A1C1 for ; Sat, 24 Sep 2016 02:10:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D5AC2A1D7; Sat, 24 Sep 2016 02:10:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E150F2A1C2 for ; Sat, 24 Sep 2016 02:10:51 +0000 (UTC) Received: from localhost ([::1]:54605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bncQP-0008KS-Hd for patchwork-qemu-devel@patchwork.kernel.org; Fri, 23 Sep 2016 22:10:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bncQ2-0008JR-7m for qemu-devel@nongnu.org; Fri, 23 Sep 2016 22:10:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bncPy-0000AM-27 for qemu-devel@nongnu.org; Fri, 23 Sep 2016 22:10:21 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:35757) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bncPx-00009Z-Et for qemu-devel@nongnu.org; Fri, 23 Sep 2016 22:10:18 -0400 Received: from 172.24.1.60 (EHLO szxeml432-hub.china.huawei.com) ([172.24.1.60]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CII14031; Sat, 24 Sep 2016 10:10:15 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml432-hub.china.huawei.com (10.82.67.209) with Microsoft SMTP Server id 14.3.235.1; Sat, 24 Sep 2016 10:10:05 +0800 From: Gonglei To: Date: Sat, 24 Sep 2016 10:10:00 +0800 Message-ID: <1474683000-346560-4-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1474683000-346560-1-git-send-email-arei.gonglei@huawei.com> References: <1474683000-346560-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.57E5E087.0018, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: cf9bf7b71b4e5207d80de8d7659bd40a X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Subject: [Qemu-devel] [PATCH v2 3/3] crypto: add mode check in qcrypto_cipher_new() for cipher-builtin 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: Gonglei , wu.wubin@huawei.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Gonglei --- crypto/cipher-builtin.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c index fd59a9e..d710608 100644 --- a/crypto/cipher-builtin.c +++ b/crypto/cipher-builtin.c @@ -433,6 +433,16 @@ QCryptoCipher *qcrypto_cipher_new(QCryptoCipherAlgorithm alg, { QCryptoCipher *cipher; + switch (mode) { + case QCRYPTO_CIPHER_MODE_ECB: + case QCRYPTO_CIPHER_MODE_CBC: + case QCRYPTO_CIPHER_MODE_XTS: + default: + error_setg(errp, "Unsupported cipher mode %s", + QCryptoCipherMode_lookup[mode]); + return NULL; + } + cipher = g_new0(QCryptoCipher, 1); cipher->alg = alg; cipher->mode = mode;