mirror of
				https://github.com/Mbed-TLS/mbedtls.git
				synced 2025-10-30 10:45:34 +03:00 
			
		
		
		
	Refactor interuptible key agreement testing helper function
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
This commit is contained in:
		| @@ -1237,24 +1237,28 @@ static void interruptible_signverify_get_minmax_completes(uint32_t max_ops, | |||||||
|  |  | ||||||
| static uint32_t interruptible_key_agreement_get_min_num_ops(size_t key_bits) | static uint32_t interruptible_key_agreement_get_min_num_ops(size_t key_bits) | ||||||
| { | { | ||||||
|     uint32_t min_values[3][5] = { |     /* Those values are taken from documentation of mbedtls_ecp_set_max_ops() | ||||||
|         { 208, 208, 160, 136, 124 }, // P-256 |        in ecp.h. Those values can change at any time. */ | ||||||
|         { 682, 416, 320, 272, 248 }, // P-384 |     switch (key_bits) { | ||||||
|         { 1364, 832, 640, 544, 496 } // P-521 |         case 256: | ||||||
|     }; |         { | ||||||
|  |             const uint32_t min_values[5] = { 208, 208, 160, 136, 124 }; // P-256 | ||||||
|     int curve_index = -1; |             return min_values[6 - MBEDTLS_ECP_WINDOW_SIZE]; | ||||||
|     if (key_bits == 256) { |             break; | ||||||
|         curve_index = 0; |         } | ||||||
|     } |         case 384: | ||||||
|     if (key_bits == 384) { |         { | ||||||
|         curve_index = 1; |             const uint32_t min_values[5] = { 682, 416, 320, 272, 248 }; // P-384 | ||||||
|     } |             return min_values[6 - MBEDTLS_ECP_WINDOW_SIZE]; | ||||||
|     if (key_bits == 512 || key_bits <= 521) { |             break; | ||||||
|         curve_index = 2; |         } | ||||||
|     } |         case 512: | ||||||
|     if (curve_index != -1) { |         case 521: | ||||||
|         return min_values[curve_index][6 - MBEDTLS_ECP_WINDOW_SIZE]; |         { | ||||||
|  |             const uint32_t min_values[5] = { 1364, 832, 640, 544, 496 }; // P-521 | ||||||
|  |             return min_values[6 - MBEDTLS_ECP_WINDOW_SIZE]; | ||||||
|  |             break; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user