From patchwork Thu Jun 22 16:00:07 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: 106220 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp194137qgd; Thu, 22 Jun 2017 09:00:53 -0700 (PDT) X-Received: by 10.237.36.73 with SMTP id s9mr3972916qtc.137.1498147253353; Thu, 22 Jun 2017 09:00:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1498147253; cv=none; d=google.com; s=arc-20160816; b=SkZxNf58uEVzmRnnrIZgNJRBbClH22+rE5hY3o598dgPAkQda0x19jXXdwvooDTWUe 4HWYf8KudJFhE4Wdd87wlip3XhqoAgs0eJ5JMyfDjLTDTlVQz/ckFUGJ1bvDUTNubXfO paTlKbhTE2hEVyocerq7S9CuHyCuRn10lkpaBK7TWJxcwkJRhoBmCcjjmBQlryXeHm3S oWLHWuxjkzUlVgygdI1av2Uv9JDvALIr/GpKBQttyzDYCluU9iJlxrv8S3Ppd5EurjK/ 8EbCT4OgQp5/nDq06IaXjfvt/NM+RChOW5bcb/Majx0WB9LVy9ybGSlLYniEehC87Q34 F1sA== 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=mzvvT/1a8beSUlKNiw4So7wla6dMQKVCr5ejWscnd6g=; b=m0LlntEHElCDO28nw9e5klyjZDQhIz32yXZFwOKSZ0suoWkJ1ga7numPskH6Rx2kK0 y/omDm0gtEVDp6L4EpMXW5H4bTs8T7OsMN9z+97StVA8GoIJjLc1o60xpYflWZkQ/fOI eCBJ1J6q7arDHiCahqeN+hmPrZNoabTbCrGtabzRALizYBNmtS9K68VHI5aoHaYtE691 /65vkzN2YHWi+67dk9CPSLBls8TJYHAhhvnpCN+wM6qG/sUfO2mg/ZnQTdKE44rXbF7o hDvNL9yjnXOaO4pOd2jJgMibhCyE8XTg7BaajHCxggMHYdOj2lwg3tWqgKX21vYygeZI r9ZA== 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 k50si1681026qta.135.2017.06.22.09.00.53; Thu, 22 Jun 2017 09:00:53 -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 0BC6160A31; Thu, 22 Jun 2017 16:00:53 +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,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 F357E6081B; Thu, 22 Jun 2017 16:00:22 +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 132CA6069E; Thu, 22 Jun 2017 16:00:15 +0000 (UTC) Received: from forward5p.cmail.yandex.net (forward5p.cmail.yandex.net [77.88.31.20]) by lists.linaro.org (Postfix) with ESMTPS id 784BA6068E for ; Thu, 22 Jun 2017 16:00:13 +0000 (UTC) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::26]) by forward5p.cmail.yandex.net (Yandex) with ESMTP id 6E99520EDD for ; Thu, 22 Jun 2017 19:00:11 +0300 (MSK) Received: from smtp2o.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2o.mail.yandex.net (Yandex) with ESMTP id 441395080F04 for ; Thu, 22 Jun 2017 19:00:10 +0300 (MSK) Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 1vRGKnLAgv-0AESYXTi; Thu, 22 Jun 2017 19:00:10 +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: Thu, 22 Jun 2017 19:00:07 +0300 Message-Id: <1498147207-29436-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1498147207-29436-1-git-send-email-odpbot@yandex.ru> References: <1498147207-29436-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 56 Subject: [lng-odp] [PATCH v1 1/1] linux-generic: crypto: adapt HMAC code to OpenSSL 1.1.x 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 OpenSSL 1.1.x has changed HMAC API in an incompatible way. Let's adapt to it by providing version-dependent wrapper around HMAC calculation. Signed-off-by: Dmitry Eremin-Solenikov Reviewed-and-tested-by: Brian Brooks --- /** Email created from pull request 56 (lumag:hmac-1.1.x-master) ** https://github.com/Linaro/odp/pull/56 ** Patch: https://github.com/Linaro/odp/pull/56.patch ** Base sha: 09a7800c4c4a093fb962e362952f9cf562d2fc98 ** Merge commit sha: 8e626d0ef78bad290c04f5e0258149b5bec62319 **/ platform/linux-generic/odp_crypto.c | 43 +++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 6fc1907d..68fc5658 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -128,20 +128,18 @@ null_crypto_routine(odp_crypto_op_param_t *param ODP_UNUSED, } static -void packet_hmac(odp_crypto_op_param_t *param, - odp_crypto_generic_session_t *session, - uint8_t *hash) +void packet_hmac_calculate(HMAC_CTX *ctx, + odp_crypto_op_param_t *param, + odp_crypto_generic_session_t *session, + uint8_t *hash) { odp_packet_t pkt = param->out_pkt; uint32_t offset = param->auth_range.offset; uint32_t len = param->auth_range.length; - HMAC_CTX ctx; ODP_ASSERT(offset + len <= odp_packet_len(pkt)); - /* Hash it */ - HMAC_CTX_init(&ctx); - HMAC_Init_ex(&ctx, + HMAC_Init_ex(ctx, session->auth.key, session->auth.key_length, session->auth.evp_md, @@ -152,14 +150,41 @@ void packet_hmac(odp_crypto_op_param_t *param, void *mapaddr = odp_packet_offset(pkt, offset, &seglen, NULL); uint32_t maclen = len > seglen ? seglen : len; - HMAC_Update(&ctx, mapaddr, maclen); + HMAC_Update(ctx, mapaddr, maclen); offset += maclen; len -= maclen; } - HMAC_Final(&ctx, hash, NULL); + HMAC_Final(ctx, hash, NULL); +} + +#if OPENSSL_VERSION_NUMBER < 0x10100000L +static +void packet_hmac(odp_crypto_op_param_t *param, + odp_crypto_generic_session_t *session, + uint8_t *hash) +{ + HMAC_CTX ctx; + + /* Hash it */ + HMAC_CTX_init(&ctx); + packet_hmac_calculate(&ctx, param, session, hash); HMAC_CTX_cleanup(&ctx); } +#else +static +void packet_hmac(odp_crypto_op_param_t *param, + odp_crypto_generic_session_t *session, + uint8_t *hash) +{ + HMAC_CTX *ctx; + + /* Hash it */ + ctx = HMAC_CTX_new(); + packet_hmac_calculate(ctx, param, session, hash); + HMAC_CTX_free(ctx); +} +#endif static odp_crypto_alg_err_t auth_gen(odp_crypto_op_param_t *param,