diff mbox series

[API-NEXT,v2,4/4] api: crypto: enforce deprecated API status

Message ID 1490882336-13721-5-git-send-email-petri.savolainen@linaro.org
State Accepted
Commit 8184de8ef8492a739d30c354628aada2e2bab366
Headers show
Series Deprecated macros | expand

Commit Message

Petri Savolainen March 30, 2017, 1:58 p.m. UTC
Used ODP_DEPRECATE() to control if deprecated API
definitions are visible in the API or not.

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

---
 include/odp/api/spec/crypto.h       | 29 ++++++++++++++----------
 platform/linux-generic/odp_crypto.c | 45 +++++++++++++++++++++++++------------
 2 files changed, 48 insertions(+), 26 deletions(-)

-- 
2.8.1

Comments

Dmitry Eremin-Solenikov April 27, 2017, 9:46 a.m. UTC | #1
On 30.03.2017 16:58, Petri Savolainen wrote:
> diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c

> index 2ba504b..228e598 100644

> --- a/platform/linux-generic/odp_crypto.c

> +++ b/platform/linux-generic/odp_crypto.c

> @@ -644,12 +644,13 @@ int odp_crypto_capability(odp_crypto_capability_t *capa)

>  	capa->auths.bit.sha512_hmac  = 0;

>  	capa->auths.bit.aes_gcm      = 1;

>  

> -	/* Deprecated */

> +#if ODP_DEPRECATED_API

>  	capa->ciphers.bit.aes128_cbc = 1;

>  	capa->ciphers.bit.aes128_gcm = 1;

>  	capa->auths.bit.md5_96       = 1;

>  	capa->auths.bit.sha256_128   = 1;

>  	capa->auths.bit.aes128_gcm   = 1;

> +#endif


I thought that we can write this instead as

  	capa->ciphers.bit.ODP_DEPRECATED(aes128_cbc) = 1;
  	capa->ciphers.bit.ODP_DEPRECATED(aes128_gcm) = 1;
  	capa->auths.bit.ODP_DEPRECATED(md5_96)       = 1;
  	capa->auths.bit.ODP_DEPRECATED(sha256_128)   = 1;
  	capa->auths.bit.ODP_DEPRECATED(aes128_gcm)   = 1;


(same applies to other places inside odp_crypto.c).

However we can change this later if we see point in it (or maybe a
suggestion from distro guys). I'd propose to merge this series as is.
So, for the whole patchset:

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


-- 
With best wishes
Dmitry
Savolainen, Petri (Nokia - FI/Espoo) May 2, 2017, 7:21 a.m. UTC | #2
> -----Original Message-----

> From: Dmitry Eremin-Solenikov [mailto:dmitry.ereminsolenikov@linaro.org]

> Sent: Thursday, April 27, 2017 12:47 PM

> To: Petri Savolainen <petri.savolainen@linaro.org>; lng-

> odp@lists.linaro.org

> Subject: Re: [lng-odp] [API-NEXT PATCH v2 4/4] api: crypto: enforce

> deprecated API status

> 

> On 30.03.2017 16:58, Petri Savolainen wrote:

> > diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-

> generic/odp_crypto.c

> > index 2ba504b..228e598 100644

> > --- a/platform/linux-generic/odp_crypto.c

> > +++ b/platform/linux-generic/odp_crypto.c

> > @@ -644,12 +644,13 @@ int odp_crypto_capability(odp_crypto_capability_t

> *capa)

> >  	capa->auths.bit.sha512_hmac  = 0;

> >  	capa->auths.bit.aes_gcm      = 1;

> >

> > -	/* Deprecated */

> > +#if ODP_DEPRECATED_API

> >  	capa->ciphers.bit.aes128_cbc = 1;

> >  	capa->ciphers.bit.aes128_gcm = 1;

> >  	capa->auths.bit.md5_96       = 1;

> >  	capa->auths.bit.sha256_128   = 1;

> >  	capa->auths.bit.aes128_gcm   = 1;

> > +#endif

> 

> I thought that we can write this instead as

> 

>   	capa->ciphers.bit.ODP_DEPRECATED(aes128_cbc) = 1;

>   	capa->ciphers.bit.ODP_DEPRECATED(aes128_gcm) = 1;

>   	capa->auths.bit.ODP_DEPRECATED(md5_96)       = 1;

>   	capa->auths.bit.ODP_DEPRECATED(sha256_128)   = 1;

>   	capa->auths.bit.ODP_DEPRECATED(aes128_gcm)   = 1;

> 

> 

> (same applies to other places inside odp_crypto.c).

> 

> However we can change this later if we see point in it (or maybe a

> suggestion from distro guys). I'd propose to merge this series as is.

> So, for the whole patchset:

> 

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



Yes, it's an implementation / coding style / packaging / etc choice whether "#if ODP_DEPRECATED_API" or "bit.ODP_DEPRECATED(foo) = 1" is used - both are possible after this set.

Thanks, for the review.

-Petri
diff mbox series

Patch

diff --git a/include/odp/api/spec/crypto.h b/include/odp/api/spec/crypto.h
index d30f050..181c0cc 100644
--- a/include/odp/api/spec/crypto.h
+++ b/include/odp/api/spec/crypto.h
@@ -15,6 +15,8 @@ 
 #define ODP_API_CRYPTO_H_
 #include <odp/visibility_begin.h>
 
+#include <odp/api/deprecated.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -82,10 +84,10 @@  typedef enum {
 	ODP_CIPHER_ALG_AES_GCM,
 
 	/** @deprecated  Use ODP_CIPHER_ALG_AES_CBC instead */
-	ODP_CIPHER_ALG_AES128_CBC,
+	ODP_DEPRECATE(ODP_CIPHER_ALG_AES128_CBC),
 
 	/** @deprecated  Use ODP_CIPHER_ALG_AES_GCM instead */
-	ODP_CIPHER_ALG_AES128_GCM
+	ODP_DEPRECATE(ODP_CIPHER_ALG_AES128_GCM)
 
 } odp_cipher_alg_t;
 
@@ -127,13 +129,14 @@  typedef enum {
 	ODP_AUTH_ALG_AES_GCM,
 
 	/** @deprecated  Use ODP_AUTH_ALG_MD5_HMAC instead */
-	ODP_AUTH_ALG_MD5_96,
+	ODP_DEPRECATE(ODP_AUTH_ALG_MD5_96),
 
 	/** @deprecated  Use ODP_AUTH_ALG_SHA256_HMAC instead */
-	ODP_AUTH_ALG_SHA256_128,
+	ODP_DEPRECATE(ODP_AUTH_ALG_SHA256_128),
 
 	/** @deprecated  Use ODP_AUTH_ALG_AES_GCM instead */
-	ODP_AUTH_ALG_AES128_GCM
+	ODP_DEPRECATE(ODP_AUTH_ALG_AES128_GCM)
+
 } odp_auth_alg_t;
 
 /**
@@ -158,10 +161,11 @@  typedef union odp_crypto_cipher_algos_t {
 		uint32_t aes_gcm     : 1;
 
 		/** @deprecated  Use aes_cbc instead */
-		uint32_t aes128_cbc  : 1;
+		uint32_t ODP_DEPRECATE(aes128_cbc) : 1;
 
 		/** @deprecated  Use aes_gcm instead */
-		uint32_t aes128_gcm  : 1;
+		uint32_t ODP_DEPRECATE(aes128_gcm) : 1;
+
 	} bit;
 
 	/** All bits of the bit field structure
@@ -196,13 +200,14 @@  typedef union odp_crypto_auth_algos_t {
 		uint32_t aes_gcm     : 1;
 
 		/** @deprecated  Use md5_hmac instead */
-		uint32_t md5_96      : 1;
+		uint32_t ODP_DEPRECATE(md5_96)     : 1;
 
 		/** @deprecated  Use sha256_hmac instead */
-		uint32_t sha256_128  : 1;
+		uint32_t ODP_DEPRECATE(sha256_128) : 1;
 
 		/** @deprecated  Use aes_gcm instead */
-		uint32_t aes128_gcm  : 1;
+		uint32_t ODP_DEPRECATE(aes128_gcm) : 1;
+
 	} bit;
 
 	/** All bits of the bit field structure
@@ -317,7 +322,7 @@  typedef struct odp_crypto_session_param_t {
 } odp_crypto_session_param_t;
 
 /** @deprecated  Use odp_crypto_session_param_t instead */
-typedef odp_crypto_session_param_t odp_crypto_session_params_t;
+typedef odp_crypto_session_param_t ODP_DEPRECATE(odp_crypto_session_params_t);
 
 /**
  * Crypto API per packet operation parameters
@@ -373,7 +378,7 @@  typedef struct odp_crypto_op_param_t {
 } odp_crypto_op_param_t;
 
 /** @deprecated  Use odp_crypto_op_param_t instead */
-typedef odp_crypto_op_param_t odp_crypto_op_params_t;
+typedef odp_crypto_op_param_t ODP_DEPRECATE(odp_crypto_op_params_t);
 
 /**
  * Crypto API session creation return code
diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index 2ba504b..228e598 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -644,12 +644,13 @@  int odp_crypto_capability(odp_crypto_capability_t *capa)
 	capa->auths.bit.sha512_hmac  = 0;
 	capa->auths.bit.aes_gcm      = 1;
 
-	/* Deprecated */
+#if ODP_DEPRECATED_API
 	capa->ciphers.bit.aes128_cbc = 1;
 	capa->ciphers.bit.aes128_gcm = 1;
 	capa->auths.bit.md5_96       = 1;
 	capa->auths.bit.sha256_128   = 1;
 	capa->auths.bit.aes128_gcm   = 1;
+#endif
 
 	capa->max_sessions = MAX_SESSIONS;
 
@@ -740,6 +741,7 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 {
 	int rc;
 	odp_crypto_generic_session_t *session;
+	int aes_gcm = 0;
 
 	/* Default to successful result */
 	*status = ODP_CRYPTO_SES_CREATE_ERR_NONE;
@@ -782,17 +784,21 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 		rc = process_des_param(session);
 		break;
 	case ODP_CIPHER_ALG_AES_CBC:
-	     /* deprecated */
+#if ODP_DEPRECATED_API
 	case ODP_CIPHER_ALG_AES128_CBC:
+#endif
 		rc = process_aes_param(session);
 		break;
-	case ODP_CIPHER_ALG_AES_GCM:
-	     /* deprecated */
+#if ODP_DEPRECATED_API
 	case ODP_CIPHER_ALG_AES128_GCM:
+		if (param->auth_alg == ODP_AUTH_ALG_AES128_GCM)
+			aes_gcm = 1;
+		/* Fallthrough */
+#endif
+	case ODP_CIPHER_ALG_AES_GCM:
 		/* AES-GCM requires to do both auth and
 		 * cipher at the same time */
-		if (param->auth_alg == ODP_AUTH_ALG_AES_GCM ||
-		    param->auth_alg == ODP_AUTH_ALG_AES128_GCM)
+		if (param->auth_alg == ODP_AUTH_ALG_AES_GCM || aes_gcm)
 			rc = process_aes_gcm_param(session);
 		else
 			rc = -1;
@@ -807,6 +813,8 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 		return -1;
 	}
 
+	aes_gcm = 0;
+
 	/* Process based on auth */
 	switch (param->auth_alg) {
 	case ODP_AUTH_ALG_NULL:
@@ -814,22 +822,27 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 		rc = 0;
 		break;
 	case ODP_AUTH_ALG_MD5_HMAC:
-	     /* deprecated */
+#if ODP_DEPRECATED_API
 	case ODP_AUTH_ALG_MD5_96:
+#endif
 		rc = process_md5_param(session, 96);
 		break;
 	case ODP_AUTH_ALG_SHA256_HMAC:
-	     /* deprecated */
+#if ODP_DEPRECATED_API
 	case ODP_AUTH_ALG_SHA256_128:
+#endif
 		rc = process_sha256_param(session, 128);
 		break;
-	case ODP_AUTH_ALG_AES_GCM:
-	     /* deprecated */
+#if ODP_DEPRECATED_API
 	case ODP_AUTH_ALG_AES128_GCM:
+		if (param->cipher_alg == ODP_CIPHER_ALG_AES128_GCM)
+			aes_gcm = 1;
+		/* Fallthrough */
+#endif
+	case ODP_AUTH_ALG_AES_GCM:
 		/* AES-GCM requires to do both auth and
 		 * cipher at the same time */
-		if (param->cipher_alg == ODP_CIPHER_ALG_AES_GCM ||
-		    param->cipher_alg == ODP_CIPHER_ALG_AES128_GCM) {
+		if (param->cipher_alg == ODP_CIPHER_ALG_AES_GCM || aes_gcm) {
 			session->auth.func = null_crypto_routine;
 			rc = 0;
 		} else {
@@ -854,10 +867,14 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 int odp_crypto_session_destroy(odp_crypto_session_t session)
 {
 	odp_crypto_generic_session_t *generic;
+	int aes_gcm = 0;
 
 	generic = (odp_crypto_generic_session_t *)(intptr_t)session;
-	if (generic->p.cipher_alg == ODP_CIPHER_ALG_AES128_GCM ||
-	    generic->p.cipher_alg == ODP_CIPHER_ALG_AES_GCM)
+#if ODP_DEPRECATED_API
+	if (generic->p.cipher_alg == ODP_CIPHER_ALG_AES128_GCM)
+		aes_gcm = 1;
+#endif
+	if (generic->p.cipher_alg == ODP_CIPHER_ALG_AES_GCM || aes_gcm)
 		EVP_CIPHER_CTX_free(generic->cipher.data.aes_gcm.ctx);
 	memset(generic, 0, sizeof(*generic));
 	free_session(generic);