Skip to content

Commit

Permalink
Merge pull request #188 from Zondax/update-9420
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala authored May 11, 2023
2 parents abe014f + 52aff83 commit efb1e49
Show file tree
Hide file tree
Showing 56 changed files with 46,264 additions and 42,120 deletions.
252 changes: 144 additions & 108 deletions README.md

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.installer_script

include $(BOLOS_SDK)/Makefile.defines

DEFINES += HAVE_SWAP

DEFINES += APP_SECRET_MODE_ENABLED

$(info ************ TARGET_NAME = [$(TARGET_NAME)])
Expand Down Expand Up @@ -77,7 +79,7 @@ endif

APP_LOAD_PARAMS = --curve ed25519 $(COMMON_LOAD_PARAMS) --path $(APPPATH)

NANOS_STACK_SIZE := 3216
NANOS_STACK_SIZE := 3160

include $(CURDIR)/../deps/ledger-zxlib/makefiles/Makefile.devices

Expand Down
6 changes: 3 additions & 3 deletions app/Makefile.version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is the `transaction_version` field of `Runtime`
APPVERSION_M=21
APPVERSION_M=23
# This is the `spec_version` field of `Runtime`
APPVERSION_N=9391
APPVERSION_N=9420
# This is the patch version of this release
APPVERSION_P=1
APPVERSION_P=0
Binary file removed app/glyphs/icon_back.gif
Binary file not shown.
Binary file removed app/glyphs/icon_crossmark.gif
Binary file not shown.
Binary file removed app/glyphs/icon_dashboard.gif
Binary file not shown.
Binary file removed app/glyphs/icon_eye.gif
Binary file not shown.
Binary file removed app/glyphs/icon_key.gif
Binary file not shown.
Binary file removed app/glyphs/icon_refresh.gif
Binary file not shown.
Binary file removed app/glyphs/icon_validate_14.gif
Binary file not shown.
Binary file removed app/glyphs/icon_warning.gif
Binary file not shown.
24 changes: 18 additions & 6 deletions app/src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "secret.h"
#include "app_mode.h"
#include "view.h"
#include "swap.h"

static bool tx_initialized = false;

Expand Down Expand Up @@ -173,9 +174,15 @@ __Z_INLINE void handleSignSr25519(volatile uint32_t *flags, volatile uint32_t *t
THROW(APDU_CODE_DATA_INVALID);
}

view_review_init(tx_getItem, tx_getNumItems, app_return_sr25519);
view_review_show(REVIEW_TXN);
*flags |= IO_ASYNCH_REPLY;
if (G_swap_state.called_from_swap) {
G_swap_state.should_exit = 1;
app_sign_sr25519();
app_return_sr25519();
} else {
view_review_init(tx_getItem, tx_getNumItems, app_return_sr25519);
view_review_show(REVIEW_TXN);
*flags |= IO_ASYNCH_REPLY;
}
}
#endif

Expand All @@ -189,9 +196,14 @@ __Z_INLINE void handleSignEd25519(volatile uint32_t *flags, volatile uint32_t *t
THROW(APDU_CODE_DATA_INVALID);
}

view_review_init(tx_getItem, tx_getNumItems, app_sign_ed25519);
view_review_show(REVIEW_TXN);
*flags |= IO_ASYNCH_REPLY;
if (G_swap_state.called_from_swap) {
G_swap_state.should_exit = 1;
app_sign_ed25519();
} else {
view_review_init(tx_getItem, tx_getNumItems, app_sign_ed25519);
view_review_show(REVIEW_TXN);
*flags |= IO_ASYNCH_REPLY;
}
}

__Z_INLINE void handleSign(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) {
Expand Down
27 changes: 26 additions & 1 deletion app/src/common/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,42 @@
********************************************************************************/
#include "app_main.h"
#include "view.h"
#include "swap.h"

#include <os_io_seproxyhal.h>

static void app_exit(void) {
BEGIN_TRY_L(exit) {
TRY_L(exit) {
os_sched_exit(-1);
}
FINALLY_L(exit) {
}
}
END_TRY_L(exit);
}

__attribute__((section(".boot"))) int
main(void) {
main(int arg0) {
// exit critical section
__asm volatile("cpsie i");

view_init();
os_boot();

if (arg0) {
libargs_s *args = (libargs_s *) arg0;
if (args->id != 0x100) {
app_exit();
return 0;
}

swap_handle_command(args);
if (!G_swap_state.called_from_swap) {
os_lib_end();
}
}

BEGIN_TRY
{
TRY
Expand Down
10 changes: 10 additions & 0 deletions app/src/common/tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "parser.h"
#include <string.h>
#include "zxmacros.h"
#include "swap.h"

#if defined(TARGET_NANOX) || defined(TARGET_NANOS2) || defined(TARGET_STAX)
#define RAM_BUFFER_SIZE 8192
Expand Down Expand Up @@ -89,6 +90,15 @@ const char *tx_parse() {
return parser_getErrorDescription(err);
}

// If in swap mode, compare swap tx parameters with stored info.
if (G_swap_state.called_from_swap) {
err = check_swap_conditions(&ctx_parsed_tx);
CHECK_APP_CANARY()
if (err != parser_ok) {
return parser_getErrorDescription(err);
}
}

return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/substrate/substrate_coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef enum {
// Coin Specific
#define PK_ADDRESS_TYPE COIN_ADDR_TYPE
#define SUPPORTED_TX_VERSION_CURRENT LEDGER_MAJOR_VERSION
#define SUPPORTED_TX_VERSION_PREVIOUS (LEDGER_MAJOR_VERSION - 1)
#define SUPPORTED_TX_VERSION_PREVIOUS 20
#define SUPPORTED_SPEC_VERSION (LEDGER_MINOR_VERSION + 0)
#define SUPPORTED_MINIMUM_SPEC_VERSION 9300

Expand Down
32 changes: 16 additions & 16 deletions app/src/substrate/substrate_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ parser_error_t _readMethod(
pd_Method_t* method)
{
switch (c->tx_obj->transactionVersion) {
case 21:
return _readMethod_V21(c, moduleIdx, callIdx, &method->V21);
case 23:
return _readMethod_V23(c, moduleIdx, callIdx, &method->V23);
case 20:
return _readMethod_V20(c, moduleIdx, callIdx, &method->V20);
default:
Expand All @@ -38,8 +38,8 @@ parser_error_t _readMethod(
uint8_t _getMethod_NumItems(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx)
{
switch (transactionVersion) {
case 21:
return _getMethod_NumItems_V21(moduleIdx, callIdx);
case 23:
return _getMethod_NumItems_V23(moduleIdx, callIdx);
case 20:
return _getMethod_NumItems_V20(moduleIdx, callIdx);
default:
Expand All @@ -50,8 +50,8 @@ uint8_t _getMethod_NumItems(uint32_t transactionVersion, uint8_t moduleIdx, uint
const char* _getMethod_ModuleName(uint32_t transactionVersion, uint8_t moduleIdx)
{
switch (transactionVersion) {
case 21:
return _getMethod_ModuleName_V21(moduleIdx);
case 23:
return _getMethod_ModuleName_V23(moduleIdx);
case 20:
return _getMethod_ModuleName_V20(moduleIdx);
default:
Expand All @@ -62,8 +62,8 @@ const char* _getMethod_ModuleName(uint32_t transactionVersion, uint8_t moduleIdx
const char* _getMethod_Name(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx)
{
switch (transactionVersion) {
case 21:
return _getMethod_Name_V21(moduleIdx, callIdx);
case 23:
return _getMethod_Name_V23(moduleIdx, callIdx);
case 20:
return _getMethod_Name_V20(moduleIdx, callIdx);
default:
Expand All @@ -74,8 +74,8 @@ const char* _getMethod_Name(uint32_t transactionVersion, uint8_t moduleIdx, uint
const char* _getMethod_ItemName(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx, uint8_t itemIdx)
{
switch (transactionVersion) {
case 21:
return _getMethod_ItemName_V21(moduleIdx, callIdx, itemIdx);
case 23:
return _getMethod_ItemName_V23(moduleIdx, callIdx, itemIdx);
case 20:
return _getMethod_ItemName_V20(moduleIdx, callIdx, itemIdx);
default:
Expand All @@ -88,8 +88,8 @@ parser_error_t _getMethod_ItemValue(uint32_t transactionVersion, pd_Method_t* m,
uint8_t pageIdx, uint8_t* pageCount)
{
switch (transactionVersion) {
case 21:
return _getMethod_ItemValue_V21(&m->V21, moduleIdx, callIdx, itemIdx, outValue,
case 23:
return _getMethod_ItemValue_V23(&m->V23, moduleIdx, callIdx, itemIdx, outValue,
outValueLen, pageIdx, pageCount);
case 20:
return _getMethod_ItemValue_V20(&m->V20, moduleIdx, callIdx, itemIdx, outValue,
Expand All @@ -102,8 +102,8 @@ parser_error_t _getMethod_ItemValue(uint32_t transactionVersion, pd_Method_t* m,
bool _getMethod_ItemIsExpert(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx, uint8_t itemIdx)
{
switch (transactionVersion) {
case 21:
return _getMethod_ItemIsExpert_V21(moduleIdx, callIdx, itemIdx);
case 23:
return _getMethod_ItemIsExpert_V23(moduleIdx, callIdx, itemIdx);
case 20:
return _getMethod_ItemIsExpert_V20(moduleIdx, callIdx, itemIdx);
default:
Expand All @@ -114,8 +114,8 @@ bool _getMethod_ItemIsExpert(uint32_t transactionVersion, uint8_t moduleIdx, uin
bool _getMethod_IsNestingSupported(uint32_t transactionVersion, uint8_t moduleIdx, uint8_t callIdx)
{
switch (transactionVersion) {
case 21:
return _getMethod_IsNestingSupported_V21(moduleIdx, callIdx);
case 23:
return _getMethod_IsNestingSupported_V23(moduleIdx, callIdx);
case 20:
return _getMethod_IsNestingSupported_V20(moduleIdx, callIdx);
default:
Expand Down
6 changes: 3 additions & 3 deletions app/src/substrate/substrate_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {
#include "parser_common.h"
#include "stdbool.h"
#include "substrate_dispatch_V20.h"
#include "substrate_dispatch_V21.h"
#include "substrate_dispatch_V23.h"
#include <stddef.h>
#include <stdint.h>

Expand All @@ -33,8 +33,8 @@ extern "C" {
{ \
switch (txVersion) { \
\
case 21: \
return PD_CALL_##CALL##_V21; \
case 23: \
return PD_CALL_##CALL##_V23; \
\
case 20: \
return PD_CALL_##CALL##_V20; \
Expand Down
2 changes: 1 addition & 1 deletion app/src/substrate/substrate_dispatch_V20.c
Original file line number Diff line number Diff line change
Expand Up @@ -8871,7 +8871,7 @@ parser_error_t _getMethod_ItemValue_V20(
return parser_ok;
}

bool _getMethod_ItemIsExpert_V20(uint8_t moduleIdx, uint8_t callIdx, uint8_t itemIdx)
bool _getMethod_ItemIsExpert_V20(uint8_t moduleIdx, uint8_t callIdx, __Z_UNUSED uint8_t itemIdx)
{
uint16_t callPrivIdx = ((uint16_t)moduleIdx << 8u) + callIdx;

Expand Down
Loading

0 comments on commit efb1e49

Please sign in to comment.