From patchwork Thu Dec 14 11:00:15 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: 121906 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp6557863edb; Thu, 14 Dec 2017 03:07:25 -0800 (PST) X-Google-Smtp-Source: ACJfBosP8JudVLpSe3I5cpDHsbeJDNDFD2RdCOBPW2B2DkCC7gw8nPJuM4loNtKj01RG1L98ZL4r X-Received: by 10.55.126.7 with SMTP id z7mr14683073qkc.306.1513249645690; Thu, 14 Dec 2017 03:07:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513249645; cv=none; d=google.com; s=arc-20160816; b=V0r/7NMVX3t0bbD1TnSILpxWZH+H3tAniGUl0vjAdRNtXTG27iQV914v3hYNV9hzj6 XybNZcBhn/TcoBY1/VHRl6dy6EH6rGffhAr2cqb+Kk1OFLljrCzwP1Fp7pOzDikXD5EZ Lg8upAHJ5w/QRjQ+9BlGcXdfOKr819VZHSmZKUMT5W3qm5FaakvN6FhA+AJPM+FZaZ4i hwfjneyMjIr8LpGXblWBHAIfOjwzwmA2+/D5y4gqmcHQ/0Da8BmVLy9Wtv44UWZTG6vB ORaDp82lGARWZ1/uRdaRrOeoKcFwlnzxnYrpboHfdjr8VNAd178WygpGEmtNMZx20xYv 4uZg== 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=CeWmXyik54Q16A0dZeWfxXKW2gq1oSFDY+qFjJlrxG4=; b=c7AqmeC1UeMbveyP+HVUs0ai0hF9FBUQT79FV2yQJg88QAN25eaQ/FMoZvXCBY9s6s SJWJ1BZP+mNVi0CUwUUFOm6l0FwxN3vC6JodOkUWYNU9MxDWzj6IT5HJmqWANprx1Lls u2LNX//kEA9U3llfRb1WpGeJofyxC4ALtk5tfPD8EaiozZfwlKcToM0iBY7ogqjsBP5U 3+9Cr85Z5x4rUy8bcbV4mbnOIBPhKbbxKpn/hZ7Fh/TI6a8AeTNn2Z+XsS535b/F86yF glR1eFNwvaCcu1l7QzABvSX691DyzvvTB/fWop0TZSbqoXj2v1rEICrQ9RzzaUGtoNnW I4vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id z130si4013425qka.432.2017.12.14.03.07.25; Thu, 14 Dec 2017 03:07:25 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 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 62B5560693; Thu, 14 Dec 2017 11:07:25 +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 75D5E60967; Thu, 14 Dec 2017 11:01:31 +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 B1DB460960; Thu, 14 Dec 2017 11:01:19 +0000 (UTC) Received: from forward106j.mail.yandex.net (forward106j.mail.yandex.net [5.45.198.249]) by lists.linaro.org (Postfix) with ESMTPS id 87F4760916 for ; Thu, 14 Dec 2017 11:00:20 +0000 (UTC) Received: from mxback7g.mail.yandex.net (mxback7g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:168]) by forward106j.mail.yandex.net (Yandex) with ESMTP id 4AB8F1804086 for ; Thu, 14 Dec 2017 14:00:19 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback7g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 7SMT7d7Qs4-0J0ikBpO; Thu, 14 Dec 2017 14:00:19 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2d939Es19f-0ItuKV8E; Thu, 14 Dec 2017 14:00:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Thu, 14 Dec 2017 14:00:15 +0300 Message-Id: <1513249216-2411-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513249216-2411-1-git-send-email-odpbot@yandex.ru> References: <1513249216-2411-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 342 Subject: [lng-odp] [PATCH v4 3/4] linux-gen: crypto: move session type to odp_crypto module 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 There is no point in having odp_crypto_generic_session_t definition in global include file. Move it to odp_crypto module. Signed-off-by: Dmitry Eremin-Solenikov --- /** Email created from pull request 342 (lumag:openssl-ctx) ** https://github.com/Linaro/odp/pull/342 ** Patch: https://github.com/Linaro/odp/pull/342.patch ** Base sha: 6b5cdc77eb9759a2349b10372a964648559bc92c ** Merge commit sha: 3f12a06ef07bd4cf8b6a4d8350ba06e75299b8f6 **/ .../linux-generic/include/odp_crypto_internal.h | 50 ---------------------- platform/linux-generic/odp_crypto.c | 41 +++++++++++++++++- 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h index c3b70b231..bdbbf7379 100644 --- a/platform/linux-generic/include/odp_crypto_internal.h +++ b/platform/linux-generic/include/odp_crypto_internal.h @@ -11,50 +11,8 @@ extern "C" { #endif -#include - -#define MAX_IV_LEN 64 #define OP_RESULT_MAGIC 0x91919191 -/** Forward declaration of session structure */ -typedef struct odp_crypto_generic_session odp_crypto_generic_session_t; - -/** - * Algorithm handler function prototype - */ -typedef -odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param, - odp_crypto_generic_session_t *session); - -/** - * Per crypto session data structure - */ -struct odp_crypto_generic_session { - struct odp_crypto_generic_session *next; - - /* Session creation parameters */ - odp_crypto_session_param_t p; - - odp_bool_t do_cipher_first; - - struct { - /* Copy of session IV data */ - uint8_t iv_data[MAX_IV_LEN]; - uint8_t key_data[EVP_MAX_KEY_LENGTH]; - - const EVP_CIPHER *evp_cipher; - crypto_func_t func; - } cipher; - - struct { - uint8_t key[EVP_MAX_KEY_LENGTH]; - uint32_t key_length; - uint32_t bytes; - const EVP_MD *evp_md; - crypto_func_t func; - } auth; -}; - /** * Per packet operation result */ @@ -63,14 +21,6 @@ typedef struct odp_crypto_generic_op_result { odp_crypto_op_result_t result; } odp_crypto_generic_op_result_t; -/** - * Per session creation operation result - */ -typedef struct odp_crypto_generic_session_result { - odp_crypto_ses_create_err_t rc; - odp_crypto_session_t session; -} odp_crypto_generic_session_result_t; - #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c index 4c708931a..9b5d94034 100644 --- a/platform/linux-generic/odp_crypto.c +++ b/platform/linux-generic/odp_crypto.c @@ -75,6 +75,45 @@ static const odp_crypto_auth_capability_t auth_capa_sha512_hmac[] = { static const odp_crypto_auth_capability_t auth_capa_aes_gcm[] = { {.digest_len = 16, .key_len = 0, .aad_len = {.min = 8, .max = 12, .inc = 4} } }; +/** Forward declaration of session structure */ +typedef struct odp_crypto_generic_session_t odp_crypto_generic_session_t; + +/** + * Algorithm handler function prototype + */ +typedef +odp_crypto_alg_err_t (*crypto_func_t)(odp_crypto_op_param_t *param, + odp_crypto_generic_session_t *session); + +/** + * Per crypto session data structure + */ +struct odp_crypto_generic_session_t { + odp_crypto_generic_session_t *next; + + /* Session creation parameters */ + odp_crypto_session_param_t p; + + odp_bool_t do_cipher_first; + + struct { + /* Copy of session IV data */ + uint8_t iv_data[EVP_MAX_IV_LENGTH]; + uint8_t key_data[EVP_MAX_KEY_LENGTH]; + + const EVP_CIPHER *evp_cipher; + crypto_func_t func; + } cipher; + + struct { + uint8_t key[EVP_MAX_KEY_LENGTH]; + uint32_t key_length; + uint32_t bytes; + const EVP_MD *evp_md; + crypto_func_t func; + } auth; +}; + typedef struct odp_crypto_global_s odp_crypto_global_t; struct odp_crypto_global_s { @@ -705,7 +744,7 @@ odp_crypto_session_create(odp_crypto_session_param_t *param, /* Copy parameters */ session->p = *param; - if (session->p.iv.length > MAX_IV_LEN) { + if (session->p.iv.length > EVP_MAX_IV_LENGTH) { ODP_DBG("Maximum IV length exceeded\n"); free_session(session); return -1;