Skip to content
Closed
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
12 changes: 12 additions & 0 deletions apps/inheritance_app/inheritance_auth_wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <stdbool.h>
#include <stdint.h>
#include <string.h>

#include "bip39.h"
#include "card_fetch_data.h"
Expand Down Expand Up @@ -178,6 +179,15 @@ static void auth_wallet_handle_errors() {
}
LOG_ERROR("inheritance_auth_wallet error code:%d ", auth_wallet_error.type);

// Display any error msg if exists
if (0 != strlen(error_screen.core_error_msg)) {
if (error_screen.ring_buzzer) {
buzzer_start(BUZZER_DURATION);
}
delay_scr_init(error_screen.core_error_msg, DELAY_SHORT);
clear_core_error_screen();
}

switch (type) {
case AUTH_WALLET_USER_ABORT_ERROR: {
// Error already sent to host, nothing to do here
Expand Down Expand Up @@ -460,6 +470,8 @@ auth_wallet_error_type_e inheritance_auth_wallet(inheritance_query_t *query) {
auth_wallet_get_pairs() && auth_wallet_get_signature() && send_result()) {
delay_scr_init(ui_text_inheritance_wallet_auth_success, DELAY_TIME);
SET_ERROR_TYPE(AUTH_WALLET_OK);
} else {
delay_scr_init(ui_text_inheritance_wallet_auth_fail, DELAY_TIME);
}
auth_wallet_handle_errors();
memzero(auth, sizeof(auth_wallet_config_t));
Expand Down
28 changes: 20 additions & 8 deletions apps/inheritance_app/inheritance_decrypt_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "card_fetch_data.h"
#include "card_operation_typedefs.h"
#include "constant_texts.h"
#include "core_error.h"
#include "core_session.h"
#include "inheritance/core.pb.h"
#include "inheritance/decrypt_data_with_pin.pb.h"
Expand All @@ -80,6 +81,7 @@
#include "status_api.h"
#include "ui_core_confirm.h"
#include "ui_screens.h"
#include "ui_state_machine.h"
#include "utils.h"
#include "wallet.h"
#include "wallet_list.h"
Expand Down Expand Up @@ -258,7 +260,7 @@ static void decryption_handle_errors() {
if (decryption_error.type == DECRYPTION_OK) {
return;
}
LOG_ERROR("inheritance_encrypt_data Error Code:%d Flow Tag:%d ",
LOG_ERROR("inheritance_decrypt_data Error Code:%d Flow Tag:%d ",
decryption_error.type,
decryption_error.flow);
decryption_error_type_e type = decryption_error.type;
Expand Down Expand Up @@ -355,7 +357,7 @@ STATIC bool inheritance_decryption_handle_initiate_query(
result.decrypt.which_response =
INHERITANCE_DECRYPT_DATA_WITH_PIN_RESPONSE_CONFIRMATION_TAG;
inheritance_send_result(&result);
delay_scr_init(ui_text_processing, DELAY_TIME);
delay_scr_init(ui_text_processing, DELAY_SHORT);
return true;
}

Expand Down Expand Up @@ -602,13 +604,18 @@ static bool decrypt_data(void) {
status = false;
break;
}

if (!decrypt_message_data()) {
status = false;
break;
}

} while (0);
delay_scr_init(ui_text_processing, DELAY_TIME);

// Display Processing only if proceeding with flow
if (status) {
delay_scr_init(ui_text_processing, DELAY_SHORT);
}
return status;
}

Expand All @@ -620,9 +627,14 @@ static bool show_data(void) {
uint8_t tag = decryption_context->data[i].plain_data[0];

if (tag == INHERITANCE_ONLY_SHOW_ON_DEVICE) {
message_scr_init(
(const char *)&decryption_context->data[i]
.plain_data[3]); ///< sizeof (tag) + sizeof (length) = 3
char msg[100] = {0};
snprintf(msg,
sizeof(msg),
UI_TEXT_PIN, ///< TODO: Make this generic
&decryption_context->data[i].plain_data[3]);
message_scr_init(msg); ///< sizeof (tag) + sizeof (length) = 3
// Do not care about the return value from confirmation screen
(void)get_state_on_confirm_scr(0, 0, 0);
} else {
uint16_t offset = 1; // Skip tag
decryption_context->response_payload.decrypted_data[response_count]
Expand Down Expand Up @@ -661,10 +673,10 @@ decryption_error_type_e inheritance_decrypt_data(inheritance_query_t *query) {
if (inheritance_decryption_handle_initiate_query(query) &&
inheritance_get_encrypted_data(query) && decrypt_data() && show_data() &&
send_decrypted_data(query)) {
delay_scr_init(ui_text_inheritance_decryption_flow_success, DELAY_TIME);
delay_scr_init(ui_text_inheritance_decryption_flow_success, DELAY_SHORT);
SET_ERROR_TYPE(DECRYPTION_OK);
} else {
delay_scr_init(ui_text_inheritance_decryption_flow_failure, DELAY_TIME);
delay_scr_init(ui_text_inheritance_decryption_flow_failure, DELAY_SHORT);
}
decryption_handle_errors();

Expand Down
21 changes: 20 additions & 1 deletion apps/inheritance_app/inheritance_encrypt_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
*****************************************************************************/

#include <stdint.h>
#include <string.h>

#include "bignum.h"
#include "card_fetch_data.h"
#include "constant_texts.h"
#include "core_error.h"
#include "core_session.h"
#include "inheritance/common.pb.h"
#include "inheritance/core.pb.h"
Expand All @@ -80,6 +82,7 @@
#include "ui_core_confirm.h"
#include "ui_delay.h"
#include "ui_input_text.h"
#include "ui_message.h"
#include "utils.h"
#include "verify_pin_flow.h"
#include "wallet.h"
Expand Down Expand Up @@ -315,6 +318,16 @@ static void encryption_handle_errors() {
LOG_ERROR("inheritance_encrypt_data Error Code:%d Flow Tag:%d ",
encryption_error.type,
encryption_error.flow);

// Display any error msg if exists
if (0 != strlen(error_screen.core_error_msg)) {
if (error_screen.ring_buzzer) {
buzzer_start(BUZZER_DURATION);
}
delay_scr_init(error_screen.core_error_msg, DELAY_TIME);
clear_core_error_screen();
}

encryption_error_type_e type = encryption_error.type;
switch (type) {
case ENCRYPTION_ERROR_DEFAULT:
Expand Down Expand Up @@ -650,6 +663,8 @@ static bool encrypt_data(void) {
status = false;
break;
}
set_app_flow_status(INHERITANCE_ENCRYPT_DATA_STATUS_PIN_ENTERED);

if (!serialize_message_data()) {
status = false;
break;
Expand All @@ -659,6 +674,7 @@ static bool encrypt_data(void) {
status = false;
break;
}
set_app_flow_status(INHERITANCE_ENCRYPT_DATA_STATUS_MESSAGE_ENCRYPTED);

if (!serialize_packet()) {
status = false;
Expand All @@ -671,7 +687,10 @@ static bool encrypt_data(void) {
}
} while (0);

delay_scr_init(ui_text_processing, DELAY_TIME);
// Display Processing only if proceeding with flow
if (status) {
delay_scr_init(ui_text_processing, DELAY_SHORT);
}
return status;
}

Expand Down
10 changes: 3 additions & 7 deletions common/core/core_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
/*****************************************************************************
* EXTERN VARIABLES
*****************************************************************************/
error_screen_t error_screen;

/*****************************************************************************
* PRIVATE MACROS AND DEFINES
Expand All @@ -81,12 +82,6 @@
/*****************************************************************************
* PRIVATE TYPEDEFS
*****************************************************************************/
typedef struct {
char core_error_msg[60]; /**< Buffer to store the error message that needs to
be displayed */
bool ring_buzzer; /**< Configuration parameter to record if buzzer is required
while the error is being displayed */
} error_screen_t;

/*****************************************************************************
* STATIC FUNCTION PROTOTYPES
Expand All @@ -107,7 +102,6 @@ static void display_core_error();
/*****************************************************************************
* STATIC VARIABLES
*****************************************************************************/
static error_screen_t error_screen = {0};

/*****************************************************************************
* GLOBAL VARIABLES
Expand Down Expand Up @@ -182,6 +176,8 @@ void handle_core_errors() {
}

display_core_error();
// clear error_screen after display
clear_core_error_screen();
return;
}

Expand Down
7 changes: 7 additions & 0 deletions common/core/core_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@
/*****************************************************************************
* TYPEDEFS
*****************************************************************************/
typedef struct {
char core_error_msg[60]; /**< Buffer to store the error message that needs to
be displayed */
bool ring_buzzer; /**< Configuration parameter to record if buzzer is required
while the error is being displayed */
} error_screen_t;

/*****************************************************************************
* EXPORTED VARIABLES
*****************************************************************************/
extern error_screen_t error_screen;

/*****************************************************************************
* GLOBAL FUNCTION PROTOTYPES
Expand Down
1 change: 1 addition & 0 deletions src/card_operations/card_fetch_wallet_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ bool card_fetch_wallet_name(const uint8_t *wallet_id, char *wallet_name) {
}

if (0 == strlen(wallet_name)) {
buzzer_start(BUZZER_DURATION);
delay_scr_init(ui_text_wallet_doesnt_exists_on_this_card, DELAY_TIME);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/constant_texts.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#define UI_TEXT_BLIND_SIGNING_WARNING \
LV_SYMBOL_WARNING " Blind Signing\nProceed at your own risk!"
#define UI_TEXT_VERIFY_HD_PATH "Verify Derivation Path"
#define UI_TEXT_PIN "PIN"
#define UI_TEXT_PIN "PIN\n %s"
#define UI_TEXT_VERIFY_DESTINATION_TAG "Verify Destination Tag\n%lu"

// product hash
Expand Down
12 changes: 6 additions & 6 deletions src/wallet/verify_pin_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,13 +254,13 @@ static bool get_verified_pin(const uint8_t *wallet_id,
}

if (COMPLETED == current_state) {
return true;
} else if (reject_cb && EARLY_EXIT == current_state) {
// Inform the host of any rejection
reject_cb(ERROR_COMMON_ERROR_USER_REJECTION_TAG,
ERROR_USER_REJECTION_CONFIRMATION);
return false;
}
return true;
return false;
}

/*****************************************************************************
Expand All @@ -272,15 +272,15 @@ bool verify_pin(const uint8_t *wallet_id,
if ((NULL == wallet_id) || (NULL == pin_out)) {
return false;
}

bool status = false;
clear_wallet_data();
mnemonic_clear();

if (!get_verified_pin(wallet_id, PIN_INPUT, pin_out, reject_cb)) {
return false;
if (get_verified_pin(wallet_id, PIN_INPUT, pin_out, reject_cb)) {
status = true;
}

mnemonic_clear();
clear_wallet_data();
return true;
return status;
}
Loading