From patchwork Thu Jun 1 08:22:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Eremin-Solenikov X-Patchwork-Id: 100825 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp696596qge; Thu, 1 Jun 2017 01:31:05 -0700 (PDT) X-Received: by 10.55.136.1 with SMTP id k1mr336103qkd.104.1496305864987; Thu, 01 Jun 2017 01:31:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305864; cv=none; d=google.com; s=arc-20160816; b=h9ua55WJtMzR0Y79wqhAGZPrvdLW2s9rdaaxyRKGKjQp2EWpJ+KQvpAvGkrxEBE+43 RExWxaSB2hnnykvEVjhKD5v7WhEMvvMJZGb+9P92zgTN2jCiH9luuMeHDgQ6UGmWxYH3 4CCIZ5XRGYvtD1aUTvAAKil0bKcsq5bVbttLi76g+wW3i6UZ+WC5Y+Ikp2vNAJmE5kZ0 H3PYHy8hXh7ntDYc7Mn0FdGfwZqbyjya/BOk6VCekYj95lmhllBojx2E2KLJfLNpUjyw 5ZzRTbZHECy0LMgKlA9QjGdv9Aon0XqExQKd+V9hUr+KtNmBCsgBmuUmWgd54NxTJ9Kn dp9A== 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:references:in-reply-to :message-id:date:to:from:delivered-to:arc-authentication-results; bh=BWxiANhz+T8lxYlL128mWhJ+G9r2LxFQFZI+//rq7pI=; b=UsrAIbLIfpteparCrgEH6tVLnLTXyQjQF0fT7eJT9ewlG5ViGH16kG2MZqEcBPFs77 LmShB0vIx8Fp/NmDAFSwNGkSbwzEUjSQaT7onuiDVmlDTVE0R/AwOgXUnLouNPgjO+m0 WM6qYvrLifMSSpMpmGhS2mSkXMVSdvCNKmk7tz0vnFjZeQkhFvGpPSOHPCqFc5T0763m +tzHflYcwIhsG8mTzd/M8zOemuJ+Mjq+DNWoH2Z5W65szcUU2fi0PKQEIro8/iV+DVLX NgFAJmZ4ySQxK2zf3Pu0rXi0aNEbCjzyCe9j+dOsuYLW8IILawkiZT4W6rDKHWAa57du d0wQ== 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 99si713983qta.163.2017.06.01.01.31.04; Thu, 01 Jun 2017 01:31:04 -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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 90B0160972; Thu, 1 Jun 2017 08:31:04 +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=-1.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_SPAM, 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 2104E60D73; Thu, 1 Jun 2017 08:24:43 +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 7DF2160A0F; Thu, 1 Jun 2017 08:24:31 +0000 (UTC) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com [209.85.215.51]) by lists.linaro.org (Postfix) with ESMTPS id A6CEE60A0F for ; Thu, 1 Jun 2017 08:23:32 +0000 (UTC) Received: by mail-lf0-f51.google.com with SMTP id 99so22039663lfu.1 for ; Thu, 01 Jun 2017 01:23:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=BWxiANhz+T8lxYlL128mWhJ+G9r2LxFQFZI+//rq7pI=; b=gBFOiHpMQMTrazQ0IvfumMwxDWmtpDphFF/jtQ62EqASbFG8icAD2seJAj+xn0jiTb FKUcyZg0k3G41SHwO+sC0UP8HSDVUjMAavbA8wLyZsF6xv58/VI9Sqwf/qxwUKe2uptm XbRJbHr5CaVHjmeWEqU8Ry2mMfA8FTgMzpzOSVuycBtqhyyP7SKcmH86MbprZJS/r/p9 aRipw410M3pMOqpJ1KqU9SMY3gCyjqeEIM0BZNAm7qrKQrFhxvkVY8+e74/qGLeAGK03 e6DMdHQWO23OjQlZMm9gM4sbMdtxUHChXB5LAiyY06bSdYs40zsu8L3pxqnD7MkE83w7 QdWw== X-Gm-Message-State: AODbwcCNl6L/FsSnGSLx+QmdxePSCQNC+wz5YTQrDvwkv8Bf9YZZ7yaV Coxf8kb/W8qNGIaJR2X+BYHq X-Received: by 10.25.35.87 with SMTP id j84mr140450lfj.118.1496305411251; Thu, 01 Jun 2017 01:23:31 -0700 (PDT) Received: from forlindon.lumag.auriga.ru ([188.162.64.12]) by smtp.gmail.com with ESMTPSA id c78sm4185837lfh.25.2017.06.01.01.23.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:30 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:48 +0300 Message-Id: <20170601082320.4673-9-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170601082320.4673-1-dmitry.ereminsolenikov@linaro.org> References: <20170601082320.4673-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH API-NEXT v4 05/23] linux-generic: 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" Signed-off-by: Dmitry Eremin-Solenikov --- platform/linux-generic/odp_crypto.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) -- 2.11.0 diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index a993542f50b5..472ee3107de3 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,23 @@ 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: + /* Fixed digest tag length with deprecated algo */ + 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: + /* Fixed digest tag length with deprecated algo */ + 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: