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
14 changes: 7 additions & 7 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "os.h"

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

Expand All @@ -27,17 +27,17 @@ const internalStorage_t N_storage_real;
void config_init(void) {
if (N_storage.initialized != 0x01) {
internalStorage_t storage;
storage.dataAllowed = 0x00;
storage.unknownActionAllowed = 0x00;
storage.initialized = 0x01;
nvm_write((void *) &N_storage, (void *) &storage, sizeof(internalStorage_t));
}
}

bool is_data_allowed(void) {
return N_storage.dataAllowed == 1;
bool is_unknown_action_allowed(void) {
return N_storage.unknownActionAllowed == 1;
}

void toogle_data_allowed(void) {
uint8_t value = (is_data_allowed() ? 0 : 1);
nvm_write((void *) &N_storage.dataAllowed, (void *) &value, sizeof(uint8_t));
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));
}
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "os.h"

void config_init(void);
bool is_data_allowed(void);
void toogle_data_allowed(void);
bool is_unknown_action_allowed(void);
void toogle_unknown_action_allowed(void);

#endif
12 changes: 6 additions & 6 deletions src/eos_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ void initTxContext(txProcessingContext_t *context,
cx_sha256_t *sha256,
cx_sha256_t *dataSha256,
txProcessingContent_t *processingContent,
uint8_t dataAllowed) {
uint8_t allowUnknownAction) {
memset(context, 0, sizeof(txProcessingContext_t));
context->sha256 = sha256;
context->dataSha256 = dataSha256;
context->content = processingContent;
context->state = TLV_CHAIN_ID;
context->dataAllowed = dataAllowed;
context->unknownActionAllowed = allowUnknownAction;
cx_sha256_init(context->sha256);
cx_sha256_init(context->dataSha256);
}
Expand Down Expand Up @@ -348,7 +348,7 @@ void printArgument(uint8_t argNum, txProcessingContext_t *context) {
parseNewAccount(buffer, bufferLength, argNum, arg);
break;
default:
if (context->dataAllowed == 1) {
if (context->unknownActionAllowed == 1) {
parseUnknownAction(context->dataChecksum,
sizeof(context->dataChecksum),
argNum,
Expand All @@ -358,7 +358,7 @@ void printArgument(uint8_t argNum, txProcessingContext_t *context) {
return;
}

if (context->dataAllowed == 1) {
if (context->unknownActionAllowed == 1) {
parseUnknownAction(context->dataChecksum, sizeof(context->dataChecksum), argNum, arg);
}
}
Expand Down Expand Up @@ -894,7 +894,7 @@ static parserStatus_e processTxInternal(txProcessingContext_t *context) {
break;

case TLV_ACTION_DATA_SIZE:
if (isKnownAction(context) || context->dataAllowed == 0) {
if (isKnownAction(context) || context->unknownActionAllowed == 0) {
processField(context);
} else {
processUnknownActionDataSize(context);
Expand All @@ -904,7 +904,7 @@ static parserStatus_e processTxInternal(txProcessingContext_t *context) {
case TLV_ACTION_DATA:
if (isKnownAction(context)) {
processActionData(context);
} else if (context->dataAllowed == 1) {
} else if (context->unknownActionAllowed == 1) {
processUnknownActionData(context);
} else {
PRINTF("UNKNOWN ACTION");
Expand Down
4 changes: 2 additions & 2 deletions src/eos_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct txProcessingContext_t {
name_t contractActionName;
uint8_t sizeBuffer[12];
uint8_t actionDataBuffer[512];
uint8_t dataAllowed;
uint8_t unknownActionAllowed;
checksum256 dataChecksum;
txProcessingContent_t *content;
} txProcessingContext_t;
Expand All @@ -93,7 +93,7 @@ void initTxContext(txProcessingContext_t *context,
cx_sha256_t *sha256,
cx_sha256_t *dataSha256,
txProcessingContent_t *processingContent,
uint8_t dataAllowed);
uint8_t unknownActionAllowed);
parserStatus_e parseTx(txProcessingContext_t *context, uint8_t *buffer, uint32_t length);

void printArgument(uint8_t argNum, txProcessingContext_t *processingContext);
Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ uint32_t handleGetAppConfiguration(uint8_t p1,
UNUSED(workBuffer);
UNUSED(dataLength);
UNUSED(flags);
G_io_apdu_buffer[0] = (is_data_allowed() ? 0x01 : 0x00);
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;
Expand Down Expand Up @@ -302,7 +302,7 @@ uint32_t handleSign(uint8_t p1,
&sha256,
&dataSha256,
&txContent,
is_data_allowed() ? 0x01 : 0x00);
is_unknown_action_allowed() ? 0x01 : 0x00);
} else if (p1 != P1_MORE) {
return 0x6B00;
}
Expand Down
22 changes: 5 additions & 17 deletions src/ui_bagl.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,30 +87,16 @@ void ui_idle(void) {

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

#if defined(TARGET_NANOS)

UX_STEP_CB(ux_settings_flow_1_step,
bnnn_paging,
switch_settings_contract_data(),
{
.title = "Contract data",
.text = confirmLabel,
});

#else

UX_STEP_CB(ux_settings_flow_1_step,
bnnn,
switch_settings_contract_data(),
{
"Contract data",
"Allow contract data",
"Unknown Action",
"in transactions",
confirmLabel,
});

#endif

UX_STEP_CB(ux_settings_flow_2_step,
pb,
ui_idle(),
Expand All @@ -122,12 +108,14 @@ UX_STEP_CB(ux_settings_flow_2_step,
UX_FLOW(ux_settings_flow, &ux_settings_flow_1_step, &ux_settings_flow_2_step);

static void display_settings(void) {
strlcpy(confirmLabel, (is_data_allowed() ? "Allowed" : "NOT Allowed"), sizeof(confirmLabel));
strlcpy(confirmLabel,
(is_unknown_action_allowed() ? "Allowed" : "NOT Allowed"),
sizeof(confirmLabel));
ux_flow_init(0, ux_settings_flow, NULL);
}

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

Expand Down
8 changes: 4 additions & 4 deletions src/ui_nbgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ static void controlsCallback(int token, uint8_t index, int page) {
if (token != FIRST_USER_TOKEN) {
return;
}
toogle_data_allowed();
switches[0].initState = is_data_allowed();
toogle_unknown_action_allowed();
switches[0].initState = is_unknown_action_allowed();
}

void ui_idle(void) {
static nbgl_contentInfoList_t infosList = {0};
static nbgl_content_t contents[1] = {0};
static nbgl_genericContents_t settingContents = {0};

switches[0].initState = is_data_allowed();
switches[0].initState = is_unknown_action_allowed();
switches[0].text = "Contract data";
switches[0].subText = "Allow contract data in transactions";
switches[0].subText = "Allow unknown action in transactions";
switches[0].token = FIRST_USER_TOKEN;

contents[0].type = SWITCHES_LIST;
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/apps/eos.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, client):
def send_get_app_configuration(self) -> Tuple[bool, Tuple[int, int, int]]:
rapdu: RAPDU = self._client.exchange(CLA, INS.INS_GET_APP_CONFIGURATION, 0, 0, b"")
response = rapdu.data
# response = dataAllowed (1) ||
# response = unknownActionAllowed (1) ||
# MAJOR_VERSION (1) ||
# MINOR_VERSION (1) ||
# PATCH_VERSION (1)
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.
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.
2 changes: 1 addition & 1 deletion tests/functional/test_sign_cmd.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from json import load
import pytest

from ledgered.devices import Device, DeviceType
from ledgered.devices import Device, DeviceType # type: ignore
from ragger.backend.interface import RaisePolicy
from ragger.bip import pack_derivation_path
from ragger.navigator import NavInsID
Expand Down
Loading