Skip to content

Commit

Permalink
todo2
Browse files Browse the repository at this point in the history
  • Loading branch information
janmazak committed Feb 14, 2024
1 parent d503f28 commit e907122
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/signMsg_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ static ins_sign_msg_context_t* ctx = &(instructionState.signMsgContext);

void signMsg_handleInit_ui_runStep()
{
TRACE("UI step %d", ctx->ui_step);
TRACE_STACK_USAGE();
ui_callback_fn_t* this_fn = signMsg_handleInit_ui_runStep;

UI_STEP_BEGIN(ctx->ui_step, this_fn);
Expand Down Expand Up @@ -47,12 +49,12 @@ void signMsg_handleInit_ui_runStep()
ui_getPathScreen(pathStr, SIZEOF(pathStr), &ctx->witnessPath);
fill_and_display_if_required("Signing path", pathStr, this_fn, respond_with_user_reject);
#endif // HAVE_BAGL

}
UI_STEP(HANDLE_INIT_ADDRESS_FIELD_DISPLAY_KEY_HASH) {
if (ctx->addressFieldType == CIP8_ADDRESS_FIELD_ADDRESS) {
UI_STEP_JUMP(HANDLE_INIT_ADDRESS_FIELD_DISPLAY_ADDRESS);
}
}
UI_STEP(HANDLE_INIT_ADDRESS_FIELD_DISPLAY_KEY_HASH) {

uint8_t hash[28];
blake2b_224_hash(
ctx->witnessKey, SIZEOF(ctx->witnessKey),
Expand All @@ -71,10 +73,12 @@ void signMsg_handleInit_ui_runStep()
ui_getHexBufferScreen(bufferHex, SIZEOF(bufferHex), hash, SIZEOF(hash));
fill_and_display_if_required("Address field", bufferHex, this_fn, respond_with_user_reject);
#endif // HAVE_BAGL

UI_STEP_JUMP(HANDLE_INIT_RESPOND);
}
UI_STEP(HANDLE_INIT_ADDRESS_FIELD_DISPLAY_ADDRESS) {
if (ctx->addressFieldType != CIP8_ADDRESS_FIELD_ADDRESS) {
UI_STEP_JUMP(HANDLE_INIT_RESPOND);
}

uint8_t addressBuffer[MAX_ADDRESS_SIZE] = {0};
size_t addressSize = deriveAddress(&ctx->addressParams, addressBuffer, SIZEOF(addressBuffer));
ASSERT(addressSize > 0);
Expand Down Expand Up @@ -136,8 +140,7 @@ void _displayMsgEmpty(ui_callback_fn_t* callback)
callback
);
#elif defined(HAVE_NBGL)
set_light_confirmation(true);
display_prompt("Empty", "message", this_fn, respond_with_user_reject);
fill_and_display_if_required("Empty", "message", callback, respond_with_user_reject);
#endif // HAVE_BAGL
}

Expand All @@ -162,8 +165,7 @@ void _displayMsgIntro(ui_callback_fn_t* callback)
callback
);
#elif defined(HAVE_NBGL)
set_light_confirmation(true);
display_prompt(l1, l2, this_fn, respond_with_user_reject);
fill_and_display_if_required(l1, l2, callback, respond_with_user_reject);
#endif // HAVE_BAGL
}

Expand Down Expand Up @@ -195,8 +197,7 @@ void _displayMsgFull(ui_callback_fn_t* callback)
callback
);
#elif defined(HAVE_NBGL)
set_light_confirmation(true);
display_prompt(l1, l2, this_fn, respond_with_user_reject);
fill_and_display_if_required(l1, l2, callback, respond_with_user_reject);
#endif // HAVE_BAGL
}

Expand All @@ -222,8 +223,7 @@ void _displayMsgChunk(ui_callback_fn_t* callback)
callback
);
#elif defined(HAVE_NBGL)
set_light_confirmation(true);
display_prompt(l1, l2, this_fn, respond_with_user_reject);
fill_and_display_if_required(l1, l2, callback, respond_with_user_reject);
#endif // HAVE_BAGL
}

Expand All @@ -240,12 +240,14 @@ void signMsg_handleChunk_ui_runStep()
UI_STEP(HANDLE_CHUNK_STEP_INTRO) {
if (ctx->msgLength == 0) {
_displayMsgEmpty(this_fn);
UI_STEP_JUMP(HANDLE_CHUNK_STEP_RESPOND);
} else {
_displayMsgIntro(this_fn);
}
}
UI_STEP(HANDLE_CHUNK_STEP_DISPLAY) {
if (ctx->msgLength == 0) {
UI_STEP_JUMP(HANDLE_CHUNK_STEP_RESPOND);
}
if (ctx->remainingBytes == 0) {
_displayMsgFull(this_fn);
} else {
Expand Down Expand Up @@ -297,9 +299,12 @@ void signMsg_handleConfirm_ui_runStep()
memmove(wireResponse.witnessKey, ctx->witnessKey, PUBLIC_KEY_SIZE);

io_send_buf(SUCCESS, (uint8_t*) &wireResponse, SIZEOF(wireResponse));
ui_idle();
#ifdef HAVE_BAGL
ui_displayBusy(); // displays dots, called only after I/O to avoid freezing
#endif // HAVE_BAGL

ctx->stage = SIGN_MSG_STAGE_NONE;
ui_idle();
}
UI_STEP_END(HANDLE_CONFIRM_STEP_INVALID);
}
2 changes: 2 additions & 0 deletions src/signOpCert.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ void signOpCert_handleAPDU(

static void signOpCert_ui_runStep()
{
TRACE("UI step %d", ctx->ui_step);
TRACE_STACK_USAGE();
ui_callback_fn_t* this_fn = signOpCert_ui_runStep;

UI_STEP_BEGIN(ctx->ui_step, this_fn);
Expand Down

0 comments on commit e907122

Please sign in to comment.