From patchwork Fri May 19 23:00:05 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: 100214 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp533462qge; Fri, 19 May 2017 16:01:47 -0700 (PDT) X-Received: by 10.237.53.184 with SMTP id c53mr11745416qte.227.1495234907493; Fri, 19 May 2017 16:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495234907; cv=none; d=google.com; s=arc-20160816; b=AcRj9Q6YABxlPyD49NLzIXA/e4kvyALhXpJ3gzDYmrB41hF9TMyChXdkmi2h6NNA5/ rdYjsDkhTiV424yM8zmOkLU4p5PVW3TUSUTMVl6puIhu00LOMmsfK+q6JwTY4E0mggm+ +Vhl8j7tWFw5HKqXz9m8ZAG1aOVN3Nzb72ENSKVEiZWXcsWXQrYLIA07bZN+pDKT69HS wclP5R7jeZ4ft2wO9N9WD1C4yMTCn79mdOV60JSG9be3ZQbROzz3aj3R54xLK2AAJg3t KMhXK0ZytdABK+5AQgd7bLQ/qfRMnJo8/nU3RwzZfmtXAX8cVHku9so+sEdroLNLLAlS ig5Q== 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=nMcdikBkHBwfND80siELLiWlMqywtuiohCZ0PUOKWVQ8DuvldYqTeX5trvVLlB0jZp zD0rR8fiYLP3D1nhL+X1fU+OBmFoMTKvj3KrwAX9+WiKncZZvWNzjRyiMPBBoJLhuK3A MshcoAJmJ1roWrEJ5m387+ne457Ma+uhqHQkjxN3jxunvpfpUokgy4DigkvOzQD0z7us rR021x5NQycLsIf39Wzr9Fjj7R0pgZAF8yrKUTyYUpOzsh1zigcJhq5N+zRA1eRIYwO2 l5vFeS68cULSY3/uYq1AezrUP8GML1kDfAqpVr/kFrknpKnfLIZ5bm2d+7/n3f4d8EAR iOpA== 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 o6si10224987qkf.317.2017.05.19.16.01.47; Fri, 19 May 2017 16:01:47 -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 2448760EEA; Fri, 19 May 2017 23:01:47 +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 DBC0E60EAE; Fri, 19 May 2017 23:00:30 +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 E1FFB60EA1; Fri, 19 May 2017 23:00:21 +0000 (UTC) Received: from forward5h.cmail.yandex.net (forward5h.cmail.yandex.net [87.250.230.20]) by lists.linaro.org (Postfix) with ESMTPS id 7652360982 for ; Fri, 19 May 2017 23:00:19 +0000 (UTC) Received: from smtp2j.mail.yandex.net (smtp2j.mail.yandex.net [95.108.130.60]) by forward5h.cmail.yandex.net (Yandex) with ESMTP id 27CA821B0A for ; Sat, 20 May 2017 02:00:18 +0300 (MSK) Received: from smtp2j.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2j.mail.yandex.net (Yandex) with ESMTP id 026173EC114A for ; Sat, 20 May 2017 02:00:17 +0300 (MSK) Received: by smtp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id upK1d19rxX-0GxCHPkL; Sat, 20 May 2017 02: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: Sat, 20 May 2017 02:00:05 +0300 Message-Id: <1495234807-19672-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1495234807-19672-1-git-send-email-odpbot@yandex.ru> References: <1495234807-19672-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: