mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 20:22:59 -05:00 
			
		
		
		
	psa_hmac_setup_internal: fix double call of psa_hash_setup
In the common case (key no longer than the block size), psa_hash_setup was being called twice in succession. With current implementations this is just a small performance loss, but potentially with alternative implementations this could have lead to a memory leak.
This commit is contained in:
		
							parent
							
								
									ff94abdf3a
								
							
						
					
					
						commit
						1e6bfdff5e
					
				@ -1424,12 +1424,11 @@ static psa_status_t psa_hmac_setup_internal( psa_hmac_internal_data *hmac,
 | 
			
		||||
    if( block_size == 0 )
 | 
			
		||||
        return( PSA_ERROR_NOT_SUPPORTED );
 | 
			
		||||
 | 
			
		||||
    status = psa_hash_setup( &hmac->hash_ctx, hash_alg );
 | 
			
		||||
    if( status != PSA_SUCCESS )
 | 
			
		||||
        return( status );
 | 
			
		||||
 | 
			
		||||
    if( key_length > block_size )
 | 
			
		||||
    {
 | 
			
		||||
        status = psa_hash_setup( &hmac->hash_ctx, hash_alg );
 | 
			
		||||
        if( status != PSA_SUCCESS )
 | 
			
		||||
            goto cleanup;
 | 
			
		||||
        status = psa_hash_update( &hmac->hash_ctx, key, key_length );
 | 
			
		||||
        if( status != PSA_SUCCESS )
 | 
			
		||||
            goto cleanup;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user