Skip to content

Commit

Permalink
Merge pull request #14 from Bilb/develop
Browse files Browse the repository at this point in the history
chore: remove uneeded printf
  • Loading branch information
apaillier-ledger committed Mar 14, 2023
2 parents b9c6398 + 31d04b0 commit 6efbf7d
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 35 deletions.
2 changes: 0 additions & 2 deletions src/oxen_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ void clear_protocol(void) {
}

int check_protocol(void) {
PRINTF("check_protocol with %02x\n", G_oxen_state.protocol_barrier);

/* if locked and pin is verified, unlock */
if ((G_oxen_state.protocol_barrier == PROTOCOL_LOCKED_UNLOCKABLE) &&
(os_global_pin_is_validated() == PIN_VERIFIED)) {
Expand Down
19 changes: 0 additions & 19 deletions src/oxen_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,15 @@ void monero_init(void) {

G_oxen_state.protocol = 0xff;
G_oxen_state.protocol_barrier = PROTOCOL_UNLOCKED;
PRINTF("before monero_init_private_key\n");

// load key
monero_init_private_key();
PRINTF("after monero_init_private_key\n");

// ux conf
monero_init_ux();
PRINTF("after monero_init_ux\n");

// Let's go!
G_oxen_state.state = STATE_IDLE;
PRINTF("G_oxen_state.state = STATE_IDLE\n");

// I guess we currently crash before being here on the nanoX so there is no point if going
// further for now
Expand Down Expand Up @@ -93,46 +89,36 @@ void monero_init_private_key(void) {
path[2] = 0x80000000;
path[3] = 0x00000000;
path[4] = 0x00000000;
PRINTF("monero_init_private_key\n");

os_perso_derive_node_bip32(CX_CURVE_SECP256K1, path, 5, seed, chain);

PRINTF("N_oxen_state->key_mode: %02x \n", N_oxen_state->key_mode);
switch (N_oxen_state->key_mode) {
case KEY_MODE_SEED:
PRINTF("KEY_MODE_SEED case before\n");

oxen_keccak_256(&G_oxen_state.keccak, seed, 32, G_oxen_state.spend_priv);
monero_reduce(G_oxen_state.spend_priv);
oxen_keccak_256(&G_oxen_state.keccak,
G_oxen_state.spend_priv,
32,
G_oxen_state.view_priv);
monero_reduce(G_oxen_state.view_priv);
PRINTF("KEY_MODE_SEED case after\n");

break;

case KEY_MODE_EXTERNAL:
PRINTF("KEY_MODE_EXTERNAL\n");
memmove(G_oxen_state.view_priv, (void*) N_oxen_state->view_priv, 32);
memmove(G_oxen_state.spend_priv, (void*) N_oxen_state->spend_priv, 32);
break;

default:
PRINTF("SW_SECURITY_LOAD_KEY throw\n");
THROW(SW_SECURITY_LOAD_KEY);
return;
}
monero_ecmul_G(G_oxen_state.view_pub, G_oxen_state.view_priv);
PRINTF("after monero_ecmul_G1\n");

monero_ecmul_G(G_oxen_state.spend_pub, G_oxen_state.spend_priv);
PRINTF("after monero_ecmul_G2\n");

// generate key protection
monero_aes_derive(&G_oxen_state.spk, chain, G_oxen_state.view_priv, G_oxen_state.spend_priv);
PRINTF("after monero_aes_derive\n");

G_oxen_state.key_set = 1;
}
Expand Down Expand Up @@ -162,8 +148,6 @@ void monero_init_ux(void) {
void oxen_install(unsigned char netId) {
unsigned char c;

PRINTF("oxen_install on network %d\n", netId);

// full reset data
nvm_write(N_oxen_state, NULL, sizeof(oxen_nv_state_t));

Expand All @@ -183,7 +167,6 @@ void oxen_install(unsigned char netId) {
unsigned char always_export = VIEWKEY_EXPORT_ALWAYS_ALLOW;
nvm_write(&N_oxen_state->viewkey_export_mode, &always_export, 1);
#endif
PRINTF("oxen_install on network %d DONE\n", netId);
}

/* ----------------------------------------------------------------------- */
Expand Down Expand Up @@ -236,8 +219,6 @@ int monero_apdu_lock(void) {
}

void monero_lock_and_throw(int sw) {
PRINTF("monero_lock_and_throw\n");

G_oxen_state.protocol_barrier = PROTOCOL_LOCKED;
snprintf(G_oxen_state.ux_info1, sizeof(G_oxen_state.ux_info1), "Security Err");
snprintf(G_oxen_state.ux_info2, sizeof(G_oxen_state.ux_info2), "%x", sw);
Expand Down
10 changes: 0 additions & 10 deletions src/oxen_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ void monero_main(void) {
volatile unsigned short sw = 0;
BEGIN_TRY {
TRY {
PRINTF("=== monero_main ===\n");
monero_io_do(io_flags);
sw = monero_dispatch();
}
Expand Down Expand Up @@ -180,11 +179,9 @@ __attribute__((section(".boot"))) int main(void) {
__asm volatile("cpsie i");
unsigned int cont = 1;
// not sure if that works before
PRINTF("before os_boot \n");

// ensure exception will work as planned io_seproxyhal_init
os_boot();
PRINTF("after os_boot \n");

while (cont) {
UX_INIT();
Expand All @@ -193,11 +190,9 @@ __attribute__((section(".boot"))) int main(void) {
TRY {
// start communication with MCU
io_seproxyhal_init();
PRINTF("io_seproxyhal_init done \n");

USB_power(0);
USB_power(1);
PRINTF("USB_power \n");

#ifdef HAVE_USB_CLASS_CCID
io_usb_ccid_set_card_inserted(1);
Expand All @@ -210,7 +205,6 @@ __attribute__((section(".boot"))) int main(void) {
#endif

monero_init();
PRINTF("monero_init done \n");

// set up initial screen
ui_menu_main_display();
Expand All @@ -223,14 +217,10 @@ __attribute__((section(".boot"))) int main(void) {
monero_main();
}
CATCH(EXCEPTION_IO_RESET) {
PRINTF("catch EXCEPTION_IO_RESET \n");

// reset IO and UX
;
}
CATCH_OTHER(e) {
PRINTF("catch OTHER \n");

cont = 0;
}
FINALLY {
Expand Down
4 changes: 0 additions & 4 deletions src/oxen_ux_nano.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void ui_menu_pinlock_display(void) {
} u;

} ux_params;
PRINTF("ui_menu_pinlock_display\n");

os_global_pin_invalidate();
G_oxen_state.protocol_barrier = PROTOCOL_LOCKED_UNLOCKABLE;
Expand Down Expand Up @@ -103,7 +102,6 @@ UX_FLOW(ux_flow_info_icon3, &ux_menu_info_icon3_step);
UX_FLOW(ux_flow_info_icon4, &ux_menu_info_icon4_step);

unsigned int ui_menu_info_action(void) {
PRINTF("ui_menu_info_action with %02x\n", G_oxen_state.protocol_barrier);
if (G_oxen_state.protocol_barrier == PROTOCOL_LOCKED)
ui_menu_pinlock_display();
else
Expand Down Expand Up @@ -751,14 +749,12 @@ UX_FLOW(ux_flow_main,
FLOW_LOOP);

void ui_menu_main_display(void) {
PRINTF("ui_menu_main_display before\n");
// reserve a display stack slot if none yet
if (G_ux.stack_count == 0) {
ux_stack_push();
}

ux_flow_init(0, ux_flow_main, NULL);
PRINTF("ui_menu_main_display after\n");
}
/* --- INIT --- */

Expand Down

0 comments on commit 6efbf7d

Please sign in to comment.