From patchwork Mon May 22 22:00:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 100341 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp51587qge; Mon, 22 May 2017 15:21:59 -0700 (PDT) X-Received: by 10.55.161.72 with SMTP id k69mr24679871qke.81.1495491718963; Mon, 22 May 2017 15:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495491718; cv=none; d=google.com; s=arc-20160816; b=GC9Ysxunlax7K2DNWb6q9Hu9WRyu7z7wPQrGGrH/y7rpmokbfdBOrdVkmEW6Clfg67 yOubq3E07RdzQ5hy0Zuv8RoJtbGLFqFYLNvayZea0wkVYZvGXdA851nRA/UaDnW4hUz5 uIjmpBPn2QF2Y5Wg9l4xwTIWI/zL2zqv0MwvgeC2O/1DqQvu7VfdQWk6d+vSnGu6Hzrf wkqsuRFLmnYjTUiuvZq/+3j4rqc4J26ElSMf488DCVDDGEzhRbkv9ti+CURHgkWzWon0 R/1yW82IPdtbzTnjEW9wKZx+BERF3aeRWZvHlbSsZW6eBAhmwjOr+xfiWRfhOTKpqlEt uoqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=EyC7zpAnGeCX6HKNnpRH3TVli2Mtv+e468P5NUav0S8=; b=RfYfiz+9cULx+bbuRNcHcPD2Gn2Pqxkkr5LCc4Wnu+3413SUoHPFp043sAe+trE1yp 7CWmy2vQDVzEbgSDJWFdVexqZRmlMWE3ie6o5LVQ0+SmKKOAPBy0khvbAsoJ9XQnl+kX Uj/hbNUfJIlnyEFNtmEkojDd6H4ZcBCTS4jOr/EWk9d/75N5z+BwRYm9a1sa//8VEaqE at3VxMkDf/F7p45t13CsSdluLsJjHoIZa4Sk/3cjS4rdxy8mGNgNJHEc0FRa4RwPtYmR IWv+SNIT/YtCuGqjLkBUOPX5x8CJvtyf1A98a+BpB9NjjTQcb3TOFajjQBDpoyV5HVHC iikw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 50si19526149qtm.62.2017.05.22.15.21.58; Mon, 22 May 2017 15:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 7D73660B4B; Mon, 22 May 2017 22:21:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1D00860EEC; Mon, 22 May 2017 22:03:32 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1196660EEA; Mon, 22 May 2017 22:03:28 +0000 (UTC) Received: from forward5h.cmail.yandex.net (forward5h.cmail.yandex.net [87.250.230.20]) by lists.linaro.org (Postfix) with ESMTPS id 285CB60BEC for ; Mon, 22 May 2017 22:00:45 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:7]) by forward5h.cmail.yandex.net (Yandex) with ESMTP id 1486821192 for ; Tue, 23 May 2017 01:00:44 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id D09AD1A800A0 for ; Tue, 23 May 2017 01:00:43 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id W3J1KhwBo7-0gx0jIXv; Tue, 23 May 2017 01:00:42 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) X-Yandex-Suid-Status: 1 0 From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 23 May 2017 01:00:34 +0300 Message-Id: <1495490436-30157-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495490436-30157-1-git-send-email-odpbot@yandex.ru> References: <1495490436-30157-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 24 Subject: [lng-odp] [PATCH API-NEXT v4 5/7] linux: crypto: use auth_digest_len when calculating HMACs X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Dmitry Eremin-Solenikov Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 24 (lumag:crypto-dal) ** https://github.com/Linaro/odp/pull/24 ** Patch: https://github.com/Linaro/odp/pull/24.patch ** Base sha: 826ee894aa0ebd09d42a17e1de077c46bc5b366a ** Merge commit sha: ad894972724a7ec25c384144f46258caf3224cc9 **/ platform/linux-generic/odp_crypto.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index a993542f..d6b4ee3f 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -522,7 +522,6 @@ static int process_des_param(odp_crypto_generic_session_t *session) } static int process_auth_param(odp_crypto_generic_session_t *session, - uint32_t bits, uint32_t key_length, const EVP_MD *evp_md) { @@ -535,7 +534,9 @@ static int process_auth_param(odp_crypto_generic_session_t *session, session->auth.evp_md = evp_md; /* Number of valid bytes */ - session->auth.bytes = bits / 8; + session->auth.bytes = session->p.auth_digest_len; + if (session->auth.bytes < (unsigned)EVP_MD_size(evp_md) / 2) + return -1; /* Convert keys */ session->auth.key_length = key_length; @@ -745,17 +746,21 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, session->auth.func = null_crypto_routine; rc = 0; break; - case ODP_AUTH_ALG_MD5_HMAC: #if ODP_DEPRECATED_API case ODP_AUTH_ALG_MD5_96: + session->p.auth_digest_len = 96 / 8; + /* Fallthrough */ #endif - rc = process_auth_param(session, 96, 16, EVP_md5()); + case ODP_AUTH_ALG_MD5_HMAC: + rc = process_auth_param(session, 16, EVP_md5()); break; - case ODP_AUTH_ALG_SHA256_HMAC: #if ODP_DEPRECATED_API case ODP_AUTH_ALG_SHA256_128: + session->p.auth_digest_len = 128 / 8; + /* Fallthrough */ #endif - rc = process_auth_param(session, 128, 32, EVP_sha256()); + case ODP_AUTH_ALG_SHA256_HMAC: + rc = process_auth_param(session, 32, EVP_sha256()); break; #if ODP_DEPRECATED_API case ODP_AUTH_ALG_AES128_GCM: