From patchwork Fri May 19 22:00:06 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: 100209 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp516501qge; Fri, 19 May 2017 15:02:15 -0700 (PDT) X-Received: by 10.36.178.88 with SMTP id h24mr31816421iti.31.1495231335679; Fri, 19 May 2017 15:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495231335; cv=none; d=google.com; s=arc-20160816; b=AJxvDphEC7yaQxeSzv9MXdYj+2vp31CbZxyiqvGLwQJN2S+BmibXGUVWTQzLO6M0uu 8AwbClFQUJkqa0XNlpygB+PTVHlUu6BfjzqzrExYgcg3EVvTMuoDMTKorCsbn8/3EDF9 8jieTCYd5DoTMb7U1BimVAnlZNF4rOMOuFR6bAsglLlkv1csHt4c/w+9Epz8ukbukuUf g1sqL/Bmj14Ws7xaYMUuoBZ1baMRUzB4/YB1t9G7s+zsx9Vuy9ljz0UDL+xEVn04VC8r apEi3Xk7z921pX3jtUwAv7QChH51ICgNM7jOx8fQShySBye5Ak7vUA2rEHD0urMVANzJ UdEg== 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=ShN0Q79QvZZ+jPefgiSIFDzue9JOxc80tBWYP8LvHJI=; b=KLgGNkE9rO3LfkgdOdkdZpmCK4Y3T0MyfOtigM4qNCiV1rLtmC+FiYcuFRXbe0nmdW tX5ftTofWyoGccPIDG9IXSIfMwpB953eQTNGdCdbrf3xjOmFP91JElTSgWDbxRNeph6N 3UwuZwq+3FL6sWw4S4AWLO8eLHmXnAuqKol3pDF8oyRXGyY75AlvD7KH9IaSa9iTs/uF oUlPOCX+EFRyOskRF56O48INX75Fw+8R4bvkHr56Sc+ebcIjKHQdwqXngJ3ZDOKvordr XqjTuSWZA87lIgE3iSkF9bAjjdHDidU62MtFDQml10lh20fvPudN34Pb4eS7icJghL3Q Ddhg== 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 n40si10364842ioe.34.2017.05.19.15.02.15; Fri, 19 May 2017 15:02:15 -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 341C460924; Fri, 19 May 2017 22:02:15 +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 90B0860E9E; Fri, 19 May 2017 22:01:00 +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 E2AB160861; Fri, 19 May 2017 22:00:53 +0000 (UTC) Received: from forward3h.cmail.yandex.net (forward3h.cmail.yandex.net [87.250.230.18]) by lists.linaro.org (Postfix) with ESMTPS id 4D95460EA1 for ; Fri, 19 May 2017 22:00:20 +0000 (UTC) Received: from smtp3o.mail.yandex.net (smtp3o.mail.yandex.net [37.140.190.28]) by forward3h.cmail.yandex.net (Yandex) with ESMTP id D016521198 for ; Sat, 20 May 2017 01:00:18 +0300 (MSK) Received: from smtp3o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp3o.mail.yandex.net (Yandex) with ESMTP id A75BA2940E88 for ; Sat, 20 May 2017 01:00:17 +0300 (MSK) Received: by smtp3o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 53lQSrIN00-0HwGp8LW; Sat, 20 May 2017 01:00:17 +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: Sat, 20 May 2017 01:00:06 +0300 Message-Id: <1495231208-19354-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495231208-19354-1-git-send-email-odpbot@yandex.ru> References: <1495231208-19354-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 24 Subject: [lng-odp] [PATCH API-NEXT v3 3/5] 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: 78b12f0da50bf257f978a197b2667405a94a4938 **/ 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: