From patchwork Thu Jun 1 08:22:47 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: 100824 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp696389qge; Thu, 1 Jun 2017 01:30:30 -0700 (PDT) X-Received: by 10.55.72.77 with SMTP id v74mr295236qka.208.1496305830434; Thu, 01 Jun 2017 01:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496305830; cv=none; d=google.com; s=arc-20160816; b=epvztxGRNf5oH/U9LP7It+OyzaoUheqhNkbKR/cir+nqYOAZgQogLN8/119qSpNx8/ yK0BPM3FjVD99BV4ZTotG/6MKeiaE+pzR7wWamPDV7jKgUyP19bW+LgM8bRpvOrRt8KX i8wBmhBC5xczRvtn/sgy2EeBiSFeA+5SARi5/JT7ifRlSBUPSTjV52ysKOA+BzZPkc5j r2+2B0FOu9ek934hbMwxxLdQAcS7NRZDdhE+CB+1GEdrTOYBXo7ZsECdB8i9/Spl+T5b TCGgmDrWL5cH11cAY45pgQWugVtN+w1YhDx7JHyVUd09RV9gjVpOF5W1DxjhHOvOPcW5 sEAg== 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=QEJSG6oxtZUDo3nLaBc4SoVHCJbK4O128b7KG7E0U6W4pOTXHVjkz0+PZogeYJOn0V 1RhpzuUGphooFsCvrGvikoGvi4w4WYpj10GbGEMjAM/OH5g3w8JwMNd8GrXOTRZhkO+C nRT2lWYLtSpcEGshEsJojTwNJ75MyXz722xYsGC+91KJkBj1o+kBVLL1lC3ars+BdVjt rE0yui317KxV5Umo0U8MjyOcmuOJJ4G38iK3ynroSR5utziYraN4Ci4+ky6H5xfvBrVJ RySKOKX5j650KjHtdCksAZxNaaguejB71FaxUiwhUS5ZA8Z+2FumTwVEQ937fV1To90b MmHw== 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 m3si18830078qkd.257.2017.06.01.01.30.30; Thu, 01 Jun 2017 01:30:30 -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 0C6DC60A1A; Thu, 1 Jun 2017 08:30:30 +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 C6B8460D70; Thu, 1 Jun 2017 08:24:40 +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 5DCD960BE9; Thu, 1 Jun 2017 08:24:31 +0000 (UTC) Received: from mail-lf0-f47.google.com (mail-lf0-f47.google.com [209.85.215.47]) by lists.linaro.org (Postfix) with ESMTPS id 6E85A60972 for ; Thu, 1 Jun 2017 08:23:31 +0000 (UTC) Received: by mail-lf0-f47.google.com with SMTP id c184so17268517lfe.2 for ; Thu, 01 Jun 2017 01:23:31 -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=TIDpNbvUW0PVVqX7QZ8Wvc2ADslkKwg6J7Ty5s+xESuPXP8/NjXuE0RMdjFpxT92Yj wJiu1DeFpngaxb/JTqpXxhuZb1FhABs0O37vyC6P3v0C+X5s0bvr0mdnmRsJRBUaY350 bc8qPXRH0F3QdY4Ru6Fh524SoxakM3NH0UkWixaT4fIpyT1zaVQ/2JvhKZ7ozDpkHRq+ Le9uobuBD+VTpLv2DyHOlPyxfFQhFlsu1li9LSeA2hEBVFbU6umSY1umWBZ+TWbbLBY0 5NPWmwaQv+4H6DzFc1M/wORUAfdteJNM9RJSqFzr00N4LBVQicVynfitTz49cAX71nLc /jlw== X-Gm-Message-State: AODbwcD6M+yM/mGJamatXjPO+WXdqFBPI5PE5MXdrNvsfLriffywk6EB AvQwuqsnAE4Tk+yg9M1b0abL X-Received: by 10.25.162.133 with SMTP id l127mr102625lfe.99.1496305410083; Thu, 01 Jun 2017 01:23:30 -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.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 01:23:29 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 11:22:47 +0300 Message-Id: <20170601082320.4673-8-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 05/23] 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" 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: