diff mbox series

[API-NEXT,v5,2/6] linux-gen: crypto: move session type to odp_crypto module

Message ID 1515024013-30222-3-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v5,1/6] validation: crypto: stop declaring test functions as public | expand

Commit Message

Github ODP bot Jan. 4, 2018, midnight UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


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 <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 352 (lumag:crypto_gmac_iv)
 ** https://github.com/Linaro/odp/pull/352
 ** Patch: https://github.com/Linaro/odp/pull/352.patch
 ** Base sha: 6303c7d0e98fafe0f14c8c4dd9989b3b7633ebf4
 ** Merge commit sha: 5a1e35f8e8d8df2bc17b098f7c9c92611ea98e23
 **/
 platform/linux-generic/Makefile.am                 |  1 -
 .../linux-generic/include/odp_crypto_internal.h    | 73 ----------------------
 platform/linux-generic/odp_crypto.c                | 46 +++++++++++++-
 3 files changed, 44 insertions(+), 76 deletions(-)
 delete mode 100644 platform/linux-generic/include/odp_crypto_internal.h
diff mbox series

Patch

diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index 9f7993d81..12d8131e8 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -140,7 +140,6 @@  noinst_HEADERS = \
 		  include/odp_classification_inlines.h \
 		  include/odp_classification_internal.h \
 		  include/odp_config_internal.h \
-		  include/odp_crypto_internal.h \
 		  include/odp_debug_internal.h \
 		  include/odp_errno_define.h \
 		  include/odp_forward_typedefs_internal.h \
diff --git a/platform/linux-generic/include/odp_crypto_internal.h b/platform/linux-generic/include/odp_crypto_internal.h
deleted file mode 100644
index 32178d9de..000000000
--- a/platform/linux-generic/include/odp_crypto_internal.h
+++ /dev/null
@@ -1,73 +0,0 @@ 
-/* Copyright (c) 2014, Linaro Limited
- * All rights reserved.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- */
-
-#ifndef ODP_CRYPTO_INTERNAL_H_
-#define ODP_CRYPTO_INTERNAL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <openssl/evp.h>
-
-#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_packet_t pkt,
-				      const odp_crypto_packet_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;
-		union {
-			const EVP_MD *evp_md;
-			const EVP_CIPHER *evp_cipher;
-		};
-		crypto_func_t func;
-	} auth;
-};
-
-/**
- * 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
-
-#endif
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 2038aa46b..3b110c191 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -15,7 +15,6 @@ 
 #include <odp/api/debug.h>
 #include <odp/api/align.h>
 #include <odp/api/shared_memory.h>
-#include <odp_crypto_internal.h>
 #include <odp_debug_internal.h>
 #include <odp/api/hints.h>
 #include <odp/api/random.h>
@@ -89,6 +88,49 @@  static const odp_crypto_auth_capability_t auth_capa_aes_gcm[] = {
 static const odp_crypto_auth_capability_t auth_capa_aes_gmac[] = {
 {.digest_len = 16, .key_len = 16, .aad_len = {.min = 0, .max = 0, .inc = 0} } };
 
+/** 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_packet_t pkt,
+				      const odp_crypto_packet_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;
+		union {
+			const EVP_MD *evp_md;
+			const EVP_CIPHER *evp_cipher;
+		};
+		crypto_func_t func;
+	} auth;
+};
+
 typedef struct odp_crypto_global_s odp_crypto_global_t;
 
 struct odp_crypto_global_s {
@@ -860,7 +902,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");
 		*status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
 		goto err;