@@ -928,9 +928,10 @@ int mbedtls_aes_xts_setkey_dec(mbedtls_aes_xts_context *ctx,
928
928
* AES-ECB block encryption
929
929
*/
930
930
#if !defined(MBEDTLS_AES_ENCRYPT_ALT )
931
- int mbedtls_internal_aes_encrypt (mbedtls_aes_context * ctx ,
932
- const unsigned char input [16 ],
933
- unsigned char output [16 ])
931
+ #if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY )
932
+ static int internal_aes_encrypt (mbedtls_aes_context * ctx ,
933
+ const unsigned char input [16 ],
934
+ unsigned char output [16 ])
934
935
{
935
936
int i ;
936
937
uint32_t * RK = ctx -> buf + ctx -> rk_offset ;
@@ -984,15 +985,50 @@ int mbedtls_internal_aes_encrypt(mbedtls_aes_context *ctx,
984
985
985
986
return 0 ;
986
987
}
987
- #endif /* !MBEDTLS_AES_ENCRYPT_ALT */
988
+ #endif
988
989
990
+ int mbedtls_internal_aes_encrypt (mbedtls_aes_context * ctx ,
991
+ const unsigned char input [16 ],
992
+ unsigned char output [16 ])
993
+ {
994
+ int mode = MBEDTLS_AES_ENCRYPT ;
995
+
996
+ (void ) mode ;
997
+ #if defined(MAY_NEED_TO_ALIGN )
998
+ aes_maybe_realign (ctx );
999
+ #endif
1000
+
1001
+ #if defined(MBEDTLS_AESNI_HAVE_CODE )
1002
+ if (mbedtls_aesni_has_support (MBEDTLS_AESNI_AES )) {
1003
+ return mbedtls_aesni_crypt_ecb (ctx , mode , input , output );
1004
+ }
1005
+ #endif
1006
+
1007
+ #if defined(MBEDTLS_AESCE_HAVE_CODE )
1008
+ if (MBEDTLS_AESCE_HAS_SUPPORT ()) {
1009
+ return mbedtls_aesce_crypt_ecb (ctx , mode , input , output );
1010
+ }
1011
+ #endif
1012
+
1013
+ #if defined(MBEDTLS_VIA_PADLOCK_HAVE_CODE )
1014
+ if (aes_padlock_ace > 0 ) {
1015
+ return mbedtls_padlock_xcryptecb (ctx , mode , input , output );
1016
+ }
1017
+ #endif
1018
+
1019
+ #if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY )
1020
+ return internal_aes_encrypt (ctx , input , output );
1021
+ #endif
1022
+ }
1023
+ #endif /* !MBEDTLS_AES_ENCRYPT_ALT */
989
1024
/*
990
1025
* AES-ECB block decryption
991
1026
*/
992
1027
#if !defined(MBEDTLS_AES_DECRYPT_ALT )
993
- int mbedtls_internal_aes_decrypt (mbedtls_aes_context * ctx ,
994
- const unsigned char input [16 ],
995
- unsigned char output [16 ])
1028
+ #if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY )
1029
+ static int internal_aes_decrypt (mbedtls_aes_context * ctx ,
1030
+ const unsigned char input [16 ],
1031
+ unsigned char output [16 ])
996
1032
{
997
1033
int i ;
998
1034
uint32_t * RK = ctx -> buf + ctx -> rk_offset ;
@@ -1046,6 +1082,41 @@ int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx,
1046
1082
1047
1083
return 0 ;
1048
1084
}
1085
+ #endif
1086
+
1087
+ int mbedtls_internal_aes_decrypt (mbedtls_aes_context * ctx ,
1088
+ const unsigned char input [16 ],
1089
+ unsigned char output [16 ])
1090
+ {
1091
+ int mode = MBEDTLS_AES_DECRYPT ;
1092
+
1093
+ (void ) mode ;
1094
+ #if defined(MAY_NEED_TO_ALIGN )
1095
+ aes_maybe_realign (ctx );
1096
+ #endif
1097
+
1098
+ #if defined(MBEDTLS_AESNI_HAVE_CODE )
1099
+ if (mbedtls_aesni_has_support (MBEDTLS_AESNI_AES )) {
1100
+ return mbedtls_aesni_crypt_ecb (ctx , mode , input , output );
1101
+ }
1102
+ #endif
1103
+
1104
+ #if defined(MBEDTLS_AESCE_HAVE_CODE )
1105
+ if (MBEDTLS_AESCE_HAS_SUPPORT ()) {
1106
+ return mbedtls_aesce_crypt_ecb (ctx , mode , input , output );
1107
+ }
1108
+ #endif
1109
+
1110
+ #if defined(MBEDTLS_VIA_PADLOCK_HAVE_CODE )
1111
+ if (aes_padlock_ace > 0 ) {
1112
+ return mbedtls_padlock_xcryptecb (ctx , mode , input , output );
1113
+ }
1114
+ #endif
1115
+
1116
+ #if !defined(MBEDTLS_AES_USE_HARDWARE_ONLY )
1117
+ return internal_aes_decrypt (ctx , input , output );
1118
+ #endif
1119
+ }
1049
1120
#endif /* !MBEDTLS_AES_DECRYPT_ALT */
1050
1121
1051
1122
#if defined(MAY_NEED_TO_ALIGN )
0 commit comments