From patchwork Thu Jun 1 09:03:21 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: 100842 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp707323qge; Thu, 1 Jun 2017 02:08:09 -0700 (PDT) X-Received: by 10.237.37.55 with SMTP id v52mr462956qtc.31.1496308089375; Thu, 01 Jun 2017 02:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496308089; cv=none; d=google.com; s=arc-20160816; b=WGb6TwR6QDtHJTi0h2MxEShds7ctYSntHLUWuDQ0KMk4OiP1u/hszRH8RZ47zr9g3/ yMXNPGkv7jJ+pKdHzJzQMJn8R7HsntGXn0v0Gt1+Oi1AGtCj2nvUcr9YeLCxdL1Rtm+4 r8/wZOfYVby18+iBBJygDp0OwIbJYMFsIEdPNkR4ygduo2LjS5N1vOmbramQZaS+dOj4 ERxPQfQLNxPJaxB4Ghm46rFbUMXSaRgUnIw/DlzTAiFiXZQM0yQbSpWiYnRy0MMTvGO2 Ts/WYIN+34aQ2PC/Xw5L4yRWbhIwdm/dlra/40/wpCpKNnRjVwXlr0zC3Uz+ImXpvM8t XhHw== 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=JhKvYlt91IJmgIond5WyZ2+8TsJ35i1PwAdMLMS3ieBlDM8dcoPMuWgoc2tSKuUao2 Re+YhTio7Kj1rTGvl42jsEBZjlivz0/LhNdoBbtU2fsDvcimB3HflJf8+ueSA0S1NMI9 4uJmP/ehf9YMoZ2VkACAmOn8iXcTf6PlbaPbc7L+9bvL+Zw/3GJET6+QoKKbsX7ATxmp b+q/Esd2b0wSpnTpmQYHFOQUNwQ2LGHOd88ptXNvdoI+WZvBI9/1vAlfJeETiZcu5RIT Pe/A4lyLmrw3TX40zXh/NvOm6oBsdE4tJZ9PB+oD/Q//wvG+YdiQlFCNGLLWbVNs/pds tO3w== 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 j11si19336045qtc.85.2017.06.01.02.08.09; Thu, 01 Jun 2017 02:08:09 -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 097C060933; Thu, 1 Jun 2017 09:08:09 +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 2A70E608C3; Thu, 1 Jun 2017 09:04:24 +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 59DF4607E5; Thu, 1 Jun 2017 09:04:19 +0000 (UTC) Received: from mail-lf0-f46.google.com (mail-lf0-f46.google.com [209.85.215.46]) by lists.linaro.org (Postfix) with ESMTPS id 45369607E5 for ; Thu, 1 Jun 2017 09:03:49 +0000 (UTC) Received: by mail-lf0-f46.google.com with SMTP id a136so8033176lfa.0 for ; Thu, 01 Jun 2017 02:03:49 -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=qUfHeBnlz+SkQpKebKztKLv/mA7FWo04Bz6AD0dJmuVb0AawNr3RB6Ko7DjMzjScwN ZdJ0eF+089x4BGTTxrbASgZ/ElJ92+qqB1SXmkUkyaontbpUxrYNXpMedYMc3Er8SjDp ZXz+iLk1OP1+sz5OWLaWESvtMHQR4LAPiP7Wz6mGxvRAGXxm3Qbe8LEcWLz4Oqxf+jcI MiloLTAvf20U2b8j2bIH4b7KvdbbDFjhL6T1dPxK9rwj92UScXGkgyVSNzNTSzWF8eBc EzQj/srhG6ZvzyZo/+z3i1e3mQL8K4hX8+FaczuFkh4OYnSqGh+YB1rjvzx0ISwWL7Se 01Mg== X-Gm-Message-State: AODbwcBDU1NPh6ip0dY9t0jHpyP2Q5J628iNWBZpLnoBQSTm5A9C+dxX 9vMGsd+hdlVNLdru7lUEBenZ X-Received: by 10.25.221.198 with SMTP id w67mr187878lfi.114.1496307827948; Thu, 01 Jun 2017 02:03:47 -0700 (PDT) Received: from forlindon.lumag.auriga.ru ([188.162.64.12]) by smtp.gmail.com with ESMTPSA id 129sm4232819ljf.36.2017.06.01.02.03.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 02:03:47 -0700 (PDT) From: Dmitry Eremin-Solenikov To: lng-odp@lists.linaro.org Date: Thu, 1 Jun 2017 12:03:21 +0300 Message-Id: <20170601090339.9313-6-dmitry.ereminsolenikov@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170601090339.9313-1-dmitry.ereminsolenikov@linaro.org> References: <20170601090339.9313-1-dmitry.ereminsolenikov@linaro.org> Subject: [lng-odp] [PATCH API-NEXT v5 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: