mirror of
https://github.com/bettse/seader.git
synced 2026-03-29 08:00:07 +00:00
mem: eliminate 280 bytes of static BSS
Stack-allocate the two mbedtls DES contexts in loclass optimized_elite (128 bytes each) and the APDU runner progress text buffer (24 bytes). All three were static/global but are used only within single call frames.
This commit is contained in:
@@ -162,21 +162,20 @@ static void loclass_rk(const uint8_t* key, uint8_t n, uint8_t* outp_key) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static mbedtls_des_context loclass_ctx_enc;
|
|
||||||
static mbedtls_des_context loclass_ctx_dec;
|
|
||||||
|
|
||||||
static void loclass_desdecrypt_iclass(uint8_t* iclass_key, uint8_t* input, uint8_t* output) {
|
static void loclass_desdecrypt_iclass(uint8_t* iclass_key, uint8_t* input, uint8_t* output) {
|
||||||
uint8_t key_std_format[8] = {0};
|
uint8_t key_std_format[8] = {0};
|
||||||
loclass_permutekey_rev(iclass_key, key_std_format);
|
loclass_permutekey_rev(iclass_key, key_std_format);
|
||||||
mbedtls_des_setkey_dec(&loclass_ctx_dec, key_std_format);
|
mbedtls_des_context ctx;
|
||||||
mbedtls_des_crypt_ecb(&loclass_ctx_dec, input, output);
|
mbedtls_des_setkey_dec(&ctx, key_std_format);
|
||||||
|
mbedtls_des_crypt_ecb(&ctx, input, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loclass_desencrypt_iclass(const uint8_t* iclass_key, uint8_t* input, uint8_t* output) {
|
static void loclass_desencrypt_iclass(const uint8_t* iclass_key, uint8_t* input, uint8_t* output) {
|
||||||
uint8_t key_std_format[8] = {0};
|
uint8_t key_std_format[8] = {0};
|
||||||
loclass_permutekey_rev(iclass_key, key_std_format);
|
loclass_permutekey_rev(iclass_key, key_std_format);
|
||||||
mbedtls_des_setkey_enc(&loclass_ctx_enc, key_std_format);
|
mbedtls_des_context ctx;
|
||||||
mbedtls_des_crypt_ecb(&loclass_ctx_enc, input, output);
|
mbedtls_des_setkey_enc(&ctx, key_std_format);
|
||||||
|
mbedtls_des_crypt_ecb(&ctx, input, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#define TAG "Seader:Scene:APDURunner"
|
#define TAG "Seader:Scene:APDURunner"
|
||||||
|
|
||||||
char seader_scene_apdu_runner_update_text[24];
|
|
||||||
|
|
||||||
void seader_apdu_runner_worker_callback(uint32_t event, void* context) {
|
void seader_apdu_runner_worker_callback(uint32_t event, void* context) {
|
||||||
Seader* seader = context;
|
Seader* seader = context;
|
||||||
view_dispatcher_send_custom_event(seader->view_dispatcher, event);
|
view_dispatcher_send_custom_event(seader->view_dispatcher, event);
|
||||||
@@ -43,14 +41,14 @@ bool seader_scene_apdu_runner_on_event(void* context, SceneManagerEvent event) {
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.event == SeaderWorkerEventAPDURunnerUpdate) {
|
} else if(event.event == SeaderWorkerEventAPDURunnerUpdate) {
|
||||||
SeaderAPDURunnerContext apdu_runner_ctx = seader->apdu_runner_ctx;
|
SeaderAPDURunnerContext apdu_runner_ctx = seader->apdu_runner_ctx;
|
||||||
|
char update_text[24];
|
||||||
snprintf(
|
snprintf(
|
||||||
seader_scene_apdu_runner_update_text,
|
update_text,
|
||||||
sizeof(seader_scene_apdu_runner_update_text),
|
sizeof(update_text),
|
||||||
"APDU Runner\n%d/%d",
|
"APDU Runner\n%d/%d",
|
||||||
apdu_runner_ctx.current_line + 1,
|
apdu_runner_ctx.current_line + 1,
|
||||||
apdu_runner_ctx.total_lines);
|
apdu_runner_ctx.total_lines);
|
||||||
popup_set_header(
|
popup_set_header(popup, update_text, 68, 30, AlignLeft, AlignTop);
|
||||||
popup, seader_scene_apdu_runner_update_text, 68, 30, AlignLeft, AlignTop);
|
|
||||||
consumed = true;
|
consumed = true;
|
||||||
} else if(event.event == SeaderWorkerEventAPDURunnerSuccess) {
|
} else if(event.event == SeaderWorkerEventAPDURunnerSuccess) {
|
||||||
notification_message(seader->notifications, &sequence_success);
|
notification_message(seader->notifications, &sequence_success);
|
||||||
|
|||||||
Reference in New Issue
Block a user