@@ -182,16 +182,25 @@ static inline int check_padding_and_structure(unsigned char *out, int length, in
182
182
return 0 ;
183
183
}
184
184
185
+ #ifndef MBEDTLS_CIPHER_MODE_CTR
185
186
static void handleErrors (void )
186
187
{
187
188
ERR_print_errors_fp (stderr );
188
189
error ();
189
190
}
191
+ #endif
190
192
191
- static inline int AES_ctr_decrypt (unsigned char * ciphertext ,
192
- int ciphertext_len , unsigned char * key ,
193
- unsigned char * iv , unsigned char * plaintext )
193
+ static inline void AES_ctr_decrypt (unsigned char * ciphertext ,
194
+ int ciphertext_len , unsigned char * key ,
195
+ unsigned char * iv , unsigned char * plaintext )
194
196
{
197
+ #ifdef MBEDTLS_CIPHER_MODE_CTR
198
+ size_t nc_off = 0 ;
199
+ mbedtls_aes_context ctx ;
200
+ mbedtls_aes_init (& ctx );
201
+ mbedtls_aes_setkey_enc (& ctx , key , 256 );
202
+ mbedtls_aes_crypt_ctr (& ctx , ciphertext_len , & nc_off , iv , iv , ciphertext , plaintext );
203
+ #else
195
204
EVP_CIPHER_CTX * ctx ;
196
205
197
206
int len ;
@@ -215,8 +224,7 @@ static inline int AES_ctr_decrypt(unsigned char *ciphertext,
215
224
plaintext_len += len ;
216
225
217
226
EVP_CIPHER_CTX_free (ctx );
218
-
219
- return plaintext_len ;
227
+ #endif
220
228
}
221
229
222
230
static void common_crypt_code (char * password , unsigned char * out , int full_decrypt )
0 commit comments