Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ sudo docker run --rm -ti -v "$(pwd -P):/app" --user $(id -u):$(id -g) -v "/tmp/.
cd /app
python3 -m venv private_app_env --system-site-packages
source private_app_env/bin/activate
speculos build/nanosp/bin/app.elf --model nanosp
speculos build/nanos2/bin/app.elf --model nanosp
```

## Compilation Options
Expand Down
4 changes: 2 additions & 2 deletions doc/eosapp.asc
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ None
|==============================================================================================================================
| *Description* | *Length*
| Flags
0x01 : arbitrary data signature enabled by user
| 01
0x01 : arbitrary data signature enabled by user | 01
0x01 : arbitrary data signature enabled by user | 01
| Application major version | 01
| Application minor version | 01
| Application patch version | 01
Expand Down
24 changes: 24 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

typedef struct internalStorage_t {
uint8_t unknownActionAllowed;
uint8_t verbose;
uint8_t initialized;
} internalStorage_t;

Expand All @@ -28,11 +29,19 @@ void config_init(void) {
if (N_storage.initialized != 0x01) {
internalStorage_t storage;
storage.unknownActionAllowed = 0x00;
storage.verbose = 0x00;
storage.initialized = 0x01;
nvm_write((void *) &N_storage, (void *) &storage, sizeof(internalStorage_t));
}
}

/*
* Allow unknown actions
* This app contains a fixed list of supported contracts
* Contracts not matching this list are considered "unknown"
* This setting allows for review and signing of unknown contracts
* By default Off
*/
bool is_unknown_action_allowed(void) {
return N_storage.unknownActionAllowed == 1;
}
Expand All @@ -41,3 +50,18 @@ void toogle_unknown_action_allowed(void) {
uint8_t value = (is_unknown_action_allowed() ? 0 : 1);
nvm_write((void *) &N_storage.unknownActionAllowed, (void *) &value, sizeof(uint8_t));
}

/*
* Show verbose settings
* Presents null.vaulta actions for review otherwise signed blind
* Shows checksums on unknown actions
* Shows authorities on actions
*/
bool is_verbose(void) {
return N_storage.verbose == 1;
}

void toogle_verbose_config(void) {
uint8_t value = (is_verbose() ? 0 : 1);
nvm_write((void *) &N_storage.verbose, (void *) &value, sizeof(uint8_t));
}
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@
void config_init(void);
bool is_unknown_action_allowed(void);
void toogle_unknown_action_allowed(void);
bool is_verbose(void);
void toogle_verbose_config(void);

#endif
9 changes: 5 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,11 @@ uint32_t handleGetAppConfiguration(uint8_t p1,
UNUSED(dataLength);
UNUSED(flags);
G_io_apdu_buffer[0] = (is_unknown_action_allowed() ? 0x01 : 0x00);
G_io_apdu_buffer[1] = MAJOR_VERSION;
G_io_apdu_buffer[2] = MINOR_VERSION;
G_io_apdu_buffer[3] = PATCH_VERSION;
*tx = 4;
G_io_apdu_buffer[1] = (is_verbose() ? 0x01 : 0x00);
G_io_apdu_buffer[2] = MAJOR_VERSION;
G_io_apdu_buffer[3] = MINOR_VERSION;
G_io_apdu_buffer[4] = PATCH_VERSION;
*tx = 5;
return SWO_SUCCESS;
}

Expand Down
80 changes: 54 additions & 26 deletions src/ui_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

static char actionCounter[32];
static char confirmLabel[32];
static char smallConfirmLabel[16];

// display stepped screens
static unsigned int ux_step;
Expand All @@ -37,32 +38,42 @@ static unsigned int ux_step_count;
static char confirm_text1[16];
static char confirm_text2[16];

static void display_settings(void);
static void display_settings_flow(void);
static void switch_settings_contract_data(void);
static void switch_settings_verbose_config(void);
static void display_next_state(uint8_t state);

static void maybe_push_stack(void);

///////////////////////////COMMON FUNCTIONS////////////////////////////
static void maybe_push_stack(void) {
// reserve a display stack slot if none yet
if (G_ux.stack_count == 0) {
ux_stack_push();
}
}
///////////////////////////////////////////////////////////////////////////////

UX_STEP_NOCB(ux_idle_flow_1_step,
UX_STEP_NOCB(ux_idle_ready_step,
nn, // pnn,
{
"Application",
"is ready",
});
UX_STEP_NOCB(ux_idle_flow_2_step,
UX_STEP_NOCB(ux_display_version_step,
bn,
{
"Version",
APPVERSION,
});
UX_STEP_CB(ux_idle_flow_3_step,
UX_STEP_CB(ux_settings_step,
pb,
display_settings(),
display_settings_flow(),
{
&C_icon_coggle,
"Settings",
});
UX_STEP_CB(ux_idle_flow_4_step,
UX_STEP_CB(ux_quit_step,
pb,
os_sched_exit(-1),
{
Expand All @@ -71,37 +82,33 @@ UX_STEP_CB(ux_idle_flow_4_step,
});

UX_FLOW(ux_idle_flow,
&ux_idle_flow_1_step,
&ux_idle_flow_2_step,
&ux_idle_flow_3_step,
&ux_idle_flow_4_step);
&ux_idle_ready_step,
&ux_display_version_step,
&ux_settings_step,
&ux_quit_step);

void ui_idle(void) {
// reserve a display stack slot if none yet
if (G_ux.stack_count == 0) {
ux_stack_push();
}
maybe_push_stack();

ux_flow_init(0, ux_idle_flow, NULL);
}

////////////////////////////////////////////////////////////////////////////////

UX_STEP_NOCB(ux_abort_flow_1_step,
nn, // pnn,
{"Aborting: Detected", "Unknown Trx"});
UX_STEP_NOCB(ux_abort_warning_step,
bnn, // pnn,
{"Aborting", "Detected", "Unknown Trx"});

UX_FLOW(ux_abort_flow,
&ux_abort_flow_1_step,
&ux_idle_flow_2_step,
&ux_idle_flow_3_step,
&ux_idle_flow_4_step);
&ux_abort_warning_step,
&ux_display_version_step,
&ux_display_version_step,
&ux_quit_step);

void ui_abort_unknown_action(void) {
// reserve a display stack slot if none yet
if (G_ux.stack_count == 0) {
ux_stack_push();
}
maybe_push_stack();

ux_flow_init(0, ux_abort_flow, NULL);
}
Expand All @@ -119,25 +126,46 @@ UX_STEP_CB(ux_settings_flow_1_step,
});

UX_STEP_CB(ux_settings_flow_2_step,
bnnn,
switch_settings_verbose_config(),
{
"Verbose",
"Show Details",
"in transactions",
smallConfirmLabel,
});

UX_STEP_CB(ux_settings_flow_3_step,
pb,
ui_idle(),
{
&C_icon_back_x,
"Back",
});

UX_FLOW(ux_settings_flow, &ux_settings_flow_1_step, &ux_settings_flow_2_step);
UX_FLOW(ux_settings_flow,
&ux_settings_flow_1_step,
&ux_settings_flow_2_step,
&ux_settings_flow_3_step);

static void display_settings(void) {
static void display_settings_flow(void) {
strlcpy(confirmLabel,
(is_unknown_action_allowed() ? "Allowed" : "NOT Allowed"),
sizeof(confirmLabel));

strlcpy(smallConfirmLabel, (is_verbose() ? "On" : "Off"), sizeof(smallConfirmLabel));

ux_flow_init(0, ux_settings_flow, NULL);
}

static void switch_settings_contract_data(void) {
toogle_unknown_action_allowed();
display_settings();
display_settings_flow();
}

static void switch_settings_verbose_config(void) {
toogle_verbose_config();
display_settings_flow();
}

///////////////////////////////////////////////////////////////////////////////
Expand Down
34 changes: 27 additions & 7 deletions src/ui_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,34 @@

void app_exit(void);

static nbgl_contentSwitch_t switches[1] = {0};
static nbgl_contentSwitch_t switches[2] = {0};
static const char* const INFO_TYPES[] = {"Version"};
static const char* const INFO_CONTENTS[] = {APPVERSION};

#define SWITCH_COUNT 2
enum { SWITCH_UNKNOWN_ACTION = 0, SWITCH_VERBOSE = 1 };
#define TOKEN_OFFSET FIRST_USER_TOKEN

static void controlsCallback(int token, uint8_t index, int page) {
UNUSED(index);
UNUSED(page);

if (token != FIRST_USER_TOKEN) {
return;
int switchIndex = token - TOKEN_OFFSET;

if (switchIndex < 0 || switchIndex >= SWITCH_COUNT) {
return; // Invalid token, do nothing
}

switch (switchIndex) {
case SWITCH_UNKNOWN_ACTION:
toogle_unknown_action_allowed();
switches[SWITCH_UNKNOWN_ACTION].initState = is_unknown_action_allowed();
break;
case SWITCH_VERBOSE:
toogle_verbose_config();
switches[SWITCH_VERBOSE].initState = is_verbose();
break;
}
toogle_unknown_action_allowed();
switches[0].initState = is_unknown_action_allowed();
}

void ui_idle(void) {
Expand All @@ -57,10 +72,15 @@ void ui_idle(void) {
switches[0].initState = is_unknown_action_allowed();
switches[0].text = "Contract data";
switches[0].subText = "Allow unknown action in transactions";
switches[0].token = FIRST_USER_TOKEN;
switches[0].token = TOKEN_OFFSET + SWITCH_UNKNOWN_ACTION;

switches[1].initState = is_verbose();
switches[1].text = "Verbose";
switches[1].subText = "Review Null.Vaulta transactions\nShow authorizations\nShow checksums";
switches[1].token = TOKEN_OFFSET + SWITCH_VERBOSE;

contents[0].type = SWITCHES_LIST;
contents[0].content.switchesList.nbSwitches = 1;
contents[0].content.switchesList.nbSwitches = 2;
contents[0].content.switchesList.switches = switches;
contents[0].contentActionCallback = controlsCallback;

Expand Down
14 changes: 8 additions & 6 deletions tests/functional/apps/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,22 @@ class EosClient:
def __init__(self, client):
self._client = client

def send_get_app_configuration(self) -> Tuple[bool, Tuple[int, int, int]]:
def send_get_app_configuration(self) -> Tuple[bool, bool, Tuple[int, int, int]]:
rapdu: RAPDU = self._client.exchange(CLA, INS.INS_GET_APP_CONFIGURATION, 0, 0, b"")
response = rapdu.data
# response = unknownActionAllowed (1) ||
#. verbose (1) ||
# MAJOR_VERSION (1) ||
# MINOR_VERSION (1) ||
# PATCH_VERSION (1)
assert len(response) == 4
assert len(response) == 5

data_allowed = int(response[0]) == 1
major = int(response[1])
minor = int(response[2])
patch = int(response[3])
return data_allowed, (major, minor, patch)
is_verbose = int(response[1]) == 1
major = int(response[2])
minor = int(response[3])
patch = int(response[4])
return data_allowed, is_verbose, (major, minor, patch)

def compute_adress_from_public_key(self, public_key: bytes) -> str:
return EosAddrEncoder.EncodeKey(public_key)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Loading
Loading