From patchwork Wed Nov 19 10:27:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 41121 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6078620CBB for ; Wed, 19 Nov 2014 10:31:33 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf492816eek.11 for ; Wed, 19 Nov 2014 02:31:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:subject:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=kU4/8RQ3gAW2FENZxV2Ui+Ovk4CogC26kQ8lIXEnIHk=; b=Lyvxa4jcPhylE9R2ZRdd9UIxq0Eql0UFiiIxXco9UVnNBUrGTpJWveFdt7Z/Wx/6Rq pxUgBvIsryTezfeCQUv72BhEIs65sqj8HD8cfEt4TRsorxQt1dwBlvfAVaZiJkj/N9xN axaa2mqa1NKX/O4WuN7IuHTcYUQ6dB0u+B+RnvX5U5a44pVFGguRXy8DY7ZH1M0Zs1Nu aNhMlV6wH2LSPMLaT1mLPb6vyrrxSnLVRcN/zW5VzpcQ4Cv45udzeur+PqdTQ1siaDXJ CIs5m7Sg8SB3AxoghtGg8ZvLhgmDdD17xLT6Fd9gI7HxXztYOBmIprZgrfy9KuH2F7C/ J/XA== X-Gm-Message-State: ALoCoQldnAaUwxVEDMJIYdkL8c0n8fyRgQALCak5Lli+oEszmxYah4yzbfsT6xJSjO9g7MhpBYF/ X-Received: by 10.180.8.9 with SMTP id n9mr585190wia.6.1416393092613; Wed, 19 Nov 2014 02:31:32 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.1 with SMTP id a1ls1137996lae.19.gmail; Wed, 19 Nov 2014 02:31:32 -0800 (PST) X-Received: by 10.112.130.10 with SMTP id oa10mr25376028lbb.12.1416393092452; Wed, 19 Nov 2014 02:31:32 -0800 (PST) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id o10si1381744laj.15.2014.11.19.02.31.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 02:31:32 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by mail-la0-f52.google.com with SMTP id q1so248155lam.11 for ; Wed, 19 Nov 2014 02:31:32 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr4553062laa.71.1416393092359; Wed, 19 Nov 2014 02:31:32 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp59313lbc; Wed, 19 Nov 2014 02:31:31 -0800 (PST) X-Received: by 10.140.30.201 with SMTP id d67mr27138151qgd.55.1416393090039; Wed, 19 Nov 2014 02:31:30 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id s11si1672713qge.11.2014.11.19.02.31.29 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 19 Nov 2014 02:31:30 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xr2Xn-0003kk-Sh; Wed, 19 Nov 2014 10:31:27 +0000 Received: from mail-bn1on0060.outbound.protection.outlook.com ([157.56.110.60] helo=na01-bn1-obe.outbound.protection.outlook.com) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xr2Xh-0003kX-OR for lng-odp@lists.linaro.org; Wed, 19 Nov 2014 10:31:21 +0000 Received: from BY2PR03MB1016.namprd03.prod.outlook.com (10.242.238.26) by BY2PR03MB426.namprd03.prod.outlook.com (10.141.141.140) with Microsoft SMTP Server (TLS) id 15.1.16.15; Wed, 19 Nov 2014 10:31:15 +0000 Received: from CH1PR03CA009.namprd03.prod.outlook.com (10.255.156.154) by BY2PR03MB1016.namprd03.prod.outlook.com (10.242.238.26) with Microsoft SMTP Server (TLS) id 15.1.16.15; Wed, 19 Nov 2014 10:30:54 +0000 Received: from BL2FFO11FD007.protection.gbl (10.255.156.132) by CH1PR03CA009.outlook.office365.com (10.255.156.154) with Microsoft SMTP Server (TLS) id 15.1.16.15 via Frontend Transport; Wed, 19 Nov 2014 10:30:54 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD007.mail.protection.outlook.com (10.173.161.3) with Microsoft SMTP Server (TLS) id 15.1.6.13 via Frontend Transport; Wed, 19 Nov 2014 10:30:54 +0000 Received: from fsr-fed1364-15.ea.freescale.net (fsr-fed1364-15.ea.freescale.net [10.171.81.144]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id sAJAUqfg032098; Wed, 19 Nov 2014 03:30:53 -0700 From: To: Date: Wed, 19 Nov 2014 12:27:42 +0200 Message-ID: <1416392862-6874-1-git-send-email-alexandru.badicioiu@linaro.org> X-Mailer: git-send-email 1.7.3.4 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130608666548511103; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(448002)(199003)(189002)(31966008)(120916001)(99396003)(36756003)(47776003)(50986999)(64706001)(20776003)(93916002)(97736003)(86362001)(46102003)(86152002)(92566001)(102836001)(92726001)(50466002)(84676001)(81156004)(85326001)(48376002)(106466001)(21056001)(87286001)(77156002)(62966003)(19580405001)(6806004)(44976005)(19580395003)(4396001)(68736004)(69596002)(50226001)(95666004)(104016003)(88136002)(87936001)(104166001)(89996001)(107046002)(33646002)(229853001)(2351001)(110136001); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR03MB1016; H:az84smr01.freescale.net; FPR:; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB1016; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB1016; X-Forefront-PRVS: 04004D94E2 Received-SPF: PermError (protection.outlook.com: domain of linaro.org used an invalid SPF mechanism) X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(402001)(401002)(400003); SRVR:BY2PR03MB1016; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB426; X-Topics: crypto patch Subject: [lng-odp] [PATCH v1] crypto : use override_iv_ptr when session IV is NULL X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alexandru.badicioiu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Alexandru Badicioiu NULL session IV prevents using per operation IV (override_iv_ptr). This fixes *_OVR_IV cunit tests segfaults. Signed-off-by: Alexandru Badicioiu --- platform/linux-generic/odp_crypto.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 596c717..9ca2251 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -147,7 +147,7 @@ enum crypto_alg_err des_encrypt(odp_crypto_op_params_t *params, { uint8_t *data = odp_packet_addr(params->out_pkt); uint32_t len = params->cipher_range.length; - DES_cblock *iv; + DES_cblock *iv = NULL; DES_cblock iv_temp; /* @@ -155,8 +155,10 @@ enum crypto_alg_err des_encrypt(odp_crypto_op_params_t *params, * and if we are processing packets on parallel threads * we could get corruption. */ - memcpy(iv_temp, session->cipher.iv.data, sizeof(iv_temp)); - iv = &iv_temp; + if (session->cipher.iv.data) { + memcpy(iv_temp, session->cipher.iv.data, sizeof(iv_temp)); + iv = &iv_temp; + } /* Adjust pointer for beginning of area to cipher */ data += params->cipher_range.offset; @@ -165,6 +167,10 @@ enum crypto_alg_err des_encrypt(odp_crypto_op_params_t *params, if (params->override_iv_ptr) iv = (DES_cblock *)params->override_iv_ptr; + /* No session or operation IV */ + if (!iv) + return ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER; + /* Encrypt it */ DES_ede3_cbc_encrypt(data, data, @@ -214,10 +220,6 @@ int process_des_params(odp_crypto_generic_session_t *session, if (!((0 == params->iv.length) || (8 == params->iv.length))) return -1; - /* Verify IV pointer */ - if (params->iv.length && !params->iv.data) - return -1; - /* Set function */ if (ODP_CRYPTO_OP_ENCODE == params->op) session->cipher.func = des_encrypt;