From patchwork Mon May 22 21:59:54 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: 100321 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp45810qge; Mon, 22 May 2017 15:04:39 -0700 (PDT) X-Received: by 10.55.111.198 with SMTP id k189mr24836426qkc.160.1495490679119; Mon, 22 May 2017 15:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495490679; cv=none; d=google.com; s=arc-20160816; b=lSwAtst/L2e5Q4NpZJVD8TP6KixUyk0xl9YS79q1nrKJ//4PryOq2N0OL3miClsvAG lHtSdw2Ka4jGykg8wPFLpUgzmiRxu7pGaTOD28Wyui+Gxit4j1pyS5/dLdRTvOZuV5Qi u4F48CsGecK6pr+alUATAh+EjH8YQBoi1VGZkx+ex+Yek8MM2LZuDGtjPTDgLhQkOxrF f+y9Jjg+BQ4H4LuTcfvwXjC8ScaHjgPGylJFgvS7PqAdK0ZNjnpbEzzC0WmJgpKxnXwC QhYYgITDKM8/tQy+lFmI0gM1x2xh52CixPngZ4ljebVRGvSZez3co/lzU2ARlHtedUJa 4wtQ== 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=2rij8sdZprZb3zGF68XQ2ij7nyU+K6mbHEHg95NQ0KY=; b=NGElQF5sgrqNjP1VBPpkSKlYPQfJA1qaOwF8JYeOEDBqNAaG102CGj+VT32RL42d6A uZKpRqyB5rkYi8KY3OQ80eMY9x+KEXpusmUkSl9a/3+D4JrsyAgj9VhX/Pwok/l7RN0v h8XwsfcSfeDX4Vi00JzttCLKCz0r0MyIYstMsuOTZwFs/tlC//MwppJww23OSn46PESZ L0XK4P6BI8re9S6mvpFZKfFB28WZfr5+zyX7ugU7PS8n5DLkCXntC9yXNxSWmPD77I9X fN+GlzLHP1JxrKWT+BgclHXsXYr9vbBIQ+6SE2wu7kq+8B4ub2IzgK8BUgIAh1uxW92F aA+g== 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 40si19812458qtx.221.2017.05.22.15.04.38; Mon, 22 May 2017 15:04:39 -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 C7B596079A; Mon, 22 May 2017 22:04:38 +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 8971A60BE4; Mon, 22 May 2017 22:00:44 +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 5287C6082A; Mon, 22 May 2017 22:00:21 +0000 (UTC) Received: from forward4m.cmail.yandex.net (forward4m.cmail.yandex.net [5.255.216.22]) by lists.linaro.org (Postfix) with ESMTPS id A03D2607D7 for ; Mon, 22 May 2017 22:00:18 +0000 (UTC) Received: from smtp3m.mail.yandex.net (smtp3m.mail.yandex.net [IPv6:2a02:6b8:0:2519::125]) by forward4m.cmail.yandex.net (Yandex) with ESMTP id 3A1D620C0D for ; Tue, 23 May 2017 01:00:17 +0300 (MSK) Received: from smtp3m.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3m.mail.yandex.net (Yandex) with ESMTP id 07B072840EF6 for ; Tue, 23 May 2017 01:00:16 +0300 (MSK) Received: by smtp3m.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id ll1QrMKPBI-0GEeMG9J; Tue, 23 May 2017 01:00:16 +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 00:59:54 +0300 Message-Id: <1495490409-30066-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495490409-30066-1-git-send-email-odpbot@yandex.ru> References: <1495490409-30066-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 34 Subject: [lng-odp] [PATCH API-NEXT v2 5/20] 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 34 (lumag:crypto-update-main-new) ** https://github.com/Linaro/odp/pull/34 ** Patch: https://github.com/Linaro/odp/pull/34.patch ** Base sha: 826ee894aa0ebd09d42a17e1de077c46bc5b366a ** Merge commit sha: 7c49c61063e2d57f049a5436cf12a3c36710bb34 **/ 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: