mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-10-30 19:20:40 -04:00 
			
		
		
		
	aes: Check aes_padlock_ace > 0 before calling padlock
Sometime user may forget to call mbedtls_aes_setkey_enc or mbedtls_aes_setkey_dec before mbedtls_aes_crypt_ecb and then the code normally crash inside the assembly code. With this patch, the code will stop inside the C source code which is more convenient to locate the problem. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Change-Id: I0e1d6b219f8709f8acaee5f345344335fc82fed3
This commit is contained in:
		
							parent
							
								
									5b416e95b2
								
							
						
					
					
						commit
						12e18369e8
					
				| @ -1023,7 +1023,7 @@ int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx, | |||||||
| #endif | #endif | ||||||
| 
 | 
 | ||||||
| #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) | #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) | ||||||
|     if( aes_padlock_ace ) |     if( aes_padlock_ace > 0) | ||||||
|     { |     { | ||||||
|         if( mbedtls_padlock_xcryptecb( ctx, mode, input, output ) == 0 ) |         if( mbedtls_padlock_xcryptecb( ctx, mode, input, output ) == 0 ) | ||||||
|             return( 0 ); |             return( 0 ); | ||||||
| @ -1065,7 +1065,7 @@ int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx, | |||||||
|         return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); |         return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH ); | ||||||
| 
 | 
 | ||||||
| #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) | #if defined(MBEDTLS_PADLOCK_C) && defined(MBEDTLS_HAVE_X86) | ||||||
|     if( aes_padlock_ace ) |     if( aes_padlock_ace > 0 ) | ||||||
|     { |     { | ||||||
|         if( mbedtls_padlock_xcryptcbc( ctx, mode, length, iv, input, output ) == 0 ) |         if( mbedtls_padlock_xcryptcbc( ctx, mode, length, iv, input, output ) == 0 ) | ||||||
|             return( 0 ); |             return( 0 ); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Xiang Xiao
						Xiang Xiao