@@ -2415,8 +2415,8 @@ void cipher_encrypt( int alg_arg, int key_type_arg,
2415
2415
&function_output_length ) );
2416
2416
total_output_length += function_output_length;
2417
2417
status = psa_cipher_finish( &operation,
2418
- output + function_output_length ,
2419
- output_buffer_size,
2418
+ output + total_output_length ,
2419
+ output_buffer_size - total_output_length ,
2420
2420
&function_output_length );
2421
2421
total_output_length += function_output_length;
2422
2422
@@ -2439,12 +2439,16 @@ exit:
2439
2439
void cipher_encrypt_multipart( int alg_arg, int key_type_arg,
2440
2440
data_t *key,
2441
2441
data_t *input,
2442
- int first_part_size,
2442
+ int first_part_size_arg,
2443
+ int output1_length_arg, int output2_length_arg,
2443
2444
data_t *expected_output )
2444
2445
{
2445
2446
psa_key_handle_t handle = 0;
2446
2447
psa_key_type_t key_type = key_type_arg;
2447
2448
psa_algorithm_t alg = alg_arg;
2449
+ size_t first_part_size = first_part_size_arg;
2450
+ size_t output1_length = output1_length_arg;
2451
+ size_t output2_length = output2_length_arg;
2448
2452
unsigned char iv[16] = {0};
2449
2453
size_t iv_size;
2450
2454
unsigned char *output = NULL;
@@ -2475,20 +2479,23 @@ void cipher_encrypt_multipart( int alg_arg, int key_type_arg,
2475
2479
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
2476
2480
ASSERT_ALLOC( output, output_buffer_size );
2477
2481
2478
- TEST_ASSERT( (unsigned int) first_part_size < input->len );
2482
+ TEST_ASSERT( first_part_size <= input->len );
2479
2483
PSA_ASSERT( psa_cipher_update( &operation, input->x, first_part_size,
2480
2484
output, output_buffer_size,
2481
2485
&function_output_length ) );
2486
+ TEST_ASSERT( function_output_length == output1_length );
2482
2487
total_output_length += function_output_length;
2483
2488
PSA_ASSERT( psa_cipher_update( &operation,
2484
2489
input->x + first_part_size,
2485
2490
input->len - first_part_size,
2486
- output, output_buffer_size,
2491
+ output + total_output_length,
2492
+ output_buffer_size - total_output_length,
2487
2493
&function_output_length ) );
2494
+ TEST_ASSERT( function_output_length == output2_length );
2488
2495
total_output_length += function_output_length;
2489
2496
PSA_ASSERT( psa_cipher_finish( &operation,
2490
- output + function_output_length ,
2491
- output_buffer_size,
2497
+ output + total_output_length ,
2498
+ output_buffer_size - total_output_length ,
2492
2499
&function_output_length ) );
2493
2500
total_output_length += function_output_length;
2494
2501
PSA_ASSERT( psa_cipher_abort( &operation ) );
@@ -2507,13 +2514,17 @@ exit:
2507
2514
void cipher_decrypt_multipart( int alg_arg, int key_type_arg,
2508
2515
data_t *key,
2509
2516
data_t *input,
2510
- int first_part_size,
2517
+ int first_part_size_arg,
2518
+ int output1_length_arg, int output2_length_arg,
2511
2519
data_t *expected_output )
2512
2520
{
2513
2521
psa_key_handle_t handle = 0;
2514
2522
2515
2523
psa_key_type_t key_type = key_type_arg;
2516
2524
psa_algorithm_t alg = alg_arg;
2525
+ size_t first_part_size = first_part_size_arg;
2526
+ size_t output1_length = output1_length_arg;
2527
+ size_t output2_length = output2_length_arg;
2517
2528
unsigned char iv[16] = {0};
2518
2529
size_t iv_size;
2519
2530
unsigned char *output = NULL;
@@ -2545,21 +2556,24 @@ void cipher_decrypt_multipart( int alg_arg, int key_type_arg,
2545
2556
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
2546
2557
ASSERT_ALLOC( output, output_buffer_size );
2547
2558
2548
- TEST_ASSERT( (unsigned int) first_part_size < input->len );
2559
+ TEST_ASSERT( first_part_size <= input->len );
2549
2560
PSA_ASSERT( psa_cipher_update( &operation,
2550
2561
input->x, first_part_size,
2551
2562
output, output_buffer_size,
2552
2563
&function_output_length ) );
2564
+ TEST_ASSERT( function_output_length == output1_length );
2553
2565
total_output_length += function_output_length;
2554
2566
PSA_ASSERT( psa_cipher_update( &operation,
2555
2567
input->x + first_part_size,
2556
2568
input->len - first_part_size,
2557
- output, output_buffer_size,
2569
+ output + total_output_length,
2570
+ output_buffer_size - total_output_length,
2558
2571
&function_output_length ) );
2572
+ TEST_ASSERT( function_output_length == output2_length );
2559
2573
total_output_length += function_output_length;
2560
2574
PSA_ASSERT( psa_cipher_finish( &operation,
2561
- output + function_output_length ,
2562
- output_buffer_size,
2575
+ output + total_output_length ,
2576
+ output_buffer_size - total_output_length ,
2563
2577
&function_output_length ) );
2564
2578
total_output_length += function_output_length;
2565
2579
PSA_ASSERT( psa_cipher_abort( &operation ) );
@@ -2622,8 +2636,8 @@ void cipher_decrypt( int alg_arg, int key_type_arg,
2622
2636
&function_output_length ) );
2623
2637
total_output_length += function_output_length;
2624
2638
status = psa_cipher_finish( &operation,
2625
- output + function_output_length ,
2626
- output_buffer_size,
2639
+ output + total_output_length ,
2640
+ output_buffer_size - total_output_length ,
2627
2641
&function_output_length );
2628
2642
total_output_length += function_output_length;
2629
2643
TEST_EQUAL( status, expected_status );
@@ -2689,7 +2703,8 @@ void cipher_verify_output( int alg_arg, int key_type_arg,
2689
2703
output1, output1_size,
2690
2704
&output1_length ) );
2691
2705
PSA_ASSERT( psa_cipher_finish( &operation1,
2692
- output1 + output1_length, output1_size,
2706
+ output1 + output1_length,
2707
+ output1_size - output1_length,
2693
2708
&function_output_length ) );
2694
2709
2695
2710
output1_length += function_output_length;
@@ -2707,7 +2722,7 @@ void cipher_verify_output( int alg_arg, int key_type_arg,
2707
2722
function_output_length = 0;
2708
2723
PSA_ASSERT( psa_cipher_finish( &operation2,
2709
2724
output2 + output2_length,
2710
- output2_size,
2725
+ output2_size - output2_length ,
2711
2726
&function_output_length ) );
2712
2727
2713
2728
output2_length += function_output_length;
@@ -2729,11 +2744,12 @@ void cipher_verify_output_multipart( int alg_arg,
2729
2744
int key_type_arg,
2730
2745
data_t *key,
2731
2746
data_t *input,
2732
- int first_part_size )
2747
+ int first_part_size_arg )
2733
2748
{
2734
2749
psa_key_handle_t handle = 0;
2735
2750
psa_key_type_t key_type = key_type_arg;
2736
2751
psa_algorithm_t alg = alg_arg;
2752
+ size_t first_part_size = first_part_size_arg;
2737
2753
unsigned char iv[16] = {0};
2738
2754
size_t iv_size = 16;
2739
2755
size_t iv_length = 0;
@@ -2769,7 +2785,7 @@ void cipher_verify_output_multipart( int alg_arg,
2769
2785
PSA_BLOCK_CIPHER_BLOCK_SIZE( key_type ) );
2770
2786
ASSERT_ALLOC( output1, output1_buffer_size );
2771
2787
2772
- TEST_ASSERT( (unsigned int) first_part_size < input->len );
2788
+ TEST_ASSERT( first_part_size <= input->len );
2773
2789
2774
2790
PSA_ASSERT( psa_cipher_update( &operation1, input->x, first_part_size,
2775
2791
output1, output1_buffer_size,
0 commit comments