mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-04 04:32:24 -05:00 
			
		
		
		
	Simplify the test and description
Previously the check was convoluted. This has been simplified and given a more appropriate suggestion as per gilles suggestion Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
This commit is contained in:
		
							parent
							
								
									da36c9f2ce
								
							
						
					
					
						commit
						113d80c219
					
				@ -630,27 +630,9 @@ void block_cipher_key_type( int type_arg, int block_size_arg )
 | 
			
		||||
                PSA_KEY_TYPE_CATEGORY_SYMMETRIC );
 | 
			
		||||
    TEST_EQUAL( PSA_BLOCK_CIPHER_BLOCK_LENGTH( type ), block_size );
 | 
			
		||||
 | 
			
		||||
    /* PSA_ROUND_UP_TO_MULTIPLE(block_size, length) in crypto_sizes.h
 | 
			
		||||
     * Requires block sizes to be a power of 2.
 | 
			
		||||
     * The following creates a bit and shifts along until it finds a
 | 
			
		||||
     * match or a mismatch.
 | 
			
		||||
     */
 | 
			
		||||
    int check = 0;
 | 
			
		||||
 | 
			
		||||
    for (size_t index = 1; index > 0; index = index << 1)
 | 
			
		||||
    {
 | 
			
		||||
        if (index == block_size)
 | 
			
		||||
        {
 | 
			
		||||
            check = 0;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        if (index > block_size)
 | 
			
		||||
        {
 | 
			
		||||
            check = 1;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    TEST_EQUAL( check, 0);
 | 
			
		||||
    /* Check that the block size is a power of 2. This is required, at least, 
 | 
			
		||||
    for PSA_ROUND_UP_TO_MULTIPLE(block_size, length) in crypto_sizes.h. */
 | 
			
		||||
    TEST_ASSERT( ( ( block_size - 1 ) & block_size ) == 0 );
 | 
			
		||||
}
 | 
			
		||||
/* END_CASE */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user