mirror of https://github.com/arendst/Tasmota.git
Merge pull request #15771 from s-hadinger/berry_crypto_optim
Berry optimization of crypto module
This commit is contained in:
commit
79b2ff4093
|
@ -48,6 +48,7 @@ be_extern_native_module(uuid);
|
|||
be_extern_native_module(animate);
|
||||
be_extern_native_module(partition_core);
|
||||
be_extern_native_module(crc);
|
||||
be_extern_native_module(crypto);
|
||||
#ifdef USE_ZIGBEE
|
||||
be_extern_native_module(zigbee);
|
||||
#endif // USE_ZIGBEE
|
||||
|
@ -156,6 +157,9 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
|
|||
&be_native_module(flash),
|
||||
&be_native_module(partition_core),
|
||||
&be_native_module(crc),
|
||||
#ifdef USE_ALEXA_AVS
|
||||
&be_native_module(crypto),
|
||||
#endif
|
||||
|
||||
/* user-defined modules register end */
|
||||
NULL /* do not remove */
|
||||
|
@ -276,7 +280,6 @@ BERRY_LOCAL bclass_array be_class_table = {
|
|||
NULL, /* do not remove */
|
||||
};
|
||||
|
||||
extern void be_load_crypto_lib(bvm *vm);
|
||||
extern void be_load_ctypes_energy_definitions_lib(bvm *vm);
|
||||
|
||||
/* this code loads the native class definitions */
|
||||
|
@ -288,9 +291,6 @@ BERRY_API void be_load_custom_libs(bvm *vm)
|
|||
#if !BE_USE_PRECOMPILED_OBJECT
|
||||
/* be_load_xxxlib(vm); */
|
||||
#endif
|
||||
#ifdef USE_ALEXA_AVS
|
||||
be_load_crypto_lib(vm); // sub-module
|
||||
#endif
|
||||
#ifdef USE_ENERGY_SENSOR
|
||||
be_load_ctypes_energy_definitions_lib(vm); // ctype class
|
||||
#endif // USE_ENERGY_SENSOR
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#include "be_constobj.h"
|
||||
|
||||
static be_define_const_map_slots(m_libcrypto_map) {
|
||||
{ be_const_key_weak(AES_GCM, -1), be_const_class(be_class_aes_gcm) },
|
||||
{ be_const_key_weak(EC_C25519, -1), be_const_class(be_class_ec_c25519) },
|
||||
};
|
||||
|
||||
static be_define_const_map(
|
||||
m_libcrypto_map,
|
||||
2
|
||||
);
|
||||
|
||||
static be_define_const_module(
|
||||
m_libcrypto,
|
||||
"crypto"
|
||||
);
|
||||
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(crypto);
|
|
@ -19,21 +19,8 @@ extern int m_ec_c25519_sharedkey(bvm *vm);
|
|||
|
||||
#include "be_fixed_be_class_aes_gcm.h"
|
||||
#include "be_fixed_be_class_ec_c25519.h"
|
||||
#include "be_fixed_crypto.h"
|
||||
|
||||
void be_load_crypto_lib(bvm *vm) {
|
||||
// insert the class GCM in module AES
|
||||
be_newmodule(vm);
|
||||
be_setname(vm, -1, "crypto");
|
||||
be_setglobal(vm, "crypto");
|
||||
|
||||
be_pushntvclass(vm, &be_class_aes_gcm);
|
||||
be_setmember(vm, -2, "AES_GCM");
|
||||
be_pop(vm, 1);
|
||||
|
||||
be_pushntvclass(vm, &be_class_ec_c25519);
|
||||
be_setmember(vm, -2, "EC_C25519");
|
||||
be_pop(vm, 2);
|
||||
}
|
||||
/* @const_object_info_begin
|
||||
|
||||
class be_class_aes_gcm (scope: global, name: AES_GCM, strings: weak) {
|
||||
|
@ -51,6 +38,11 @@ class be_class_ec_c25519 (scope: global, name: EC_C25519, strings: weak) {
|
|||
shared_key, func(m_ec_c25519_sharedkey)
|
||||
}
|
||||
|
||||
module crypto (scope: global, strings: weak) {
|
||||
AES_GCM, class(be_class_aes_gcm)
|
||||
EC_C25519, class(be_class_ec_c25519)
|
||||
}
|
||||
|
||||
@const_object_info_end */
|
||||
|
||||
#endif // USE_ALEXA_AVS
|
||||
|
|
Loading…
Reference in New Issue