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
diff --git a/library/aes.c b/library/aes.c
index b36b81c..c10d4ae 100644
--- a/library/aes.c
+++ b/library/aes.c
@@ -1023,7 +1023,7 @@
#endif
#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 )
return( 0 );
@@ -1065,7 +1065,7 @@
return( MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH );
#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 )
return( 0 );