mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 20:22:59 -05:00 
			
		
		
		
	Move BYTES_TO_U32_LE to common.h
The macro BYTES_TO_U32_LE appears in poly1305.c and chacha20.c. Removes duplicate code and save vertical space the macro has been moved to common.h. Improves maintainability. Signed-off-by: Joe Subbiani <joe.subbiani@arm.com>
This commit is contained in:
		
							parent
							
								
									50dde56543
								
							
						
					
					
						commit
						3b394509da
					
				@ -54,13 +54,6 @@
 | 
			
		||||
#define CHACHA20_VALIDATE( cond )                                           \
 | 
			
		||||
    MBEDTLS_INTERNAL_VALIDATE( cond )
 | 
			
		||||
 | 
			
		||||
#define BYTES_TO_U32_LE( data, offset )                           \
 | 
			
		||||
    ( (uint32_t) (data)[offset]                                   \
 | 
			
		||||
      | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 )     \
 | 
			
		||||
      | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 )    \
 | 
			
		||||
      | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 )    \
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
#define ROTL32( value, amount ) \
 | 
			
		||||
    ( (uint32_t) ( (value) << (amount) ) | ( (value) >> ( 32 - (amount) ) ) )
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -71,9 +71,19 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c
 | 
			
		||||
 * To tidy up code and save horizontal and vertical space, use byte 
 | 
			
		||||
 * reading macros to cast
 | 
			
		||||
 */
 | 
			
		||||
#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff )  )
 | 
			
		||||
#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8 ) & 0xff )  )
 | 
			
		||||
#define BYTE_0( x ) ( (uint8_t) ( ( x ) & 0xff ) )
 | 
			
		||||
#define BYTE_1( x ) ( (uint8_t) ( ( ( x ) >> 8  ) & 0xff ) )
 | 
			
		||||
#define BYTE_2( x ) ( (uint8_t) ( ( ( x ) >> 16 ) & 0xff ) )
 | 
			
		||||
#define BYTE_3( x ) ( (uint8_t) ( ( ( x ) >> 24 ) & 0xff ) )
 | 
			
		||||
 | 
			
		||||
/** 
 | 
			
		||||
 * 
 | 
			
		||||
 */
 | 
			
		||||
#define BYTES_TO_U32_LE( data, offset )                         \
 | 
			
		||||
    ( (uint32_t) (data)[offset]                                 \
 | 
			
		||||
      | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 )   \
 | 
			
		||||
      | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 )  \
 | 
			
		||||
      | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 )  \
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
#endif /* MBEDTLS_LIBRARY_COMMON_H */
 | 
			
		||||
 | 
			
		||||
@ -52,13 +52,6 @@
 | 
			
		||||
 | 
			
		||||
#define POLY1305_BLOCK_SIZE_BYTES ( 16U )
 | 
			
		||||
 | 
			
		||||
#define BYTES_TO_U32_LE( data, offset )                           \
 | 
			
		||||
    ( (uint32_t) (data)[offset]                                     \
 | 
			
		||||
          | (uint32_t) ( (uint32_t) (data)[( offset ) + 1] << 8 )   \
 | 
			
		||||
          | (uint32_t) ( (uint32_t) (data)[( offset ) + 2] << 16 )  \
 | 
			
		||||
          | (uint32_t) ( (uint32_t) (data)[( offset ) + 3] << 24 )  \
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Our implementation is tuned for 32-bit platforms with a 64-bit multiplier.
 | 
			
		||||
 * However we provided an alternative for platforms without such a multiplier.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user