27
27
28
28
#include "py/mpconfig.h"
29
29
30
- #if MICROPY_PY_UCRYPTOLIB
30
+ #if MICROPY_PY_CRYPTOLIB
31
31
32
32
#include <assert.h>
33
33
#include <string.h>
@@ -90,7 +90,7 @@ typedef struct _mp_obj_aes_t {
90
90
} mp_obj_aes_t ;
91
91
92
92
static inline bool is_ctr_mode (int block_mode ) {
93
- #if MICROPY_PY_UCRYPTOLIB_CTR
93
+ #if MICROPY_PY_CRYPTOLIB_CTR
94
94
return block_mode == UCRYPTOLIB_MODE_CTR ;
95
95
#else
96
96
return false;
@@ -140,7 +140,7 @@ STATIC void aes_process_cbc_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t *
140
140
}
141
141
}
142
142
143
- #if MICROPY_PY_UCRYPTOLIB_CTR
143
+ #if MICROPY_PY_CRYPTOLIB_CTR
144
144
// axTLS doesn't have CTR support out of the box. This implements the counter part using the ECB primitive.
145
145
STATIC void aes_process_ctr_impl (AES_CTX_IMPL * ctx , const uint8_t * in , uint8_t * out , size_t in_len , struct ctr_params * ctr_params ) {
146
146
size_t n = ctr_params -> offset ;
@@ -203,7 +203,7 @@ STATIC void aes_process_cbc_impl(AES_CTX_IMPL *ctx, const uint8_t *in, uint8_t *
203
203
mbedtls_aes_crypt_cbc (& ctx -> u .mbedtls_ctx , encrypt ? MBEDTLS_AES_ENCRYPT : MBEDTLS_AES_DECRYPT , in_len , ctx -> iv , in , out );
204
204
}
205
205
206
- #if MICROPY_PY_UCRYPTOLIB_CTR
206
+ #if MICROPY_PY_CRYPTOLIB_CTR
207
207
STATIC void aes_process_ctr_impl (AES_CTX_IMPL * ctx , const uint8_t * in , uint8_t * out , size_t in_len , struct ctr_params * ctr_params ) {
208
208
mbedtls_aes_crypt_ctr (& ctx -> u .mbedtls_ctx , in_len , & ctr_params -> offset , ctx -> iv , ctr_params -> encrypted_counter , in , out );
209
209
}
@@ -219,7 +219,7 @@ STATIC mp_obj_t cryptolib_aes_make_new(const mp_obj_type_t *type, size_t n_args,
219
219
switch (block_mode ) {
220
220
case UCRYPTOLIB_MODE_ECB :
221
221
case UCRYPTOLIB_MODE_CBC :
222
- #if MICROPY_PY_UCRYPTOLIB_CTR
222
+ #if MICROPY_PY_CRYPTOLIB_CTR
223
223
case UCRYPTOLIB_MODE_CTR :
224
224
#endif
225
225
break ;
@@ -318,7 +318,7 @@ STATIC mp_obj_t aes_process(size_t n_args, const mp_obj_t *args, bool encrypt) {
318
318
aes_process_cbc_impl (& self -> ctx , in_bufinfo .buf , out_buf_ptr , in_bufinfo .len , encrypt );
319
319
break ;
320
320
321
- #if MICROPY_PY_UCRYPTOLIB_CTR
321
+ #if MICROPY_PY_CRYPTOLIB_CTR
322
322
case UCRYPTOLIB_MODE_CTR :
323
323
aes_process_ctr_impl (& self -> ctx , in_bufinfo .buf , out_buf_ptr , in_bufinfo .len ,
324
324
ctr_params_from_aes (self ));
@@ -359,10 +359,10 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(
359
359
STATIC const mp_rom_map_elem_t mp_module_cryptolib_globals_table [] = {
360
360
{ MP_ROM_QSTR (MP_QSTR___name__ ), MP_ROM_QSTR (MP_QSTR_cryptolib ) },
361
361
{ MP_ROM_QSTR (MP_QSTR_aes ), MP_ROM_PTR (& cryptolib_aes_type ) },
362
- #if MICROPY_PY_UCRYPTOLIB_CONSTS
362
+ #if MICROPY_PY_CRYPTOLIB_CONSTS
363
363
{ MP_ROM_QSTR (MP_QSTR_MODE_ECB ), MP_ROM_INT (UCRYPTOLIB_MODE_ECB ) },
364
364
{ MP_ROM_QSTR (MP_QSTR_MODE_CBC ), MP_ROM_INT (UCRYPTOLIB_MODE_CBC ) },
365
- #if MICROPY_PY_UCRYPTOLIB_CTR
365
+ #if MICROPY_PY_CRYPTOLIB_CTR
366
366
{ MP_ROM_QSTR (MP_QSTR_MODE_CTR ), MP_ROM_INT (UCRYPTOLIB_MODE_CTR ) },
367
367
#endif
368
368
#endif
@@ -377,4 +377,4 @@ const mp_obj_module_t mp_module_cryptolib = {
377
377
378
378
MP_REGISTER_MODULE (MP_QSTR_cryptolib , mp_module_cryptolib );
379
379
380
- #endif // MICROPY_PY_UCRYPTOLIB
380
+ #endif // MICROPY_PY_CRYPTOLIB
0 commit comments