diff mbox series

[API-NEXT,1/9] api: ipsec: add salt parameter

Message ID 20170711123118.14745-1-petri.savolainen@linaro.org
State New
Headers show
Series [API-NEXT,1/9] api: ipsec: add salt parameter | expand

Commit Message

Petri Savolainen July 11, 2017, 12:31 p.m. UTC
Added a parameter for passing salt for AES GCM. Currently,
only option for length is 4 bytes, but later on other algorithms
may need more/less salt data.

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

---
 include/odp/api/spec/ipsec.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

-- 
2.13.0

Comments

Dmitry Eremin-Solenikov July 12, 2017, 8:25 a.m. UTC | #1
On 11.07.2017 15:31, Petri Savolainen wrote:
> Added a parameter for passing salt for AES GCM. Currently,

> only option for length is 4 bytes, but later on other algorithms

> may need more/less salt data.

> 

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

> ---

>  include/odp/api/spec/ipsec.h | 10 ++++++++++

>  1 file changed, 10 insertions(+)

> 

> diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h

> index e602e4b8..15dbb164 100644

> --- a/include/odp/api/spec/ipsec.h

> +++ b/include/odp/api/spec/ipsec.h

> @@ -384,6 +384,16 @@ typedef struct odp_ipsec_crypto_param_t {

>  	/** Authentication key */

>  	odp_crypto_key_t auth_key;

>  

> +	/** Salt for SA's that use AES_GCM algorithm. Other algorithms ignore

> +	 *  these fields. */


I'd suggest more generic wording:
- Additional static IV data used as salt or nonce for block IV
computation if algorithm/block mode requires it. For example, GCM
requires 4 bytes salt, CCM requires 3 bytes salt, CTR mode requires 4
bytes nonce.

> +	struct {

> +		/** Pointer to salt data. */

> +		const uint8_t *ptr;

> +

> +		/** Salt length. Valid value for AES_GCM is 4. */

> +		uint32_t len;

> +	} salt;

> +

>  } odp_ipsec_crypto_param_t;

>  

>  /**

> 



-- 
With best wishes
Dmitry
Dmitry Eremin-Solenikov July 12, 2017, 8:52 a.m. UTC | #2
On 11.07.2017 15:31, Petri Savolainen wrote:
> Added a parameter for passing salt for AES GCM. Currently,

> only option for length is 4 bytes, but later on other algorithms

> may need more/less salt data.

> 

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


Except the suggestion for PATCH 1/9, the rest of the patches is
Reviewed-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


-- 
With best wishes
Dmitry
Peltonen, Janne (Nokia - FI/Espoo) July 12, 2017, 9:31 a.m. UTC | #3
Dmitry Eremin-Solenikov wrote:
> On 11.07.2017 15:31, Petri Savolainen wrote:

> > Added a parameter for passing salt for AES GCM. Currently,

> > only option for length is 4 bytes, but later on other algorithms

> > may need more/less salt data.

> >

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

> > ---

> >  include/odp/api/spec/ipsec.h | 10 ++++++++++

> >  1 file changed, 10 insertions(+)

> >

> > diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h

> > index e602e4b8..15dbb164 100644

> > --- a/include/odp/api/spec/ipsec.h

> > +++ b/include/odp/api/spec/ipsec.h

> > @@ -384,6 +384,16 @@ typedef struct odp_ipsec_crypto_param_t {

> >  	/** Authentication key */

> >  	odp_crypto_key_t auth_key;

> >

> > +	/** Salt for SA's that use AES_GCM algorithm. Other algorithms ignore

> > +	 *  these fields. */

> 

> I'd suggest more generic wording:

> - Additional static IV data used as salt or nonce for block IV

> computation if algorithm/block mode requires it. For example, GCM

> requires 4 bytes salt, CCM requires 3 bytes salt, CTR mode requires 4

> bytes nonce.


I do not think that would be very good either since this is not for
computing ESP IV but GCM/CCM IV which is called nonce in the context
of ESP. IOW, I think the description should not refer to IV.

Maybe it should just be called 'additional keying material' and maybe the
structure name should also be changed from salt to something more generic.
An alternative would be to require that much more bytes in the key field(s)
but that would sort of change the meaning of odp_crypto_key_t when used in
the context of IPsec (the same algorithm would require different key lengths
depending on whether it is used through the IPsec API or the crypto API).

	Janne

> 

> > +	struct {

> > +		/** Pointer to salt data. */

> > +		const uint8_t *ptr;

> > +

> > +		/** Salt length. Valid value for AES_GCM is 4. */

> > +		uint32_t len;

> > +	} salt;

> > +

> >  } odp_ipsec_crypto_param_t;

> >

> >  /**

> >

> 

> 

> --

> With best wishes

> Dmitry
Dmitry Eremin-Solenikov July 12, 2017, 9:34 a.m. UTC | #4
On 12.07.2017 12:31, Peltonen, Janne (Nokia - FI/Espoo) wrote:
> Dmitry Eremin-Solenikov wrote:

>> On 11.07.2017 15:31, Petri Savolainen wrote:

>>> Added a parameter for passing salt for AES GCM. Currently,

>>> only option for length is 4 bytes, but later on other algorithms

>>> may need more/less salt data.

>>>

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

>>> ---

>>>  include/odp/api/spec/ipsec.h | 10 ++++++++++

>>>  1 file changed, 10 insertions(+)

>>>

>>> diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h

>>> index e602e4b8..15dbb164 100644

>>> --- a/include/odp/api/spec/ipsec.h

>>> +++ b/include/odp/api/spec/ipsec.h

>>> @@ -384,6 +384,16 @@ typedef struct odp_ipsec_crypto_param_t {

>>>  	/** Authentication key */

>>>  	odp_crypto_key_t auth_key;

>>>

>>> +	/** Salt for SA's that use AES_GCM algorithm. Other algorithms ignore

>>> +	 *  these fields. */

>>

>> I'd suggest more generic wording:

>> - Additional static IV data used as salt or nonce for block IV

>> computation if algorithm/block mode requires it. For example, GCM

>> requires 4 bytes salt, CCM requires 3 bytes salt, CTR mode requires 4

>> bytes nonce.

> 

> I do not think that would be very good either since this is not for

> computing ESP IV but GCM/CCM IV which is called nonce in the context

> of ESP. IOW, I think the description should not refer to IV.

> 

> Maybe it should just be called 'additional keying material' and maybe the

> structure name should also be changed from salt to something more generic.


I think nonce should be enough, with the comment that some algorithms
use it as salt.

> An alternative would be to require that much more bytes in the key field(s)

> but that would sort of change the meaning of odp_crypto_key_t when used in

> the context of IPsec (the same algorithm would require different key lengths

> depending on whether it is used through the IPsec API or the crypto API).


I think, think would be worse solution.

> 

> 	Janne

> 

>>

>>> +	struct {

>>> +		/** Pointer to salt data. */

>>> +		const uint8_t *ptr;

>>> +

>>> +		/** Salt length. Valid value for AES_GCM is 4. */

>>> +		uint32_t len;

>>> +	} salt;

>>> +

>>>  } odp_ipsec_crypto_param_t;

>>>

>>>  /**

>>>

>>

>>

>> --

>> With best wishes

>> Dmitry



-- 
With best wishes
Dmitry
Savolainen, Petri (Nokia - FI/Espoo) July 12, 2017, 12:59 p.m. UTC | #5
> -----Original Message-----

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

> Sent: Wednesday, July 12, 2017 11:53 AM

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

> odp@lists.linaro.org

> Subject: Re: [lng-odp] [API-NEXT PATCH 1/9] api: ipsec: add salt parameter

> 

> On 11.07.2017 15:31, Petri Savolainen wrote:

> > Added a parameter for passing salt for AES GCM. Currently,

> > only option for length is 4 bytes, but later on other algorithms

> > may need more/less salt data.

> >

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

> 

> Except the suggestion for PATCH 1/9, the rest of the patches is

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


Sent v2 with 1/9 modified, other patches was not changed. There's more generic salt/nonce params, for both cipher and auth.

-Petri
diff mbox series

Patch

diff --git a/include/odp/api/spec/ipsec.h b/include/odp/api/spec/ipsec.h
index e602e4b8..15dbb164 100644
--- a/include/odp/api/spec/ipsec.h
+++ b/include/odp/api/spec/ipsec.h
@@ -384,6 +384,16 @@  typedef struct odp_ipsec_crypto_param_t {
 	/** Authentication key */
 	odp_crypto_key_t auth_key;
 
+	/** Salt for SA's that use AES_GCM algorithm. Other algorithms ignore
+	 *  these fields. */
+	struct {
+		/** Pointer to salt data. */
+		const uint8_t *ptr;
+
+		/** Salt length. Valid value for AES_GCM is 4. */
+		uint32_t len;
+	} salt;
+
 } odp_ipsec_crypto_param_t;
 
 /**