From patchwork Thu Jun 15 08: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: 105630 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp680931qgd; Thu, 15 Jun 2017 01:01:12 -0700 (PDT) X-Received: by 10.55.192.68 with SMTP id o65mr4930272qki.13.1497513672180; Thu, 15 Jun 2017 01:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497513672; cv=none; d=google.com; s=arc-20160816; b=h/eyTp8nTMef2bk8jw4H/j61oat3+ZzL8VgyFUQk2GKIkadUoJnIwfoDKI3ft04DWA FTFan7xQLUODGea4Ew2p7Fja6K+96jKRZABJDxVrd84aqPvfLAOThWGOoiIs4ZREAGva Em//VYcspmwGuvQbyDjFMIS8TPZFSZkgCOD3oPavg1x53Aufe6uhMOdeAbb9JHbF1rLk F6R5ahID0+RYNbtEwz0Bx2brW2ANo+p2aJJpHtHxas4Jk3Cj/1kBAzx4xpc04jsfw2Kn QOop7rt/foLBYpZyKRTVPubSaRkrYV56e9sIGFSABrRhb3kbZeh7CzNaG2YU/wVeulg7 8HrQ== 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=JoYIKFavxiQFKVhkGZ53jSgpVnBLKCYWmmWOZQr7UNs=; b=v0RmXYYq4aqkAOrN88kq4Fqo+xwPzJJmS76yjRn1vQJVGlKLrJuhH9k/T7xkZFJyl5 5EVYXynesYTYnYh5HZBwDXl0C7RlolXx/xzpJyHM7KnszFy+dOv3zRipqtbUzKATFqvy EUCbnsSah0oYslGC5qA74qdKlNy6NKqvQbQpnRkNK2F3gslQ6TzgdrZGa4UVmKo0f+W1 9UIxlWqyYjNEGKpe6HxGbSiNRTita9FyiWpb59NfVULUKM0VR0D08zL5ng6XJL4V5o6N ULo5tv7BS5hPn8lUR925/Asiw1m+HvfN+dlKDd9EBhpYI3JGmZ2fjTBwG2pT7tsgG/MJ MPfg== 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 g14si2346145qte.292.2017.06.15.01.01.11; Thu, 15 Jun 2017 01:01:12 -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 D556760950; Thu, 15 Jun 2017 08:01:11 +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 C7F606090D; Thu, 15 Jun 2017 08:01:07 +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 1D03260911; Thu, 15 Jun 2017 08:01:05 +0000 (UTC) Received: from forward5p.cmail.yandex.net (forward5p.cmail.yandex.net [77.88.31.20]) by lists.linaro.org (Postfix) with ESMTPS id BCB966090D for ; Thu, 15 Jun 2017 08:00:57 +0000 (UTC) Received: from smtp2p.mail.yandex.net (smtp2p.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b6:7]) by forward5p.cmail.yandex.net (Yandex) with ESMTP id 9C6C020F07 for ; Thu, 15 Jun 2017 11:00:55 +0300 (MSK) Received: from smtp2p.mail.yandex.net (localhost.localdomain [127.0.0.1]) by smtp2p.mail.yandex.net (Yandex) with ESMTP id 0A4651A80193 for ; Thu, 15 Jun 2017 11:00:16 +0300 (MSK) Received: by smtp2p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id JePL9FIDp0-0FkKpHjC; Thu, 15 Jun 2017 11:00:15 +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, 15 Jun 2017 11:00:07 +0300 Message-Id: <1497513607-20195-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497513607-20195-1-git-send-email-odpbot@yandex.ru> References: <1497513607-20195-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 51 Subject: [lng-odp] [PATCH API-NEXT 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 --- /** Email created from pull request 51 (lumag:hmac-1.1.x) ** https://github.com/Linaro/odp/pull/51 ** Patch: https://github.com/Linaro/odp/pull/51.patch ** Base sha: 4f97e500a097928e308a415c32a88465adc5f5cc ** Merge commit sha: 31e0b980e18e6b8761600e5ab0f4aadbf88bdbac **/ 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,