diff mbox series

[v1,4/12] api: crypto: use cipher_iv_ptr instead of override_iv_ptr

Message ID 1516608010-2535-5-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [v1,1/12] validation: crypto: stop declaring test functions as public | expand

Commit Message

Github ODP bot Jan. 22, 2018, 8 a.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


In preparation to add auth-specific IV, rename override_iv_ptr field to
ciper_iv_ptr. Provide deprecated compatibility field override_iv_ptr.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>

Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org>

Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>

---
/** Email created from pull request 413 (SonicwallYhe:api-next)
 ** https://github.com/Linaro/odp/pull/413
 ** Patch: https://github.com/Linaro/odp/pull/413.patch
 ** Base sha: 5a4502fc6bc53e6503169da3028f456b64811a0b
 ** Merge commit sha: 6669be7b55ab094f9e27d2101a6bb005ca87e405
 **/
 example/ipsec/odp_ipsec.c                        |  2 +-
 include/odp/api/spec/crypto.h                    | 18 ++++++++++++----
 platform/linux-generic/odp_crypto.c              | 26 ++++++++++++------------
 platform/linux-generic/odp_ipsec.c               |  8 ++++----
 test/validation/api/crypto/odp_crypto_test_inp.c | 18 ++++++++--------
 5 files changed, 41 insertions(+), 31 deletions(-)
diff mbox series

Patch

diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c
index 001f52084..c0978d0df 100644
--- a/example/ipsec/odp_ipsec.c
+++ b/example/ipsec/odp_ipsec.c
@@ -635,7 +635,7 @@  pkt_disposition_e do_ipsec_in_classify(odp_packet_t *pkt,
 	if (esp) {
 		params.cipher_range.offset = ipv4_data_p(ip) + hdr_len - buf;
 		params.cipher_range.length = ipv4_data_len(ip) - hdr_len;
-		params.override_iv_ptr = esp->iv;
+		params.cipher_iv_ptr = esp->iv;
 	}
 
 	/* Issue crypto request */
diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index 25ce2f86c..e44892fbf 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -400,8 +400,13 @@  typedef struct odp_crypto_op_param_t {
 	 */
 	odp_packet_t out_pkt;
 
-	/** Override session IV pointer */
-	uint8_t *override_iv_ptr;
+	/** Override session IV pointer for cipher */
+	union {
+		/** @deprecated use cipher_iv_ptr */
+		uint8_t *ODP_DEPRECATE(override_iv_ptr);
+		/** Override session IV pointer for cipher */
+		uint8_t *cipher_iv_ptr;
+	};
 
 	/** Offset from start of packet for hash result
 	 *
@@ -436,8 +441,13 @@  typedef struct odp_crypto_packet_op_param_t {
 	/** Session handle from creation */
 	odp_crypto_session_t session;
 
-	/** Override session IV pointer */
-	uint8_t *override_iv_ptr;
+	/** Override session IV pointer for cipher */
+	union {
+		/** @deprecated use cipher_iv_ptr */
+		uint8_t *ODP_DEPRECATE(override_iv_ptr);
+		/** Override session IV pointer for cipher */
+		uint8_t *cipher_iv_ptr;
+	};
 
 	/** Offset from start of packet for hash result
 	 *
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index eab82e9fa..35a83ce0f 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -434,8 +434,8 @@  odp_crypto_alg_err_t cipher_encrypt(odp_packet_t pkt,
 	void *iv_ptr;
 	int ret;
 
-	if (param->override_iv_ptr)
-		iv_ptr = param->override_iv_ptr;
+	if (param->cipher_iv_ptr)
+		iv_ptr = param->cipher_iv_ptr;
 	else if (session->p.cipher_iv.data)
 		iv_ptr = session->cipher.iv_data;
 	else
@@ -465,8 +465,8 @@  odp_crypto_alg_err_t cipher_decrypt(odp_packet_t pkt,
 	void *iv_ptr;
 	int ret;
 
-	if (param->override_iv_ptr)
-		iv_ptr = param->override_iv_ptr;
+	if (param->cipher_iv_ptr)
+		iv_ptr = param->cipher_iv_ptr;
 	else if (session->p.cipher_iv.data)
 		iv_ptr = session->cipher.iv_data;
 	else
@@ -528,8 +528,8 @@  odp_crypto_alg_err_t aes_gcm_encrypt(odp_packet_t pkt,
 	uint8_t block[EVP_MAX_MD_SIZE];
 	int ret;
 
-	if (param->override_iv_ptr)
-		iv_ptr = param->override_iv_ptr;
+	if (param->cipher_iv_ptr)
+		iv_ptr = param->cipher_iv_ptr;
 	else if (session->p.cipher_iv.data)
 		iv_ptr = session->cipher.iv_data;
 	else
@@ -575,8 +575,8 @@  odp_crypto_alg_err_t aes_gcm_decrypt(odp_packet_t pkt,
 	uint8_t block[EVP_MAX_MD_SIZE];
 	int ret;
 
-	if (param->override_iv_ptr)
-		iv_ptr = param->override_iv_ptr;
+	if (param->cipher_iv_ptr)
+		iv_ptr = param->cipher_iv_ptr;
 	else if (session->p.cipher_iv.data)
 		iv_ptr = session->cipher.iv_data;
 	else
@@ -641,8 +641,8 @@  odp_crypto_alg_err_t aes_gmac_gen(odp_packet_t pkt,
 	uint8_t block[EVP_MAX_MD_SIZE];
 	int ret;
 
-	if (param->override_iv_ptr)
-		iv_ptr = param->override_iv_ptr;
+	if (param->cipher_iv_ptr)
+		iv_ptr = param->cipher_iv_ptr;
 	else if (session->p.cipher_iv.data)
 		iv_ptr = session->cipher.iv_data;
 	else
@@ -680,8 +680,8 @@  odp_crypto_alg_err_t aes_gmac_check(odp_packet_t pkt,
 	uint8_t block[EVP_MAX_MD_SIZE];
 	int ret;
 
-	if (param->override_iv_ptr)
-		iv_ptr = param->override_iv_ptr;
+	if (param->cipher_iv_ptr)
+		iv_ptr = param->cipher_iv_ptr;
 	else if (session->p.cipher_iv.data)
 		iv_ptr = session->cipher.iv_data;
 	else
@@ -1101,7 +1101,7 @@  odp_crypto_operation(odp_crypto_op_param_t *param,
 	int rc;
 
 	packet_param.session = param->session;
-	packet_param.override_iv_ptr = param->override_iv_ptr;
+	packet_param.cipher_iv_ptr = param->cipher_iv_ptr;
 	packet_param.hash_result_offset = param->hash_result_offset;
 	packet_param.aad_ptr = param->aad_ptr;
 	packet_param.cipher_range = param->cipher_range;
diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c
index b023d308d..ab4fb5543 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -477,7 +477,7 @@  static int ipsec_in_esp(odp_packet_t *pkt,
 				    state->ip_hdr_len -
 				    state->in.hdr_len -
 				    ipsec_sa->icv_len;
-	param->override_iv_ptr = state->iv;
+	param->cipher_iv_ptr = state->iv;
 
 	state->esp.aad.spi = esp.spi;
 	state->esp.aad.seq_no = esp.seq_no;
@@ -560,7 +560,7 @@  static int ipsec_in_ah(odp_packet_t *pkt,
 		return -1;
 	}
 
-	param->override_iv_ptr = state->iv;
+	param->cipher_iv_ptr = state->iv;
 
 	state->in.hdr_len = (ah.ah_len + 2) * 4;
 	state->in.trl_len = 0;
@@ -1079,7 +1079,7 @@  static int ipsec_out_esp(odp_packet_t *pkt,
 		return -1;
 	}
 
-	param->override_iv_ptr = state->iv;
+	param->cipher_iv_ptr = state->iv;
 
 	memset(&esp, 0, sizeof(esp));
 	esp.spi = odp_cpu_to_be_32(ipsec_sa->spi);
@@ -1229,7 +1229,7 @@  static int ipsec_out_ah(odp_packet_t *pkt,
 		return -1;
 	}
 
-	param->override_iv_ptr = state->iv;
+	param->cipher_iv_ptr = state->iv;
 
 	if (odp_packet_extend_head(pkt, hdr_len, NULL, NULL) < 0) {
 		status->error.alg = 1;
diff --git a/test/validation/api/crypto/odp_crypto_test_inp.c b/test/validation/api/crypto/odp_crypto_test_inp.c
index d795baafc..7309b5d52 100644
--- a/test/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/validation/api/crypto/odp_crypto_test_inp.c
@@ -78,7 +78,7 @@  static const char *cipher_alg_name(odp_cipher_alg_t cipher)
 static int alg_op(odp_packet_t pkt,
 		  odp_bool_t *ok,
 		  odp_crypto_session_t session,
-		  uint8_t *op_iv_ptr,
+		  uint8_t *cipher_iv_ptr,
 		  odp_packet_data_range_t *cipher_range,
 		  odp_packet_data_range_t *auth_range,
 		  uint8_t *aad,
@@ -99,8 +99,8 @@  static int alg_op(odp_packet_t pkt,
 
 	op_params.cipher_range = *cipher_range;
 	op_params.auth_range = *auth_range;
-	if (op_iv_ptr)
-		op_params.override_iv_ptr = op_iv_ptr;
+	if (cipher_iv_ptr)
+		op_params.cipher_iv_ptr = cipher_iv_ptr;
 
 	op_params.aad_ptr = aad;
 
@@ -153,7 +153,7 @@  static int alg_op(odp_packet_t pkt,
 static int alg_packet_op(odp_packet_t pkt,
 			 odp_bool_t *ok,
 			 odp_crypto_session_t session,
-			 uint8_t *op_iv_ptr,
+			 uint8_t *cipher_iv_ptr,
 			 odp_packet_data_range_t *cipher_range,
 			 odp_packet_data_range_t *auth_range,
 			 uint8_t *aad,
@@ -171,8 +171,8 @@  static int alg_packet_op(odp_packet_t pkt,
 
 	op_params.cipher_range = *cipher_range;
 	op_params.auth_range = *auth_range;
-	if (op_iv_ptr)
-		op_params.override_iv_ptr = op_iv_ptr;
+	if (cipher_iv_ptr)
+		op_params.cipher_iv_ptr = cipher_iv_ptr;
 
 	op_params.aad_ptr = aad;
 
@@ -210,7 +210,7 @@  static int alg_packet_op(odp_packet_t pkt,
 static int alg_packet_op_enq(odp_packet_t pkt,
 			     odp_bool_t *ok,
 			     odp_crypto_session_t session,
-			     uint8_t *op_iv_ptr,
+			     uint8_t *cipher_iv_ptr,
 			     odp_packet_data_range_t *cipher_range,
 			     odp_packet_data_range_t *auth_range,
 			     uint8_t *aad,
@@ -229,8 +229,8 @@  static int alg_packet_op_enq(odp_packet_t pkt,
 
 	op_params.cipher_range = *cipher_range;
 	op_params.auth_range = *auth_range;
-	if (op_iv_ptr)
-		op_params.override_iv_ptr = op_iv_ptr;
+	if (cipher_iv_ptr)
+		op_params.cipher_iv_ptr = cipher_iv_ptr;
 
 	op_params.aad_ptr = aad;