diff mbox series

[API-NEXT,v2,2/20] test: crypto: explicitly pass AAD to crypto subsystem

Message ID 1495490409-30066-3-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v2,1/20] test: crypto: explicitly pass auth_digest_len to crypto subsystem | expand

Commit Message

Github ODP bot May 22, 2017, 9:59 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


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

---
/** Email created from pull request 34 (lumag:crypto-update-main-new)
 ** https://github.com/Linaro/odp/pull/34
 ** Patch: https://github.com/Linaro/odp/pull/34.patch
 ** Base sha: 826ee894aa0ebd09d42a17e1de077c46bc5b366a
 ** Merge commit sha: 7c49c61063e2d57f049a5436cf12a3c36710bb34
 **/
 .../validation/api/crypto/odp_crypto_test_inp.c    | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

Savolainen, Petri (Nokia - FI/Espoo) May 31, 2017, 11:33 a.m. UTC | #1
> -----Original Message-----

> From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of

> Github ODP bot

> Sent: Tuesday, May 23, 2017 1:00 AM

> To: lng-odp@lists.linaro.org

> Subject: [lng-odp] [PATCH API-NEXT v2 2/20] test: crypto: explicitly pass

> AAD to crypto subsystem

> 

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

> 

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

> ---

> /** Email created from pull request 34 (lumag:crypto-update-main-new)

>  ** https://github.com/Linaro/odp/pull/34

>  ** Patch: https://github.com/Linaro/odp/pull/34.patch

>  ** Base sha: 826ee894aa0ebd09d42a17e1de077c46bc5b366a

>  ** Merge commit sha: 7c49c61063e2d57f049a5436cf12a3c36710bb34

>  **/

>  .../validation/api/crypto/odp_crypto_test_inp.c    | 37

> ++++++++++++++++++++++

>  1 file changed, 37 insertions(+)

> 

> 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 3d09e374..3f57a907 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

> @@ -74,6 +74,8 @@ static void alg_test(odp_crypto_op_t op,

>  		     odp_crypto_key_t auth_key,

>  		     odp_packet_data_range_t *cipher_range,

>  		     odp_packet_data_range_t *auth_range,

> +		     uint8_t *aad,

> +		     uint32_t aad_len,

>  		     const uint8_t *plaintext,

>  		     unsigned int plaintext_len,

>  		     const uint8_t *ciphertext,

> @@ -240,6 +242,9 @@ static void alg_test(odp_crypto_op_t op,

>  	if (op_iv_ptr)

>  		op_params.override_iv_ptr = op_iv_ptr;

> 

> +	op_params.aad.ptr = aad;

> +	op_params.aad.length = aad_len;

> +

>  	op_params.hash_result_offset = plaintext_len;

>  	if (0 != digest_len) {

>  		memcpy(data_addr + op_params.hash_result_offset,

> @@ -472,6 +477,7 @@ void crypto_test_enc_alg_3des_cbc(void)

>  			 ODP_AUTH_ALG_NULL,

>  			 auth_key,

>  			 NULL, NULL,

> +			 NULL, 0,

>  			 tdes_cbc_reference_plaintext[i],

>  			 tdes_cbc_reference_length[i],

>  			 tdes_cbc_reference_ciphertext[i],

> @@ -508,6 +514,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)

>  			 ODP_AUTH_ALG_NULL,

>  			 auth_key,

>  			 NULL, NULL,

> +			 NULL, 0,

>  			 tdes_cbc_reference_plaintext[i],

>  			 tdes_cbc_reference_length[i],

>  			 tdes_cbc_reference_ciphertext[i],

> @@ -548,6 +555,7 @@ void crypto_test_dec_alg_3des_cbc(void)

>  			 ODP_AUTH_ALG_NULL,

>  			 auth_key,

>  			 NULL, NULL,

> +			 NULL, 0,

>  			 tdes_cbc_reference_ciphertext[i],

>  			 tdes_cbc_reference_length[i],

>  			 tdes_cbc_reference_plaintext[i],

> @@ -586,6 +594,7 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)

>  			 ODP_AUTH_ALG_NULL,

>  			 auth_key,

>  			 NULL, NULL,

> +			 NULL, 0,

>  			 tdes_cbc_reference_ciphertext[i],

>  			 tdes_cbc_reference_length[i],

>  			 tdes_cbc_reference_plaintext[i],

> @@ -636,6 +645,9 @@ void crypto_test_enc_alg_aes128_gcm(void)

>  			 &aes128_gcm_cipher_range[i],

>  			 &aes128_gcm_auth_range[i],


Shouldn't you insert the new parameters in her? Between auth_range and plaintext.

>  			 aes128_gcm_reference_plaintext[i],

> +			 aes128_gcm_cipher_range[i].offset -

> +			 aes128_gcm_auth_range[i].offset,


Shouldn't this first added param be aad pointer ?

> +			 aes128_gcm_reference_plaintext[i],


Shouldn't this second added param be aad length ?


The same issues are copy-pasted to all aes128 gcm cases.

-Petri
Dmitry Eremin-Solenikov May 31, 2017, 1:14 p.m. UTC | #2
On 31.05.2017 14:33, Savolainen, Petri (Nokia - FI/Espoo) wrote:
> 

> 

>> -----Original Message-----

>> From: lng-odp [mailto:lng-odp-bounces@lists.linaro.org] On Behalf Of

>> Github ODP bot

>> Sent: Tuesday, May 23, 2017 1:00 AM

>> To: lng-odp@lists.linaro.org

>> Subject: [lng-odp] [PATCH API-NEXT v2 2/20] test: crypto: explicitly pass

>> AAD to crypto subsystem

>>

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

>>

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

>> ---

>> /** Email created from pull request 34 (lumag:crypto-update-main-new)

>>  ** https://github.com/Linaro/odp/pull/34

>>  ** Patch: https://github.com/Linaro/odp/pull/34.patch

>>  ** Base sha: 826ee894aa0ebd09d42a17e1de077c46bc5b366a

>>  ** Merge commit sha: 7c49c61063e2d57f049a5436cf12a3c36710bb34

>>  **/

>>  .../validation/api/crypto/odp_crypto_test_inp.c    | 37

>> ++++++++++++++++++++++

>>  1 file changed, 37 insertions(+)

>>

>> 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 3d09e374..3f57a907 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

>> @@ -74,6 +74,8 @@ static void alg_test(odp_crypto_op_t op,

>>  		     odp_crypto_key_t auth_key,

>>  		     odp_packet_data_range_t *cipher_range,

>>  		     odp_packet_data_range_t *auth_range,

>> +		     uint8_t *aad,

>> +		     uint32_t aad_len,

>>  		     const uint8_t *plaintext,

>>  		     unsigned int plaintext_len,

>>  		     const uint8_t *ciphertext,

>> @@ -240,6 +242,9 @@ static void alg_test(odp_crypto_op_t op,

>>  	if (op_iv_ptr)

>>  		op_params.override_iv_ptr = op_iv_ptr;

>>

>> +	op_params.aad.ptr = aad;

>> +	op_params.aad.length = aad_len;

>> +

>>  	op_params.hash_result_offset = plaintext_len;

>>  	if (0 != digest_len) {

>>  		memcpy(data_addr + op_params.hash_result_offset,

>> @@ -472,6 +477,7 @@ void crypto_test_enc_alg_3des_cbc(void)

>>  			 ODP_AUTH_ALG_NULL,

>>  			 auth_key,

>>  			 NULL, NULL,

>> +			 NULL, 0,

>>  			 tdes_cbc_reference_plaintext[i],

>>  			 tdes_cbc_reference_length[i],

>>  			 tdes_cbc_reference_ciphertext[i],

>> @@ -508,6 +514,7 @@ void crypto_test_enc_alg_3des_cbc_ovr_iv(void)

>>  			 ODP_AUTH_ALG_NULL,

>>  			 auth_key,

>>  			 NULL, NULL,

>> +			 NULL, 0,

>>  			 tdes_cbc_reference_plaintext[i],

>>  			 tdes_cbc_reference_length[i],

>>  			 tdes_cbc_reference_ciphertext[i],

>> @@ -548,6 +555,7 @@ void crypto_test_dec_alg_3des_cbc(void)

>>  			 ODP_AUTH_ALG_NULL,

>>  			 auth_key,

>>  			 NULL, NULL,

>> +			 NULL, 0,

>>  			 tdes_cbc_reference_ciphertext[i],

>>  			 tdes_cbc_reference_length[i],

>>  			 tdes_cbc_reference_plaintext[i],

>> @@ -586,6 +594,7 @@ void crypto_test_dec_alg_3des_cbc_ovr_iv(void)

>>  			 ODP_AUTH_ALG_NULL,

>>  			 auth_key,

>>  			 NULL, NULL,

>> +			 NULL, 0,

>>  			 tdes_cbc_reference_ciphertext[i],

>>  			 tdes_cbc_reference_length[i],

>>  			 tdes_cbc_reference_plaintext[i],

>> @@ -636,6 +645,9 @@ void crypto_test_enc_alg_aes128_gcm(void)

>>  			 &aes128_gcm_cipher_range[i],

>>  			 &aes128_gcm_auth_range[i],

> 

> Shouldn't you insert the new parameters in her? Between auth_range and plaintext.

> 

>>  			 aes128_gcm_reference_plaintext[i],

>> +			 aes128_gcm_cipher_range[i].offset -

>> +			 aes128_gcm_auth_range[i].offset,

> 

> Shouldn't this first added param be aad pointer ?


In fact I have reused original test vectors, which come in form of
packet ::= AAD DATA

with auth_range pointing to AAD start and cipher_range pointing to data.
If you think this is counterintuitive, I can split AAD away.

Probably I should do that, as the question arose.

> 

>> +			 aes128_gcm_reference_plaintext[i],

> 

> Shouldn't this second added param be aad length ?

> 

> 

> The same issues are copy-pasted to all aes128 gcm cases.


-- 
With best wishes
Dmitry
diff mbox series

Patch

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 3d09e374..3f57a907 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
@@ -74,6 +74,8 @@  static void alg_test(odp_crypto_op_t op,
 		     odp_crypto_key_t auth_key,
 		     odp_packet_data_range_t *cipher_range,
 		     odp_packet_data_range_t *auth_range,
+		     uint8_t *aad,
+		     uint32_t aad_len,
 		     const uint8_t *plaintext,
 		     unsigned int plaintext_len,
 		     const uint8_t *ciphertext,
@@ -240,6 +242,9 @@  static void alg_test(odp_crypto_op_t op,
 	if (op_iv_ptr)
 		op_params.override_iv_ptr = op_iv_ptr;
 
+	op_params.aad.ptr = aad;
+	op_params.aad.length = aad_len;
+
 	op_params.hash_result_offset = plaintext_len;
 	if (0 != digest_len) {
 		memcpy(data_addr + op_params.hash_result_offset,
@@ -472,6 +477,7 @@  void crypto_test_enc_alg_3des_cbc(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 tdes_cbc_reference_plaintext[i],
 			 tdes_cbc_reference_length[i],
 			 tdes_cbc_reference_ciphertext[i],
@@ -508,6 +514,7 @@  void crypto_test_enc_alg_3des_cbc_ovr_iv(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 tdes_cbc_reference_plaintext[i],
 			 tdes_cbc_reference_length[i],
 			 tdes_cbc_reference_ciphertext[i],
@@ -548,6 +555,7 @@  void crypto_test_dec_alg_3des_cbc(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 tdes_cbc_reference_ciphertext[i],
 			 tdes_cbc_reference_length[i],
 			 tdes_cbc_reference_plaintext[i],
@@ -586,6 +594,7 @@  void crypto_test_dec_alg_3des_cbc_ovr_iv(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 tdes_cbc_reference_ciphertext[i],
 			 tdes_cbc_reference_length[i],
 			 tdes_cbc_reference_plaintext[i],
@@ -636,6 +645,9 @@  void crypto_test_enc_alg_aes128_gcm(void)
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
 			 aes128_gcm_reference_plaintext[i],
+			 aes128_gcm_cipher_range[i].offset -
+			 aes128_gcm_auth_range[i].offset,
+			 aes128_gcm_reference_plaintext[i],
 			 aes128_gcm_reference_length[i],
 			 aes128_gcm_reference_ciphertext[i],
 			 aes128_gcm_reference_length[i],
@@ -681,6 +693,9 @@  void crypto_test_enc_alg_aes128_gcm_ovr_iv(void)
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
 			 aes128_gcm_reference_plaintext[i],
+			 aes128_gcm_cipher_range[i].offset -
+			 aes128_gcm_auth_range[i].offset,
+			 aes128_gcm_reference_plaintext[i],
 			 aes128_gcm_reference_length[i],
 			 aes128_gcm_reference_ciphertext[i],
 			 aes128_gcm_reference_length[i],
@@ -731,6 +746,9 @@  void crypto_test_dec_alg_aes128_gcm(void)
 			 auth_key,
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
+			 aes128_gcm_reference_plaintext[i],
+			 aes128_gcm_cipher_range[i].offset -
+			 aes128_gcm_auth_range[i].offset,
 			 aes128_gcm_reference_ciphertext[i],
 			 aes128_gcm_reference_length[i] +
 			 aes128_gcm_reference_tag_length[i],
@@ -750,6 +768,9 @@  void crypto_test_dec_alg_aes128_gcm(void)
 			 auth_key,
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
+			 aes128_gcm_reference_plaintext[i],
+			 aes128_gcm_cipher_range[i].offset -
+			 aes128_gcm_auth_range[i].offset,
 			 aes128_gcm_reference_ciphertext[i],
 			 aes128_gcm_reference_length[i] +
 			 aes128_gcm_reference_tag_length[i],
@@ -799,6 +820,9 @@  void crypto_test_dec_alg_aes128_gcm_ovr_iv(void)
 			 auth_key,
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
+			 aes128_gcm_reference_plaintext[i],
+			 aes128_gcm_cipher_range[i].offset -
+			 aes128_gcm_auth_range[i].offset,
 			 aes128_gcm_reference_ciphertext[i],
 			 aes128_gcm_reference_length[i] +
 			 aes128_gcm_reference_tag_length[i],
@@ -818,6 +842,9 @@  void crypto_test_dec_alg_aes128_gcm_ovr_iv(void)
 			 auth_key,
 			 &aes128_gcm_cipher_range[i],
 			 &aes128_gcm_auth_range[i],
+			 aes128_gcm_reference_plaintext[i],
+			 aes128_gcm_cipher_range[i].offset -
+			 aes128_gcm_auth_range[i].offset,
 			 aes128_gcm_reference_ciphertext[i],
 			 aes128_gcm_reference_length[i] +
 			 aes128_gcm_reference_tag_length[i],
@@ -865,6 +892,7 @@  void crypto_test_enc_alg_aes128_cbc(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 aes128_cbc_reference_plaintext[i],
 			 aes128_cbc_reference_length[i],
 			 aes128_cbc_reference_ciphertext[i],
@@ -901,6 +929,7 @@  void crypto_test_enc_alg_aes128_cbc_ovr_iv(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 aes128_cbc_reference_plaintext[i],
 			 aes128_cbc_reference_length[i],
 			 aes128_cbc_reference_ciphertext[i],
@@ -941,6 +970,7 @@  void crypto_test_dec_alg_aes128_cbc(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 aes128_cbc_reference_ciphertext[i],
 			 aes128_cbc_reference_length[i],
 			 aes128_cbc_reference_plaintext[i],
@@ -979,6 +1009,7 @@  void crypto_test_dec_alg_aes128_cbc_ovr_iv(void)
 			 ODP_AUTH_ALG_NULL,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 aes128_cbc_reference_ciphertext[i],
 			 aes128_cbc_reference_length[i],
 			 aes128_cbc_reference_plaintext[i],
@@ -1025,6 +1056,7 @@  void crypto_test_gen_alg_hmac_md5(void)
 			 ODP_AUTH_ALG_MD5_HMAC,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 hmac_md5_reference_plaintext[i],
 			 hmac_md5_reference_length[i],
 			 NULL, 0,
@@ -1063,6 +1095,7 @@  void crypto_test_check_alg_hmac_md5(void)
 			 ODP_AUTH_ALG_MD5_HMAC,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 hmac_md5_reference_plaintext[i],
 			 hmac_md5_reference_length[i],
 			 NULL, 0,
@@ -1078,6 +1111,7 @@  void crypto_test_check_alg_hmac_md5(void)
 			 ODP_AUTH_ALG_MD5_HMAC,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 hmac_md5_reference_plaintext[i],
 			 hmac_md5_reference_length[i],
 			 NULL, 0,
@@ -1127,6 +1161,7 @@  void crypto_test_gen_alg_hmac_sha256(void)
 			 ODP_AUTH_ALG_SHA256_HMAC,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 hmac_sha256_reference_plaintext[i],
 			 hmac_sha256_reference_length[i],
 			 NULL, 0,
@@ -1167,6 +1202,7 @@  void crypto_test_check_alg_hmac_sha256(void)
 			 ODP_AUTH_ALG_SHA256_HMAC,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 hmac_sha256_reference_plaintext[i],
 			 hmac_sha256_reference_length[i],
 			 NULL, 0,
@@ -1182,6 +1218,7 @@  void crypto_test_check_alg_hmac_sha256(void)
 			 ODP_AUTH_ALG_SHA256_HMAC,
 			 auth_key,
 			 NULL, NULL,
+			 NULL, 0,
 			 hmac_sha256_reference_plaintext[i],
 			 hmac_sha256_reference_length[i],
 			 NULL, 0,