Re: [lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw cipher/auth algorithm check

2017-01-16 Thread Savolainen, Petri (Nokia - FI/Espoo)
Now when master is up to date with api-next, this patch set may be merged to 
master also. Actually, it would be good to have it in the release since it 
fixes false assumptions (in crypto validation test) and makes it possible to 
pass the test with various crypto implementations (that follow the API spec).

-Petri


> -Original Message-
> From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of Maxim
> Uvarov
> Sent: Monday, January 16, 2017 6:35 PM
> To: lng-odp@lists.linaro.org
> Subject: Re: [lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw
> cipher/auth algorithm check
> 
> Merged,
> Maxim.
> 
> On 01/12/17 09:01, Krishna Garapati wrote:
> > for this series,
> >
> > Reviewed-by: Balakrishna Garapati <balakrishna.garap...@linaro.org>
> >
> > /Krishna
> >
> > On 10 January 2017 at 13:09, Matias Elo <matias@nokia.com> wrote:
> >
> >> Some algorithms may be implemented using hardware and some using
> software.
> >> All supported algorithms should be set in capacity.auths
> /capacity.ciphers
> >> independent of implementation types.
> >>
> >> Signed-off-by: Matias Elo <matias@nokia.com>
> >> ---


Re: [lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw cipher/auth algorithm check

2017-01-16 Thread Maxim Uvarov
Merged,
Maxim.

On 01/12/17 09:01, Krishna Garapati wrote:
> for this series,
> 
> Reviewed-by: Balakrishna Garapati 
> 
> /Krishna
> 
> On 10 January 2017 at 13:09, Matias Elo  wrote:
> 
>> Some algorithms may be implemented using hardware and some using software.
>> All supported algorithms should be set in capacity.auths /capacity.ciphers
>> independent of implementation types.
>>
>> Signed-off-by: Matias Elo 
>> ---
>>  .../validation/api/crypto/odp_crypto_test_inp.c| 69
>> ++
>>  1 file changed, 31 insertions(+), 38 deletions(-)
>>
>> diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
>> b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
>> index de9d6e4..db58344 100644
>> --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
>> +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
>> @@ -47,7 +47,7 @@ static void alg_test(odp_crypto_op_t op,
>>  uint32_t digest_len)
>>  {
>> odp_crypto_session_t session;
>> -   odp_crypto_capability_t capability;
>> +   odp_crypto_capability_t capa;
>> int rc;
>> odp_crypto_ses_create_err_t status;
>> odp_bool_t posted;
>> @@ -63,50 +63,43 @@ static void alg_test(odp_crypto_op_t op,
>> int num, i;
>> int found;
>>
>> -   rc = odp_crypto_capability();
>> +   rc = odp_crypto_capability();
>> CU_ASSERT(!rc);
>>
>> -   if (capability.hw_ciphers.all_bits) {
>> -   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
>> -   !(capability.hw_ciphers.bit.trides_cbc))
>> -   rc = -1;
>> -   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
>> -   !(capability.hw_ciphers.bit.aes_cbc))
>> -   rc = -1;
>> -   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
>> -   !(capability.hw_ciphers.bit.aes_gcm))
>> -   rc = -1;
>> -   } else {
>> -   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
>> -   !(capability.ciphers.bit.trides_cbc))
>> -   rc = -1;
>> -   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
>> -   !(capability.ciphers.bit.aes_cbc))
>> -   rc = -1;
>> -   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
>> -   !(capability.ciphers.bit.aes_gcm))
>> -   rc = -1;
>> -   }
>> +   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
>> +   !(capa.ciphers.bit.trides_cbc))
>> +   rc = -1;
>> +   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
>> +   !(capa.ciphers.bit.aes_cbc))
>> +   rc = -1;
>> +   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
>> +   !(capa.ciphers.bit.aes_gcm))
>> +   rc = -1;
>> +   if (cipher_alg == ODP_CIPHER_ALG_DES &&
>> +   !(capa.ciphers.bit.des))
>> +   rc = -1;
>> +   if (cipher_alg == ODP_CIPHER_ALG_NULL &&
>> +   !(capa.ciphers.bit.null))
>> +   rc = -1;
>>
>> CU_ASSERT(!rc);
>> +   CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) ==
>> 0);
>>
>> -   if (capability.hw_auths.all_bits) {
>> -   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
>> -   !(capability.hw_auths.bit.aes_gcm))
>> -   rc = -1;
>> -   if (auth_alg == ODP_AUTH_ALG_NULL &&
>> -   !(capability.hw_auths.bit.null))
>> -   rc = -1;
>> -   } else {
>> -   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
>> -   !(capability.auths.bit.aes_gcm))
>> -   rc = -1;
>> -   if (auth_alg == ODP_AUTH_ALG_NULL &&
>> -   !(capability.auths.bit.null))
>> -   rc = -1;
>> -   }
>> +   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
>> +   !(capa.auths.bit.aes_gcm))
>> +   rc = -1;
>> +   if (auth_alg == ODP_AUTH_ALG_MD5_HMAC &&
>> +   !(capa.auths.bit.md5_hmac))
>> +   rc = -1;
>> +   if (auth_alg == ODP_AUTH_ALG_NULL &&
>> +   !(capa.auths.bit.null))
>> +   rc = -1;
>> +   if (auth_alg == ODP_AUTH_ALG_SHA256_HMAC &&
>> +   !(capa.auths.bit.sha256_hmac))
>> +   rc = -1;
>>
>> CU_ASSERT(!rc);
>> +   CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
>>
>> num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
>>MAX_ALG_CAPA);
>> --
>> 2.7.4
>>
>>



Re: [lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw cipher/auth algorithm check

2017-01-13 Thread Elo, Matias (Nokia - FI/Espoo)

> Can we add sync/Async in capabilities and add similar check before running 
> synchronous and asynchronous suites?
> 
> Regards
> Nikhil
> 

This would require crypto API changes. Adding simple sync/async capability 
flags may not be enough since used algorithm/packet size may determine if a 
particular mode is supported.

Implementing this would also require some modifications to the test framework. 
E.g. registering test suites with ODP_SUITE_INFO()/ODP_SUITE_INFO_CONDITIONAL() 
macros in the same manner as tests are currently registered.

-Matias



Re: [lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw cipher/auth algorithm check

2017-01-12 Thread Nikhil Agarwal
Can we add sync/Async in capabilities and add similar check before running 
synchronous and asynchronous suites?

Regards
Nikhil

-Original Message-
From: lng-odp [mailto:lng-odp-boun...@lists.linaro.org] On Behalf Of Matias Elo
Sent: Tuesday, January 10, 2017 5:39 PM
To: lng-odp@lists.linaro.org
Subject: [lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw cipher/auth 
algorithm check

Some algorithms may be implemented using hardware and some using software.
All supported algorithms should be set in capacity.auths /capacity.ciphers 
independent of implementation types.

Signed-off-by: Matias Elo <matias@nokia.com>
---
 .../validation/api/crypto/odp_crypto_test_inp.c| 69 ++
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c 
b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index de9d6e4..db58344 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -47,7 +47,7 @@ static void alg_test(odp_crypto_op_t op,
 uint32_t digest_len)
 {
odp_crypto_session_t session;
-   odp_crypto_capability_t capability;
+   odp_crypto_capability_t capa;
int rc;
odp_crypto_ses_create_err_t status;
odp_bool_t posted;
@@ -63,50 +63,43 @@ static void alg_test(odp_crypto_op_t op,
int num, i;
int found;
 
-   rc = odp_crypto_capability();
+   rc = odp_crypto_capability();
CU_ASSERT(!rc);
 
-   if (capability.hw_ciphers.all_bits) {
-   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
-   !(capability.hw_ciphers.bit.trides_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
-   !(capability.hw_ciphers.bit.aes_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
-   !(capability.hw_ciphers.bit.aes_gcm))
-   rc = -1;
-   } else {
-   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
-   !(capability.ciphers.bit.trides_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
-   !(capability.ciphers.bit.aes_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
-   !(capability.ciphers.bit.aes_gcm))
-   rc = -1;
-   }
+   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
+   !(capa.ciphers.bit.trides_cbc))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
+   !(capa.ciphers.bit.aes_cbc))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
+   !(capa.ciphers.bit.aes_gcm))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_DES &&
+   !(capa.ciphers.bit.des))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_NULL &&
+   !(capa.ciphers.bit.null))
+   rc = -1;
 
CU_ASSERT(!rc);
+   CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) == 0);
 
-   if (capability.hw_auths.all_bits) {
-   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
-   !(capability.hw_auths.bit.aes_gcm))
-   rc = -1;
-   if (auth_alg == ODP_AUTH_ALG_NULL &&
-   !(capability.hw_auths.bit.null))
-   rc = -1;
-   } else {
-   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
-   !(capability.auths.bit.aes_gcm))
-   rc = -1;
-   if (auth_alg == ODP_AUTH_ALG_NULL &&
-   !(capability.auths.bit.null))
-   rc = -1;
-   }
+   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
+   !(capa.auths.bit.aes_gcm))
+   rc = -1;
+   if (auth_alg == ODP_AUTH_ALG_MD5_HMAC &&
+   !(capa.auths.bit.md5_hmac))
+   rc = -1;
+   if (auth_alg == ODP_AUTH_ALG_NULL &&
+   !(capa.auths.bit.null))
+   rc = -1;
+   if (auth_alg == ODP_AUTH_ALG_SHA256_HMAC &&
+   !(capa.auths.bit.sha256_hmac))
+   rc = -1;
 
CU_ASSERT(!rc);
+   CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
 
num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
   MAX_ALG_CAPA);
--
2.7.4



Re: [lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw cipher/auth algorithm check

2017-01-11 Thread Krishna Garapati
for this series,

Reviewed-by: Balakrishna Garapati 

/Krishna

On 10 January 2017 at 13:09, Matias Elo  wrote:

> Some algorithms may be implemented using hardware and some using software.
> All supported algorithms should be set in capacity.auths /capacity.ciphers
> independent of implementation types.
>
> Signed-off-by: Matias Elo 
> ---
>  .../validation/api/crypto/odp_crypto_test_inp.c| 69
> ++
>  1 file changed, 31 insertions(+), 38 deletions(-)
>
> diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
> b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
> index de9d6e4..db58344 100644
> --- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
> +++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
> @@ -47,7 +47,7 @@ static void alg_test(odp_crypto_op_t op,
>  uint32_t digest_len)
>  {
> odp_crypto_session_t session;
> -   odp_crypto_capability_t capability;
> +   odp_crypto_capability_t capa;
> int rc;
> odp_crypto_ses_create_err_t status;
> odp_bool_t posted;
> @@ -63,50 +63,43 @@ static void alg_test(odp_crypto_op_t op,
> int num, i;
> int found;
>
> -   rc = odp_crypto_capability();
> +   rc = odp_crypto_capability();
> CU_ASSERT(!rc);
>
> -   if (capability.hw_ciphers.all_bits) {
> -   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
> -   !(capability.hw_ciphers.bit.trides_cbc))
> -   rc = -1;
> -   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
> -   !(capability.hw_ciphers.bit.aes_cbc))
> -   rc = -1;
> -   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
> -   !(capability.hw_ciphers.bit.aes_gcm))
> -   rc = -1;
> -   } else {
> -   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
> -   !(capability.ciphers.bit.trides_cbc))
> -   rc = -1;
> -   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
> -   !(capability.ciphers.bit.aes_cbc))
> -   rc = -1;
> -   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
> -   !(capability.ciphers.bit.aes_gcm))
> -   rc = -1;
> -   }
> +   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
> +   !(capa.ciphers.bit.trides_cbc))
> +   rc = -1;
> +   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
> +   !(capa.ciphers.bit.aes_cbc))
> +   rc = -1;
> +   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
> +   !(capa.ciphers.bit.aes_gcm))
> +   rc = -1;
> +   if (cipher_alg == ODP_CIPHER_ALG_DES &&
> +   !(capa.ciphers.bit.des))
> +   rc = -1;
> +   if (cipher_alg == ODP_CIPHER_ALG_NULL &&
> +   !(capa.ciphers.bit.null))
> +   rc = -1;
>
> CU_ASSERT(!rc);
> +   CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) ==
> 0);
>
> -   if (capability.hw_auths.all_bits) {
> -   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
> -   !(capability.hw_auths.bit.aes_gcm))
> -   rc = -1;
> -   if (auth_alg == ODP_AUTH_ALG_NULL &&
> -   !(capability.hw_auths.bit.null))
> -   rc = -1;
> -   } else {
> -   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
> -   !(capability.auths.bit.aes_gcm))
> -   rc = -1;
> -   if (auth_alg == ODP_AUTH_ALG_NULL &&
> -   !(capability.auths.bit.null))
> -   rc = -1;
> -   }
> +   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
> +   !(capa.auths.bit.aes_gcm))
> +   rc = -1;
> +   if (auth_alg == ODP_AUTH_ALG_MD5_HMAC &&
> +   !(capa.auths.bit.md5_hmac))
> +   rc = -1;
> +   if (auth_alg == ODP_AUTH_ALG_NULL &&
> +   !(capa.auths.bit.null))
> +   rc = -1;
> +   if (auth_alg == ODP_AUTH_ALG_SHA256_HMAC &&
> +   !(capa.auths.bit.sha256_hmac))
> +   rc = -1;
>
> CU_ASSERT(!rc);
> +   CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
>
> num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
>MAX_ALG_CAPA);
> --
> 2.7.4
>
>


[lng-odp] [API-NEXT PATCH 1/4] validation: crypto: fix hw cipher/auth algorithm check

2017-01-10 Thread Matias Elo
Some algorithms may be implemented using hardware and some using software.
All supported algorithms should be set in capacity.auths /capacity.ciphers
independent of implementation types.

Signed-off-by: Matias Elo 
---
 .../validation/api/crypto/odp_crypto_test_inp.c| 69 ++
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c 
b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
index de9d6e4..db58344 100644
--- a/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
+++ b/test/common_plat/validation/api/crypto/odp_crypto_test_inp.c
@@ -47,7 +47,7 @@ static void alg_test(odp_crypto_op_t op,
 uint32_t digest_len)
 {
odp_crypto_session_t session;
-   odp_crypto_capability_t capability;
+   odp_crypto_capability_t capa;
int rc;
odp_crypto_ses_create_err_t status;
odp_bool_t posted;
@@ -63,50 +63,43 @@ static void alg_test(odp_crypto_op_t op,
int num, i;
int found;
 
-   rc = odp_crypto_capability();
+   rc = odp_crypto_capability();
CU_ASSERT(!rc);
 
-   if (capability.hw_ciphers.all_bits) {
-   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
-   !(capability.hw_ciphers.bit.trides_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
-   !(capability.hw_ciphers.bit.aes_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
-   !(capability.hw_ciphers.bit.aes_gcm))
-   rc = -1;
-   } else {
-   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
-   !(capability.ciphers.bit.trides_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
-   !(capability.ciphers.bit.aes_cbc))
-   rc = -1;
-   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
-   !(capability.ciphers.bit.aes_gcm))
-   rc = -1;
-   }
+   if (cipher_alg == ODP_CIPHER_ALG_3DES_CBC &&
+   !(capa.ciphers.bit.trides_cbc))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_AES_CBC &&
+   !(capa.ciphers.bit.aes_cbc))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_AES_GCM &&
+   !(capa.ciphers.bit.aes_gcm))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_DES &&
+   !(capa.ciphers.bit.des))
+   rc = -1;
+   if (cipher_alg == ODP_CIPHER_ALG_NULL &&
+   !(capa.ciphers.bit.null))
+   rc = -1;
 
CU_ASSERT(!rc);
+   CU_ASSERT((~capa.ciphers.all_bits & capa.hw_ciphers.all_bits) == 0);
 
-   if (capability.hw_auths.all_bits) {
-   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
-   !(capability.hw_auths.bit.aes_gcm))
-   rc = -1;
-   if (auth_alg == ODP_AUTH_ALG_NULL &&
-   !(capability.hw_auths.bit.null))
-   rc = -1;
-   } else {
-   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
-   !(capability.auths.bit.aes_gcm))
-   rc = -1;
-   if (auth_alg == ODP_AUTH_ALG_NULL &&
-   !(capability.auths.bit.null))
-   rc = -1;
-   }
+   if (auth_alg == ODP_AUTH_ALG_AES_GCM &&
+   !(capa.auths.bit.aes_gcm))
+   rc = -1;
+   if (auth_alg == ODP_AUTH_ALG_MD5_HMAC &&
+   !(capa.auths.bit.md5_hmac))
+   rc = -1;
+   if (auth_alg == ODP_AUTH_ALG_NULL &&
+   !(capa.auths.bit.null))
+   rc = -1;
+   if (auth_alg == ODP_AUTH_ALG_SHA256_HMAC &&
+   !(capa.auths.bit.sha256_hmac))
+   rc = -1;
 
CU_ASSERT(!rc);
+   CU_ASSERT((~capa.auths.all_bits & capa.hw_auths.all_bits) == 0);
 
num = odp_crypto_cipher_capability(cipher_alg, cipher_capa,
   MAX_ALG_CAPA);
-- 
2.7.4