Skip to content

[PATCH API-NEXT v5] Major cryptography code update#34

Closed
lumag wants to merge 23 commits intoOpenDataPlane:api-nextfrom
lumag:crypto-update-main-new
Closed

[PATCH API-NEXT v5] Major cryptography code update#34
lumag wants to merge 23 commits intoOpenDataPlane:api-nextfrom
lumag:crypto-update-main-new

Conversation

@lumag
Copy link
Copy Markdown

@lumag lumag commented May 22, 2017

@muvarov muvarov changed the title Major cryptography code update [PATCH API-NEXT v1] Major cryptography code update May 22, 2017
@lumag lumag force-pushed the crypto-update-main-new branch from a7c3ddf to 5ae6f6f Compare May 22, 2017 10:51
@muvarov muvarov changed the title [PATCH API-NEXT v1] Major cryptography code update [PATCH API-NEXT v2] Major cryptography code update May 22, 2017
@lumag lumag changed the title [PATCH API-NEXT v2] Major cryptography code update [PATCH API-NEXT v1] Major cryptography code update May 22, 2017
@lumag lumag force-pushed the crypto-update-main-new branch from 5ae6f6f to a60e15c Compare May 22, 2017 21:16
@muvarov muvarov changed the title [PATCH API-NEXT v1] Major cryptography code update [PATCH API-NEXT v2] Major cryptography code update May 22, 2017
@muvarov muvarov changed the title [PATCH API-NEXT v2] Major cryptography code update [PATCH API-NEXT v3] Major cryptography code update May 22, 2017
@lumag lumag changed the title [PATCH API-NEXT v3] Major cryptography code update [PATCH API-NEXT v2] Major cryptography code update May 22, 2017
@muvarov
Copy link
Copy Markdown
Contributor

muvarov commented May 31, 2017

From: Dmitry Eremin-Solenikov 
 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 
>>
>> Signed-off-by: Dmitry Eremin-Solenikov 
>> ---
>> /** 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
 

@lumag lumag force-pushed the crypto-update-main-new branch from 951e361 to ab422d6 Compare June 1, 2017 06:11
@muvarov muvarov changed the title [PATCH API-NEXT v2] Major cryptography code update [PATCH API-NEXT v3] Major cryptography code update Jun 1, 2017
@codecov-io
Copy link
Copy Markdown

codecov-io commented Jun 1, 2017

Codecov Report

Merging #34 into api-next will decrease coverage by 0.104%.
The diff coverage is 86.046%.

@@              Coverage Diff               @@
##           api-next       #34       +/-   ##
==============================================
- Coverage    75.979%   75.875%   -0.105%     
==============================================
  Files           171       170        -1     
  Lines         29192     29165       -27     
==============================================
- Hits          22180     22129       -51     
- Misses         7012      7036       +24
Impacted Files Coverage Δ
test/common_plat/performance/odp_crypto.c 78.853% <63.636%> (+0.01%) ⬆️
...n_plat/validation/api/crypto/odp_crypto_test_inp.c 85.21% <90.654%> (+0.504%) ⬆️
platform/linux-generic/pktio/ipc.c 61.341% <0%> (-15.655%) ⬇️
test/linux-generic/pktio_ipc/ipc_common.c 67.213% <0%> (-8.197%) ⬇️
test/common_plat/validation/api/timer/timer.c 79.124% <0%> (-2.357%) ⬇️
test/linux-generic/pktio_ipc/pktio_ipc1.c 69.273% <0%> (-1.676%) ⬇️
platform/linux-generic/_ishm.c 73.211% <0%> (-0.305%) ⬇️
test/linux-generic/pktio_ipc/pktio_ipc2.c
... and 3 more

Dmitry Eremin-Solenikov added 2 commits June 1, 2017 10:03
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
@lumag lumag force-pushed the crypto-update-main-new branch from ab422d6 to d2995e6 Compare June 1, 2017 07:28
@muvarov muvarov changed the title [PATCH API-NEXT v3] Major cryptography code update [PATCH API-NEXT v4] Major cryptography code update Jun 1, 2017
Dmitry Eremin-Solenikov added 9 commits June 1, 2017 11:25
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
In addition to truncated digests (used by IPsec) add full-length
capabilities to SHA* algos.

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

Make AES-GCM use recently introduced aad and auth_digest_len fields.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
There is no need to memcpy IV if it gets passed to EVP functions.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Using single context for all operations is not thread safe: multiple
threads can access the same context in parallel, affecting its internal
state. Make AES-GCM functions use local context for en/decryption
operations.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Rewrite AES-CBC to use generic EVP interface following AES-GCM
implementation.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Dmitry Eremin-Solenikov added 12 commits June 1, 2017 11:26
Rewrite 3DES-CBC to use generic EVP interface following AES-GCM
implementation.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
There is now nearly no difference between AES-CBC and 3DES-CBC code.
Merge it into generic 'cipher' support, easing adding support for other
ciphers in future.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
If odp_crypto_session_create() failed, there is no point in
checking/freeing session, as it might not have been updated.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
There is no point in having separate cases for NULL algorithms. Add
capabilities returning 0 key/digest/iv length.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>
@lumag lumag force-pushed the crypto-update-main-new branch from d2995e6 to 4c2ebeb Compare June 1, 2017 08:26
@muvarov muvarov changed the title [PATCH API-NEXT v4] Major cryptography code update [PATCH API-NEXT v5] Major cryptography code update Jun 1, 2017
@lumag
Copy link
Copy Markdown
Author

lumag commented Jun 2, 2017

Merged

@lumag lumag closed this Jun 2, 2017
@lumag lumag deleted the crypto-update-main-new branch June 2, 2017 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants