mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-10-31 03:30:35 -04:00 
			
		
		
		
	Tidy up logic in psa_mac_sign_finish
Simplify the logic in psa_mac_sign_finish. Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
		
							parent
							
								
									b5dd7c794d
								
							
						
					
					
						commit
						8036bddb01
					
				| @ -2394,12 +2394,8 @@ psa_status_t psa_mac_sign_finish( psa_mac_operation_t *operation, | |||||||
|     psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; |     psa_status_t status = PSA_ERROR_CORRUPTION_DETECTED; | ||||||
|     psa_status_t abort_status = PSA_ERROR_CORRUPTION_DETECTED; |     psa_status_t abort_status = PSA_ERROR_CORRUPTION_DETECTED; | ||||||
| 
 | 
 | ||||||
|     /* Set the output length and content to a safe default, such that in
 |     if( operation->id == 0 ) | ||||||
|      * case the caller misses an error check, the output would be an |     { | ||||||
|      * unachievable MAC. */ |  | ||||||
|     *mac_length = mac_size; |  | ||||||
| 
 |  | ||||||
|     if( operation->id == 0 ) { |  | ||||||
|         status = PSA_ERROR_BAD_STATE; |         status = PSA_ERROR_BAD_STATE; | ||||||
|         goto cleanup; |         goto cleanup; | ||||||
|     } |     } | ||||||
| @ -2428,6 +2424,7 @@ psa_status_t psa_mac_sign_finish( psa_mac_operation_t *operation, | |||||||
|                                                  mac, operation->mac_size, |                                                  mac, operation->mac_size, | ||||||
|                                                  mac_length ); |                                                  mac_length ); | ||||||
| 
 | 
 | ||||||
|  | cleanup: | ||||||
|     /* In case of success, set the potential excess room in the output buffer
 |     /* In case of success, set the potential excess room in the output buffer
 | ||||||
|      * to an invalid value, to avoid potentially leaking a longer MAC. |      * to an invalid value, to avoid potentially leaking a longer MAC. | ||||||
|      * In case of error, set the output length and content to a safe default, |      * In case of error, set the output length and content to a safe default, | ||||||
| @ -2444,7 +2441,6 @@ psa_status_t psa_mac_sign_finish( psa_mac_operation_t *operation, | |||||||
|         memset( &mac[operation->mac_size], '!', |         memset( &mac[operation->mac_size], '!', | ||||||
|                 mac_size - operation->mac_size ); |                 mac_size - operation->mac_size ); | ||||||
| 
 | 
 | ||||||
| cleanup: |  | ||||||
|     abort_status = psa_mac_abort( operation ); |     abort_status = psa_mac_abort( operation ); | ||||||
| 
 | 
 | ||||||
|     return( status == PSA_SUCCESS ? abort_status : status ); |     return( status == PSA_SUCCESS ? abort_status : status ); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Dave Rodgman
						Dave Rodgman