Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Zondax/ledger-zxlib
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3ffe64882bece4e6a17895ce306c0129862681c6
Choose a base ref
...
head repository: Zondax/ledger-zxlib
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: df81cb767d464995327218f0fb92eaa2dd3b4db3
Choose a head ref

Commits on Aug 16, 2023

  1. add app flags for swap

    carlosala committed Aug 16, 2023
    Copy the full SHA
    b1c053a View commit details
  2. bump container

    carlosala committed Aug 16, 2023
    Copy the full SHA
    dd72522 View commit details
  3. bump version

    carlosala committed Aug 16, 2023
    Copy the full SHA
    7bb01dd View commit details
  4. Copy the full SHA
    928c759 View commit details

Commits on Aug 28, 2023

  1. feat: bump container

    carlosala committed Aug 28, 2023
    Copy the full SHA
    83989ff View commit details
  2. Copy the full SHA
    ca77800 View commit details

Commits on Sep 8, 2023

  1. disable callback

    ftheirs committed Sep 8, 2023
    Copy the full SHA
    e701bd1 View commit details
  2. bump version

    ftheirs committed Sep 8, 2023
    Copy the full SHA
    24c98a4 View commit details
  3. Merge pull request #110 from Zondax/disable_callback

    Disable callback
    ftheirs authored Sep 8, 2023
    Copy the full SHA
    6b44298 View commit details

Commits on Sep 18, 2023

  1. feat: bump container

    carlosala committed Sep 18, 2023
    Copy the full SHA
    2861f89 View commit details
  2. Copy the full SHA
    3eeb1b0 View commit details
  3. Copy the full SHA
    489da6a View commit details

Commits on Sep 25, 2023

  1. chore: bump container

    carlosala committed Sep 25, 2023
    Copy the full SHA
    4bce187 View commit details
  2. Copy the full SHA
    b5e1e7d View commit details

Commits on Oct 2, 2023

  1. Remove superfluous RAM reset in swap mode

    Use app callback to return to Exchange after a swap completion
    fbeutin-ledger committed Oct 2, 2023
    Copy the full SHA
    da707a9 View commit details

Commits on Oct 6, 2023

  1. bump container

    carlosala committed Oct 6, 2023
    Copy the full SHA
    3a83c45 View commit details
  2. bump version

    carlosala committed Oct 6, 2023
    Copy the full SHA
    97ce990 View commit details
  3. Copy the full SHA
    393d53e View commit details

Commits on Oct 12, 2023

  1. Copy the full SHA
    20c03b6 View commit details
  2. chore: bump container

    carlosala committed Oct 12, 2023
    Copy the full SHA
    652095a View commit details
  3. Copy the full SHA
    52dfdea View commit details

Commits on Nov 2, 2023

  1. Copy the full SHA
    6fba6d8 View commit details
  2. Copy the full SHA
    e71d390 View commit details
  3. Copy the full SHA
    f3c791d View commit details
  4. chore: bump version

    carlosala committed Nov 2, 2023
    Copy the full SHA
    3dc2b88 View commit details
  5. Copy the full SHA
    7f80d18 View commit details

Commits on Dec 8, 2023

  1. feat: bump container

    carlosala committed Dec 8, 2023
    Copy the full SHA
    c7500c3 View commit details
  2. fix: do not define stack size for nanos

    Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
    ftheirs and carlosala committed Dec 8, 2023
    Copy the full SHA
    5c933fa View commit details
  3. revert: move UNUSED macro back to any env

    This reverts commit 20c03b6.
    carlosala committed Dec 8, 2023
    Copy the full SHA
    c685e15 View commit details
  4. chore: bump version

    Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
    ftheirs and carlosala committed Dec 8, 2023
    Copy the full SHA
    0289a35 View commit details
  5. Copy the full SHA
    42e82e9 View commit details

Commits on Dec 12, 2023

  1. add new macro

    ftheirs committed Dec 12, 2023
    Copy the full SHA
    5a48bac View commit details
  2. bump version

    ftheirs committed Dec 12, 2023
    Copy the full SHA
    bee7fcb View commit details
  3. Merge pull request #117 from Zondax/dev

    Add new macro
    ftheirs authored Dec 12, 2023
    Copy the full SHA
    0a86522 View commit details
  4. add missing include

    ftheirs committed Dec 12, 2023
    Copy the full SHA
    e0a9503 View commit details
  5. bump version

    ftheirs committed Dec 12, 2023
    Copy the full SHA
    331810b View commit details
  6. move include to right place

    carlosala committed Dec 12, 2023
    Copy the full SHA
    2020bf6 View commit details

Commits on Dec 13, 2023

  1. Merge pull request #118 from Zondax/dev

    Fix
    chcmedeiros authored Dec 13, 2023
    Copy the full SHA
    9bb9095 View commit details
  2. add missing include

    Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
    chcmedeiros and carlosala committed Dec 13, 2023
    Copy the full SHA
    bc70e6e View commit details
  3. bump version

    chcmedeiros authored and carlosala committed Dec 13, 2023
    Copy the full SHA
    a74347f View commit details
  4. Copy the full SHA
    df81cb7 View commit details
12 changes: 1 addition & 11 deletions app/common/app_main.c
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
#include "app_mode.h"
#ifdef HAVE_SWAP
#include "swap.h"
#endif
#endif // HAVE_SWAP

unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];

@@ -157,11 +157,6 @@ void app_init() {

#ifdef HAVE_BLE
// Enable Bluetooth
#ifdef HAVE_SWAP
if (G_swap_state.called_from_swap) {
memset(&G_io_asynch_ux_callback, 0, sizeof(G_io_asynch_ux_callback));
}
#endif // HAVE_SWAP
BLE_power(0, NULL);
BLE_power(1, NULL);
#endif // HAVE_BLE
@@ -220,11 +215,6 @@ void app_main() {
}
FINALLY;
{
#ifdef HAVE_SWAP
if (G_swap_state.called_from_swap && G_swap_state.should_exit) {
os_sched_exit(0);
}
#endif
}
}
END_TRY;
1 change: 1 addition & 0 deletions app/ui/view.c
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@

#include "view_internal.h"
#include "actions.h"
#include "zxmacros.h"

view_t viewdata;
unsigned int review_type = 0;
1 change: 1 addition & 0 deletions app/ui/view.h
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@
********************************************************************************/
#pragma once

#include <stdbool.h>
#include <stdint.h>
#include "coin.h"
#include "zxerror.h"
1 change: 1 addition & 0 deletions app/ui/view_inspect_s.c
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
#include "view_templates.h"
#include "ux.h"
#include "bagl.h"
#include "zxmacros.h"

static void h_inspect_button_left();
static void h_inspect_button_right();
1 change: 1 addition & 0 deletions app/ui/view_inspect_x.c
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
#include "view_nano_inspect.h"
#include "view_templates.h"
#include "view_nano.h"
#include "zxmacros.h"

extern const ux_flow_step_t *ux_review_flow[MAX_REVIEW_UX_SCREENS];

7 changes: 3 additions & 4 deletions app/ui/view_nano_inspect.c
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
#include "view_internal.h"
#include "view_templates.h"
#include "view_nano.h"
#include "zxmacros.h"

void h_inspect_init() {
ZEMU_LOGF(50, "h_inspect_init\n")
@@ -41,14 +42,12 @@ void view_inspect_init(viewfunc_getInnerItem_t view_funcGetInnerItem,
}

bool h_paging_inspect_go_to_root_screen() {
return (viewdata.innerField.level >= 0) &&
(viewdata.innerField.paging.itemIdx == 0)
return (viewdata.innerField.paging.itemIdx == 0)
&& (viewdata.innerField.trace[0] != 0);
}

bool h_paging_inspect_back_screen() {
return (viewdata.innerField.level >= 0) &&
(viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1))
return (viewdata.innerField.paging.itemIdx == (viewdata.innerField.paging.itemCount - 1))
&& (viewdata.innerField.trace[0] != 0);
}

4 changes: 4 additions & 0 deletions app/ui/view_x.c
Original file line number Diff line number Diff line change
@@ -164,7 +164,11 @@ UX_FLOW_DEF_NOCB(ux_review_flow_2_review_title, pbb, { &C_icon_app, REVIEW_SCREE
UX_FLOW_DEF_NOCB(ux_review_flow_3_review_title, pbb, { &C_icon_app, "Review", "configuration",});

UX_STEP_INIT(ux_review_flow_2_start_step, NULL, NULL, { h_review_loop_start(); });
#ifdef HAVE_INSPECT
UX_STEP_CB_INIT(ux_review_flow_2_step, bnnn_paging, h_review_loop_inside(), inspect_init(), { .title = viewdata.key, .text = viewdata.value, });
#else
UX_STEP_NOCB_INIT(ux_review_flow_2_step, bnnn_paging, { h_review_loop_inside(); }, { .title = viewdata.key, .text = viewdata.value, });
#endif
UX_STEP_INIT(ux_review_flow_2_end_step, NULL, NULL, { h_review_loop_end(); });
UX_STEP_VALID(ux_review_flow_3_step, pb, h_approve(0), { &C_icon_validate_14, APPROVE_LABEL });
UX_STEP_VALID(ux_review_flow_4_step, pb, h_reject(review_type), { &C_icon_crossmark, REJECT_LABEL });
4 changes: 2 additions & 2 deletions dockerized_build.mk
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ $(info EXAMPLE_VUE_DIR : $(EXAMPLE_VUE_DIR))
$(info TESTS_JS_DIR : $(TESTS_JS_DIR))
$(info TESTS_JS_PACKAGE : $(TESTS_JS_PACKAGE))

DOCKER_IMAGE_ZONDAX=zondax/ledger-app-builder:ledger-afb65b17862f69d49fd3ecd07403a30dcc6add11
DOCKER_IMAGE_ZONDAX=zondax/ledger-app-builder:ledger-4e23f9e59b2f54100b2d5078a38779531d0f87e8
DOCKER_IMAGE_LEDGER=ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest

ifdef INTERACTIVE
@@ -315,7 +315,7 @@ cpp_test:

.PHONY: fuzz_build
fuzz_build:
cmake -B build -DCMAKE_C_COMPILER=clang-11 -DCMAKE_CXX_COMPILER=clang++-11 -DCMAKE_BUILD_TYPE=Debug -DENABLE_FUZZING=1 -DENABLE_SANITIZERS=1 .
cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DENABLE_FUZZING=1 -DENABLE_SANITIZERS=1 .
make -C build

.PHONY: fuzz
1 change: 1 addition & 0 deletions include/segwit_addr.h
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@
#define _SEGWIT_ADDR_H_ 1

#include <stdint.h>
#include <stddef.h>

/** Encode a SegWit address
*
4 changes: 2 additions & 2 deletions include/utf8.h
Original file line number Diff line number Diff line change
@@ -700,7 +700,7 @@ utf8_int8_t *c = utf8_null;
size_t bytes = 0;

/* Find the end of the string or stop when n is reached */
while ('\0' != src[bytes] && bytes < n) {
while (bytes < n && '\0' != src[bytes]) {
bytes++;
}

@@ -722,7 +722,7 @@ return utf8_null;
bytes = 0;

/* copy src byte-by-byte into our new utf8 string */
while ('\0' != src[bytes] && bytes < n) {
while (bytes < n && '\0' != src[bytes]) {
c[bytes] = src[bytes];
bytes++;
}
36 changes: 0 additions & 36 deletions include/zxerror.h
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@

#pragma once

#include "zxmacros.h"

#ifdef __cplusplus
extern "C" {
#endif
@@ -37,40 +35,6 @@ typedef enum {
zxerr_ledger_api_error = 0b00001111,
} zxerr_t;

__Z_INLINE uint8_t getErrorMessage(char *buffer, uint16_t bufferLen, zxerr_t err) {
MEMZERO(buffer, bufferLen);
if (bufferLen == 0) {
return 0;
}

switch (err) {
case zxerr_unknown:
snprintf(buffer, bufferLen - 1, "zxerr_unknown");
break;
case zxerr_ok:
snprintf(buffer, bufferLen - 1, "zxerr_ok");
break;
case zxerr_no_data:
snprintf(buffer, bufferLen - 1, "zxerr_no_data");
break;
case zxerr_out_of_bounds:
snprintf(buffer, bufferLen - 1, "zxerr_out_of_bounds");
break;
case zxerr_encoding_failed:
snprintf(buffer, bufferLen - 1, "zxerr_encoding_failed");
break;
case zxerr_invalid_crypto_settings:
snprintf(buffer, bufferLen - 1, "zxerr_invalid_crypto_settings");
break;
case zxerr_ledger_api_error:
snprintf(buffer, bufferLen - 1, "zxerr_ledger_api_error");
break;
default:
snprintf(buffer, bufferLen - 1, "err N/A");
}
return strlen(buffer);
}

//0b00000000
//0b00000011
//0b00000101
16 changes: 10 additions & 6 deletions include/zxformat.h
Original file line number Diff line number Diff line change
@@ -413,20 +413,24 @@ __Z_INLINE void pageStringHex(char *outValue, uint16_t outValueLen,
if (inValueLen == 0) {
return;
}
const uint16_t msgHexLen = inValueLen * 2;
// Last char from OutVal will be filled with a null terminator in array_to_hexstr function
*pageCount = (uint8_t) (msgHexLen / (outValueLen - 1) );
const uint16_t lastChunkLen = (msgHexLen % (outValueLen - 1));
// leaving space for null terminator
const uint16_t bytesPerPage = (outValueLen - 1) / 2;
*pageCount = (uint8_t) (inValueLen / bytesPerPage);
const uint16_t lastChunkLen = inValueLen % bytesPerPage;

if (lastChunkLen > 0) {
(*pageCount)++;
}

if (pageIdx < *pageCount) {
if (lastChunkLen > 0 && pageIdx == *pageCount - 1) {
array_to_hexstr(outValue, outValueLen, (const uint8_t*)inValue+(pageIdx * (outValueLen/2)), lastChunkLen/2);
array_to_hexstr(outValue, outValueLen,
(const uint8_t *)inValue + pageIdx * bytesPerPage,
lastChunkLen);
} else {
array_to_hexstr(outValue, outValueLen, (const uint8_t*)inValue+(pageIdx * (outValueLen/2)), outValueLen/2);
array_to_hexstr(outValue, outValueLen,
(const uint8_t *)inValue + pageIdx * bytesPerPage,
bytesPerPage);
}
}
}
13 changes: 11 additions & 2 deletions include/zxmacros_ledger.h
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
#include "cx.h"
#include "os_io_seproxyhal.h"
#include "ux.h"
#include "zxerror.h"

#define MEMCPY_NV nvm_write

@@ -67,7 +68,7 @@ extern unsigned int app_stack_canary;
if (__cx_err != CX_OK) { \
return __cx_err; \
} \
} while (0);
} while (0)


#define CATCH_CXERROR(CALL) \
@@ -76,6 +77,14 @@ extern unsigned int app_stack_canary;
if (__cx_err != CX_OK) { \
goto catch_cx_error; \
} \
} while (0);
} while (0)

#define CHECK_CX_OK(CALL) \
do { \
cx_err_t __cx_err = CALL; \
if (__cx_err != CX_OK) { \
return zxerr_unknown; \
} \
} while (0)

#endif
6 changes: 3 additions & 3 deletions include/zxversion.h
Original file line number Diff line number Diff line change
@@ -15,6 +15,6 @@
********************************************************************************/
#pragma once

#define ZXLIB_MAJOR 19
#define ZXLIB_MINOR 8
#define ZXLIB_PATCH 0
#define ZXLIB_MAJOR 21
#define ZXLIB_MINOR 0
#define ZXLIB_PATCH 2
22 changes: 18 additions & 4 deletions makefiles/Makefile.devices
Original file line number Diff line number Diff line change
@@ -16,12 +16,14 @@
#*******************************************************************************

ifeq ($(TARGET_NAME),TARGET_NANOS)
ifeq ($(HAVE_SWAP),1)
APP_LOAD_PARAMS += --appFlags 0x800
else
APP_LOAD_PARAMS += --appFlags 0x000
endif

ifeq ($(NANOS_STACK_SIZE),)
APP_STACK_SIZE:=3150
else
APP_STACK_SIZE:= $(NANOS_STACK_SIZE)
ifneq ($(NANOS_STACK_SIZE),)
$(error NANOS_STACK_SIZE is deprecated. Remove NANOS_STACK_SIZE definition in app/Makefile)
endif

ICONNAME:=$(CURDIR)/nanos_icon.gif
@@ -30,21 +32,33 @@ OUTPUT_INSTALLER := $(CURDIR)/pkg/installer_s.sh
endif

ifeq ($(TARGET_NAME),TARGET_NANOX)
ifeq ($(HAVE_SWAP),1)
APP_LOAD_PARAMS += --appFlags 0xA00
else
APP_LOAD_PARAMS += --appFlags 0x200
endif
ICONNAME:=$(CURDIR)/nanox_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_x.elf
OUTPUT_INSTALLER:= $(CURDIR)/pkg/installer_x.sh
endif

ifeq ($(TARGET_NAME),TARGET_NANOS2)
ifeq ($(HAVE_SWAP),1)
APP_LOAD_PARAMS += --appFlags 0x800
else
APP_LOAD_PARAMS += --appFlags 0x000
endif
ICONNAME:=$(CURDIR)/nanox_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_s2.elf
OUTPUT_INSTALLER:= $(CURDIR)/pkg/installer_s2.sh
endif

ifeq ($(TARGET_NAME),TARGET_STAX)
ifeq ($(HAVE_SWAP),1)
APP_LOAD_PARAMS += --appFlags 0xA00
else
APP_LOAD_PARAMS += --appFlags 0x200
endif
ICONNAME:=$(CURDIR)/stax_icon.gif
OUTPUT_ELF ?= $(CURDIR)/output/app_stax.elf
OUTPUT_INSTALLER:= $(CURDIR)/pkg/installer_stax.sh