diff --git a/.github/workflows/containerized-build.yml b/.github/workflows/containerized-build.yml index 86152c563..14d19dcce 100644 --- a/.github/workflows/containerized-build.yml +++ b/.github/workflows/containerized-build.yml @@ -19,9 +19,9 @@ jobs: - name: Build Firmware (${{ inputs.firmware }} - ${{ inputs.target }}) run: | if [[ "${{ github.ref_type }}" == "tag" ]]; then - export VERSION_TAG=$(echo "${{ github.ref }}" | awk -F/ '{print $3}') + export VERSION_TAG=$(echo "${{ github.ref }}" | cut -f 3- -d '/'') elif [[ "${{ github.ref_type }}" == "branch" ]]; then - export VERSION_TAG=$(echo "${{ github.ref }}" | awk -F/ '{print $3}') + export VERSION_TAG=$(echo "${{ github.ref }}" | cut -f 3- -d '/'') else # reftype is repository; use default branch export VERSION_TAG=main diff --git a/.vscode/launch.json b/.vscode/launch.json index b1060a499..d5c93d4c9 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -25,10 +25,30 @@ ], "preLaunchTask": "build-simulator" }, + { + "name": "Simulator Debug Unit Tests", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceRoot}/bin/Cypherock_Simulator", + "args": [], + "stopAtEntry": true, + "cwd": "${workspaceRoot}/bin", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ], + "preLaunchTask": "build-simulator-units-tests" + }, { "name": "Main Debug [Launch]", "cwd": "${workspaceRoot}", - "executable": "build/Cypherock-Main.elf", + "executable": "build/Main/Cypherock-Main.elf", "request": "launch", "type": "cortex-debug", "servertype": "openocd", @@ -44,7 +64,7 @@ { "name": "Main Debug [Attach]", "cwd": "${workspaceRoot}", - "executable": "build/Cypherock-Main.elf", + "executable": "build/Main/Cypherock-Main.elf", "request": "attach", "type": "cortex-debug", "servertype": "openocd", diff --git a/.vscode/settings.json b/.vscode/settings.json index 58df5a942..eb22ad697 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,10 +8,10 @@ "FIRMWARE_TYPE":"Main", }, "terminal.integrated.env.linux": { - "PATH": "${workspaceFolder}/venv/bin:${env:PATH}", + "PATH": "${env:HOME}/.local/bin:${workspaceFolder}/venv/bin:${env:PATH}", }, "terminal.integrated.env.osx": { - "PATH": "${workspaceFolder}/venv/bin:${env:PATH}", + "PATH": "${env:HOME}/.local/bin:${workspaceFolder}/venv/bin:${env:PATH}", }, "terminal.integrated.env.windows": { "PATH": "${workspaceFolder}/venv/Scripts:${workspaceFolder}/venv/bin:${env:PATH}", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 1f6aced1a..1a27525db 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -14,7 +14,17 @@ ], "group": "build" }, - + { + "label": "build-simulator-units-tests", + "type": "shell", + "command": "utilities/build.sh", + "args": [ + "-tunit_tests", + "-fmain", + "-psimulator", + ], + "group": "build" + }, { "label": "build-device", "type": "shell", diff --git a/apps/btc_family/btc_pub_key.c b/apps/btc_family/btc_pub_key.c index f79ff2d6b..6c56aac18 100644 --- a/apps/btc_family/btc_pub_key.c +++ b/apps/btc_family/btc_pub_key.c @@ -60,9 +60,12 @@ * INCLUDES *****************************************************************************/ +#include "bip32.h" #include "btc_api.h" #include "btc_helpers.h" #include "btc_priv.h" +#include "coin_utils.h" +#include "curves.h" #include "reconstruct_wallet_flow.h" #include "status_api.h" #include "ui_core_confirm.h" diff --git a/apps/btc_family/btc_txn.c b/apps/btc_family/btc_txn.c index d3517bb9d..9f065e2c1 100644 --- a/apps/btc_family/btc_txn.c +++ b/apps/btc_family/btc_txn.c @@ -60,12 +60,15 @@ * INCLUDES *****************************************************************************/ +#include "bip32.h" #include "btc_api.h" #include "btc_helpers.h" #include "btc_priv.h" #include "btc_script.h" #include "btc_txn_helpers.h" +#include "coin_utils.h" #include "constant_texts.h" +#include "curves.h" #include "reconstruct_wallet_flow.h" #include "status_api.h" #include "ui_core_confirm.h" diff --git a/apps/btc_family/btc_xpub.c b/apps/btc_family/btc_xpub.c index b3e7e028f..cbee47400 100644 --- a/apps/btc_family/btc_xpub.c +++ b/apps/btc_family/btc_xpub.c @@ -63,6 +63,7 @@ #include "btc_api.h" #include "btc_helpers.h" #include "btc_priv.h" +#include "curves.h" #include "reconstruct_wallet_flow.h" #include "status_api.h" #include "ui_core_confirm.h" diff --git a/apps/evm_family/evm_priv.h b/apps/evm_family/evm_priv.h index 01bdc4e6e..95f37f279 100644 --- a/apps/evm_family/evm_priv.h +++ b/apps/evm_family/evm_priv.h @@ -15,6 +15,7 @@ * INCLUDES *****************************************************************************/ +#include "eth.h" #include "events.h" #include "evm_api.h" #include "evm_context.h" diff --git a/apps/evm_family/evm_sign_msg.c b/apps/evm_family/evm_sign_msg.c index c1786d7a4..b553c2152 100644 --- a/apps/evm_family/evm_sign_msg.c +++ b/apps/evm_family/evm_sign_msg.c @@ -366,9 +366,18 @@ static bool get_user_verification() { case EVM_SIGN_MSG_TYPE_PERSONAL_SIGN: { // TODO: Add a limit on size of data per confirmation based on LVGL buffer // and split message into multiple confirmations accordingly - result = core_scroll_page(UI_TEXT_VERIFY_MESSAGE, - (const char *)sign_msg_ctx.msg_data, - evm_send_error); + size_t len = 4 * sign_msg_ctx.init.total_msg_size; + char *escaped_str = malloc(len); + uint8_t status = string_to_escaped_string( + (const char *)sign_msg_ctx.msg_data, escaped_str, len); + if (1 == status || 5 == status) { + free(escaped_str); + result = false; + break; + } + result = + core_scroll_page(UI_TEXT_VERIFY_MESSAGE, escaped_str, evm_send_error); + free(escaped_str); } break; case EVM_SIGN_MSG_TYPE_SIGN_TYPED_DATA: { diff --git a/apps/evm_family/evm_typed_data_helper.c b/apps/evm_family/evm_typed_data_helper.c index d70485e93..cf264a6df 100644 --- a/apps/evm_family/evm_typed_data_helper.c +++ b/apps/evm_family/evm_typed_data_helper.c @@ -178,7 +178,13 @@ bool evm_get_typed_struct_data_digest( uint8_t *data = NULL; uint16_t data_size = 0, offset = 0; - data_size = sizeof(ETH_SIGN_TYPED_DATA_IDENTIFIER) - 1 + HASH_SIZE * 2; + data_size = sizeof(ETH_SIGN_TYPED_DATA_IDENTIFIER) - 1; + if (0 < typed_data->domain.children_count) { + data_size += HASH_SIZE; + if (0 < typed_data->message.children_count) + data_size += HASH_SIZE; + } + data = malloc(data_size); ASSERT(NULL != data); memzero(data, data_size); @@ -187,9 +193,21 @@ bool evm_get_typed_struct_data_digest( sizeof(ETH_SIGN_TYPED_DATA_IDENTIFIER) - 1); offset += sizeof(ETH_SIGN_TYPED_DATA_IDENTIFIER) - 1; - eip712_status = hash_struct(&(typed_data->domain), data + offset); - offset += HASH_SIZE; - eip712_status |= hash_struct(&(typed_data->message), data + offset); + if (0 < typed_data->domain.children_count) { + eip712_status = hash_struct(&(typed_data->domain), data + offset); + offset += HASH_SIZE; + if (0 < typed_data->message.children_count) { + eip712_status |= hash_struct(&(typed_data->message), data + offset); + } + } + // Setting the primary_type to "EIP712Domain" is technically in spec + // In this case, we ignore the "message" part and only use the "domain" part + // https://ethereum-magicians.org/t/eip-712-standards-clarification-primarytype-as-domaintype/3286 + else if (!strncmp(UI_TEXT_EIP712_DOMAIN_TYPE, + typed_data->message.struct_name, + sizeof(UI_TEXT_EIP712_DOMAIN_TYPE))) { + eip712_status = EIP712_OK; + } if (EIP712_OK == eip712_status) { keccak_256(data, data_size, digest_out); diff --git a/apps/manager_app/device_authentication_api.c b/apps/manager_app/device_authentication_api.c index 0493db3e9..aebd73dc9 100644 --- a/apps/manager_app/device_authentication_api.c +++ b/apps/manager_app/device_authentication_api.c @@ -57,9 +57,9 @@ */ #include "atca_host.h" #include "board.h" -#include "controller_level_four.h" #include "cryptoauthlib.h" #include "curves.h" +#include "flash_api.h" #include "nist256p1.h" #include "sec_flash.h" #include "string.h" @@ -67,6 +67,7 @@ #include "stm32l4xx_it.h" #endif +#include "atca_basic.h" #include "device_authentication_api.h" #define SIGNATURE_SIZE 64 diff --git a/apps/manager_app/device_authentication_api.h b/apps/manager_app/device_authentication_api.h index 7588cdd03..9aa627930 100644 --- a/apps/manager_app/device_authentication_api.h +++ b/apps/manager_app/device_authentication_api.h @@ -17,16 +17,45 @@ *****************************************************************************/ #include +#include "atca_iface.h" +#include "atca_status.h" #include "stddef.h" #include "stdint.h" /***************************************************************************** * MACROS AND DEFINES *****************************************************************************/ +#define DEFAULT_ATECC_RETRIES 5 +#define DEVICE_SERIAL_SIZE 32 /***************************************************************************** * TYPEDEFS *****************************************************************************/ +typedef enum { + slot_0_unused = 0U, + slot_1_unused = 1U, + slot_2_auth_key = 2U, + slot_3_nfc_pair_key = 3U, + slot_4_unused = 4U, + slot_5_challenge = 5U, + slot_6_io_key = 6U, + slot_7_unused = 7U, + slot_8_serial = 8U, + slot_9_unused = 9U, + slot_10_unused = 10U, + slot_11_unused = 11U, + slot_12_unused = 12U, + slot_13_unused = 13U, + slot_14_unused = 14U, + slot_15_unused = 15U +} atecc_slot_define_t; +typedef struct { + uint8_t device_serial[DEVICE_SERIAL_SIZE], retries; + ATCA_STATUS status; + ATCAIfaceCfg *cfg_atecc608a_iface; +} atecc_data_t; + +extern atecc_data_t atecc_data; /***************************************************************************** * EXPORTED VARIABLES diff --git a/apps/manager_app/get_device_info.c b/apps/manager_app/get_device_info.c index 793a33ef9..5194066f0 100644 --- a/apps/manager_app/get_device_info.c +++ b/apps/manager_app/get_device_info.c @@ -60,7 +60,9 @@ * INCLUDES *****************************************************************************/ -#include "controller_level_four.h" +#include "application_startup.h" +#include "atca_status.h" +#include "device_authentication_api.h" #include "flash_api.h" #include "manager_api.h" #include "manager_app.h" diff --git a/apps/manager_app/manager_app.c b/apps/manager_app/manager_app.c index 37106c052..4e980d597 100644 --- a/apps/manager_app/manager_app.c +++ b/apps/manager_app/manager_app.c @@ -164,6 +164,10 @@ void manager_app_main(usb_event_t usb_evt, const void *app_config) { manager_confirm_firmware_update(&query); break; } + case MANAGER_QUERY_SELECT_WALLET_TAG: { + manager_wallet_selector(&query); + break; + } default: { /* In case we ever encounter invalid query, convey to the host app */ manager_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG, diff --git a/apps/manager_app/manager_app_priv.h b/apps/manager_app/manager_app_priv.h index 28d33def6..8f763df02 100644 --- a/apps/manager_app/manager_app_priv.h +++ b/apps/manager_app/manager_app_priv.h @@ -89,4 +89,11 @@ void manager_export_wallets(manager_query_t *query); * @param query Reference to the decoded query struct from the host app */ void manager_confirm_firmware_update(manager_query_t *query); + +/** + * @brief + * + * @param query Reference to the decoded query struct from the host app + */ +void manager_wallet_selector(manager_query_t *query); #endif diff --git a/apps/manager_app/wallet_selector.c b/apps/manager_app/wallet_selector.c new file mode 100644 index 000000000..7f48ca58d --- /dev/null +++ b/apps/manager_app/wallet_selector.c @@ -0,0 +1,234 @@ +/** + * @file wallet_selector.c + * @author Cypherock X1 Team + * @brief Exports list of existing wallets to the host + * @copyright Copyright (c) 2023 HODL TECH PTE LTD + *
You may obtain a copy of license at https://mitcc.org/ + * + ****************************************************************************** + * @attention + * + * (c) Copyright 2023 by HODL TECH PTE LTD + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * + * "Commons Clause" License Condition v1.0 + * + * The Software is provided to you by the Licensor under the License, + * as defined below, subject to the following condition. + * + * Without limiting other conditions in the License, the grant of + * rights under the License will not include, and the License does not + * grant to you, the right to Sell the Software. + * + * For purposes of the foregoing, "Sell" means practicing any or all + * of the rights granted to you under the License to provide to third + * parties, for a fee or other consideration (including without + * limitation fees for hosting or consulting/ support services related + * to the Software), a product or service whose value derives, entirely + * or substantially, from the functionality of the Software. Any license + * notice or attribution required by the License must also include + * this Commons Clause License Condition notice. + * + * Software: All X1Wallet associated files. + * License: MIT + * Licensor: HODL TECH PTE LTD + * + ****************************************************************************** + */ + +/***************************************************************************** + * INCLUDES + *****************************************************************************/ +#include "events.h" +#include "flash_api.h" +#include "manager_api.h" +#include "ui_core_confirm.h" +#include "wallet_list.h" + +/***************************************************************************** + * EXTERN VARIABLES + *****************************************************************************/ + +/***************************************************************************** + * PRIVATE MACROS AND DEFINES + *****************************************************************************/ + +/***************************************************************************** + * PRIVATE TYPEDEFS + *****************************************************************************/ + +/***************************************************************************** + * STATIC FUNCTION PROTOTYPES + *****************************************************************************/ +/** + * @brief Checks if the provided query contains expected request. + * @details The function performs the check on the request type and if the check + * fails, then it will send an error to the host manager app and return false. + * + * @param query Reference to an instance of manager_query_t containing query + * received from host app + * @param which_request The expected request type enum + * + * @return bool Indicating if the check succeeded or failed + * @retval true If the query contains the expected request + * @retval false If the query does not contain the expected request + */ +static bool check_which_request(const manager_query_t *query, + pb_size_t which_request); + +/** + * @brief The functions presents wallet list to the user & waits for input. + * @details The function waits for user action and returns true if the + * selections was completed by the user. In case if user chooses a wallet + * that is unusable, the function will convey the situation to the user & + * prompt the user to choose a wallet again. + * + * @param flash_wallet_idx Reference to store the selected wallet index as on + * flash + * + * @return bool Indicating if the user chose a valid wallet to continue with + * @retval true If user chose a valid wallet + * @retval false If user rejected, timeout happened, or abort received. + */ +// static bool choose_wallet(uint8_t *flash_wallet_idx); + +/** + * @brief Fills wallet list in structure type manager_wallet_item_t with + * details of the provided wallet_idx on device storage. + * + * @param wallet a Pointer to the structure to be filled + * @param wallet_idx Index of wallet in storage whose details are to be copied + */ +static void fill_wallet(manager_wallet_item_t *wallet, uint8_t wallet_idx); + +/***************************************************************************** + * STATIC VARIABLES + *****************************************************************************/ + +/***************************************************************************** + * GLOBAL VARIABLES + *****************************************************************************/ + +/***************************************************************************** + * STATIC FUNCTIONS + *****************************************************************************/ +static bool check_which_request(const manager_query_t *query, + pb_size_t which_request) { + if (which_request != query->get_wallets.which_request) { + manager_send_error(ERROR_COMMON_ERROR_CORRUPT_DATA_TAG, + ERROR_DATA_FLOW_INVALID_REQUEST); + return false; + } + + return true; +} + +// static bool choose_wallet(uint8_t *flash_wallet_idx) { + +// } + +static void fill_wallet(manager_wallet_item_t *wallet, uint8_t wallet_idx) { + const Flash_Wallet *flash_wallet = get_wallet_by_index(wallet_idx); + ASSERT(flash_wallet != NULL); + + snprintf(wallet->name, sizeof(wallet->name), "%s", flash_wallet->wallet_name); + memcpy(wallet->id, flash_wallet->wallet_id, WALLET_ID_SIZE); + + uint8_t wallet_info = flash_wallet->wallet_info; + wallet->has_passphrase = WALLET_IS_PASSPHRASE_SET(wallet_info); + wallet->has_pin = WALLET_IS_PIN_SET(wallet_info); + + ASSERT(NULL != flash_wallet); + + // Wallet is NOT in usable state if + // 1. It is in locked state in any of the X1 cards + // 2. Wallet state in X1 Vault flash is not VALID_WALLET + // 3. Card state in X1 Vault flash is not 0xF + if (flash_wallet->is_wallet_locked || VALID_WALLET != flash_wallet->state || + 0x0F != flash_wallet->cards_states) { + wallet->is_valid = false; + } else { + wallet->is_valid = true; + } +} + +/***************************************************************************** + * GLOBAL FUNCTIONS + *****************************************************************************/ +void manager_wallet_selector(manager_query_t *query) { + if (!check_which_request(query, MANAGER_SELECT_WALLET_REQUEST_INITIATE_TAG)) { + return; + } + + /* Create an array of pointers holding the string to display on the menu. */ + const char *options[MAX_WALLETS_ALLOWED] = {0}; + static uint16_t choice_idx = 0; + uint8_t option_count = get_wallet_list(&options[0]); + + while (true) { + menu_init_with_choice( + options, option_count, "Wallet Select", choice_idx, true); + + evt_status_t events = get_events(EVENT_CONFIG_UI, MAX_INACTIVITY_TIMEOUT); + if (true == events.p0_event.flag) { + // core will handle p0 events, exit now + break; + } + if (UI_EVENT_REJECT == events.ui_event.event_type) { + // user rejected, send error and exit + manager_send_error(ERROR_COMMON_ERROR_USER_REJECTION_TAG, + ERROR_USER_REJECTION_CONFIRMATION); + break; + } + + uint8_t flash_wallet_idx = 0; + choice_idx = events.ui_event.list_selection - 1; + + ASSERT(UI_EVENT_LIST_CHOICE == events.ui_event.event_type); + ASSERT(SUCCESS == + get_index_by_name(options[choice_idx], &flash_wallet_idx)); + if (get_wallet_data_by_id(get_wallet_id(flash_wallet_idx), &wallet, NULL)) { + manager_result_t result = + init_manager_result(MANAGER_RESULT_SELECT_WALLET_TAG); + result.select_wallet.which_response = + MANAGER_SELECT_WALLET_RESPONSE_RESULT_TAG; + result.select_wallet.result.has_wallet = true; + fill_wallet(&result.select_wallet.result.wallet, flash_wallet_idx); + + manager_send_result(&result); + break; + } else { + bool retry_choice = + core_scroll_page(NULL, ui_text_wallet_selector_invalid, NULL); + + if (false == retry_choice) { + // user selected to choose a different wallet + manager_send_error(ERROR_COMMON_ERROR_USER_REJECTION_TAG, + ERROR_USER_REJECTION_CONFIRMATION); + break; + } + } + } + + return; +} \ No newline at end of file diff --git a/common/coin_support/coin_utils.h b/common/coin_support/coin_utils.h index 397e65e23..5a5832f07 100644 --- a/common/coin_support/coin_utils.h +++ b/common/coin_support/coin_utils.h @@ -53,6 +53,7 @@ #define DASH_COIN_VERSION 0x00000000 /// ETHEREUM coin index +#define ETHEREUM_COIN_INDEX 0x8000003C #define ETHEREUM ETHEREUM_COIN_INDEX /// NEAR coin index diff --git a/common/coin_support/eth_sign_data/abi_decode.c b/common/coin_support/eth_sign_data/abi_decode.c index fc33e968e..73cc77329 100644 --- a/common/coin_support/eth_sign_data/abi_decode.c +++ b/common/coin_support/eth_sign_data/abi_decode.c @@ -60,7 +60,9 @@ #include #include "abi.h" +#include "address.h" #include "assert_conf.h" +#include "evm_priv.h" #include "utils.h" /* Global functions @@ -215,11 +217,11 @@ ui_display_node *ABI_Stringify(Abi_Type_e inputAbiType, case Abi_address_e: { char staticBufferInUTF8[43] = "0x"; - byte_array_to_hex_string(pAbiTypeData + Abi_address_e_OFFSET_BE, - 20, - &(staticBufferInUTF8[2]), - 41); - + // generating checksum'd address + ethereum_address_checksum((pAbiTypeData + Abi_address_e_OFFSET_BE), + &(staticBufferInUTF8[2]), + false, + g_evm_app->chain_id); ui_node = ui_create_display_node("Datatype:address\0", 25, &(staticBufferInUTF8[0]), diff --git a/common/core/core_flow_init.c b/common/core/core_flow_init.c index 07fed66dd..afecb734a 100644 --- a/common/core/core_flow_init.c +++ b/common/core/core_flow_init.c @@ -125,8 +125,17 @@ engine_ctx_t core_step_engine_ctx = { engine_ctx_t *get_core_flow_ctx(void) { engine_reset_flow(&core_step_engine_ctx); + const manager_onboarding_step_t step = onboarding_get_last_step(); /// Check if onboarding is complete or not - if (MANAGER_ONBOARDING_STEP_COMPLETE != onboarding_get_last_step()) { + if (MANAGER_ONBOARDING_STEP_COMPLETE != step) { + // reset partial-onboarding if auth flag is reset (which can happen via + // secure-bootloader). Refer PRF-7078 + if (MANAGER_ONBOARDING_STEP_VIRGIN_DEVICE < step && + DEVICE_NOT_AUTHENTICATED == get_auth_state()) { + // bypass onboarding_set_step_done as we want to force reset + save_onboarding_step(MANAGER_ONBOARDING_STEP_VIRGIN_DEVICE); + } + // Skip onbaording for infield devices with pairing and/or wallets count is // greater than zero if ((get_wallet_count() > 0) || (get_keystore_used_count() > 0)) { diff --git a/common/cypherock-common b/common/cypherock-common index aa836c796..7fcd2bcf6 160000 --- a/common/cypherock-common +++ b/common/cypherock-common @@ -1 +1 @@ -Subproject commit aa836c796375c7c1bdb90f35011b0be0e35d80df +Subproject commit 7fcd2bcf6b1a90ead126191444c7fdd07c40764a diff --git a/common/interfaces/user_interface/ui_common.c b/common/interfaces/user_interface/ui_common.c index 321247bf6..e52a1b757 100644 --- a/common/interfaces/user_interface/ui_common.c +++ b/common/interfaces/user_interface/ui_common.c @@ -64,8 +64,8 @@ const char *ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const char *ALPHA_NUMERIC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; const char *NUMBERS = "0123456789"; const char *HEX = "0123456789ABCDEF"; -const char *PASSPHRASE = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "; +const char *PASSPHRASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0" + "123456789 !\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~"; /// Global callback method called when an event is marked over void (*ui_mark_event_over)(); diff --git a/common/interfaces/user_interface/ui_input_mnemonics.c b/common/interfaces/user_interface/ui_input_mnemonics.c index d9b499b24..0f343a9e5 100644 --- a/common/interfaces/user_interface/ui_input_mnemonics.c +++ b/common/interfaces/user_interface/ui_input_mnemonics.c @@ -58,7 +58,9 @@ */ #include "ui_input_mnemonics.h" +#include "bip39.h" #include "ui_events_priv.h" + static void ui_mnem_create(); static void refresh_screen_texts(); static void shrink(); diff --git a/common/interfaces/user_interface/ui_input_text.h b/common/interfaces/user_interface/ui_input_text.h index 3daa998df..262c030b3 100644 --- a/common/interfaces/user_interface/ui_input_text.h +++ b/common/interfaces/user_interface/ui_input_text.h @@ -16,7 +16,7 @@ #define MAX_INPUT_SIZE \ 10 // This is the max number of characters that can be shown in a screen -#define MAX_CHARACTER_INPUT_LIST 80 +#define MAX_CHARACTER_INPUT_LIST 100 #define MAX_PIN_SIZE 8 #define MAX_PASSPHRASE_SIZE 63 #define MAX_ARRAY_SIZE 512 diff --git a/common/interfaces/user_interface/ui_menu.c b/common/interfaces/user_interface/ui_menu.c index 8ea408dc1..ca8c556f2 100644 --- a/common/interfaces/user_interface/ui_menu.c +++ b/common/interfaces/user_interface/ui_menu.c @@ -79,10 +79,11 @@ static struct Menu_Object *obj = NULL; */ static void menu_create(); -void menu_init(const char *option_list[], - const int number_of_options, - const char heading[], - const bool back_button_allowed) { +void menu_init_with_choice(const char *option_list[], + const int number_of_options, + const char heading[], + const int initial_selection, + const bool back_button_allowed) { ASSERT(NULL != option_list); ASSERT(NULL != heading); @@ -96,7 +97,7 @@ void menu_init(const char *option_list[], if (data != NULL) { data->number_of_options = number_of_options; - data->current_index = 0; + data->current_index = initial_selection; data->back_button_allowed = back_button_allowed; snprintf(data->heading, sizeof(data->heading), "%s", heading); diff --git a/common/interfaces/user_interface/ui_menu.h b/common/interfaces/user_interface/ui_menu.h index 3faa2c1d4..7869ff7e2 100644 --- a/common/interfaces/user_interface/ui_menu.h +++ b/common/interfaces/user_interface/ui_menu.h @@ -17,6 +17,9 @@ #define MENU_MAX_NUMBER_OF_OPTIONS 12 #define MAX_LEN_OF_MENU_OPTIONS 25 +// wrapper for reducing changes in codebase +#define menu_init(o, n, h, b) menu_init_with_choice(o, n, h, 0, b) + /** * @brief struct to store Menu data and meta data * @details @@ -59,6 +62,7 @@ struct Menu_Object { * @param option_list Array of char array for options * @param number_of_options Number of options * @param heading Heading text + * @param initial_selection The default selected choice * @param back_button_allowed Show a back button * * @return @@ -69,9 +73,9 @@ struct Menu_Object { * * @note */ -void menu_init(const char *option_list[], - int number_of_options, - const char heading[], - bool back_button_allowed); - +void menu_init_with_choice(const char *option_list[], + const int number_of_options, + const char heading[], + const int initial_selection, + const bool back_button_allowed); #endif // UI_MENU_H \ No newline at end of file diff --git a/common/libraries/util/utils.c b/common/libraries/util/utils.c index 2729cf60a..1f215600e 100644 --- a/common/libraries/util/utils.c +++ b/common/libraries/util/utils.c @@ -65,12 +65,13 @@ #include "assert_conf.h" #include "bip32.h" #include "bip39.h" -#include "controller_level_four.h" #include "crypto_random.h" #include "cryptoauthlib.h" #include "curves.h" +#include "device_authentication_api.h" #include "logger.h" #include "lv_font.h" +#include "lv_txt.h" #include "sha2.h" #include "wallet.h" @@ -622,8 +623,11 @@ uint8_t string_to_escaped_string(const char *input, bool g_ret = lv_font_get_glyph_dsc(font_p, &g, letter, '\0'); uint8_t bytes_read = in_idx - old_idx; - if (0 != letter && true == g_ret) { - // the glyph exists; keep the encoded character as it is + if (0 != letter && ('\n' == letter || '\r' == letter || true == g_ret)) { + // the glyph exists; keep the encoded character as it is. + // Additionally, CR/LF characters are handled as special case by LVGL + // hence glyphs for CR/LF are meaningless so we should keep it as it is + // refer common/lvgl/src/lv_misc/lv_txt.c#174 if ((out_idx + bytes_read + 1) >= out_len) return 5; memcpy(&escaped_string[out_idx], &input[old_idx], bytes_read); diff --git a/common/lv_conf.h b/common/lv_conf.h index eb4d7f837..64be0efcc 100644 --- a/common/lv_conf.h +++ b/common/lv_conf.h @@ -37,6 +37,8 @@ #define LV_COLOR_DEPTH 1 #endif +#define LV_SUBPX_BGR 0 + /* Swap the 2 bytes of RGB565 color. * Useful if the display has a 8 bit interface (e.g. SPI)*/ #define LV_COLOR_16_SWAP 0 @@ -281,7 +283,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ * LV_FONT_DECLARE(my_font_2) */ -#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font) LV_FONT_DECLARE(my_logo) LV_FONT_DECLARE(nfc_logo) +#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(nfc_logo) LV_FONT_DECLARE(special_char) /*Always set a default font from the built-in fonts*/ #define LV_FONT_DEFAULT &lv_font_roboto_12 diff --git a/common/lvgl/scripts/built_in_font/FontAwesomeNew.woff b/common/lvgl/scripts/built_in_font/FontAwesomeNew.woff new file mode 100644 index 000000000..791b41013 Binary files /dev/null and b/common/lvgl/scripts/built_in_font/FontAwesomeNew.woff differ diff --git a/common/lvgl/scripts/built_in_font/Verdana.ttf b/common/lvgl/scripts/built_in_font/Verdana.ttf new file mode 100644 index 000000000..aa4422f4c Binary files /dev/null and b/common/lvgl/scripts/built_in_font/Verdana.ttf differ diff --git a/common/lvgl/scripts/built_in_font/built_in_font_gen.py b/common/lvgl/scripts/built_in_font/built_in_font_gen.py index 1f5d64b1b..3b0a86ab8 100644 --- a/common/lvgl/scripts/built_in_font/built_in_font_gen.py +++ b/common/lvgl/scripts/built_in_font/built_in_font_gen.py @@ -39,9 +39,36 @@ else: compr = "" -#Built in symbols -syms = "61441,61448,61451,61452,61453,61457,61459,61460,61461,61465,61468,61473,61478,61479,61480,61502,61504,61512,61515,61516,61517,61521,61522,61523,61524,61543,61544,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61671,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62099" +#Alpha and numeric ascii chars (backspace and delete) - custom font +alpha_syms = "0x41-0x5A,0x61-0x7A" +numeric_syms = "0x30-0x39" + +#Special Charactors - verdana +special_syms = "0x20-0x2F,0x3A-0x40,0x5B-0x60,0x7B-0x7F" + +#Built in symbols - font awesome +syms = "61441,61448,61451,61452,61453,61457,61459,61460,61461,61465,61468,61473,61478,61479,61480,61502,61504,61512,61515,61516,61517,61521,61522,61523,61524,61536,61543,61544,61550,61552,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61671,61674,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62099,62087,62189" + +extra_syms = "62212,62218,62810,63426,63650" + #Run the command -cmd = "lv_font_conv {} --bpp {} --size {} --font ./Roboto-Regular.woff -r {} --font FontAwesome.ttf -r {} --format lvgl -o {} --force-fast-kern-format".format(compr, args.bpp, args.size, args.range[0], syms, args.output) +cmd = "lv_font_conv {} "\ + "--bpp {} "\ + "--size {} "\ + "--font {} -r {} "\ + "--font {} -r {} "\ + "--font Verdana.ttf -r {} "\ + "--font FontAwesome.ttf -r {} "\ + "--font FontAwesomeNew.woff -r {} "\ + "-o {} "\ + "--format lvgl "\ + "--force-fast-kern-format".\ + format(compr, args.bpp, args.size, args.font, alpha_syms, args.font, numeric_syms, special_syms, syms, extra_syms, args.output) os.system(cmd) + + +#usage: lv_font_conv [-h] [-v] --size PIXELS [-o ] --bpp {1,2,3,4,8} [--lcd | --lcd-v] [--use-color-info] --format {dump,bin,lvgl} --font [-r RANGE] [--symbols SYMBOLS] + # [--autohint-off] [--autohint-strong] [--force-fast-kern-format] [--no-compress] [--no-prefilter] [--no-kerning] [--lv-include ] [--full-info] + +#command to generate font .c script: python built_in_font_gen.py --bpp 1 --size 12 --font Roboto-Regular.woff -o lv_font_roboto_12 \ No newline at end of file diff --git a/common/lvgl/src/lv_font/lv_font_roboto_12.c b/common/lvgl/src/lv_font/lv_font_roboto_12.c index 98e23dc7f..4865d002f 100644 --- a/common/lvgl/src/lv_font/lv_font_roboto_12.c +++ b/common/lvgl/src/lv_font/lv_font_roboto_12.c @@ -1,11 +1,15 @@ -#include "lvgl/lvgl.h" - /******************************************************************************* * Size: 12 px * Bpp: 1 - * Opts: + * Opts: --no-compress --no-prefilter --bpp 1 --size 12 --font Roboto-Regular.woff -r 0x41-0x5A,0x61-0x7A --font Roboto-Regular.woff -r 0x30-0x39 --font verdana.ttf -r 0x20-0x2F,0x3A-0x40,0x5B-0x60,0x7B-0x7F --font FontAwesome.ttf -r 61441,61448,61451,61452,61453,61457,61459,61460,61461,61465,61468,61473,61478,61479,61480,61502,61504,61512,61515,61516,61517,61521,61522,61523,61524,61536,61543,61544,61550,61552,61553,61556,61559,61560,61561,61563,61587,61589,61636,61637,61639,61671,61674,61683,61724,61732,61787,61931,62016,62017,62018,62019,62020,62099,62087,62189 --font fa.woff -r 62212,62218,62810,63426,63650 -o lv_font_roboto_12 --format lvgl --force-fast-kern-format ******************************************************************************/ +#ifdef LV_LVGL_H_INCLUDE_SIMPLE +#include "lvgl.h" +#else +#include "lvgl/lvgl.h" +#endif + #ifndef LV_FONT_ROBOTO_12 #define LV_FONT_ROBOTO_12 1 #endif @@ -17,515 +21,520 @@ *----------------*/ /*Store the image of the glyphs*/ -static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { - /* U+20 " " */ +static LV_ATTRIBUTE_LARGE_CONST const uint8_t glyph_bitmap[] = { + /* U+0020 " " */ 0x0, - /* U+21 "!" */ + /* U+0021 "!" */ 0xfc, 0x80, - /* U+22 "\"" */ - 0xfc, + /* U+0022 "\"" */ + 0xaa, 0xa0, - /* U+23 "#" */ - 0x28, 0xaf, 0xd2, 0x4b, 0xf5, 0x14, 0x50, + /* U+0023 "#" */ + 0x14, 0x14, 0x7f, 0x24, 0x28, 0x28, 0xfe, 0x48, + 0x48, - /* U+24 "$" */ - 0x23, 0xa7, 0x18, 0x30, 0xc1, 0x8c, 0x5c, 0x40, + /* U+0024 "$" */ + 0x21, 0xfa, 0x68, 0xe0, 0xf2, 0x49, 0xf8, 0x82, + 0x0, - /* U+25 "%" */ - 0x60, 0x94, 0x94, 0x68, 0x10, 0x16, 0x29, 0x29, - 0x6, + /* U+0025 "%" */ + 0x61, 0x12, 0x22, 0x48, 0x49, 0x6, 0x4c, 0x12, + 0x42, 0x48, 0x89, 0x10, 0xc0, - /* U+26 "&" */ - 0x30, 0x91, 0x23, 0x86, 0x1a, 0xa3, 0x44, 0x7c, + /* U+0026 "&" */ + 0x30, 0x24, 0x12, 0xe, 0x5, 0x24, 0x52, 0x19, + 0x8c, 0x79, 0x0, - /* U+27 "'" */ + /* U+0027 "'" */ 0xe0, - /* U+28 "(" */ - 0x29, 0x49, 0x24, 0x91, 0x22, + /* U+0028 "(" */ + 0x24, 0x48, 0x88, 0x88, 0x84, 0x42, - /* U+29 ")" */ - 0x89, 0x12, 0x49, 0x25, 0x28, + /* U+0029 ")" */ + 0x42, 0x21, 0x11, 0x11, 0x12, 0x24, - /* U+2A "*" */ - 0x21, 0x3e, 0xc5, 0x0, + /* U+002A "*" */ + 0x25, 0x5d, 0xf2, 0x0, - /* U+2B "+" */ - 0x20, 0x82, 0x3f, 0x20, 0x82, 0x0, + /* U+002B "+" */ + 0x10, 0x20, 0x47, 0xf1, 0x2, 0x4, 0x0, - /* U+2C "," */ - 0x54, + /* U+002C "," */ + 0x7a, - /* U+2D "-" */ - 0xe0, + /* U+002D "-" */ + 0xf0, - /* U+2E "." */ + /* U+002E "." */ 0x80, - /* U+2F "/" */ - 0x10, 0x84, 0x42, 0x11, 0x8, 0x44, 0x0, + /* U+002F "/" */ + 0x8, 0xc4, 0x22, 0x10, 0x88, 0x42, 0x21, 0x0, - /* U+30 "0" */ + /* U+0030 "0" */ 0x74, 0xe3, 0x18, 0xc6, 0x3b, 0x70, - /* U+31 "1" */ + /* U+0031 "1" */ 0x3c, 0x92, 0x49, 0x20, - /* U+32 "2" */ + /* U+0032 "2" */ 0x74, 0x62, 0x11, 0x11, 0x88, 0xf8, - /* U+33 "3" */ + /* U+0033 "3" */ 0x74, 0x42, 0x13, 0x4, 0x31, 0x70, - /* U+34 "4" */ + /* U+0034 "4" */ 0x8, 0x62, 0x8a, 0x4b, 0x2f, 0xc2, 0x8, - /* U+35 "5" */ - 0xfc, 0x21, 0xe1, 0x86, 0x31, 0x70, + /* U+0035 "5" */ + 0xfc, 0x21, 0xe1, 0x86, 0x33, 0x70, - /* U+36 "6" */ + /* U+0036 "6" */ 0x32, 0x21, 0xe8, 0xc6, 0x39, 0x70, - /* U+37 "7" */ + /* U+0037 "7" */ 0xfc, 0x10, 0x82, 0x10, 0x43, 0x8, 0x20, - /* U+38 "8" */ + /* U+0038 "8" */ 0x74, 0x63, 0x17, 0x46, 0x31, 0x70, - /* U+39 "9" */ + /* U+0039 "9" */ 0x74, 0xe3, 0x18, 0xbc, 0x22, 0x60, - /* U+3A ":" */ + /* U+003A ":" */ 0x82, - /* U+3B ";" */ - 0x87, + /* U+003B ";" */ + 0x40, 0x15, 0x60, - /* U+3C "<" */ - 0x9, 0xb1, 0xc3, 0x84, + /* U+003C "<" */ + 0x6, 0x33, 0x87, 0x3, 0x80, 0xc0, 0x0, - /* U+3D "=" */ - 0xf8, 0x1, 0xf0, + /* U+003D "=" */ + 0xfe, 0x0, 0x7, 0xf0, - /* U+3E ">" */ - 0x83, 0x6, 0x7e, 0x40, + /* U+003E ">" */ + 0xc0, 0x60, 0x38, 0x73, 0x98, 0x0, 0x0, - /* U+3F "?" */ - 0x72, 0x42, 0x11, 0x10, 0x80, 0x20, + /* U+003F "?" */ + 0xf4, 0x42, 0x11, 0x10, 0x80, 0x20, - /* U+40 "@" */ - 0x1e, 0x8, 0x64, 0xa, 0x39, 0x92, 0x64, 0x99, - 0x26, 0x5b, 0x9b, 0x90, 0x6, 0x0, 0xf8, + /* U+0040 "@" */ + 0x1e, 0x18, 0x65, 0xea, 0x89, 0xa2, 0x68, 0x9a, + 0x25, 0x7e, 0x60, 0x7, 0x80, - /* U+41 "A" */ + /* U+0041 "A" */ 0x18, 0x18, 0x18, 0x24, 0x24, 0x64, 0x7e, 0x42, 0xc2, - /* U+42 "B" */ + /* U+0042 "B" */ 0xfa, 0x18, 0x61, 0xfa, 0x18, 0x61, 0xf8, - /* U+43 "C" */ + /* U+0043 "C" */ 0x39, 0x18, 0x60, 0x82, 0x8, 0x51, 0x38, - /* U+44 "D" */ + /* U+0044 "D" */ 0xf2, 0x28, 0x61, 0x86, 0x18, 0x62, 0xf0, - /* U+45 "E" */ + /* U+0045 "E" */ 0xfc, 0x21, 0xf, 0xc2, 0x10, 0xf8, - /* U+46 "F" */ + /* U+0046 "F" */ 0xfc, 0x21, 0xf, 0xc2, 0x10, 0x80, - /* U+47 "G" */ + /* U+0047 "G" */ 0x3c, 0x8e, 0x4, 0x8, 0xf0, 0x60, 0xa1, 0x3c, - /* U+48 "H" */ + /* U+0048 "H" */ 0x83, 0x6, 0xc, 0x1f, 0xf0, 0x60, 0xc1, 0x82, - /* U+49 "I" */ + /* U+0049 "I" */ 0xff, 0x80, - /* U+4A "J" */ + /* U+004A "J" */ 0x8, 0x42, 0x10, 0x86, 0x31, 0x70, - /* U+4B "K" */ + /* U+004B "K" */ 0x8e, 0x29, 0x28, 0xe2, 0x49, 0xa2, 0x84, - /* U+4C "L" */ + /* U+004C "L" */ 0x84, 0x21, 0x8, 0x42, 0x10, 0xf8, - /* U+4D "M" */ + /* U+004D "M" */ 0xc3, 0xc3, 0xc3, 0xa5, 0xa5, 0xa5, 0x99, 0x99, 0x99, - /* U+4E "N" */ + /* U+004E "N" */ 0x83, 0x87, 0x8d, 0x99, 0x33, 0x63, 0xc3, 0x82, - /* U+4F "O" */ + /* U+004F "O" */ 0x38, 0x8a, 0xc, 0x18, 0x30, 0x60, 0xa2, 0x38, - /* U+50 "P" */ + /* U+0050 "P" */ 0xfa, 0x18, 0x61, 0xfa, 0x8, 0x20, 0x80, - /* U+51 "Q" */ + /* U+0051 "Q" */ 0x38, 0x8a, 0xc, 0x18, 0x30, 0x60, 0xa2, 0x3c, 0xc, - /* U+52 "R" */ - 0xfa, 0x18, 0x61, 0xfa, 0x28, 0xa1, 0x84, + /* U+0052 "R" */ + 0xfa, 0x18, 0x61, 0xfa, 0x68, 0xa1, 0x84, - /* U+53 "S" */ - 0x7a, 0x38, 0x70, 0x30, 0x38, 0x71, 0x78, + /* U+0053 "S" */ + 0x7a, 0x38, 0x70, 0x30, 0x38, 0x61, 0x78, - /* U+54 "T" */ + /* U+0054 "T" */ 0xfe, 0x20, 0x40, 0x81, 0x2, 0x4, 0x8, 0x10, - /* U+55 "U" */ + /* U+0055 "U" */ 0x86, 0x18, 0x61, 0x86, 0x18, 0x73, 0x78, - /* U+56 "V" */ + /* U+0056 "V" */ 0xc2, 0x85, 0x1a, 0x22, 0x45, 0x8a, 0xc, 0x18, - /* U+57 "W" */ + /* U+0057 "W" */ 0xc4, 0x53, 0x14, 0xa5, 0x2b, 0x4a, 0x8c, 0xa3, 0x18, 0xc6, 0x31, 0x0, - /* U+58 "X" */ + /* U+0058 "X" */ 0x42, 0xc8, 0xb0, 0xc1, 0x7, 0xb, 0x32, 0x42, - /* U+59 "Y" */ + /* U+0059 "Y" */ 0xc6, 0x89, 0xb1, 0x42, 0x82, 0x4, 0x8, 0x10, - /* U+5A "Z" */ + /* U+005A "Z" */ 0xfc, 0x30, 0x84, 0x30, 0x84, 0x30, 0xfc, - /* U+5B "[" */ - 0xea, 0xaa, 0xaa, 0xc0, + /* U+005B "[" */ + 0xf2, 0x49, 0x24, 0x92, 0x70, - /* U+5C "\\" */ - 0x82, 0x10, 0xc2, 0x10, 0x42, 0x10, 0x40, + /* U+005C "\\" */ + 0x41, 0x4, 0x8, 0x20, 0x81, 0x4, 0x8, 0x20, + 0x81, - /* U+5D "]" */ - 0xd5, 0x55, 0x55, 0xc0, + /* U+005D "]" */ + 0xe4, 0x92, 0x49, 0x24, 0xf0, - /* U+5E "^" */ - 0x21, 0x14, 0xa5, 0x0, + /* U+005E "^" */ + 0x18, 0x38, 0x24, 0x42, 0xc2, - /* U+5F "_" */ - 0xf8, + /* U+005F "_" */ + 0xff, - /* U+60 "`" */ - 0x4c, + /* U+0060 "`" */ + 0x94, - /* U+61 "a" */ + /* U+0061 "a" */ 0x74, 0x42, 0xf8, 0xc5, 0xe0, - /* U+62 "b" */ + /* U+0062 "b" */ 0x84, 0x21, 0xe9, 0xc6, 0x31, 0x9f, 0x80, - /* U+63 "c" */ - 0x7b, 0x28, 0x20, 0x83, 0x27, 0x0, + /* U+0063 "c" */ + 0x76, 0x61, 0x8, 0x65, 0xc0, - /* U+64 "d" */ + /* U+0064 "d" */ 0x8, 0x42, 0xfc, 0xc6, 0x31, 0xcb, 0xc0, - /* U+65 "e" */ - 0x76, 0x63, 0xf8, 0x65, 0xc0, + /* U+0065 "e" */ + 0x73, 0x28, 0xbf, 0x83, 0x27, 0x80, - /* U+66 "f" */ + /* U+0066 "f" */ 0x34, 0x4f, 0x44, 0x44, 0x44, - /* U+67 "g" */ - 0x7e, 0x63, 0x18, 0xe5, 0xe1, 0x9b, 0x80, + /* U+0067 "g" */ + 0x7e, 0x63, 0x18, 0xe5, 0xe1, 0x8b, 0x80, - /* U+68 "h" */ + /* U+0068 "h" */ 0x84, 0x21, 0xe8, 0xc6, 0x31, 0x8c, 0x40, - /* U+69 "i" */ + /* U+0069 "i" */ 0xbf, 0x80, - /* U+6A "j" */ + /* U+006A "j" */ 0x45, 0x55, 0x57, - /* U+6B "k" */ + /* U+006B "k" */ 0x84, 0x21, 0x2b, 0x73, 0x94, 0x94, 0x40, - /* U+6C "l" */ + /* U+006C "l" */ 0xff, 0xc0, - /* U+6D "m" */ + /* U+006D "m" */ 0xf7, 0x44, 0x62, 0x31, 0x18, 0x8c, 0x46, 0x22, - /* U+6E "n" */ + /* U+006E "n" */ 0xf4, 0x63, 0x18, 0xc6, 0x20, - /* U+6F "o" */ + /* U+006F "o" */ 0x7b, 0x38, 0x61, 0x87, 0x37, 0x80, - /* U+70 "p" */ + /* U+0070 "p" */ 0xf4, 0xe3, 0x18, 0xcf, 0xd0, 0x84, 0x0, - /* U+71 "q" */ + /* U+0071 "q" */ 0x7e, 0x63, 0x18, 0xe5, 0xe1, 0x8, 0x40, - /* U+72 "r" */ + /* U+0072 "r" */ 0xf2, 0x49, 0x20, - /* U+73 "s" */ + /* U+0073 "s" */ 0x74, 0x60, 0xe0, 0xc5, 0xc0, - /* U+74 "t" */ + /* U+0074 "t" */ 0x4b, 0xa4, 0x92, 0x60, - /* U+75 "u" */ + /* U+0075 "u" */ 0x8c, 0x63, 0x18, 0xc5, 0xe0, - /* U+76 "v" */ + /* U+0076 "v" */ 0x89, 0x24, 0x94, 0x30, 0xc2, 0x0, - /* U+77 "w" */ + /* U+0077 "w" */ 0x88, 0xa4, 0x95, 0x4a, 0xa5, 0x51, 0x10, 0x88, - /* U+78 "x" */ + /* U+0078 "x" */ 0x49, 0x23, 0xc, 0x31, 0x24, 0x80, - /* U+79 "y" */ + /* U+0079 "y" */ 0x89, 0x24, 0x94, 0x30, 0xc3, 0x8, 0x23, 0x0, - /* U+7A "z" */ + /* U+007A "z" */ 0xf8, 0xc4, 0x44, 0x63, 0xe0, - /* U+7B "{" */ - 0x29, 0x24, 0xa2, 0x49, 0x22, + /* U+007B "{" */ + 0x19, 0x8, 0x42, 0x32, 0xc, 0x21, 0x8, 0x30, - /* U+7C "|" */ - 0xff, 0xe0, + /* U+007C "|" */ + 0xff, 0xf0, - /* U+7D "}" */ - 0x89, 0x24, 0x8a, 0x49, 0x28, + /* U+007D "}" */ + 0xc1, 0x8, 0x42, 0x18, 0x26, 0x21, 0x9, 0x80, - /* U+7E "~" */ - 0x65, 0x2a, 0x70, + /* U+007E "~" */ + 0x71, 0x99, 0x8e, /* U+F001 "" */ - 0x0, 0x70, 0x3f, 0x1f, 0xf1, 0xfb, 0x1c, 0x31, - 0x83, 0x18, 0x31, 0x83, 0x19, 0xf7, 0x9f, 0xf8, - 0x47, 0x0, + 0x0, 0x0, 0xf1, 0xfc, 0x7f, 0x1e, 0x44, 0x11, + 0x4, 0x47, 0x13, 0xfc, 0x6f, 0x0, /* U+F008 "" */ - 0xbf, 0xde, 0x7, 0xa0, 0x5e, 0x7, 0xbf, 0xde, - 0x7, 0xa0, 0x5e, 0x7, 0xbf, 0xd0, + 0xff, 0xfc, 0x82, 0x64, 0x13, 0xe0, 0xf9, 0x4, + 0xc8, 0x27, 0xff, 0xf2, 0x9, 0xf0, 0x7c, 0x82, + 0x64, 0x13, 0xff, 0xf0, /* U+F00B "" */ - 0xf7, 0xf7, 0xbf, 0xfd, 0xfe, 0x0, 0xf, 0x7f, - 0x7b, 0xff, 0xdf, 0xc0, 0x0, 0xf7, 0xf7, 0xbf, - 0xfd, 0xfc, + 0xef, 0xfe, 0xff, 0x0, 0xe, 0xff, 0xef, 0xf0, + 0x0, 0x0, 0xe, 0xff, 0xef, 0xf0, /* U+F00C "" */ - 0x0, 0x20, 0x7, 0x0, 0xe4, 0x1c, 0xe3, 0x87, - 0x70, 0x3e, 0x1, 0xc0, 0x8, 0x0, + 0x0, 0x80, 0x74, 0x3b, 0x9c, 0xfe, 0x1f, 0x3, + 0x80, 0x40, /* U+F00D "" */ - 0xc3, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0xc3, + 0x42, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0x42, /* U+F011 "" */ - 0x6, 0x2, 0x64, 0x76, 0xe6, 0x66, 0xc6, 0x3c, - 0x63, 0xc6, 0x3c, 0x3, 0x60, 0x67, 0xe, 0x3f, - 0xc0, 0xf0, + 0xc, 0xb, 0x47, 0xfb, 0xb6, 0xcc, 0xf3, 0x3c, + 0xf, 0x87, 0x61, 0x8f, 0xc0, /* U+F013 "" */ - 0xe, 0x4, 0xf0, 0x7f, 0xef, 0xfe, 0x71, 0xe7, - 0xc, 0x71, 0xef, 0xfe, 0x7f, 0xe4, 0xf0, 0xe, - 0x0, + 0xc, 0x1f, 0xe7, 0xf9, 0xce, 0xe1, 0xf8, 0x77, + 0x39, 0xfe, 0x7f, 0x83, 0x0, + + /* U+F014 "" */ + 0x1c, 0x11, 0x3f, 0xe8, 0x14, 0xb, 0x55, 0xaa, + 0xd5, 0x6a, 0xa0, 0x5f, 0xc0, /* U+F015 "" */ - 0x3, 0x30, 0x1e, 0xc1, 0xcf, 0xc, 0xcc, 0x6f, - 0xdb, 0x7f, 0xb3, 0xff, 0xf, 0x3c, 0x3c, 0xf0, - 0xf3, 0xc0, + 0xd, 0x82, 0x70, 0xb6, 0x7f, 0xef, 0xfa, 0xff, + 0x1c, 0xe3, 0x9c, /* U+F019 "" */ - 0xe, 0x0, 0xe0, 0xe, 0x0, 0xe0, 0x3f, 0xc3, - 0xf8, 0x1f, 0x0, 0xe0, 0xf5, 0xff, 0xff, 0xff, - 0x5f, 0xff, + 0xe, 0x1, 0xc0, 0x38, 0x1f, 0xc1, 0xf0, 0x1c, + 0x1, 0x7, 0xdf, 0xff, 0xbf, 0xfc, /* U+F01C "" */ - 0x1f, 0xe0, 0xc0, 0xc6, 0x1, 0x90, 0x2, 0xf8, - 0xf, 0xe1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0x3f, 0x18, 0x64, 0xb, 0x3, 0x80, 0x7c, 0xff, + 0xff, 0xff, /* U+F021 "" */ - 0x0, 0x31, 0xf3, 0x71, 0xfc, 0x7, 0xc3, 0xf0, - 0x0, 0x0, 0x0, 0x0, 0xfc, 0x3e, 0x3, 0xf8, - 0xec, 0xf8, 0xc0, 0x0, + 0x3f, 0x5c, 0xf6, 0x1f, 0xf, 0x0, 0x0, 0xf, + 0xf, 0x86, 0xbe, 0x0, /* U+F026 "" */ - 0xc, 0x7f, 0xff, 0xff, 0xf1, 0xc3, + 0x8, 0xff, 0xff, 0xfc, 0x61, /* U+F027 "" */ - 0xc, 0xe, 0x3f, 0x7f, 0x9f, 0xdf, 0xe0, 0x70, - 0x18, + 0x8, 0x18, 0xfa, 0xf9, 0xf9, 0xfa, 0x18, 0x8, /* U+F028 "" */ - 0x0, 0x60, 0x1, 0x83, 0x34, 0x38, 0xdf, 0xda, - 0xfe, 0x57, 0xf6, 0xbf, 0x8d, 0x1c, 0xd0, 0x61, - 0x80, 0x18, + 0x0, 0x81, 0x28, 0x62, 0xfd, 0xdf, 0x9b, 0xf7, + 0x46, 0x68, 0x42, 0x0, 0x80, /* U+F03E "" */ - 0xff, 0xf9, 0xff, 0x9f, 0xf9, 0xef, 0xfc, 0x7d, - 0x83, 0xc0, 0x38, 0x3, 0xff, 0xf0, + 0xff, 0xfc, 0x0, 0x60, 0x3, 0x60, 0x1b, 0x8, + 0xc0, 0xe6, 0x7f, 0xb7, 0xfd, 0xbf, 0xec, 0x0, + 0x7f, 0xfe, + + /* U+F040 "" */ + 0x1, 0x80, 0x70, 0x6c, 0x3c, 0x1f, 0xf, 0x87, + 0xc2, 0xe0, 0xd0, 0x38, 0x0, /* U+F048 "" */ - 0xc3, 0xc7, 0xcf, 0xdf, 0xff, 0xff, 0xdf, 0xcf, - 0xc7, 0xc3, + 0xc3, 0x8f, 0x3e, 0xff, 0xff, 0xf7, 0xe7, 0xc7, + 0x84, /* U+F04B "" */ - 0x0, 0x1c, 0x3, 0xe0, 0x7f, 0xf, 0xf9, 0xff, - 0xbf, 0xff, 0xfe, 0xff, 0x9f, 0xc3, 0xe0, 0x70, - 0x0, 0x0, + 0x0, 0x60, 0x3c, 0x1f, 0xf, 0xe7, 0xff, 0xfd, + 0xf8, 0xf0, 0x70, 0x20, 0x0, /* U+F04C "" */ - 0xfb, 0xff, 0x7f, 0xef, 0xfd, 0xff, 0xbf, 0xf7, - 0xfe, 0xff, 0xdf, 0xfb, 0xff, 0x7c, + 0xf3, 0xfc, 0xff, 0x3f, 0xcf, 0xf3, 0xfc, 0xff, + 0x3f, 0xcf, 0xf3, 0xfc, 0xf0, /* U+F04D "" */ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, + 0xff, 0xff, 0xff, 0xff, 0xf0, /* U+F051 "" */ - 0xc3, 0xe3, 0xf3, 0xfb, 0xff, 0xff, 0xfb, 0xf3, - 0xe3, 0xc3, + 0x87, 0x8f, 0x9f, 0xbf, 0xff, 0xfd, 0xf3, 0xc7, + 0xc, /* U+F052 "" */ - 0xc, 0x3, 0xc0, 0x7c, 0x1f, 0xc7, 0xfd, 0xff, - 0xbf, 0xf0, 0x0, 0xff, 0xff, 0xff, 0xff, 0x80, + 0xc, 0x7, 0x83, 0xf1, 0xfe, 0xff, 0xc0, 0x0, + 0x3, 0xff, 0xff, 0xc0, /* U+F053 "" */ - 0xc, 0x73, 0x9c, 0xe3, 0x87, 0xe, 0x1c, 0x30, + 0x4, 0x1c, 0x71, 0xc7, 0x1c, 0x1c, 0x1c, 0x1c, + 0x1c, 0x10, /* U+F054 "" */ - 0x83, 0x87, 0xe, 0x1c, 0x73, 0x9c, 0xe2, 0x0, + 0xc1, 0xc3, 0xc3, 0xc3, 0xc3, 0xcf, 0x3c, 0xf1, + 0xc3, 0x0, /* U+F060 "" */ - 0xc, 0x3, 0x80, 0xe0, 0x38, 0xf, 0xff, 0xff, - 0xdc, 0x1, 0xc0, 0x1c, 0x1, 0x80, + 0xc, 0x7, 0x83, 0xc1, 0xe0, 0xff, 0xff, 0xf7, + 0x80, 0xf0, 0x1e, 0x3, 0x0, /* U+F067 "" */ - 0xe, 0x1, 0xc0, 0x38, 0x7, 0xf, 0xff, 0xff, - 0xc3, 0x80, 0x70, 0xe, 0x1, 0xc0, + 0x1c, 0xe, 0x7, 0x1f, 0xff, 0xff, 0xfc, 0x70, + 0x38, 0x1c, 0x0, /* U+F068 "" */ - 0xff, 0xff, 0xfc, + 0xff, 0xff, 0xc0, /* U+F06E "" */ - 0xf, 0x81, 0xc7, 0x1c, 0x1d, 0xc6, 0x7e, 0xfb, - 0xf7, 0xdd, 0xdd, 0xc7, 0x1c, 0xf, 0x80, + 0xf, 0x3, 0xbc, 0x57, 0xa9, 0xf9, 0x9f, 0x94, + 0xf2, 0x30, 0xc0, 0xf0, /* U+F070 "" */ - 0x0, 0x1, 0xc0, 0x1, 0xdf, 0x0, 0xe3, 0x80, - 0xd3, 0x84, 0xfb, 0x9c, 0x77, 0x3c, 0x6e, 0x38, - 0x78, 0x38, 0x70, 0x1e, 0x30, 0x0, 0x30, 0x0, - 0x0, + 0x7, 0x83, 0xb0, 0x57, 0x29, 0x69, 0x9c, 0x94, + 0xd2, 0x28, 0x41, 0xb0, 0x0, 0x0, /* U+F071 "" */ - 0x3, 0x0, 0x1c, 0x0, 0xf8, 0x3, 0xf0, 0x1c, - 0xc0, 0x73, 0x83, 0xcf, 0x1f, 0xfc, 0x7c, 0xfb, - 0xf3, 0xef, 0xff, 0x80, + 0x6, 0x0, 0x60, 0xf, 0x1, 0x98, 0x19, 0x83, + 0x9c, 0x3f, 0xc7, 0x9e, 0xf9, 0xff, 0xff, /* U+F074 "" */ - 0x0, 0x0, 0x6, 0xe1, 0xff, 0x3f, 0x17, 0x60, - 0xe4, 0x1f, 0x6f, 0xbf, 0xf1, 0xf0, 0x6, 0x0, - 0x40, + 0x0, 0x0, 0x6, 0xf3, 0xf1, 0x66, 0x1c, 0x0, + 0xc0, 0x18, 0x1, 0x66, 0xe3, 0xf0, 0x6, /* U+F077 "" */ - 0x0, 0x3, 0x1, 0xe0, 0xcc, 0x61, 0xb0, 0x30, - 0x0, + 0x4, 0x1, 0xc0, 0x7c, 0x1d, 0xc7, 0x1d, 0xc1, + 0xd0, 0x10, /* U+F078 "" */ - 0x0, 0x30, 0x36, 0x18, 0xcc, 0x1e, 0x3, 0x0, - 0x0, + 0x40, 0x5c, 0x1f, 0xc7, 0x1d, 0xc1, 0xf0, 0x1c, + 0x1, 0x0, /* U+F079 "" */ - 0x30, 0x0, 0xf7, 0xf3, 0xf0, 0x65, 0xa0, 0xc3, - 0x1, 0x86, 0xb, 0x4c, 0x1f, 0x9f, 0xde, 0x0, - 0x18, + 0x37, 0xf1, 0xe0, 0xcf, 0xc3, 0xc, 0xc, 0x30, + 0xfc, 0xc1, 0xe3, 0xfb, 0x0, /* U+F07B "" */ - 0x78, 0xf, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, + 0x70, 0x1f, 0x3, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xe0, /* U+F093 "" */ - 0x6, 0x0, 0xf0, 0x1f, 0x83, 0xfc, 0x7, 0x0, - 0x70, 0x7, 0x0, 0x70, 0xf7, 0xff, 0xff, 0xff, - 0x5f, 0xff, + 0x4, 0x1, 0xc0, 0x7c, 0x1f, 0xc0, 0xe0, 0x1c, + 0x3, 0x87, 0x7, 0xff, 0xff, 0xf7, 0xff, 0x80, /* U+F095 "" */ - 0x0, 0x0, 0xf, 0x0, 0xf0, 0x1f, 0x0, 0xf0, - 0x6, 0x0, 0xe0, 0x1c, 0x73, 0xcf, 0xf8, 0xfe, - 0xf, 0xc0, 0x0, 0x0, + 0x40, 0x70, 0x38, 0x18, 0x4, 0x3, 0x0, 0xcc, + 0x3f, 0x7, 0x0, /* U+F0C4 "" */ - 0x70, 0x5b, 0x3f, 0x6f, 0x3f, 0xc1, 0xf0, 0x3e, - 0x1f, 0xe6, 0xde, 0xd9, 0xee, 0x8, + 0x60, 0x9, 0x3, 0x88, 0xdc, 0x92, 0x76, 0xc0, + 0xe8, 0x7f, 0x6c, 0x99, 0x98, 0x7f, 0x0, /* U+F0C5 "" */ - 0x1f, 0x43, 0xef, 0x7f, 0xef, 0xfd, 0xff, 0xbf, - 0xf7, 0xfe, 0xff, 0xdf, 0xf8, 0x3, 0xfc, 0x0, + 0x1f, 0x3, 0x10, 0x51, 0xff, 0x19, 0x86, 0x98, + 0xc9, 0x8f, 0x98, 0x81, 0xf8, 0x10, 0x81, 0x8, + 0x10, 0xff, /* U+F0C7 "" */ - 0xff, 0x98, 0x1b, 0x3, 0xe0, 0x7c, 0xf, 0xff, - 0xfe, 0x7f, 0x8f, 0xf9, 0xff, 0xfc, + 0xff, 0x2c, 0xeb, 0x2e, 0xc9, 0xbe, 0x60, 0x1b, + 0xf6, 0x85, 0xa1, 0x68, 0x5f, 0xfc, /* U+F0E7 "" */ - 0x78, 0x78, 0xf8, 0xf0, 0xff, 0xfe, 0xfc, 0x1c, - 0x18, 0x18, 0x10, 0x30, + 0x71, 0xc6, 0x1f, 0xfb, 0x61, 0x4, 0x20, 0x82, + 0x0, /* U+F0EA "" */ - 0x18, 0x3b, 0x8e, 0xe3, 0xf8, 0xe0, 0x3b, 0xae, - 0xe7, 0xbf, 0xef, 0xfb, 0xf0, 0xfc, 0x3f, + 0xff, 0x8c, 0x18, 0xff, 0x8f, 0x8c, 0xf8, 0xaf, + 0x8b, 0xf8, 0xff, 0x81, 0xf8, 0x1f, 0x81, 0x8, + 0x10, 0xff, /* U+F0F3 "" */ - 0x4, 0x0, 0x80, 0x7c, 0x1f, 0xc3, 0xf8, 0x7f, - 0x1f, 0xf3, 0xfe, 0x7f, 0xdf, 0xfc, 0x0, 0x7, + 0x4, 0x3, 0xe0, 0xfe, 0x1f, 0xc3, 0xf8, 0x7f, + 0xf, 0xe3, 0xfe, 0x7f, 0xdf, 0xfc, 0x78, 0x7, 0x0, /* U+F11C "" */ - 0xff, 0xff, 0x52, 0xbd, 0x4a, 0xff, 0xff, 0xeb, - 0x5f, 0xff, 0xfd, 0x2, 0xf4, 0xb, 0xff, 0xfc, + 0xff, 0xfc, 0x0, 0x75, 0xab, 0x0, 0x5a, 0xd6, + 0xc0, 0x6, 0x7e, 0xbf, 0xff, /* U+F124 "" */ - 0x0, 0x0, 0xf, 0x3, 0xf0, 0xfe, 0x3f, 0xef, - 0xfc, 0xff, 0xc0, 0x78, 0x7, 0x80, 0x78, 0x7, - 0x0, 0x70, 0x2, 0x0, + 0x0, 0x0, 0xc1, 0xe3, 0xe7, 0xf7, 0xf0, 0x38, + 0x18, 0xc, 0x4, 0x0, /* U+F15B "" */ - 0xfa, 0x7d, 0xbe, 0xff, 0xf, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, + 0xfe, 0x3f, 0x4f, 0xdb, 0xf1, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, /* U+F1EB "" */ - 0x7, 0xc0, 0x7f, 0xf1, 0xe0, 0xf7, 0x0, 0x70, - 0x7c, 0x3, 0xfe, 0x6, 0xc, 0x0, 0x0, 0x3, - 0x80, 0x7, 0x0, 0xe, 0x0, + 0x6, 0x1, 0xff, 0x1c, 0x1f, 0x9f, 0x23, 0x8e, + 0x18, 0x30, 0x3c, 0x1, 0xb0, 0x0, 0x0, 0x10, + 0x0, /* U+F240 "" */ - 0xff, 0xff, 0x80, 0x1f, 0x7f, 0xfe, 0xff, 0xbd, - 0xff, 0x78, 0x1, 0xff, 0xff, 0x80, + 0xff, 0xfe, 0x80, 0x2, 0xbf, 0xfa, 0xbf, 0xf9, + 0xbf, 0xf9, 0xbf, 0xf9, 0xbf, 0xfb, 0x80, 0x2, + 0xff, 0xfe, /* U+F241 "" */ - 0xff, 0xff, 0x80, 0x1f, 0x7f, 0x3e, 0xfe, 0x3d, - 0xfc, 0x78, 0x1, 0xff, 0xff, 0x80, + 0xff, 0xfe, 0x80, 0x2, 0xbf, 0xe2, 0xbf, 0xe1, + 0xbf, 0xe1, 0xbf, 0xe1, 0xbf, 0xe3, 0x80, 0x2, + 0xff, 0xfe, /* U+F242 "" */ - 0xff, 0xff, 0x80, 0x1f, 0x78, 0x3e, 0xf0, 0x3d, - 0xe0, 0x78, 0x1, 0xff, 0xff, 0x80, + 0xff, 0xfe, 0x80, 0x2, 0xbf, 0x2, 0xbf, 0x1, + 0xbf, 0x1, 0xbf, 0x1, 0xbf, 0x3, 0x80, 0x2, + 0xff, 0xfe, /* U+F243 "" */ - 0xff, 0xff, 0x80, 0x1f, 0x60, 0x3e, 0xc0, 0x3d, - 0x80, 0x78, 0x1, 0xff, 0xff, 0x80, + 0xff, 0xfe, 0x80, 0x2, 0xb8, 0x2, 0xb8, 0x1, + 0xb8, 0x1, 0xb8, 0x1, 0xb8, 0x3, 0x80, 0x2, + 0xff, 0xfe, /* U+F244 "" */ - 0xff, 0xff, 0x80, 0x1f, 0x0, 0x3e, 0x0, 0x3c, - 0x0, 0x78, 0x1, 0xff, 0xff, 0x80, + 0xff, 0xfe, 0x80, 0x2, 0x80, 0x2, 0x80, 0x1, + 0x80, 0x1, 0x80, 0x1, 0x80, 0x3, 0x80, 0x2, + 0xff, 0xfe, /* U+F287 "" */ 0x0, 0xc0, 0x7, 0x80, 0x10, 0x7, 0x20, 0x6f, @@ -533,16 +542,14 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { 0xf0, /* U+F293 "" */ - 0x3e, 0x3b, 0x9c, 0xdb, 0x7c, 0xbf, 0x1f, 0x9f, - 0x87, 0xd5, 0xf9, 0x9d, 0xc7, 0xc0, + 0x3e, 0x3b, 0xbc, 0xdb, 0x3c, 0x1f, 0x1f, 0x8f, + 0x83, 0xd9, 0xf9, 0x9d, 0xc7, 0xc0, /* U+F2ED "" */ - 0xe, 0x1f, 0xfc, 0x0, 0x0, 0x7, 0xfc, 0xd5, - 0x9a, 0xb3, 0x56, 0x6a, 0xcd, 0x59, 0xab, 0x3f, - 0xe0, + 0x0, /* U+F304 "" */ - 0x0, 0x0, 0xe, 0x0, 0xf0, 0x37, 0x7, 0xa0, + 0x0, 0x40, 0xe, 0x0, 0xf0, 0x37, 0x7, 0xa0, 0xfc, 0x1f, 0x83, 0xf0, 0x7e, 0xf, 0xc0, 0xf8, 0xf, 0x0, 0x80, 0x0, @@ -571,160 +578,162 @@ static LV_ATTRIBUTE_LARGE_CONST const uint8_t gylph_bitmap[] = { static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { {.bitmap_index = 0, .adv_w = 0, .box_w = 0, .box_h = 0, .ofs_x = 0, .ofs_y = 0} /* id = 0 reserved */, - {.bitmap_index = 0, .adv_w = 48, .box_w = 1, .box_h = 1, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1, .adv_w = 49, .box_w = 1, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 3, .adv_w = 61, .box_w = 2, .box_h = 3, .ofs_x = 1, .ofs_y = 7}, - {.bitmap_index = 4, .adv_w = 118, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 11, .adv_w = 108, .box_w = 5, .box_h = 12, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 19, .adv_w = 141, .box_w = 8, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 28, .adv_w = 119, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 36, .adv_w = 33, .box_w = 1, .box_h = 3, .ofs_x = 1, .ofs_y = 7}, - {.bitmap_index = 37, .adv_w = 66, .box_w = 3, .box_h = 13, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 42, .adv_w = 67, .box_w = 3, .box_h = 13, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 47, .adv_w = 83, .box_w = 5, .box_h = 5, .ofs_x = 0, .ofs_y = 4}, - {.bitmap_index = 51, .adv_w = 109, .box_w = 6, .box_h = 7, .ofs_x = 1, .ofs_y = 1}, - {.bitmap_index = 57, .adv_w = 38, .box_w = 2, .box_h = 3, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 58, .adv_w = 53, .box_w = 3, .box_h = 1, .ofs_x = 0, .ofs_y = 3}, - {.bitmap_index = 59, .adv_w = 51, .box_w = 1, .box_h = 1, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 60, .adv_w = 79, .box_w = 5, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 67, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 73, .adv_w = 108, .box_w = 3, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 77, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 83, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 89, .adv_w = 108, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 96, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 102, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 108, .adv_w = 108, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 115, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 121, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 127, .adv_w = 47, .box_w = 1, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 128, .adv_w = 41, .box_w = 1, .box_h = 8, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 129, .adv_w = 98, .box_w = 5, .box_h = 6, .ofs_x = 1, .ofs_y = 1}, - {.bitmap_index = 133, .adv_w = 105, .box_w = 5, .box_h = 4, .ofs_x = 1, .ofs_y = 3}, - {.bitmap_index = 136, .adv_w = 100, .box_w = 5, .box_h = 6, .ofs_x = 1, .ofs_y = 1}, - {.bitmap_index = 140, .adv_w = 91, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 146, .adv_w = 172, .box_w = 10, .box_h = 12, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 161, .adv_w = 125, .box_w = 8, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 170, .adv_w = 120, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 177, .adv_w = 125, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 184, .adv_w = 126, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 191, .adv_w = 109, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 197, .adv_w = 106, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 203, .adv_w = 131, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 211, .adv_w = 137, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 219, .adv_w = 52, .box_w = 1, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 221, .adv_w = 106, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 227, .adv_w = 120, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 234, .adv_w = 103, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 240, .adv_w = 168, .box_w = 8, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 249, .adv_w = 137, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 257, .adv_w = 132, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 265, .adv_w = 121, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 272, .adv_w = 132, .box_w = 7, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 281, .adv_w = 118, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 288, .adv_w = 114, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 295, .adv_w = 115, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 303, .adv_w = 125, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 310, .adv_w = 122, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 318, .adv_w = 170, .box_w = 10, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 330, .adv_w = 120, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 338, .adv_w = 115, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 346, .adv_w = 115, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 353, .adv_w = 51, .box_w = 2, .box_h = 13, .ofs_x = 1, .ofs_y = -2}, - {.bitmap_index = 357, .adv_w = 79, .box_w = 5, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 364, .adv_w = 51, .box_w = 2, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 368, .adv_w = 80, .box_w = 5, .box_h = 5, .ofs_x = 0, .ofs_y = 5}, - {.bitmap_index = 372, .adv_w = 87, .box_w = 5, .box_h = 1, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 373, .adv_w = 59, .box_w = 3, .box_h = 2, .ofs_x = 0, .ofs_y = 8}, - {.bitmap_index = 374, .adv_w = 104, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 379, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 386, .adv_w = 101, .box_w = 6, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 392, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 399, .adv_w = 102, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 404, .adv_w = 67, .box_w = 4, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 409, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 416, .adv_w = 106, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 423, .adv_w = 47, .box_w = 1, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 425, .adv_w = 46, .box_w = 2, .box_h = 12, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 428, .adv_w = 97, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 435, .adv_w = 47, .box_w = 1, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 437, .adv_w = 168, .box_w = 9, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 445, .adv_w = 106, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 450, .adv_w = 110, .box_w = 6, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 456, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 463, .adv_w = 109, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 470, .adv_w = 65, .box_w = 3, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 473, .adv_w = 99, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 478, .adv_w = 63, .box_w = 3, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 482, .adv_w = 106, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 487, .adv_w = 93, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 493, .adv_w = 144, .box_w = 9, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 501, .adv_w = 95, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 507, .adv_w = 91, .box_w = 6, .box_h = 10, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 515, .adv_w = 95, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, - {.bitmap_index = 520, .adv_w = 65, .box_w = 3, .box_h = 13, .ofs_x = 1, .ofs_y = -3}, - {.bitmap_index = 525, .adv_w = 47, .box_w = 1, .box_h = 11, .ofs_x = 1, .ofs_y = -2}, - {.bitmap_index = 527, .adv_w = 65, .box_w = 3, .box_h = 13, .ofs_x = 0, .ofs_y = -3}, - {.bitmap_index = 532, .adv_w = 131, .box_w = 7, .box_h = 3, .ofs_x = 1, .ofs_y = 3}, - {.bitmap_index = 535, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 553, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 567, .adv_w = 192, .box_w = 13, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 585, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 599, .adv_w = 132, .box_w = 8, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 607, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 625, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 642, .adv_w = 216, .box_w = 14, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 660, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 678, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 694, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 714, .adv_w = 96, .box_w = 6, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 720, .adv_w = 144, .box_w = 9, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 729, .adv_w = 216, .box_w = 13, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 747, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 761, .adv_w = 168, .box_w = 8, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 771, .adv_w = 168, .box_w = 11, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 789, .adv_w = 168, .box_w = 11, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 803, .adv_w = 168, .box_w = 11, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 817, .adv_w = 168, .box_w = 8, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 827, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 843, .adv_w = 120, .box_w = 6, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 851, .adv_w = 120, .box_w = 6, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, - {.bitmap_index = 859, .adv_w = 168, .box_w = 11, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 873, .adv_w = 168, .box_w = 11, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 887, .adv_w = 168, .box_w = 11, .box_h = 2, .ofs_x = 0, .ofs_y = 3}, - {.bitmap_index = 890, .adv_w = 216, .box_w = 13, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 905, .adv_w = 240, .box_w = 15, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 930, .adv_w = 216, .box_w = 14, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 950, .adv_w = 192, .box_w = 12, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 967, .adv_w = 168, .box_w = 10, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 976, .adv_w = 168, .box_w = 10, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 985, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1002, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1016, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 1034, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 1054, .adv_w = 168, .box_w = 11, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1068, .adv_w = 168, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1084, .adv_w = 168, .box_w = 11, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1098, .adv_w = 120, .box_w = 8, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1110, .adv_w = 168, .box_w = 10, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1125, .adv_w = 168, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1142, .adv_w = 216, .box_w = 14, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1158, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 1178, .adv_w = 144, .box_w = 9, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1192, .adv_w = 240, .box_w = 15, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1213, .adv_w = 240, .box_w = 15, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 1227, .adv_w = 240, .box_w = 15, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 1241, .adv_w = 240, .box_w = 15, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 1255, .adv_w = 240, .box_w = 15, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 1269, .adv_w = 240, .box_w = 15, .box_h = 7, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 1283, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1300, .adv_w = 168, .box_w = 9, .box_h = 12, .ofs_x = 1, .ofs_y = -2}, - {.bitmap_index = 1314, .adv_w = 168, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1331, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, - {.bitmap_index = 1351, .adv_w = 168, .box_w = 11, .box_h = 6, .ofs_x = 0, .ofs_y = 1}, - {.bitmap_index = 1360, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, - {.bitmap_index = 1377, .adv_w = 144, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, - {.bitmap_index = 1391, .adv_w = 193, .box_w = 12, .box_h = 8, .ofs_x = 0, .ofs_y = 1} + {.bitmap_index = 0, .adv_w = 68, .box_w = 1, .box_h = 1, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1, .adv_w = 76, .box_w = 1, .box_h = 9, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 3, .adv_w = 88, .box_w = 4, .box_h = 3, .ofs_x = 1, .ofs_y = 6}, + {.bitmap_index = 5, .adv_w = 157, .box_w = 8, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 14, .adv_w = 122, .box_w = 6, .box_h = 11, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 23, .adv_w = 207, .box_w = 11, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 36, .adv_w = 140, .box_w = 9, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 47, .adv_w = 52, .box_w = 1, .box_h = 3, .ofs_x = 1, .ofs_y = 6}, + {.bitmap_index = 48, .adv_w = 87, .box_w = 4, .box_h = 12, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 54, .adv_w = 87, .box_w = 4, .box_h = 12, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 60, .adv_w = 122, .box_w = 5, .box_h = 5, .ofs_x = 1, .ofs_y = 4}, + {.bitmap_index = 64, .adv_w = 157, .box_w = 7, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 71, .adv_w = 70, .box_w = 2, .box_h = 4, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 72, .adv_w = 87, .box_w = 4, .box_h = 1, .ofs_x = 1, .ofs_y = 3}, + {.bitmap_index = 73, .adv_w = 70, .box_w = 1, .box_h = 1, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 74, .adv_w = 87, .box_w = 5, .box_h = 12, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 82, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 88, .adv_w = 108, .box_w = 3, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 92, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 98, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 104, .adv_w = 108, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 111, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 117, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 123, .adv_w = 108, .box_w = 6, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 130, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 136, .adv_w = 108, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 142, .adv_w = 87, .box_w = 1, .box_h = 7, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 143, .adv_w = 87, .box_w = 2, .box_h = 10, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 146, .adv_w = 157, .box_w = 7, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 153, .adv_w = 157, .box_w = 7, .box_h = 4, .ofs_x = 1, .ofs_y = 2}, + {.bitmap_index = 157, .adv_w = 157, .box_w = 7, .box_h = 7, .ofs_x = 2, .ofs_y = 0}, + {.bitmap_index = 164, .adv_w = 105, .box_w = 5, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 170, .adv_w = 192, .box_w = 10, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 183, .adv_w = 125, .box_w = 8, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 192, .adv_w = 120, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 199, .adv_w = 125, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 206, .adv_w = 126, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 213, .adv_w = 109, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 219, .adv_w = 106, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 225, .adv_w = 131, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 233, .adv_w = 137, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 241, .adv_w = 52, .box_w = 1, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 243, .adv_w = 106, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 249, .adv_w = 120, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 256, .adv_w = 103, .box_w = 5, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 262, .adv_w = 168, .box_w = 8, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 271, .adv_w = 137, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 279, .adv_w = 132, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 287, .adv_w = 121, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 294, .adv_w = 132, .box_w = 7, .box_h = 10, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 303, .adv_w = 118, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 310, .adv_w = 114, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 317, .adv_w = 115, .box_w = 7, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 325, .adv_w = 125, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 332, .adv_w = 122, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 340, .adv_w = 170, .box_w = 10, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 352, .adv_w = 120, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 360, .adv_w = 115, .box_w = 7, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 368, .adv_w = 115, .box_w = 6, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 375, .adv_w = 87, .box_w = 3, .box_h = 12, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 380, .adv_w = 87, .box_w = 6, .box_h = 12, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 389, .adv_w = 87, .box_w = 3, .box_h = 12, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 394, .adv_w = 157, .box_w = 8, .box_h = 5, .ofs_x = 1, .ofs_y = 4}, + {.bitmap_index = 399, .adv_w = 122, .box_w = 8, .box_h = 1, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 400, .adv_w = 122, .box_w = 2, .box_h = 3, .ofs_x = 2, .ofs_y = 8}, + {.bitmap_index = 401, .adv_w = 104, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 406, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 413, .adv_w = 101, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 418, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 425, .adv_w = 102, .box_w = 6, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 431, .adv_w = 67, .box_w = 4, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 436, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 443, .adv_w = 106, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 450, .adv_w = 47, .box_w = 1, .box_h = 9, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 452, .adv_w = 46, .box_w = 2, .box_h = 12, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 455, .adv_w = 97, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 462, .adv_w = 47, .box_w = 1, .box_h = 10, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 464, .adv_w = 168, .box_w = 9, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 472, .adv_w = 106, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 477, .adv_w = 110, .box_w = 6, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 483, .adv_w = 108, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 490, .adv_w = 109, .box_w = 5, .box_h = 10, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 497, .adv_w = 65, .box_w = 3, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 500, .adv_w = 99, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 505, .adv_w = 63, .box_w = 3, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 509, .adv_w = 106, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 514, .adv_w = 93, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 520, .adv_w = 144, .box_w = 9, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 528, .adv_w = 95, .box_w = 6, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 534, .adv_w = 91, .box_w = 6, .box_h = 10, .ofs_x = 0, .ofs_y = -3}, + {.bitmap_index = 542, .adv_w = 95, .box_w = 5, .box_h = 7, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 547, .adv_w = 122, .box_w = 5, .box_h = 12, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 555, .adv_w = 87, .box_w = 1, .box_h = 12, .ofs_x = 2, .ofs_y = -3}, + {.bitmap_index = 557, .adv_w = 122, .box_w = 5, .box_h = 12, .ofs_x = 1, .ofs_y = -3}, + {.bitmap_index = 565, .adv_w = 157, .box_w = 8, .box_h = 3, .ofs_x = 1, .ofs_y = 2}, + {.bitmap_index = 568, .adv_w = 165, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 582, .adv_w = 206, .box_w = 13, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 602, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 616, .adv_w = 192, .box_w = 10, .box_h = 8, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 626, .adv_w = 151, .box_w = 8, .box_h = 8, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 634, .adv_w = 165, .box_w = 10, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 647, .adv_w = 165, .box_w = 10, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 660, .adv_w = 151, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 673, .adv_w = 178, .box_w = 11, .box_h = 8, .ofs_x = 1, .ofs_y = 0}, + {.bitmap_index = 684, .adv_w = 178, .box_w = 11, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 698, .adv_w = 165, .box_w = 10, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 708, .adv_w = 165, .box_w = 10, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 720, .adv_w = 82, .box_w = 5, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 725, .adv_w = 123, .box_w = 8, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 733, .adv_w = 178, .box_w = 11, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 746, .adv_w = 206, .box_w = 13, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 764, .adv_w = 165, .box_w = 10, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 777, .adv_w = 110, .box_w = 7, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 786, .adv_w = 151, .box_w = 9, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 799, .adv_w = 165, .box_w = 10, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 812, .adv_w = 165, .box_w = 10, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 825, .adv_w = 110, .box_w = 7, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 834, .adv_w = 165, .box_w = 10, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 846, .adv_w = 137, .box_w = 7, .box_h = 11, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 856, .adv_w = 137, .box_w = 7, .box_h = 11, .ofs_x = 1, .ofs_y = -1}, + {.bitmap_index = 866, .adv_w = 165, .box_w = 10, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 879, .adv_w = 151, .box_w = 9, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 890, .adv_w = 151, .box_w = 9, .box_h = 2, .ofs_x = 0, .ofs_y = 4}, + {.bitmap_index = 893, .adv_w = 192, .box_w = 12, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 905, .adv_w = 192, .box_w = 12, .box_h = 9, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 919, .adv_w = 192, .box_w = 12, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 934, .adv_w = 192, .box_w = 12, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 949, .adv_w = 192, .box_w = 11, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 959, .adv_w = 192, .box_w = 11, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 969, .adv_w = 206, .box_w = 14, .box_h = 7, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 982, .adv_w = 178, .box_w = 11, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 995, .adv_w = 178, .box_w = 11, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 1011, .adv_w = 151, .box_w = 9, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1022, .adv_w = 192, .box_w = 12, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 1037, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1055, .adv_w = 165, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 1069, .adv_w = 96, .box_w = 6, .box_h = 11, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1078, .adv_w = 192, .box_w = 12, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1096, .adv_w = 192, .box_w = 11, .box_h = 12, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1113, .adv_w = 206, .box_w = 13, .box_h = 8, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1126, .adv_w = 151, .box_w = 9, .box_h = 10, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 1138, .adv_w = 165, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 1152, .adv_w = 219, .box_w = 13, .box_h = 10, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1169, .adv_w = 247, .box_w = 16, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1187, .adv_w = 247, .box_w = 16, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1205, .adv_w = 247, .box_w = 16, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1223, .adv_w = 247, .box_w = 16, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1241, .adv_w = 247, .box_w = 16, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1259, .adv_w = 247, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1276, .adv_w = 165, .box_w = 9, .box_h = 12, .ofs_x = 1, .ofs_y = -2}, + {.bitmap_index = 1290, .adv_w = 192, .box_w = 1, .box_h = 1, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1291, .adv_w = 192, .box_w = 12, .box_h = 13, .ofs_x = 0, .ofs_y = -2}, + {.bitmap_index = 1311, .adv_w = 168, .box_w = 11, .box_h = 6, .ofs_x = 0, .ofs_y = 1}, + {.bitmap_index = 1320, .adv_w = 240, .box_w = 15, .box_h = 9, .ofs_x = 0, .ofs_y = 0}, + {.bitmap_index = 1337, .adv_w = 144, .box_w = 10, .box_h = 11, .ofs_x = 0, .ofs_y = -1}, + {.bitmap_index = 1351, .adv_w = 193, .box_w = 12, .box_h = 8, .ofs_x = 0, .ofs_y = 1} }; /*--------------------- @@ -732,14 +741,14 @@ static const lv_font_fmt_txt_glyph_dsc_t glyph_dsc[] = { *--------------------*/ static const uint16_t unicode_list_1[] = { - 0x0, 0x7, 0xa, 0xb, 0xc, 0x10, 0x12, 0x14, - 0x18, 0x1b, 0x20, 0x25, 0x26, 0x27, 0x3d, 0x47, - 0x4a, 0x4b, 0x4c, 0x50, 0x51, 0x52, 0x53, 0x5f, - 0x66, 0x67, 0x6d, 0x6f, 0x70, 0x73, 0x76, 0x77, - 0x78, 0x7a, 0x92, 0x94, 0xc3, 0xc4, 0xc6, 0xe6, - 0xe9, 0xf2, 0x11b, 0x123, 0x15a, 0x1ea, 0x23f, 0x240, - 0x241, 0x242, 0x243, 0x286, 0x292, 0x2ec, 0x303, 0x309, - 0x559, 0x7c1, 0x8a1 + 0x0, 0x7, 0xa, 0xb, 0xc, 0x10, 0x12, 0x13, + 0x14, 0x18, 0x1b, 0x20, 0x25, 0x26, 0x27, 0x3d, + 0x3f, 0x47, 0x4a, 0x4b, 0x4c, 0x50, 0x51, 0x52, + 0x53, 0x5f, 0x66, 0x67, 0x6d, 0x6f, 0x70, 0x73, + 0x76, 0x77, 0x78, 0x7a, 0x92, 0x94, 0xc3, 0xc4, + 0xc6, 0xe6, 0xe9, 0xf2, 0x11b, 0x123, 0x15a, 0x1ea, + 0x23f, 0x240, 0x241, 0x242, 0x243, 0x286, 0x292, 0x2ec, + 0x303, 0x309, 0x559, 0x7c1, 0x8a1 }; /*Collect the unicode lists and glyph_id offsets*/ @@ -751,7 +760,7 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = }, { .range_start = 61441, .range_length = 2210, .glyph_id_start = 96, - .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 59, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY + .unicode_list = unicode_list_1, .glyph_id_ofs_list = NULL, .list_length = 61, .type = LV_FONT_FMT_TXT_CMAP_SPARSE_TINY } }; @@ -760,530 +769,196 @@ static const lv_font_fmt_txt_cmap_t cmaps[] = *----------------*/ -/*Pair left and right glyphs for kerning*/ -static const uint8_t kern_pair_glyph_ids[] = +/*Map glyph_ids to kern left classes*/ +static const uint8_t kern_left_class_mapping[] = { - 1, 53, - 3, 3, - 3, 8, - 3, 34, - 3, 66, - 3, 68, - 3, 69, - 3, 70, - 3, 72, - 3, 78, - 3, 79, - 3, 80, - 3, 81, - 3, 82, - 3, 84, - 3, 88, - 8, 3, - 8, 8, - 8, 34, - 8, 66, - 8, 68, - 8, 69, - 8, 70, - 8, 72, - 8, 78, - 8, 79, - 8, 80, - 8, 81, - 8, 82, - 8, 84, - 8, 88, - 9, 55, - 9, 56, - 9, 58, - 13, 3, - 13, 8, - 15, 3, - 15, 8, - 16, 16, - 34, 3, - 34, 8, - 34, 32, - 34, 36, - 34, 40, - 34, 48, - 34, 50, - 34, 53, - 34, 54, - 34, 55, - 34, 56, - 34, 58, - 34, 80, - 34, 85, - 34, 86, - 34, 87, - 34, 88, - 34, 90, - 34, 91, - 35, 53, - 35, 55, - 35, 58, - 36, 10, - 36, 53, - 36, 62, - 36, 94, - 37, 13, - 37, 15, - 37, 34, - 37, 53, - 37, 55, - 37, 57, - 37, 58, - 37, 59, - 38, 53, - 38, 68, - 38, 69, - 38, 70, - 38, 71, - 38, 72, - 38, 80, - 38, 82, - 38, 86, - 38, 87, - 38, 88, - 38, 90, - 39, 13, - 39, 15, - 39, 34, - 39, 43, - 39, 53, - 39, 66, - 39, 68, - 39, 69, - 39, 70, - 39, 72, - 39, 80, - 39, 82, - 39, 83, - 39, 86, - 39, 87, - 39, 90, - 41, 34, - 41, 53, - 41, 57, - 41, 58, - 42, 34, - 42, 53, - 42, 57, - 42, 58, - 43, 34, - 44, 14, - 44, 36, - 44, 40, - 44, 48, - 44, 50, - 44, 68, - 44, 69, - 44, 70, - 44, 72, - 44, 78, - 44, 79, - 44, 80, - 44, 81, - 44, 82, - 44, 86, - 44, 87, - 44, 88, - 44, 90, - 45, 3, - 45, 8, - 45, 34, - 45, 36, - 45, 40, - 45, 48, - 45, 50, - 45, 53, - 45, 54, - 45, 55, - 45, 56, - 45, 58, - 45, 86, - 45, 87, - 45, 88, - 45, 90, - 46, 34, - 46, 53, - 46, 57, - 46, 58, - 47, 34, - 47, 53, - 47, 57, - 47, 58, - 48, 13, - 48, 15, - 48, 34, - 48, 53, - 48, 55, - 48, 57, - 48, 58, - 48, 59, - 49, 13, - 49, 15, - 49, 34, - 49, 43, - 49, 57, - 49, 59, - 49, 66, - 49, 68, - 49, 69, - 49, 70, - 49, 72, - 49, 80, - 49, 82, - 49, 85, - 49, 87, - 49, 90, - 50, 53, - 50, 55, - 50, 56, - 50, 58, - 51, 53, - 51, 55, - 51, 58, - 53, 1, - 53, 13, - 53, 14, - 53, 15, - 53, 34, - 53, 36, - 53, 40, - 53, 43, - 53, 48, - 53, 50, - 53, 52, - 53, 53, - 53, 55, - 53, 56, - 53, 58, - 53, 66, - 53, 68, - 53, 69, - 53, 70, - 53, 72, - 53, 78, - 53, 79, - 53, 80, - 53, 81, - 53, 82, - 53, 83, - 53, 84, - 53, 86, - 53, 87, - 53, 88, - 53, 89, - 53, 90, - 53, 91, - 54, 34, - 55, 10, - 55, 13, - 55, 14, - 55, 15, - 55, 34, - 55, 36, - 55, 40, - 55, 48, - 55, 50, - 55, 62, - 55, 66, - 55, 68, - 55, 69, - 55, 70, - 55, 72, - 55, 80, - 55, 82, - 55, 83, - 55, 86, - 55, 87, - 55, 90, - 55, 94, - 56, 10, - 56, 13, - 56, 14, - 56, 15, - 56, 34, - 56, 53, - 56, 62, - 56, 66, - 56, 68, - 56, 69, - 56, 70, - 56, 72, - 56, 80, - 56, 82, - 56, 83, - 56, 86, - 56, 94, - 57, 14, - 57, 36, - 57, 40, - 57, 48, - 57, 50, - 57, 55, - 57, 68, - 57, 69, - 57, 70, - 57, 72, - 57, 80, - 57, 82, - 57, 86, - 57, 87, - 57, 90, - 58, 7, - 58, 10, - 58, 11, - 58, 13, - 58, 14, - 58, 15, - 58, 34, - 58, 36, - 58, 40, - 58, 43, - 58, 48, - 58, 50, - 58, 52, - 58, 53, - 58, 54, - 58, 55, - 58, 56, - 58, 57, - 58, 58, - 58, 62, - 58, 66, - 58, 68, - 58, 69, - 58, 70, - 58, 71, - 58, 72, - 58, 78, - 58, 79, - 58, 80, - 58, 81, - 58, 82, - 58, 83, - 58, 84, - 58, 85, - 58, 86, - 58, 87, - 58, 89, - 58, 90, - 58, 91, - 58, 94, - 59, 34, - 59, 36, - 59, 40, - 59, 48, - 59, 50, - 59, 68, - 59, 69, - 59, 70, - 59, 72, - 59, 80, - 59, 82, - 59, 86, - 59, 87, - 59, 88, - 59, 90, - 60, 43, - 60, 54, - 66, 3, - 66, 8, - 66, 87, - 66, 90, - 67, 3, - 67, 8, - 67, 87, - 67, 89, - 67, 90, - 67, 91, - 68, 3, - 68, 8, - 70, 3, - 70, 8, - 70, 87, - 70, 90, - 71, 3, - 71, 8, - 71, 10, - 71, 62, - 71, 68, - 71, 69, - 71, 70, - 71, 72, - 71, 82, - 71, 94, - 73, 3, - 73, 8, - 76, 68, - 76, 69, - 76, 70, - 76, 72, - 76, 82, - 78, 3, - 78, 8, - 79, 3, - 79, 8, - 80, 3, - 80, 8, - 80, 87, - 80, 89, - 80, 90, - 80, 91, - 81, 3, - 81, 8, - 81, 87, - 81, 89, - 81, 90, - 81, 91, - 83, 3, - 83, 8, - 83, 13, - 83, 15, - 83, 66, - 83, 68, - 83, 69, - 83, 70, - 83, 71, - 83, 72, - 83, 80, - 83, 82, - 83, 85, - 83, 87, - 83, 88, - 83, 90, - 85, 80, - 87, 3, - 87, 8, - 87, 13, - 87, 15, - 87, 66, - 87, 68, - 87, 69, - 87, 70, - 87, 71, - 87, 72, - 87, 80, - 87, 82, - 88, 13, - 88, 15, - 89, 68, - 89, 69, - 89, 70, - 89, 72, - 89, 80, - 89, 82, - 90, 3, - 90, 8, - 90, 13, - 90, 15, - 90, 66, - 90, 68, - 90, 69, - 90, 70, - 90, 71, - 90, 72, - 90, 80, - 90, 82, - 91, 68, - 91, 69, - 91, 70, - 91, 72, - 91, 80, - 91, 82, - 92, 43, - 92, 54 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 3, 4, 5, 6, 7, + 0, 8, 8, 9, 10, 11, 8, 8, + 5, 12, 13, 14, 0, 15, 9, 16, + 17, 18, 19, 20, 0, 0, 0, 0, + 0, 0, 21, 22, 0, 0, 23, 24, + 0, 0, 0, 0, 25, 0, 0, 0, + 26, 22, 0, 27, 0, 28, 0, 29, + 0, 30, 29, 31, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0 }; -/* Kerning between the respective left and right glyphs - * 4.4 format which needs to scaled with `kern_scale`*/ -static const int8_t kern_pair_values[] = +/*Map glyph_ids to kern right classes*/ +static const uint8_t kern_right_class_mapping[] = { - -4, -10, -10, -11, -5, -6, -6, -6, - -6, -2, -2, -6, -2, -6, -7, 1, - -10, -10, -11, -5, -6, -6, -6, -6, - -2, -2, -6, -2, -6, -7, 1, 2, - 2, 2, -16, -16, -16, -16, -21, -11, - -11, -6, -1, -1, -1, -1, -12, -2, - -8, -6, -9, -1, -2, -1, -5, -3, - -5, 1, -3, -2, -5, -2, -3, -1, - -2, -10, -10, -2, -3, -2, -2, -4, - -2, 2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, -22, -22, -16, - -25, 2, -3, -2, -2, -2, -2, -2, - -2, -2, -2, -2, -2, 2, -3, 2, - -3, 2, -3, 2, -3, -2, -6, -3, - -3, -3, -3, -2, -2, -2, -2, -2, - -2, -3, -2, -2, -2, -4, -6, -4, - -31, -31, 2, -6, -6, -6, -6, -26, - -5, -16, -13, -22, -4, -12, -9, -12, - 2, -3, 2, -3, 2, -3, 2, -3, - -10, -10, -2, -3, -2, -2, -4, -2, - -30, -30, -13, -19, -3, -2, -1, -1, - -1, -1, -1, -1, -1, 1, 1, 1, - -4, -3, -2, -3, -7, -2, -4, -4, - -20, -22, -20, -7, -3, -3, -22, -3, - -3, -1, 2, 2, 1, 2, -11, -9, - -9, -9, -9, -10, -10, -9, -10, -9, - -7, -11, -9, -7, -5, -7, -7, -6, - -2, 2, -21, -3, -21, -7, -1, -1, - -1, -1, 2, -4, -4, -4, -4, -4, - -4, -4, -3, -3, -1, -1, 2, 1, - -12, -6, -12, -4, 1, 1, -3, -3, - -3, -3, -3, -3, -3, -2, -2, 1, - -4, -2, -2, -2, -2, 1, -2, -2, - -2, -2, -2, -2, -2, -3, -3, -3, - 2, -5, -20, -5, -20, -9, -3, -3, - -9, -3, -3, -1, 2, -9, 2, 2, - 1, 2, 2, -7, -6, -6, -6, -2, - -6, -4, -4, -6, -4, -6, -4, -5, - -2, -4, -2, -2, -2, -3, 2, 1, - -2, -2, -2, -2, -2, -2, -2, -2, - -2, -2, -2, -3, -3, -3, -2, -2, - -6, -6, -1, -1, -3, -3, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - 2, 2, 2, 2, -2, -2, -2, -2, - -2, 2, -10, -10, -2, -2, -2, -2, - -2, -10, -10, -10, -10, -13, -13, -1, - -2, -1, -1, -3, -3, -1, -1, -1, - -1, 2, 2, -12, -12, -4, -2, -2, - -2, 1, -2, -2, -2, 5, 2, 2, - 2, -2, 1, 1, -10, -10, -1, -1, - -1, -1, 1, -1, -1, -1, -12, -12, - -2, -2, -2, -2, -2, -2, 1, 1, - -10, -10, -1, -1, -1, -1, 1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -2, -2 + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 3, 0, 4, 0, 0, 0, + 4, 0, 0, 5, 0, 0, 0, 0, + 4, 0, 4, 0, 6, 7, 8, 9, + 10, 11, 12, 13, 0, 0, 0, 0, + 0, 0, 14, 0, 15, 15, 15, 16, + 15, 0, 0, 0, 0, 0, 17, 17, + 18, 17, 15, 19, 20, 21, 22, 23, + 24, 25, 23, 26, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0 }; -/*Collect the kern pair's data in one place*/ -static const lv_font_fmt_txt_kern_pair_t kern_pairs = +/*Kern values between classes*/ +static const int8_t kern_class_values[] = { - .glyph_ids = kern_pair_glyph_ids, - .values = kern_pair_values, - .pair_cnt = 434, - .glyph_ids_size = 0 + -12, -15, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -1, 0, 0, + -12, -2, -8, -6, 0, -9, 0, 0, + 0, 0, 0, -1, 0, 0, -2, -1, + -5, -3, 0, 1, 0, 0, 0, 0, + 0, 0, -3, 0, -2, 0, 0, -5, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -2, 0, 0, 0, -3, 0, + -2, 0, -2, -4, -2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, + -2, -2, 0, -2, 0, 0, 0, -2, + -2, -2, 0, 0, 0, 0, -16, 0, + -25, 0, 2, 0, 0, 0, 0, 0, + 0, -3, -2, 0, 0, -2, -2, 0, + 0, -2, -2, 0, 0, 0, 0, 0, + 2, 0, 0, 0, -3, 0, 0, 0, + 2, -3, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -3, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -2, 0, -2, -3, 0, 0, 0, -2, + -4, -6, 0, 0, 0, 0, 2, -6, + 0, 0, -26, -5, -16, -13, 0, -22, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, -4, -12, -9, 0, 0, 0, 0, + -13, 0, -19, 0, 0, 0, 0, 0, + -3, 0, -2, -1, -1, 0, 0, -1, + 0, 0, 1, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -4, 0, + -3, -2, 0, -3, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -7, 0, -2, 0, 0, -4, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -7, -3, + -22, -1, 2, 0, 2, 1, 0, 2, + 0, -11, -9, 0, -10, -9, -7, -11, + 0, -9, -7, -5, -7, -6, 0, 0, + -7, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -4, -4, 0, 0, -4, + -3, 0, 0, -3, -1, 0, 0, 0, + 0, 0, -4, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, -3, -3, 0, + 0, -3, -2, 0, 0, -2, 0, 0, + 0, 0, 0, 0, 0, -2, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, + -2, 0, 0, -2, 0, 0, 0, -2, + -3, 0, 0, 0, 0, 0, -9, -3, + -9, -1, 2, -9, 2, 2, 1, 2, + 0, -7, -6, -2, -4, -6, -4, -5, + -2, -4, -2, 0, -2, -3, 0, 0, + 1, -2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, 0, -2, + 0, 0, 0, -2, -3, -3, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -1, 0, -1, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -2, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -1, 0, -2, -1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, -4, -2, 1, 0, -2, 0, 0, + 5, 0, 2, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -2, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -1, -1, 1, + 0, -1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + -2, 0, 0, -2, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -1, 0, 0, -1, 0, 0, + 0, 0, 0, 0, 0, 0 +}; + + +/*Collect the kern class' data in one place*/ +static const lv_font_fmt_txt_kern_classes_t kern_classes = +{ + .class_pair_values = kern_class_values, + .left_class_mapping = kern_left_class_mapping, + .right_class_mapping = kern_right_class_mapping, + .left_class_cnt = 31, + .right_class_cnt = 26, }; /*-------------------- * ALL CUSTOM DATA *--------------------*/ +#if LV_VERSION_CHECK(8, 0, 0) /*Store all the custom data of the font*/ +static lv_font_fmt_txt_glyph_cache_t cache; +static const lv_font_fmt_txt_dsc_t font_dsc = { +#else static lv_font_fmt_txt_dsc_t font_dsc = { - .glyph_bitmap = gylph_bitmap, +#endif + .glyph_bitmap = glyph_bitmap, .glyph_dsc = glyph_dsc, .cmaps = cmaps, - .kern_dsc = &kern_pairs, + .kern_dsc = &kern_classes, .kern_scale = 16, .cmap_num = 2, .bpp = 1, - .kern_classes = 0, - .bitmap_format = 0 + .kern_classes = 1, + .bitmap_format = 0, +#if LV_VERSION_CHECK(8, 0, 0) + .cache = &cache +#endif }; @@ -1292,16 +967,26 @@ static lv_font_fmt_txt_dsc_t font_dsc = { *----------------*/ /*Initialize a public general font descriptor*/ +#if LV_VERSION_CHECK(8, 0, 0) +const lv_font_t lv_font_roboto_12 = { +#else lv_font_t lv_font_roboto_12 = { +#endif .get_glyph_dsc = lv_font_get_glyph_dsc_fmt_txt, /*Function pointer to get glyph's data*/ .get_glyph_bitmap = lv_font_get_bitmap_fmt_txt, /*Function pointer to get glyph's bitmap*/ .line_height = 14, /*The maximum line height required by the font*/ .base_line = 3, /*Baseline measured from the bottom of the line*/ #if !(LVGL_VERSION_MAJOR == 6 && LVGL_VERSION_MINOR == 0) .subpx = LV_FONT_SUBPX_NONE, +#endif +#if LV_VERSION_CHECK(7, 4, 0) || LVGL_VERSION_MAJOR >= 8 + .underline_position = -1, + .underline_thickness = 1, #endif .dsc = &font_dsc /*The custom font data. Will be accessed by `get_glyph_bitmap/dsc` */ }; + + #endif /*#if LV_FONT_ROBOTO_12*/ diff --git a/common/proto-options/manager/common.options b/common/proto-options/manager/common.options new file mode 100644 index 000000000..d23a4ba55 --- /dev/null +++ b/common/proto-options/manager/common.options @@ -0,0 +1,3 @@ +# Options for file common/cypherock-common/proto/manager/common.proto +manager.WalletItem.id type:FT_STATIC max_size:32 fixed_length:true +manager.WalletItem.name type:FT_STATIC max_size:16 fixed_length:true diff --git a/common/proto-options/manager/get_wallets.options b/common/proto-options/manager/get_wallets.options index d2426ba23..5ef99e174 100644 --- a/common/proto-options/manager/get_wallets.options +++ b/common/proto-options/manager/get_wallets.options @@ -1,4 +1,2 @@ # Options for file common/cypherock-common/proto/manager/get_wallets.proto -manager.WalletItem.id type:FT_STATIC max_size:32 fixed_length:true -manager.WalletItem.name type:FT_STATIC max_size:16 fixed_length:true manager.GetWalletsResultResponse.wallet_list type:FT_STATIC max_count:4 fixed_length:true diff --git a/common/proto-options/manager/wallet_selector.options b/common/proto-options/manager/wallet_selector.options new file mode 100644 index 000000000..aa0492239 --- /dev/null +++ b/common/proto-options/manager/wallet_selector.options @@ -0,0 +1 @@ +# Options for file common/cypherock-common/proto/manager/wallet_selector.proto diff --git a/common/startup/application_startup.c b/common/startup/application_startup.c index f07a8ef48..3d1790755 100644 --- a/common/startup/application_startup.c +++ b/common/startup/application_startup.c @@ -69,11 +69,10 @@ */ #include "application_startup.h" -#include "controller_level_four.h" -#include "controller_tap_cards.h" #include "core_error.h" #include "core_flow_init.h" #include "cryptoauthlib.h" +#include "device_authentication_api.h" #include "flash_api.h" #include "flash_if.h" #include "logger.h" @@ -85,6 +84,7 @@ #include "sys_state.h" #include "systick_timer.h" #include "ui_screens.h" + #ifdef DEV_BUILD #include "dev_utils.h" #endif @@ -456,6 +456,76 @@ void device_hardware_check() { #endif } +uint32_t get_device_serial() { + atecc_data.retries = DEFAULT_ATECC_RETRIES; + bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); + + NVIC_DisableIRQ(OTG_FS_IRQn); + do { + atecc_data.status = atcab_init(atecc_data.cfg_atecc608a_iface); + atecc_data.status = atcab_read_zone(ATCA_ZONE_DATA, + slot_8_serial, + 0, + 0, + atecc_data.device_serial, + DEVICE_SERIAL_SIZE); + } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); + if (usb_irq_enable_on_entry == true) + NVIC_EnableIRQ(OTG_FS_IRQn); + + if (atecc_data.status == ATCA_SUCCESS) { + if (0 != memcmp(atecc_data.device_serial + 8, (void *)UID_BASE, 12)) { + return 1; + } else { + return SUCCESS; + } + } + return atecc_data.status; +} + +provision_status_t check_provision_status() { + uint8_t cfg[128]; + memset(cfg, 0, 128); + atecc_data.retries = DEFAULT_ATECC_RETRIES; + + bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); + NVIC_DisableIRQ(OTG_FS_IRQn); + do { + atecc_data.status = atcab_init(atecc_data.cfg_atecc608a_iface); + atecc_data.status = atcab_read_config_zone(cfg); + } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); + if (usb_irq_enable_on_entry == true) + NVIC_EnableIRQ(OTG_FS_IRQn); + + if (atecc_data.status != ATCA_SUCCESS) { + LOG_CRITICAL("xxx30: %d", atecc_data.status); + return -1; + } + + if (cfg[86] == 0x00 && + cfg[87] == 0x00) { // config zone and data zones are locked + + if (cfg[88] == 0xBF && + cfg[89] == + 0xFE) { // device serial and IO key are programmed and locked + return provision_incomplete; + + } else if ((cfg[88] & ATECC_CFG_88_MASK) == 0x00 && + (cfg[89] & ATECC_CFG_89_MASK) == + 0x00) { // private key slots are locked + return provision_complete; + } else if ((cfg[88] & ATECC_CFG_88_MASK_OLD_PROV) == 0x00 && + (cfg[89] & ATECC_CFG_89_MASK) == + 0x00) { // NFC private key slot not locked + return provision_v1_complete; + } else { + return provision_empty; + } + } else { + return provision_empty; + } +} + void device_provision_check() { #if USE_SIMULATOR == 0 const char *msg = NULL; diff --git a/common/startup/application_startup.h b/common/startup/application_startup.h index e6022756e..3aae7a165 100644 --- a/common/startup/application_startup.h +++ b/common/startup/application_startup.h @@ -54,6 +54,18 @@ /// Interval defined for user inactivity in a flow in milli seconds #define INACTIVITY_TIME (300 * 1000) +#define ATECC_CFG_88_MASK 0x4C +#define ATECC_CFG_89_MASK 0x01 + +#define ATECC_CFG_88_MASK_OLD_PROV 44 + +typedef enum { + provision_empty = 0, + provision_incomplete = 1, + provision_complete = 2, + provision_v1_complete = 3 +} provision_status_t; + extern uint8_t device_auth_flag; extern bool main_app_ready; @@ -183,6 +195,29 @@ bool fault_in_prev_boot(); */ void handle_fault_in_prev_boot(); +/** + * @brief + * @details + * + * @return uint8_t Provision status of the device + * @retval 0 Not provisioned + * @retval 1 Semi-provisioned (serial and IO-Protection Key present) + * @retval 2 Fully provisioned + * @retval 3 External auth configuration + */ +provision_status_t check_provision_status(); + +/** + * @brief fetch device serial and check if UID in the serial matches MCU UID + * or not + * @details + * + * @return uint32_t device serial fetch status or failure status + * @retval 0 fetched successfully + * @retval 1 device UID doesn't match with serial UID + */ +uint32_t get_device_serial(); + /** * @brief Detect hardware related faults * diff --git a/src/card_operations/card_internal.c b/src/card_operations/card_internal.c index c866807d4..c81ebab20 100644 --- a/src/card_operations/card_internal.c +++ b/src/card_operations/card_internal.c @@ -62,9 +62,7 @@ *****************************************************************************/ #include "card_internal.h" -#include "apdu.h" #include "app_error.h" -#include "buzzer.h" #include "core_error.h" #include "events.h" #include "nfc.h" diff --git a/src/card_operations/card_internal.h b/src/card_operations/card_internal.h index e4ccbfd71..254bb1f88 100644 --- a/src/card_operations/card_internal.h +++ b/src/card_operations/card_internal.h @@ -13,10 +13,10 @@ /***************************************************************************** * INCLUDES *****************************************************************************/ +#include "apdu.h" +#include "buzzer.h" #include "card_operation_typedefs.h" -/* TODO: Remove the include and move required struct with cleanup*/ -#include "controller_tap_cards.h" /***************************************************************************** * MACROS AND DEFINES *****************************************************************************/ @@ -24,6 +24,32 @@ /***************************************************************************** * TYPEDEFS *****************************************************************************/ + +/** + * @brief + * @details + * + * @see + * @since v1.0.0 + * + * @note + */ +typedef struct NFC_connection_data { + int8_t keystore_index; + uint8_t acceptable_cards; + uint8_t tapped_card; + uint8_t retries; + uint8_t family_id[FAMILY_ID_SIZE + + 2]; // TODO: Review(need to find reason for extra byte) + uint8_t card_key_id[4]; + bool pairing_error; + uint8_t recovery_mode; + uint8_t card_absent_retries; + uint8_t *card_version; + bool init_session_keys; + ISO7816 status; +} NFC_connection_data; + typedef struct card_operation_data { NFC_connection_data nfc_data; const char *error_message; /** Error message to be displayed for user action diff --git a/src/card_operations/card_pair.c b/src/card_operations/card_pair.c index 7094fc737..142511951 100644 --- a/src/card_operations/card_pair.c +++ b/src/card_operations/card_pair.c @@ -66,13 +66,17 @@ #include "bip32.h" #include "card_internal.h" #include "card_utils.h" -#include "controller_level_four.h" #include "core_error.h" #include "curves.h" #include "nist256p1.h" #include "ui_instruction.h" #include "utils.h" - +#if USE_SIMULATOR == 0 +#include "stm32l4xx_it.h" +#endif +#include "atca_basic.h" +#include "device_authentication_api.h" +#include "nfc.h" /***************************************************************************** * EXTERN VARIABLES *****************************************************************************/ @@ -95,6 +99,37 @@ typedef struct card_pairing_data { * STATIC FUNCTION PROTOTYPES *****************************************************************************/ +/** + * @brief Request ATECC to generate signature on the hash with private available + * on SLOT-3 + * @details + * + * @param [in] hash - hash to be signed + * @param [out] sign - signature generated + * + * @return ATCA_SUCCESS on success, otherwise an error code. + * + * @see atcab_init(), atcab_sign(), ATCAIfaceCfg, cfg_atecc608a_iface + * @since v1.0.0 + */ +static uint8_t atecc_nfc_sign_hash(const uint8_t *hash, uint8_t *sign); + +/** + * @brief Request ATECC to perform ECDH operation on pub_key with private key + * from SLOT-3 + * @details + * + * @param [in] pub_key - public key to be used for ECDH + * @param [out] shared_secret - shared secret generated + * + * @return ATCA_SUCCESS on success, otherwise an error code. + * + * @see atcab_init(), atcab_ecdh(), atcab_ecdh_ioenc(), ATCAIfaceCfg, + * cfg_atecc608a_iface + * @since v1.0.0 + */ +static uint8_t atecc_nfc_ecdh(const uint8_t *pub_key, uint8_t *shared_secret); + /***************************************************************************** * STATIC VARIABLES *****************************************************************************/ @@ -163,6 +198,50 @@ static void init_and_pair_card(card_operation_data_t *card_data, /***************************************************************************** * STATIC FUNCTIONS *****************************************************************************/ + +static uint8_t atecc_nfc_sign_hash(const uint8_t *hash, uint8_t *sign) { + atecc_data.retries = DEFAULT_ATECC_RETRIES; + + bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); + NVIC_DisableIRQ(OTG_FS_IRQn); + do { + if (atecc_data.status != ATCA_SUCCESS) + LOG_CRITICAL("PAIR SG: %04x, count:%d", + atecc_data.status, + DEFAULT_ATECC_RETRIES - atecc_data.retries); + atcab_init(atecc_data.cfg_atecc608a_iface); + atecc_data.status = atcab_sign(slot_3_nfc_pair_key, hash, sign); + } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); + if (usb_irq_enable_on_entry == true) + NVIC_EnableIRQ(OTG_FS_IRQn); + + return atecc_data.status; +} + +static uint8_t atecc_nfc_ecdh(const uint8_t *pub_key, uint8_t *shared_secret) { + uint8_t io_key[IO_KEY_SIZE]; + atecc_data.retries = DEFAULT_ATECC_RETRIES; + + if (get_io_protection_key(io_key) != SUCCESS_) + return -1; + + bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); + NVIC_DisableIRQ(OTG_FS_IRQn); + do { + if (atecc_data.status != ATCA_SUCCESS) + LOG_CRITICAL("ECDH: %04x, count:%d", + atecc_data.status, + DEFAULT_ATECC_RETRIES - atecc_data.retries); + atcab_init(atecc_data.cfg_atecc608a_iface); + atecc_data.status = + atcab_ecdh_ioenc(slot_3_nfc_pair_key, pub_key, shared_secret, io_key); + } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); + if (usb_irq_enable_on_entry == true) + NVIC_EnableIRQ(OTG_FS_IRQn); + + return atecc_data.status; +} + static uint32_t pair_card_preprocess(card_pairing_data_t *pair_data) { uint8_t digest[64] = {0}, sig[65] = {0}; uint8_t invalid_self_keypath[8] = {DEFAULT_VALUE_IN_FLASH, diff --git a/src/card_operations/card_read_verify_shares.c b/src/card_operations/card_read_verify_shares.c index efeec3b7d..cbdb16a4a 100644 --- a/src/card_operations/card_read_verify_shares.c +++ b/src/card_operations/card_read_verify_shares.c @@ -60,12 +60,14 @@ /***************************************************************************** * INCLUDES *****************************************************************************/ +#include "bip39.h" #include "card_internal.h" #include "card_operation_typedefs.h" #include "card_read_verify_share.h" #include "card_utils.h" #include "flash_api.h" #include "nfc.h" +#include "options.h" #include "shamir_wrapper.h" #include "ui_instruction.h" #include "wallet.h" diff --git a/src/level_four/core/controller/wallet_locked_controller.c b/src/card_operations/card_unlock_wallet.c similarity index 96% rename from src/level_four/core/controller/wallet_locked_controller.c rename to src/card_operations/card_unlock_wallet.c index da5ca88a8..044d532ad 100644 --- a/src/level_four/core/controller/wallet_locked_controller.c +++ b/src/card_operations/card_unlock_wallet.c @@ -1,15 +1,15 @@ /** - * @file wallet_locked_controller.c + * @file card_unlock_wallet.c * @author Cypherock X1 Team - * @brief Wallet unlock flow controller. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD + * @brief Wallet unlock flow controller + * @copyright Copyright (c) 2023 HODL TECH PTE LTD *
You may obtain a copy of license at https://mitcc.org/ * ****************************************************************************** * @attention * - * (c) Copyright 2022 by HODL TECH PTE LTD + * (c) Copyright 2023 by HODL TECH PTE LTD * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -59,15 +59,15 @@ /***************************************************************************** * INCLUDES *****************************************************************************/ -#include "card_internal.h" + #include "card_unlock_wallet.h" + +#include "buzzer.h" +#include "card_internal.h" #include "card_utils.h" -#include "constant_texts.h" -#include "core_error.h" #include "nfc.h" -#include "pow.h" #include "pow_utilities.h" -#include "ui_screens.h" +#include "ui_instruction.h" /***************************************************************************** * EXTERN VARIABLES diff --git a/src/card_operations/card_utils.c b/src/card_operations/card_utils.c index 111c4c91e..049e62641 100644 --- a/src/card_operations/card_utils.c +++ b/src/card_operations/card_utils.c @@ -64,7 +64,6 @@ #include "card_internal.h" #include "constant_texts.h" -#include "controller_tap_cards.h" #include "events.h" #include "ui_instruction.h" #include "ui_message.h" diff --git a/src/card_operations/card_utils.h b/src/card_operations/card_utils.h index 271832b50..051073de8 100644 --- a/src/card_operations/card_utils.h +++ b/src/card_operations/card_utils.h @@ -14,7 +14,6 @@ * INCLUDES *****************************************************************************/ #include "card_internal.h" -#include "controller_tap_cards.h" #include "stdbool.h" /***************************************************************************** diff --git a/src/card_operations/check_pairing.c b/src/card_operations/check_pairing.c index b16cd6458..d887457f1 100644 --- a/src/card_operations/check_pairing.c +++ b/src/card_operations/check_pairing.c @@ -104,7 +104,6 @@ static void init_tap_card_data(NFC_connection_data *connection_data); static void init_tap_card_data(NFC_connection_data *connection_data) { memset(connection_data, 0, sizeof(NFC_connection_data)); connection_data->retries = 5; - connection_data->desktop_control = false; connection_data->acceptable_cards = ACCEPTABLE_CARDS_ALL; memset(connection_data->family_id, 0xff, sizeof(connection_data->family_id)); memset(connection_data->card_key_id, 0, sizeof(connection_data->card_key_id)); diff --git a/src/constant_texts.c b/src/constant_texts.c index ef97a6c98..a88b9ac35 100644 --- a/src/constant_texts.c +++ b/src/constant_texts.c @@ -136,7 +136,8 @@ const char *ui_text_factory_reset_instruction = "You will need 2 cards to perform factory reset\nMake sure at least 2 " "cards are accessible\nDo you want to proceed?"; const char *ui_text_confirm_factory_reset = - "This will erase all wallets from device. Confirm?"; + "This will erase all wallets from device\nYour device will reset to " + "factory default settings.\nConfirm?"; const char *ui_text_erasing = "Factory reset done Device will restart"; const char *ui_text_reset_exit[NUMBER_OF_SLIDES_FACTORY_RESET_EXIT] = { "Exiting without factory reset", @@ -160,6 +161,9 @@ const char *ui_text_syncing_complete = "wallet(s) synced"; const char *ui_text_clear_device_data_instruction = "You will need 2 cards to perform clear device data\nMake sure at least 2 " "cards are accessible\nDo you want to proceed?"; +const char *ui_text_confirm_clear_device_data = + "This will erase all wallets from device\nYour device will reset and go to " + "main menu.\nConfirm?"; const char *ui_text_erasing_device_data = "Device data cleared Device will restart"; const char @@ -183,6 +187,10 @@ const char *ui_text_joystick_left = "Toggle joystick left"; const char *ui_text_joystick_center = "Center click joystick"; const char *ui_text_joystick_checkup_complete = "Joystick instructions complete"; +const char *ui_text_wallet_selector_invalid = + "The selected wallet is misconfigured\n" + "Visit the wallet from main menu to fix it\n" + "Or choose a different wallet to continue"; // Onboarding flow text const char *ui_text_onboarding_welcome = "Welcome"; diff --git a/src/constant_texts.h b/src/constant_texts.h index f659f1fbe..2a7778803 100644 --- a/src/constant_texts.h +++ b/src/constant_texts.h @@ -132,6 +132,7 @@ extern const char *ui_text_syncing_complete; // Clear user data text extern const char *ui_text_clear_device_data_instruction; +extern const char *ui_text_confirm_clear_device_data; extern const char *ui_text_erasing_device_data; extern const char *ui_text_clear_wallet_data_exit[NUMBER_OF_SLIDES_FACTORY_RESET_EXIT]; @@ -148,6 +149,7 @@ extern const char *ui_text_joystick_down; extern const char *ui_text_joystick_left; extern const char *ui_text_joystick_center; extern const char *ui_text_joystick_checkup_complete; +extern const char *ui_text_wallet_selector_invalid; // Onboarding text extern const char *ui_text_onboarding_welcome; diff --git a/src/controller_main.c b/src/controller_main.c index ae4392b8a..2334a6bbb 100644 --- a/src/controller_main.c +++ b/src/controller_main.c @@ -92,7 +92,6 @@ #include "chacha20poly1305.h" #include "communication.h" #include "constant_texts.h" -#include "controller_level_four.h" #include "cryptoauthlib.h" #include "etc.h" #include "eth.h" @@ -141,8 +140,6 @@ char arbitrary_data[4096 / 8 + 1]; // TODO: Variable required for code compilation: Delete after all coins are // ported -Send_Transaction_Data var_send_transaction_data = {0}; -Receive_Transaction_Data receive_transaction_data = {0}; /** * @brief Global Flow_level instance. @@ -169,6 +166,9 @@ Flash_Wallet wallet_for_flash; MessageData msg_data; ui_display_node *current_display_node = NULL; +uint8_t provision_date[4]; +Provision_Data_struct provision_keys_data; + Flash_Wallet *get_flash_wallet() { ASSERT((&wallet_for_flash) != NULL); diff --git a/src/controller_main.h b/src/controller_main.h index f438cb4a9..3d5d057c4 100644 --- a/src/controller_main.h +++ b/src/controller_main.h @@ -43,7 +43,6 @@ #include "sha2.h" #include "sys_state.h" #include "tasks.h" -#include "tasks_level_four.h" #include "utils.h" #include "wallet.h" @@ -250,6 +249,16 @@ extern Wallet wallet; extern lv_task_t *address_timeout_task; extern uint32_t inactivity_counter; +#pragma pack(push, 1) +typedef struct Provision_Data_Struct { + uint8_t device_private_key[32]; + uint8_t device_public_key[ECDSA_PUB_KEY_SIZE]; + uint8_t self_key_path[FS_KEYSTORE_KEYPATH_LEN]; + uint8_t priv_key[FS_KEYSTORE_PRIVKEY_LEN]; + uint8_t card_root_xpub[FS_KEYSTORE_XPUB_LEN]; +} Provision_Data_struct; +#pragma pack(pop) + /** * @brief Get the Global Flash_Wallet instance. * diff --git a/src/level_four/core/controller/card_upgrade_controller.c b/src/level_four/core/controller/card_upgrade_controller.c deleted file mode 100644 index 943d92933..000000000 --- a/src/level_four/core/controller/card_upgrade_controller.c +++ /dev/null @@ -1,140 +0,0 @@ -/** - * @file card_upgrade_controller.c - * @author Cypherock X1 Team - * @brief Card upgrade next controller. - * Handles post event (only next events) operations for card upgrade - *flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" -#include "nfc.h" -#include "ui_instruction.h" - -extern Flow_level flow_level; -extern Counter counter; -extern Wallet wallet; - -char *textDisplay; -char text[80]; - -#ifdef DEV_BUILD -static uint16_t number_of_apdus_sent; -#endif // DEV_BUILD - -void card_upgrade_controller() { -#ifdef DEV_BUILD - switch (flow_level.level_three) { - case CARD_UPGRADE_TAP_CARD_MESSAGE: - flow_level.level_three = CARD_UPGRADE_SELECT_CARD; - break; - - case CARD_UPGRADE_SELECT_CARD: { - while (nfc_select_card() != STM_SUCCESS) - ; - flow_level.level_three = CARD_UPGRADE_FORWARD_MESSAGE; - number_of_apdus_sent = 0; - snprintf(text, sizeof(text), "Sending APDU\n%d", number_of_apdus_sent); - textDisplay = text; - instruction_scr_change_text(textDisplay, false); - uint8_t arr[4]; - arr[0] = STATUS_CMD_SUCCESS; - transmit_data_to_app(STATUS_PACKET, arr, 4); - } break; - - case CARD_UPGRADE_FORWARD_MESSAGE: { - uint8_t *data_array = NULL; - uint16_t msg_size = 0; - if (get_usb_msg_by_cmd_type(APDU_PACKET, &data_array, &msg_size)) { - uint8_t max_tries = 5; - uint8_t recv_apdu[255], recv_len = 236; - ret_code_t err_code = STM_ERROR_BUSY; - - while (max_tries--) { - err_code = adafruit_pn532_in_data_exchange( - data_array, msg_size, recv_apdu, &recv_len); - - if (err_code == STM_SUCCESS) { - break; - } - } - - if (err_code == STM_SUCCESS) { - transmit_data_to_app(APDU_PACKET, recv_apdu, recv_len); - number_of_apdus_sent++; - snprintf( - text, sizeof(text), "Sending APDU\n%d", number_of_apdus_sent); - textDisplay = text; - instruction_scr_change_text(textDisplay, false); - } else { - uint8_t arr[4]; - arr[0] = STATUS_CMD_FAILURE; - transmit_data_to_app(STATUS_PACKET, arr, sizeof(arr)); - instruction_scr_destructor(); - mark_error_screen(ui_text_card_command_send_error); - reset_flow_level(); - } - clear_message_received_data(); - } else if (get_usb_msg_by_cmd_type(STOP_CARD_UPGRADE, NULL, NULL)) { - mark_error_screen(ui_text_card_update_done); - reset_flow_level(); - clear_message_received_data(); - } - } break; - - default: - break; - } -#endif -} diff --git a/src/level_four/core/controller/controller_level_four.h b/src/level_four/core/controller/controller_level_four.h deleted file mode 100644 index ab6adff4c..000000000 --- a/src/level_four/core/controller/controller_level_four.h +++ /dev/null @@ -1,398 +0,0 @@ -/** - * @file controller_level_four.h - * @author Cypherock X1 Team - * @brief Header for level four controllers. - * Houses the declarations of controllers for level one tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef CONTROLLER_LEVEL_FOUR_H -#define CONTROLLER_LEVEL_FOUR_H - -#pragma once - -#include "controller_main.h" -#include "cryptoauthlib.h" -#include "eth.h" -#include "flash_config.h" -#include "near.h" -#include "solana.h" -#include "tasks.h" - -#define DEFAULT_ATECC_RETRIES 5 - -#define DEVICE_SERIAL_SIZE 32 -#define MAXIMUM_COIN_SUPPORTED (14 + 5) // 5 for segwit support - -typedef enum { - slot_0_unused = 0U, - slot_1_unused = 1U, - slot_2_auth_key = 2U, - slot_3_nfc_pair_key = 3U, - slot_4_unused = 4U, - slot_5_challenge = 5U, - slot_6_io_key = 6U, - slot_7_unused = 7U, - slot_8_serial = 8U, - slot_9_unused = 9U, - slot_10_unused = 10U, - slot_11_unused = 11U, - slot_12_unused = 12U, - slot_13_unused = 13U, - slot_14_unused = 14U, - slot_15_unused = 15U -} atecc_slot_define_t; - -typedef struct { - uint8_t device_serial[DEVICE_SERIAL_SIZE], retries; - ATCA_STATUS status; - ATCAIfaceCfg *cfg_atecc608a_iface; -} atecc_data_t; - -extern atecc_data_t atecc_data; - -typedef enum { - provision_empty = 0, - provision_incomplete = 1, - provision_complete = 2, - provision_v1_complete = 3 -} provision_status_t; - -extern uint8_t provision_date[4]; -extern uint8_t auth_card_number; -extern solana_unsigned_txn solana_unsigned_txn_ptr; - -/** - * @brief Stores the device specific information during provisioning process. - * @details The device specific information is stored temporarily in the RAM - * during the 2nd phase of device provisioning. These are received from the - * in-house provisioning tool before a device is ready for use. - * - * @see Perm_Ext_Keys_Struct, Perm_Key_Data_Struct, Flash_Perm_Struct, - * device_provision_controller(), FIREWALL_NVDATA_APP_KEYS_ADDR, - * START_DEVICE_PROVISION, desktop_listener_task() - * @since v1.0.0 - */ -#pragma pack(push, 1) -typedef struct Provision_Data_Struct { - uint8_t device_private_key[32]; - uint8_t device_public_key[ECDSA_PUB_KEY_SIZE]; - uint8_t self_key_path[FS_KEYSTORE_KEYPATH_LEN]; - uint8_t priv_key[FS_KEYSTORE_PRIVKEY_LEN]; - uint8_t card_root_xpub[FS_KEYSTORE_XPUB_LEN]; -} Provision_Data_struct; -#pragma pack(pop) - -extern Provision_Data_struct provision_keys_data; - -/** - * @brief Stores the generated xpubs list for the add coin process. - * @details The generated xpubs list is stored temporarily in the RAM during the - * add coin process before it is sent to the desktop app. - * - * @see MAXIMUM_COIN_SUPPORTED, Add_Coin_Data, add_coin_controller(), - * add_coin_task(), desktop_listener_task(), ADD_COIN_START - * @since v1.0.0 - * - * @note The number of entries in the list should not be greater than the - * maximum number of coins supported (ref MAXIMUM_COIN_SUPPORTED). - */ -#pragma pack(push, 1) -typedef struct Cmd_Add_Coin_t { - uint8_t xpub[XPUB_SIZE]; -} Cmd_Add_Coin_t; -#pragma pack(pop) - -/** - * @brief send transaction data - * @details The transaction data is stored temporarily in the RAM during the - * intermediate phases of send transaction process. - * - * @see send_transaction_controller(), send_transaction_task(), - * desktop_listener_task(), SEND_TXN_START - * @since v1.0.0 - */ -#pragma pack(push, 1) -typedef struct Send_Transaction_Data { - uint8_t transaction_confirmation_list_index; - txn_metadata transaction_metadata; - -} Send_Transaction_Data; -#pragma pack(pop) - -extern Coin_Specific_Data_Struct coin_specific_data; -extern uint8_t *eth_unsigned_txn_byte_array; -extern Send_Transaction_Data var_send_transaction_data; - -/** - * @brief Card upgrade controller available for development purposes. - * @details This controller is used to upgrade the card using a desktop app. - * - * @see card_upgrade_task(), desktop_listener_task(), START_CARD_UPGRADE - * @since v1.0.0 - */ -void card_upgrade_controller(); - -/** - * @brief Device provision controller - * @details This controller is used to provision the device using the desktop - * app. - * - * @see desktop_listener_task(), - * START_DEVICE_PROVISION - * @since v1.0.0 - */ -void device_provision_controller(); - -/** - * @brief This controller is executed for verifying card in main application. - * @details This controller is used to verify the card with the servers using - * the desktop app. - * - * @see task_card_verification(), desktop_listener_task(), START_CARD_AUTH - * @since v1.0.0 - */ -void verify_card_controller(); - -/** - * @brief This controller is executed for verifying card in initial application. - * @details This controller is used to verify the card using the desktop app in - * initial application. - * - * @see initial_verify_card_task(), desktop_listener_task(), START_CARD_AUTH - * @since v1.0.0 - */ -void initial_verify_card_controller(); - -/** - * @brief This controller is executed when the name of a wallet is clicked and - * it is locked. - * @details This controller is used to handle next event for unlocking the - * wallet using the proof of work mechanism where the X1Wallet does the proof of - * work and sends the result to the card. - * - * @see wallet_locked_task(), wallet_locked_controller_b() - * @since v1.0.0 - */ -void wallet_locked_controller(); - -/** - * @brief Back button controller for wallet locked flow - * @details This controller is used to handle back button event for unlocking - * the wallet using the proof of work mechanism. - * - * @see wallet_locked_controller(), wallet_locked_task() - * @since v1.0.0 - */ -void wallet_locked_controller_b(); - -/** - * @brief Next button controller is executed for processing and signing unsigned - * transaction of Ethereum. - * @details This controller is used to process and sign the unsigned transaction - * for ETH that is requested from the desktop app. - * - * @see send_transaction_controller_b_eth(), send_transaction_tasks_eth(), - * send_transaction_controller(), send_transaction_tasks(), - * send_transaction_controller_b() - * @since v1.0.0 - */ -void send_transaction_controller_eth(); - -/** - * @brief Back button controller for send transaction Ethereum flow. - * @details This controller is used to handle back button events during - * processing and signing unsigned transaction for ETH. - * - * @see send_transaction_controller_eth(), send_transaction_tasks_eth(), - * send_transaction_controller(), send_transaction_tasks() - * @since v1.0.0 - */ -void send_transaction_controller_b_eth(); - -/** - * @brief Next button controller is executed for processing and signing messages - * of Ethereum. - * @details This controller is used to process and sign the messages for ETH - * that is requested from the desktop app. - * - */ -void sign_message_controller_eth(); - -/** - * @brief Back button controller for sign message Ethereum flow. - * @details This controller is used to handle back button events during - * processing and signing messages for ETH. - * - */ -void sign_message_controller_b_eth(); - -/** - * @brief Next button controller is executed for processing and signing unsigned - * transaction. - */ -void send_transaction_controller_solana(); - -/** - * @brief Back button controller is executed for handling cancellation of the - * ongoing process. - */ -void send_transaction_controller_b_solana(); - -/** - * @brief Next button controller is executed for generating address using xpub. - * @details This controller handles is used to generate receiving address for - * the BTC coins requested by desktop from a list of supported coins. - * - * @see receive_transaction_controller_b(), receive_transaction_tasks(), - * desktop_listener_task(), RECV_TXN_START, - * receive_transaction_controller_eth(), receive_transaction_tasks_eth() - * @since v1.0.0 - */ -void receive_transaction_controller_near(); - -/** - * @brief Next button controller is executed for generating address using xpub - * of Ethereum. - * @details This controller handles is used to generate receiving address for - * the ETH coins requested by desktop from a list of supported coins. - * - * @see receive_transaction_controller_b_eth(), receive_transaction_tasks_eth(), - * desktop_listener_task(), RECV_TXN_START, receive_transaction_controller(), - * receive_transaction_tasks() - * @since v1.0.0 - */ -void receive_transaction_controller_eth(); - -/** - * @brief Back button controller for receive transaction Ethereum flow. - * @details This controller is used to handle back button events during - * generating receiving address for ETH. - * - * @see receive_transaction_controller_eth(), receive_transaction_tasks_eth(), - * desktop_listener_task(), RECV_TXN_START, receive_transaction_controller(), - * receive_transaction_tasks() - * @since v1.0.0 - */ -void receive_transaction_controller_b_eth(); - -/** - * @brief Back button controller for receive transaction Near flow. - * @details This controller is used to handle back button events during - * receiving flow for Near. - * - * @see receive_transaction_controller_eth(), receive_transaction_tasks_eth(), - * desktop_listener_task(), RECV_TXN_START, receive_transaction_controller(), - * receive_transaction_tasks() - * @since v1.0.0 - */ -void receive_transaction_controller_b_near(); - -/** - * @brief Next button controller is executed for generating address using xpub - * of Ethereum. - * @details This controller handles is used to generate receiving address for - * the ETH coins requested by desktop from a list of supported coins. - * - * @see receive_transaction_controller_b_eth(), receive_transaction_tasks_eth(), - * desktop_listener_task(), RECV_TXN_START, receive_transaction_controller(), - * receive_transaction_tasks() - * @since v1.0.0 - */ -void receive_transaction_controller_solana(); - -/** - * @brief Back button controller for receive transaction Ethereum flow. - * @details This controller is used to handle back button events during - * generating receiving address for ETH. - * - * @see receive_transaction_controller_eth(), receive_transaction_tasks_eth(), - * desktop_listener_task(), RECV_TXN_START, receive_transaction_controller(), - * receive_transaction_tasks() - * @since v1.0.0 - */ -void receive_transaction_controller_b_solana(); - -/** - * @brief This controller is executed for verifying wallet added or restored on - * the device and cards. - * @details This controller is used to verify the wallet added or restored on - * the device and cards. - * - * @see verify_wallet_controller_b(), verify_wallet_tasks(), - * generate_wallet_controller(), - * restore_wallet_controller(), - * @since v1.0.0 - */ -void verify_wallet_controller(); - -/** - * @brief Back button controller for verify wallet flow. - * @details This controller is used to handle back button events during wallet - * verification of newly added wallet. - * - * @see verify_wallet_controller(), verify_wallet_tasks(), - * generate_wallet_controller(), - * restore_wallet_controller(), - * @since v1.0.0 - */ -void verify_wallet_controller_b(); - -/** - * @brief - * @details - * - * @return uint8_t Provision status of the device - * @retval 0 Not provisioned - * @retval 1 Semi-provisioned (serial and IO-Protection Key present) - * @retval 2 Fully provisioned - * @retval 3 External auth configuration - */ -provision_status_t check_provision_status(); - -/** - * @brief fetch device serial and check if UID in the serial matches MCU UID - * or not - * @details - * - * @return uint32_t device serial fetch status or failure status - * @retval 0 fetched successfully - * @retval 1 device UID doesn't match with serial UID - */ -uint32_t get_device_serial(); - -/** - * @brief Request ATECC to generate signature on the hash with private available - * on SLOT-3 - * @details - * - * @param [in] hash - hash to be signed - * @param [out] sign - signature generated - * - * @return ATCA_SUCCESS on success, otherwise an error code. - * - * @see atcab_init(), atcab_sign(), ATCAIfaceCfg, cfg_atecc608a_iface - * @since v1.0.0 - */ -uint8_t atecc_nfc_sign_hash(const uint8_t *hash, uint8_t *sign); - -/** - * @brief Request ATECC to perform ECDH operation on pub_key with private key - * from SLOT-3 - * @details - * - * @param [in] pub_key - public key to be used for ECDH - * @param [out] shared_secret - shared secret generated - * - * @return ATCA_SUCCESS on success, otherwise an error code. - * - * @see atcab_init(), atcab_ecdh(), atcab_ecdh_ioenc(), ATCAIfaceCfg, - * cfg_atecc608a_iface - * @since v1.0.0 - */ -uint8_t atecc_nfc_ecdh(const uint8_t *pub_key, uint8_t *shared_secret); - -#endif \ No newline at end of file diff --git a/src/level_four/core/controller/initial_device_provision_contoller.c b/src/level_four/core/controller/initial_device_provision_contoller.c deleted file mode 100644 index e7919d1f5..000000000 --- a/src/level_four/core/controller/initial_device_provision_contoller.c +++ /dev/null @@ -1,516 +0,0 @@ -/** - * @file initial_device_provision_contoller.c - * @author Cypherock X1 Team - * @brief Device provision controller. - * Handles post event (only next events) operations for device - *provision flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "bip32.h" -#include "communication.h" -#include "controller_level_four.h" -#include "cryptoauthlib.h" -#include "curves.h" -#include "flash_api.h" -#include "nist256p1.h" -#include "string.h" -#include "ui_delay.h" -#include "ui_instruction.h" -#if USE_SIMULATOR == 0 -#include "stm32l4xx_it.h" -#endif - -#define ATECC_CFG_88_MASK 0x4C -#define ATECC_CFG_89_MASK 0x01 - -#define ATECC_CFG_88_MASK_OLD_PROV 44 - -#if X1WALLET_INITIAL -// slot-5 shouldn't be locked -uint8_t atecc_slot_to_lock[] = {slot_2_auth_key, - slot_3_nfc_pair_key, - slot_6_io_key, - slot_8_serial, - slot_0_unused, - slot_1_unused, - slot_4_unused, - slot_7_unused, - slot_9_unused, - slot_10_unused, - slot_11_unused, - slot_12_unused, - slot_13_unused, - slot_14_unused, - slot_15_unused}; - -uint8_t provision_date[4]; -Provision_Data_struct provision_keys_data; - -extern lv_task_t *listener_task; -static lv_task_t *timeout_task; - -static void __timeout_listener(); -static void lock_all_slots(); -#endif - -uint32_t get_device_serial() { - atecc_data.retries = DEFAULT_ATECC_RETRIES; - bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); - - NVIC_DisableIRQ(OTG_FS_IRQn); - do { - atecc_data.status = atcab_init(atecc_data.cfg_atecc608a_iface); - atecc_data.status = atcab_read_zone(ATCA_ZONE_DATA, - slot_8_serial, - 0, - 0, - atecc_data.device_serial, - DEVICE_SERIAL_SIZE); - } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); - if (usb_irq_enable_on_entry == true) - NVIC_EnableIRQ(OTG_FS_IRQn); - - if (atecc_data.status == ATCA_SUCCESS) { - if (0 != memcmp(atecc_data.device_serial + 8, (void *)UID_BASE, 12)) { - return 1; - } else { - return SUCCESS; - } - } - return atecc_data.status; -} - -provision_status_t check_provision_status() { - uint8_t cfg[128]; - memset(cfg, 0, 128); - atecc_data.retries = DEFAULT_ATECC_RETRIES; - - bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); - NVIC_DisableIRQ(OTG_FS_IRQn); - do { - atecc_data.status = atcab_init(atecc_data.cfg_atecc608a_iface); - atecc_data.status = atcab_read_config_zone(cfg); - } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); - if (usb_irq_enable_on_entry == true) - NVIC_EnableIRQ(OTG_FS_IRQn); - - if (atecc_data.status != ATCA_SUCCESS) { - LOG_CRITICAL("xxx30: %d", atecc_data.status); - return -1; - } - - if (cfg[86] == 0x00 && - cfg[87] == 0x00) { // config zone and data zones are locked - - if (cfg[88] == 0xBF && - cfg[89] == - 0xFE) { // device serial and IO key are programmed and locked - return provision_incomplete; - - } else if ((cfg[88] & ATECC_CFG_88_MASK) == 0x00 && - (cfg[89] & ATECC_CFG_89_MASK) == - 0x00) { // private key slots are locked - return provision_complete; - } else if ((cfg[88] & ATECC_CFG_88_MASK_OLD_PROV) == 0x00 && - (cfg[89] & ATECC_CFG_89_MASK) == - 0x00) { // NFC private key slot not locked - return provision_v1_complete; - } else { - return provision_empty; - } - } else { - return provision_empty; - } -} - -void device_provision_controller() { -#if X1WALLET_INITIAL - switch (flow_level.level_three) { - case GENERATE_PROVSION_DATA: { - uint8_t io_protection_key[IO_KEY_SIZE] = {0}; - uint8_t serial_no[38] = {0}; - uint8_t test_ecc608_configdata[128] = { - // changes : i2c address = 0x30, secure boot disabled, - 0x01, 0x23, 0x00, 0x00, // serial no part1 - 0x00, 0x00, 0x00, 0x00, // rev no - 0x00, 0x00, 0x00, 0x00, 0x01, // serial no part2 - 0x01, // AES enabled - 0x01, // I2C enabled - 0x00, // reserved - 0xC0, // 0x60, //I2C address : coverts to 0x30 - 0x00, // reserved - 0x00, // counter match disabled - 0x00, // 0x01, //chipmode - 0x85, 0x00, 0x82, 0x00, 0x86, 0x46, 0x87, 0x46, 0x87, 0x46, 0x8F, - 0x46, 0x8F, 0x0F, 0x9F, 0x8F, 0x0F, 0x0F, 0x8F, 0x0F, 0x0F, 0x8F, - 0x0F, 0x8F, 0x0F, 0x8F, 0x0F, 0x0F, 0x0D, 0x1F, 0x0F, 0x0F, 0xFF, - 0xFF, 0xFF, - 0xFF, // monotonic counter 0 not attached to any key - 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, - 0xFF, // monotonic counter 1 not attached to any key - 0x00, 0x00, 0x00, 0x00, - 0x00, // use lock key disabled - 0x00, // volatile key permission disabled - 0x00, 0x00, // secure boot not used - 0x00, // KdflvLoc not used - 0x69, 0x76, // KdflvStr not used - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // reserved - 0x00, // use later - 0x00, // not used I2C address - 0x55, // data zone unlocked - 0x55, // config zone unlocked - 0xFF, 0xFF, // slot unlocked - 0x0E, 0x61, // ChipOptions - 0x00, 0x00, 0x00, 0x00, // certificate formatting disabled - 0x73, 0x00, 0x73, 0x00, 0x73, 0x00, 0x73, 0x00, 0x73, 0x00, 0x18, - 0x00, 0x7C, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x3A, 0x00, 0x3C, 0x00, - 0x30, 0x00, 0x3C, 0x00, 0x30, 0x00, 0x32, 0x00, 0x30, 0x00}; - - atecc_data.retries = DEFAULT_ATECC_RETRIES; - - bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); - NVIC_DisableIRQ(OTG_FS_IRQn); - do { - OTG_FS_IRQHandler(); - if (atecc_data.status != ATCA_SUCCESS) { - LOG_ERROR("PERR0-0x%02x", atecc_data.status); - } - - // atecc initialize - atecc_data.status = atcab_init(atecc_data.cfg_atecc608a_iface); - if (atecc_data.status != ATCA_SUCCESS) { - continue; - } - - // check atecc config and data zone lock atecc_data.status - bool is_locked = false; - atecc_data.status = atcab_is_locked(LOCK_ZONE_CONFIG, &is_locked); - - if (!is_locked || atecc_data.status != ATCA_SUCCESS) { - atecc_data.status = atcab_write_config_zone(test_ecc608_configdata); - if (atecc_data.status != ATCA_SUCCESS) { - continue; - } - - atecc_data.status = atcab_lock_config_zone(); - } - - is_locked = false; - atecc_data.status = atcab_is_locked(LOCK_ZONE_DATA, &is_locked); - - if (!is_locked || atecc_data.status != ATCA_SUCCESS) { - atecc_data.status = atcab_lock_data_zone(); - } - - memset(atecc_data.device_serial, 0, DEVICE_SERIAL_SIZE); - - provision_status_t provision_status = check_provision_status(); - // check if device already provisioned - if (provision_status == provision_empty) { - // called again if not locked in previous configuration - is_locked = false; - atecc_data.status = atcab_is_locked(LOCK_ZONE_CONFIG, &is_locked); - - if (!is_locked || atecc_data.status != ATCA_SUCCESS) { - atecc_data.status = atcab_lock_config_zone(); - } - - is_locked = false; - atecc_data.status = atcab_is_locked(LOCK_ZONE_DATA, &is_locked); - - if (!is_locked || atecc_data.status != ATCA_SUCCESS) { - atecc_data.status = atcab_lock_data_zone(); - } - - // fill whole serial_no with random - atecc_data.status = atcab_random(serial_no); - - // overwrite date 4bytes - memcpy(serial_no, provision_date, 4); - - // overwrite hw no 4bytes - uint32_t u32Temp = FW_get_hardware_version(); - memcpy(serial_no + 4, &u32Temp, 4); - -#if USE_SIMULATOR == 0 - // overwrite MCU UID 12 bytes - u32Temp = HAL_GetUIDw0(); - memcpy(serial_no + 8, &u32Temp, 4); - u32Temp = HAL_GetUIDw1(); - memcpy(serial_no + 12, &u32Temp, 4); - u32Temp = HAL_GetUIDw2(); - memcpy(serial_no + 16, &u32Temp, 4); -#endif - - atecc_data.status = atcab_write_zone( - ATCA_ZONE_DATA, slot_8_serial, 0, 0, serial_no, 32); - if (atecc_data.status != ATCA_SUCCESS) { - continue; - } - - // generate and write IO key - random_generate(io_protection_key, IO_KEY_SIZE); - if (atecc_data.status != ATCA_SUCCESS) { - continue; - } - - atecc_data.status = atcab_write_zone(ATCA_ZONE_DATA, - slot_6_io_key, - 0, - 0, - io_protection_key, - IO_KEY_SIZE); - if (atecc_data.status != ATCA_SUCCESS) { - continue; - } - - if (atecc_data.status == ATCA_SUCCESS) { - if (set_io_protection_key(io_protection_key) == SUCCESS_) { - // locking IO_KEY and serial number slots - atecc_data.status = atcab_lock_data_slot(slot_6_io_key); - atecc_data.status = atcab_lock_data_slot(slot_8_serial); - get_device_serial(); - } else { - memset(serial_no, 0, 32); - LOG_ERROR("PERR1-IO"); - continue; - } - } else { - memset(serial_no, 0, 32); - LOG_ERROR("PERR1-0x%02x", atecc_data.status); - continue; - } - } else if (provision_status == provision_incomplete) { - get_device_serial(); - } else { - lv_obj_clean(lv_scr_act()); - mark_error_screen(ui_text_device_already_provisioned); - reset_flow_level(); - flow_level.level_one = 6; - flow_level.show_error_screen = true; - return; - } - } while ((atecc_data.status != ATCA_SUCCESS) && (--atecc_data.retries)); - if (usb_irq_enable_on_entry == true) - NVIC_EnableIRQ(OTG_FS_IRQn); - - transmit_data_to_app(ADD_DEVICE_PROVISION, atecc_data.device_serial, 32); - - flow_level.level_three = PROVISION_STATUS_WAIT; - lv_task_set_prio(listener_task, - LV_TASK_PRIO_MID); // explicitly enable task listener - - timeout_task = - lv_task_create(__timeout_listener, 10000, LV_TASK_PRIO_HIGH, NULL); - lv_task_once(timeout_task); - } break; - - case PROVISION_STATUS_WAIT: { - // do nothing, just wait - } break; - - case PROVISION_SAVE_EXT_KEYS: { - uint8_t private_write_key[36] = {0}; - Perm_Key_Data_Struct perm_key_data; - uint8_t digest[SHA256_DIGEST_LENGTH]; - lv_task_del(timeout_task); - - get_io_protection_key(perm_key_data.io_protection_key); - - ecdsa_get_public_key33(&nist256p1, - provision_keys_data.device_private_key, - perm_key_data.ext_keys.device_auth_public_key); - if (0 != memcmp(provision_keys_data.device_public_key, - perm_key_data.ext_keys.device_auth_public_key, - 33)) { - comm_reject_request(CONFIRM_PROVISION, 0); - flow_level.level_three = PROVISION_UNSUCCESSFUL; - break; - } - - atecc_data.retries = DEFAULT_ATECC_RETRIES; - bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); - NVIC_DisableIRQ(OTG_FS_IRQn); - do { - OTG_FS_IRQHandler(); - atecc_data.status = atcab_init(atecc_data.cfg_atecc608a_iface); - if (atecc_data.status != ATCA_SUCCESS) { - continue; - } - - memset(private_write_key, 0, sizeof(private_write_key)); - memcpy( - &private_write_key[4], provision_keys_data.device_private_key, 32); - atecc_data.status = atcab_priv_write(slot_2_auth_key, - private_write_key, - slot_6_io_key, - perm_key_data.io_protection_key); - if (atecc_data.status != ATCA_SUCCESS) { - LOG_ERROR("PERR2-0x%02x", atecc_data.status); - continue; - } - - memset(private_write_key, 0, sizeof(private_write_key)); - memcpy(&private_write_key[4], provision_keys_data.priv_key, 32); - atecc_data.status = atcab_priv_write(slot_3_nfc_pair_key, - private_write_key, - slot_6_io_key, - perm_key_data.io_protection_key); - if (atecc_data.status != ATCA_SUCCESS) { - LOG_ERROR("PERR3-0x%02x", atecc_data.status); - continue; - } - } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); - if (usb_irq_enable_on_entry == true) - NVIC_EnableIRQ(OTG_FS_IRQn); - - if (atecc_data.status != ATCA_SUCCESS) { - comm_reject_request(CONFIRM_PROVISION, 0); - flow_level.level_three = PROVISION_UNSUCCESSFUL; - break; - } - - sha256_Raw(provision_keys_data.priv_key, - sizeof(provision_keys_data.priv_key), - digest); - memcpy(perm_key_data.ext_keys.self_key_id, digest, FS_KEYSTORE_KEYID_LEN); - memcpy(perm_key_data.ext_keys.self_key_path, - provision_keys_data.self_key_path, - FS_KEYSTORE_KEYPATH_LEN); - memcpy(perm_key_data.ext_keys.card_root_xpub, - provision_keys_data.card_root_xpub, - FS_KEYSTORE_XPUB_LEN); - - if (set_ext_key(&perm_key_data.ext_keys) == SUCCESS_) { - lock_all_slots(); - - if (check_provision_status() == provision_complete) - transmit_one_byte_confirm(CONFIRM_PROVISION); - else { - comm_reject_request(CONFIRM_PROVISION, 0); - flow_level.level_three = PROVISION_UNSUCCESSFUL; - LOG_ERROR("PERR5-LOCK"); - break; - } - } else { - comm_reject_request(CONFIRM_PROVISION, 0); - flow_level.level_three = PROVISION_UNSUCCESSFUL; - LOG_ERROR("PERR2-KEY"); - break; - } - reset_flow_level(); - flow_level.level_one = 10; - lv_obj_clean(lv_scr_act()); - - } break; - - case PROVISION_UNSUCCESSFUL: { - lv_obj_clean(lv_scr_act()); - mark_error_screen(ui_text_provision_fail); - reset_flow_level(); - flow_level.level_one = 6; - flow_level.show_error_screen = true; - } break; - - default: - break; - } -} - -void lock_all_slots() { - uint8_t usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); - NVIC_DisableIRQ(OTG_FS_IRQn); - - atecc_data.retries = DEFAULT_ATECC_RETRIES; - bool lock = false; - uint32_t err_count = 0; - atecc_data.status = ATCA_FUNC_FAIL; - do { - err_count = 0; - for (uint32_t i = 0; i < sizeof(atecc_slot_to_lock); i++) { - lock = false; - atecc_data.status = atcab_is_slot_locked(atecc_slot_to_lock[i], &lock); - if (atecc_data.status != ATCA_SUCCESS) { - LOG_CRITICAL("PERR4=0x%02x, retry-%d, slot=%d", - atecc_data.retries, - atecc_data.status, - atecc_slot_to_lock[i]); - err_count++; - } else if (lock == true) { - continue; - } - atecc_data.status = atcab_lock_data_slot(atecc_slot_to_lock[i]); - if (atecc_data.status != ATCA_SUCCESS) { - LOG_CRITICAL("PERR5=0x%02x, retry-%d, slot=%d", - atecc_data.retries, - atecc_data.status, - atecc_slot_to_lock[i]); - err_count++; - } - } - } while (err_count != 0 && --atecc_data.retries); - - if (usb_irq_enable_on_entry == true) - NVIC_EnableIRQ(OTG_FS_IRQn); -} - -static void __timeout_listener() { - mark_error_screen(ui_text_provision_fail); - instruction_scr_destructor(); - reset_flow_level(); - flow_level.level_one = - 6; // on command not received take to get-started screen - lv_task_del(timeout_task); -#endif -} \ No newline at end of file diff --git a/src/level_four/core/controller/initial_verify_card_controller.c b/src/level_four/core/controller/initial_verify_card_controller.c deleted file mode 100644 index d3c831fd3..000000000 --- a/src/level_four/core/controller/initial_verify_card_controller.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file initial_verify_card_controller.c - * @author Cypherock X1 Team - * @brief Verify card next controller (initial). - * Handles post event (only next events) operations for card - *verification flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "base58.h" -#include "bip32.h" -#include "buzzer.h" -#include "communication.h" -#include "controller_level_four.h" -#include "controller_tap_cards.h" -#include "curves.h" -#include "flash_api.h" -#include "nfc.h" -#include "nist256p1.h" -#include "ui_instruction.h" -#if USE_SIMULATOR == 0 -#include "stm32l4xx_it.h" -#endif - -uint8_t atecc_nfc_sign_hash(const uint8_t *hash, uint8_t *sign) { - atecc_data.retries = DEFAULT_ATECC_RETRIES; - - bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); - NVIC_DisableIRQ(OTG_FS_IRQn); - do { - if (atecc_data.status != ATCA_SUCCESS) - LOG_CRITICAL("PAIR SG: %04x, count:%d", - atecc_data.status, - DEFAULT_ATECC_RETRIES - atecc_data.retries); - atcab_init(atecc_data.cfg_atecc608a_iface); - atecc_data.status = atcab_sign(slot_3_nfc_pair_key, hash, sign); - } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); - if (usb_irq_enable_on_entry == true) - NVIC_EnableIRQ(OTG_FS_IRQn); - - return atecc_data.status; -} - -uint8_t atecc_nfc_ecdh(const uint8_t *pub_key, uint8_t *shared_secret) { - uint8_t io_key[IO_KEY_SIZE]; - atecc_data.retries = DEFAULT_ATECC_RETRIES; - - if (get_io_protection_key(io_key) != SUCCESS_) - return -1; - - bool usb_irq_enable_on_entry = NVIC_GetEnableIRQ(OTG_FS_IRQn); - NVIC_DisableIRQ(OTG_FS_IRQn); - do { - if (atecc_data.status != ATCA_SUCCESS) - LOG_CRITICAL("ECDH: %04x, count:%d", - atecc_data.status, - DEFAULT_ATECC_RETRIES - atecc_data.retries); - atcab_init(atecc_data.cfg_atecc608a_iface); - atecc_data.status = - atcab_ecdh_ioenc(slot_3_nfc_pair_key, pub_key, shared_secret, io_key); - } while (atecc_data.status != ATCA_SUCCESS && --atecc_data.retries); - if (usb_irq_enable_on_entry == true) - NVIC_EnableIRQ(OTG_FS_IRQn); - - return atecc_data.status; -} \ No newline at end of file diff --git a/src/level_four/core/controller/receive_transaction_controller_b_eth.c b/src/level_four/core/controller/receive_transaction_controller_b_eth.c deleted file mode 100644 index 9d83662c5..000000000 --- a/src/level_four/core/controller/receive_transaction_controller_b_eth.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file receive_transaction_controller_b_eth.c - * @author Cypherock X1 Team - * @brief Receive transaction next controller for ETH. - * Handles post event (only back/cancel events) operations for receive - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" - -extern Wallet_credential_data wallet_credential_data; - -void receive_transaction_controller_b_eth() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_ETH: { - comm_reject_request(RECV_TXN_USER_VERIFIED_COINS, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case RECV_TXN_ENTER_PIN_ETH: { - comm_reject_request(USER_REJECT_PIN_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - - } break; - - case RECV_TXN_ENTER_PASSPHRASE_ETH: { - comm_reject_request(USER_REJECTED_PASSPHRASE_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_ETH: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - flow_level.level_three = RECV_TXN_ENTER_PASSPHRASE_ETH; - } break; - - case RECV_TXN_DISPLAY_ADDR_ETH: { - comm_reject_request(RECV_TXN_USER_VERIFIED_ADDRESS, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - default: - break; - } - return; -} diff --git a/src/level_four/core/controller/receive_transaction_controller_b_near.c b/src/level_four/core/controller/receive_transaction_controller_b_near.c deleted file mode 100644 index 7d3d00b58..000000000 --- a/src/level_four/core/controller/receive_transaction_controller_b_near.c +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @file receive_transaction_controller_b.c - * @author Cypherock X1 Team - * @brief Receive transaction back controller for BTC. - * Handles post event (only back/cancel events) operations for receive - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" - -void receive_transaction_controller_b_near() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_NEAR: { - comm_reject_request(RECV_TXN_USER_VERIFIED_COINS, 0); - reset_flow_level(); - } break; - - case RECV_TXN_ENTER_PIN_NEAR: { - comm_reject_request(USER_REJECT_PIN_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - - } break; - - case RECV_TXN_ENTER_PASSPHRASE_NEAR: { - comm_reject_request(USER_REJECTED_PASSPHRASE_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_NEAR: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - flow_level.level_three = RECV_TXN_ENTER_PASSPHRASE_NEAR; - } break; - - case RECV_TXN_DISPLAY_ACC_NEAR: { - comm_reject_request(RECV_TXN_USER_VERIFIED_ADDRESS, 0); - reset_flow_level(); - } break; - - case RECV_TXN_DISPLAY_ADDR_NEAR: { - comm_reject_request(RECV_TXN_USER_VERIFIED_ADDRESS, 0); - reset_flow_level(); - } break; - - case RECV_TXN_SELECT_REPLACE_ACC_NEAR: { - comm_reject_request(RECV_TXN_REPLACE_ACCOUNT, 0); - reset_flow_level(); - - } break; - - case RECV_TXN_VERIFY_SAVE_ACC_NEAR: { - flow_level.level_three = RECV_TXN_SELECT_REPLACE_ACC_NEAR; - } break; - - default: - reset_flow_level(); - break; - } -} diff --git a/src/level_four/core/controller/receive_transaction_controller_b_solana.c b/src/level_four/core/controller/receive_transaction_controller_b_solana.c deleted file mode 100644 index fa9c4f15a..000000000 --- a/src/level_four/core/controller/receive_transaction_controller_b_solana.c +++ /dev/null @@ -1,108 +0,0 @@ -/** - * @file receive_transaction_controller_b_solana.c - * @author Cypherock X1 Team - * @brief Receive transaction next controller for SOLANA. - * Handles post event (only back/cancel events) operations for receive - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" - -extern Wallet_credential_data wallet_credential_data; - -void receive_transaction_controller_b_solana() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_SOLANA: { - comm_reject_request(RECV_TXN_USER_VERIFIED_COINS, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case RECV_TXN_ENTER_PIN_SOLANA: { - comm_reject_request(USER_REJECT_PIN_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - - } break; - - case RECV_TXN_ENTER_PASSPHRASE_SOLANA: { - comm_reject_request(USER_REJECTED_PASSPHRASE_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_SOLANA: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - flow_level.level_three = RECV_TXN_ENTER_PASSPHRASE_SOLANA; - } break; - - case RECV_TXN_DISPLAY_ADDR_SOLANA: { - comm_reject_request(RECV_TXN_USER_VERIFIED_ADDRESS, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - default: - break; - } - return; -} diff --git a/src/level_four/core/controller/receive_transaction_controller_eth.c b/src/level_four/core/controller/receive_transaction_controller_eth.c deleted file mode 100644 index 7049787fd..000000000 --- a/src/level_four/core/controller/receive_transaction_controller_eth.c +++ /dev/null @@ -1,220 +0,0 @@ -/** - * @file receive_transaction_controller_eth.c - * @author Cypherock X1 Team - * @brief Receive transaction next controller for ETH. - * Handles post event (only next events) operations for receive - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "bip32.h" -#include "communication.h" -#include "constant_texts.h" -#include "controller_level_four.h" -#include "controller_tap_cards.h" -#include "harmony.h" -#include "sha2.h" -#include "shamir_wrapper.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" - -extern Receive_Transaction_Data receive_transaction_data; -extern Wallet_shamir_data wallet_shamir_data; -extern Wallet_credential_data wallet_credential_data; - -void receive_transaction_controller_eth() { - switch (flow_level.level_three) { - // TODO: Rename RECV_TXN_FIND_XPUB in all receive tasks to a relevant name - // (PROCESS_METADATA) - case RECV_TXN_FIND_XPUB_ETH: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - if (WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = RECV_TXN_ENTER_PASSPHRASE_ETH; - } else { - flow_level.level_three = RECV_TXN_CHECK_PIN_ETH; - } - } break; - - case RECV_TXN_ENTER_PASSPHRASE_ETH: { - flow_level.level_three = RECV_TXN_CONFIRM_PASSPHRASE_ETH; - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_ETH: { - snprintf(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase), - "%s", - flow_level.screen_input.input_text); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = RECV_TXN_CHECK_PIN_ETH; - flow_level.level_one = 1; - } break; - - case RECV_TXN_CHECK_PIN_ETH: { - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = RECV_TXN_ENTER_PIN_ETH; - } else { - flow_level.level_three = RECV_TXN_TAP_CARD_ETH; - } - } break; - - case RECV_TXN_ENTER_PIN_ETH: { - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet_credential_data.password_single_hash); - sha256_Raw(wallet_credential_data.password_single_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = RECV_TXN_TAP_CARD_ETH; - } break; - - case RECV_TXN_TAP_CARD_ETH: { - tap_card_data.desktop_control = true; - tap_threshold_cards_for_reconstruction_flow_controller(1); - } break; - - case RECV_TXN_TAP_CARD_SEND_CMD_ETH: { - flow_level.level_three = RECV_TXN_READ_DEVICE_SHARE_ETH; - } break; - - case RECV_TXN_READ_DEVICE_SHARE_ETH: - wallet_shamir_data.share_x_coords[1] = 5; - get_flash_wallet_share_by_name((const char *)wallet.wallet_name, - wallet_shamir_data.mnemonic_shares[1]); - memcpy(wallet_shamir_data.share_encryption_data[1], - wallet_shamir_data.share_encryption_data[0], - PADDED_NONCE_SIZE + WALLET_MAC_SIZE); - flow_level.level_three = RECV_TXN_DERIVE_ADD_SCREEN_ETH; - break; - - case RECV_TXN_DERIVE_ADD_SCREEN_ETH: { - flow_level.level_three = RECV_TXN_DERIVE_ADD_ETH; - } break; - - case RECV_TXN_DERIVE_ADD_ETH: { - uint8_t secret[BLOCK_SIZE]; - if (WALLET_IS_PIN_SET(wallet.wallet_info)) - decrypt_shares(); - recover_secret_from_shares(BLOCK_SIZE, - MINIMUM_NO_OF_SHARES, - wallet_shamir_data.mnemonic_shares, - wallet_shamir_data.share_x_coords, - secret); - memzero(wallet_shamir_data.mnemonic_shares, - sizeof(wallet_shamir_data.mnemonic_shares)); - mnemonic_clear(); - const char *mnemo = - mnemonic_from_data(secret, wallet.number_of_mnemonics * 4 / 3); - HDNode node; - uint8_t seed[64]; - - memzero(seed, sizeof(seed)); - mnemonic_to_seed(mnemo, wallet_credential_data.passphrase, seed, NULL); - mnemonic_clear(); - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - hdnode_from_seed(seed, sizeof(seed), SECP256K1_NAME, &node); - - hdnode_private_ckd( - &node, BYTE_ARRAY_TO_UINT32(receive_transaction_data.purpose)); - hdnode_private_ckd( - &node, BYTE_ARRAY_TO_UINT32(receive_transaction_data.coin_index)); - hdnode_private_ckd( - &node, BYTE_ARRAY_TO_UINT32(receive_transaction_data.account_index)); - - hdnode_fill_public_key(&node); - - hdnode_public_ckd( - &node, BYTE_ARRAY_TO_UINT32(receive_transaction_data.change_index)); - hdnode_fill_public_key(&node); - hdnode_public_ckd( - &node, BYTE_ARRAY_TO_UINT32(receive_transaction_data.address_index)); - hdnode_fill_public_key(&node); - hdnode_get_ethereum_pubkeyhash(&node, - receive_transaction_data.eth_pubkeyhash); - - flow_level.level_three = RECV_TXN_DISPLAY_ADDR_ETH; - } break; - - case RECV_TXN_DISPLAY_ADDR_ETH: { - uint64_t chain_id = receive_transaction_data.network_chain_id; - uint8_t data[1 + sizeof(receive_transaction_data.address) + - 1]; // confirm byte + address length + null byte - size_t datalen; - data[0] = 1; // confirmation byte - if (chain_id != HARMONY_MAINNET_CHAIN) { - memcpy(data + 1, - receive_transaction_data.eth_pubkeyhash, - sizeof(receive_transaction_data.eth_pubkeyhash)); - datalen = 1 + sizeof(receive_transaction_data.eth_pubkeyhash); - } else { - strncpy((char *)data + 1, - receive_transaction_data.address, - sizeof(data) - 1); - datalen = strnlen((char *)data, - sizeof(data)); // send excluding the null byte - } - transmit_data_to_app(RECV_TXN_USER_VERIFIED_ADDRESS, data, datalen); - reset_flow_level(); - } break; - - default: - break; - } - - return; -} diff --git a/src/level_four/core/controller/receive_transaction_controller_near.c b/src/level_four/core/controller/receive_transaction_controller_near.c deleted file mode 100644 index d657d358e..000000000 --- a/src/level_four/core/controller/receive_transaction_controller_near.c +++ /dev/null @@ -1,364 +0,0 @@ -/** - * @file receive_transaction_controller.c - * @author Cypherock X1 Team - * @brief Receive transaction next controller (for BTC). - * Handles post event (only next events) operations for receive - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "bip32.h" -#include "communication.h" -#include "constant_texts.h" -#include "controller_level_four.h" -#include "controller_tap_cards.h" -#include "near_context.h" -#include "sha2.h" -#include "shamir_wrapper.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" - -extern Wallet_credential_data wallet_credential_data; - -extern Receive_Transaction_Data receive_transaction_data; -Coin_Specific_Data_Struct coin_specific_data; - -void receive_transaction_controller_near() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_NEAR: { - receive_transaction_data.near_acc_found = false; - - if (false && receive_transaction_data.near_account_type == 1) { - coin_specific_data.coin_type = COIN_TYPE_NEAR; - memcpy(coin_specific_data.wallet_id, - receive_transaction_data.wallet_id, - WALLET_ID_SIZE); - coin_specific_data.coin_data = - (uint8_t *)cy_malloc(NEAR_COIN_DATA_MAX_LEN); - uint16_t len = 0; - - get_coin_data(&coin_specific_data, NEAR_COIN_DATA_MAX_LEN, &len); - size_t acc_count = - near_get_account_ids_count(coin_specific_data.coin_data, len); - receive_transaction_data.near_acc_count = acc_count; - - char *acc_id[NEAR_REGISTERED_ACCOUNT_COUNT] = {0}; - - near_deserialize_account_ids( - coin_specific_data.coin_data, len, acc_id, acc_count); - - for (size_t i = 0; i < NEAR_REGISTERED_ACCOUNT_COUNT; i++) { - if (strcmp(acc_id[i], - receive_transaction_data.near_registered_account) == 0) { - receive_transaction_data.near_acc_found = true; - break; - } - } - } - - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - if (WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = RECV_TXN_ENTER_PASSPHRASE_NEAR; - } else { - flow_level.level_three = RECV_TXN_CHECK_PIN_NEAR; - } - } break; - - case RECV_TXN_ENTER_PASSPHRASE_NEAR: { - flow_level.level_three = RECV_TXN_CONFIRM_PASSPHRASE_NEAR; - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_NEAR: { - snprintf(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase), - "%s", - flow_level.screen_input.input_text); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = RECV_TXN_CHECK_PIN_NEAR; - flow_level.level_one = 1; - } break; - - case RECV_TXN_CHECK_PIN_NEAR: { - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = RECV_TXN_ENTER_PIN_NEAR; - } else { - flow_level.level_three = RECV_TXN_TAP_CARD_NEAR; - } - } break; - - case RECV_TXN_ENTER_PIN_NEAR: { - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet_credential_data.password_single_hash); - sha256_Raw(wallet_credential_data.password_single_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - - flow_level.level_three = RECV_TXN_TAP_CARD_NEAR; - } break; - - case RECV_TXN_TAP_CARD_NEAR: { - tap_card_data.desktop_control = true; - // TODO: Shorten func name - tap_threshold_cards_for_reconstruction_flow_controller(1); - } break; - - case RECV_TXN_TAP_CARD_SEND_CMD_NEAR: { - flow_level.level_three = RECV_TXN_READ_DEVICE_SHARE_NEAR; - if (!receive_transaction_data.near_acc_found && - receive_transaction_data.near_account_type == 1) - transmit_one_byte(RECV_TXN_XPUBS_EXISTS_ON_DEVICE, 1); - } break; - - case RECV_TXN_READ_DEVICE_SHARE_NEAR: - wallet_shamir_data.share_x_coords[1] = 5; - get_flash_wallet_share_by_name((const char *)wallet.wallet_name, - wallet_shamir_data.mnemonic_shares[1]); - memcpy(wallet_shamir_data.share_encryption_data[1], - wallet_shamir_data.share_encryption_data[0], - PADDED_NONCE_SIZE + WALLET_MAC_SIZE); - flow_level.level_three = RECV_TXN_DERIVE_ADD_SCREEN_NEAR; - break; - - case RECV_TXN_DERIVE_ADD_SCREEN_NEAR: { - flow_level.level_three = RECV_TXN_DERIVE_ADD_NEAR; - } break; - - case RECV_TXN_DERIVE_ADD_NEAR: { - // TODO: Extract common part i.e. secret recreation and public key - // derication - uint8_t secret[BLOCK_SIZE] = {0}; - if (WALLET_IS_PIN_SET(wallet.wallet_info)) - decrypt_shares(); - recover_secret_from_shares(BLOCK_SIZE, - MINIMUM_NO_OF_SHARES, - wallet_shamir_data.mnemonic_shares, - wallet_shamir_data.share_x_coords, - secret); - memzero(wallet_shamir_data.share_encryption_data, - sizeof(wallet_shamir_data.share_encryption_data)); - mnemonic_clear(); - const char *mnemo = - mnemonic_from_data(secret, wallet.number_of_mnemonics * 4 / 3); - HDNode node; - uint8_t seed[64] = {0}; - - memzero(seed, sizeof(seed)); - - mnemonic_to_seed(mnemo, wallet_credential_data.passphrase, seed, NULL); - mnemonic_clear(); - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - - uint32_t path[] = { - BYTE_ARRAY_TO_UINT32(receive_transaction_data.purpose), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.coin_index), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.account_index), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.change_index), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.address_index), - }; - derive_hdnode_from_path(path, 5, ED25519_NAME, seed, &node); - memzero(path, sizeof(path)); - memzero(receive_transaction_data.near_pubkey, - sizeof(receive_transaction_data.near_pubkey)); - memcpy(receive_transaction_data.near_pubkey, - node.public_key + 1, - 32 * sizeof(uint8_t)); - - if (receive_transaction_data.near_account_type == 0 || - receive_transaction_data.near_acc_found) { - flow_level.level_three = RECV_TXN_DISPLAY_ADDR_NEAR; - instruction_scr_destructor(); - } else { - flow_level.level_three = RECV_TXN_WAIT_FOR_LINK_NEAR; - } - } break; - - case RECV_TXN_WAIT_FOR_LINK_NEAR: { - uint8_t *data = NULL; - uint16_t size = 0; - if (get_usb_msg_by_cmd_type( - RECV_TXN_USER_VERIFIED_ACCOUNT, &data, &size)) { - flow_level.level_three = RECV_TXN_DISPLAY_ACC_NEAR; - clear_message_received_data(); - instruction_scr_destructor(); - } - } break; - - case RECV_TXN_DISPLAY_ACC_NEAR: { - flow_level.level_three = RECV_TXN_DISPLAY_ADDR_NEAR; - } break; - - case RECV_TXN_DISPLAY_ADDR_NEAR: { - flow_level.level_three = RECV_TXN_FINAL_SCREEN_NEAR; - - uint8_t data[1 + sizeof(receive_transaction_data.near_pubkey)] = {0}; - data[0] = 1; // confirmation byte - - if (receive_transaction_data.near_account_type == 1 && - !receive_transaction_data.near_acc_found) { - if (receive_transaction_data.near_acc_count < - NEAR_REGISTERED_ACCOUNT_COUNT) { - uint16_t len = 0; - memzero(coin_specific_data.coin_data, NEAR_COIN_DATA_MAX_LEN); - get_coin_data(&coin_specific_data, NEAR_COIN_DATA_MAX_LEN, &len); - - char *acc_id[NEAR_REGISTERED_ACCOUNT_COUNT] = {0}; - - near_deserialize_account_ids(coin_specific_data.coin_data, - len, - acc_id, - receive_transaction_data.near_acc_count); - - acc_id[receive_transaction_data.near_acc_count] = - receive_transaction_data.near_registered_account; - - uint8_t new_near_coin_data[NEAR_COIN_DATA_MAX_LEN] = {0}; - len = 0; - - near_serialize_account_ids( - (const char **)acc_id, - receive_transaction_data.near_acc_count + 1, - new_near_coin_data, - &len); - memcpy(coin_specific_data.coin_data, - new_near_coin_data, - NEAR_COIN_DATA_MAX_LEN); - - int status = set_coin_data(&coin_specific_data, len); - if (status != 0) { - comm_reject_request(COIN_SPECIFIC_DATA_ERROR, status); - reset_flow_level(); - return; - } - } else { - data[0] = 2; - flow_level.level_three = RECV_TXN_WAIT_FOR_REPLACE_NEAR_SCREEN; - } - } - - memcpy(data + 1, - receive_transaction_data.near_pubkey, - sizeof(receive_transaction_data.near_pubkey)); - transmit_data_to_app(RECV_TXN_USER_VERIFIED_ADDRESS, data, sizeof(data)); - } break; - - case RECV_TXN_WAIT_FOR_REPLACE_NEAR_SCREEN: { - flow_level.level_three = RECV_TXN_WAIT_FOR_REPLACE_NEAR; - } break; - - case RECV_TXN_WAIT_FOR_REPLACE_NEAR: { - uint8_t *data = NULL; - uint16_t size = 0; - if (get_usb_msg_by_cmd_type(RECV_TXN_REPLACE_ACCOUNT, &data, &size)) { - flow_level.level_three = RECV_TXN_SELECT_REPLACE_ACC_NEAR; - clear_message_received_data(); - instruction_scr_destructor(); - } - } break; - - case RECV_TXN_SELECT_REPLACE_ACC_NEAR: { - flow_level.level_three = RECV_TXN_VERIFY_SAVE_ACC_NEAR; - } break; - - case RECV_TXN_VERIFY_SAVE_ACC_NEAR: { - uint16_t filled_length = 0; - memzero(coin_specific_data.coin_data, NEAR_COIN_DATA_MAX_LEN); - - get_coin_data( - &coin_specific_data, NEAR_COIN_DATA_MAX_LEN, &filled_length); - size_t acc_count = near_get_account_ids_count( - coin_specific_data.coin_data, filled_length); - - char *acc_id[NEAR_REGISTERED_ACCOUNT_COUNT] = {0}; - - near_deserialize_account_ids( - coin_specific_data.coin_data, filled_length, acc_id, acc_count); - - acc_id[receive_transaction_data.near_acc_index] = - receive_transaction_data.near_registered_account; - - uint8_t new_near_coin_data[NEAR_COIN_DATA_MAX_LEN] = {0}; - filled_length = 0; - near_serialize_account_ids( - (const char **)acc_id, acc_count, new_near_coin_data, &filled_length); - memcpy(coin_specific_data.coin_data, - new_near_coin_data, - NEAR_COIN_DATA_MAX_LEN); - - int status = set_coin_data(&coin_specific_data, filled_length); - if (status != 0) { - comm_reject_request(COIN_SPECIFIC_DATA_ERROR, status); - reset_flow_level(); - return; - } - - transmit_one_byte_confirm(RECV_TXN_REPLACE_ACCOUNT); - reset_flow_level(); - } break; - - case RECV_TXN_FINAL_SCREEN_NEAR: { - reset_flow_level(); - } break; - - default: - break; - } - - return; -} diff --git a/src/level_four/core/controller/receive_transaction_controller_solana.c b/src/level_four/core/controller/receive_transaction_controller_solana.c deleted file mode 100644 index 397c5b16e..000000000 --- a/src/level_four/core/controller/receive_transaction_controller_solana.c +++ /dev/null @@ -1,205 +0,0 @@ -/** - * @file receive_transaction_controller_solana.c - * @author Cypherock X1 Team - * @brief Receive transaction next controller for SOLANA. - * Handles post event (only next events) operations for receive - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "bip32.h" -#include "communication.h" -#include "constant_texts.h" -#include "controller_level_four.h" -#include "controller_tap_cards.h" -#include "sha2.h" -#include "shamir_wrapper.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" - -extern Receive_Transaction_Data receive_transaction_data; -extern Wallet_shamir_data wallet_shamir_data; -extern Wallet_credential_data wallet_credential_data; - -void receive_transaction_controller_solana() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_SOLANA: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - if (WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = RECV_TXN_ENTER_PASSPHRASE_SOLANA; - } else { - flow_level.level_three = RECV_TXN_CHECK_PIN_SOLANA; - } - } break; - - case RECV_TXN_ENTER_PASSPHRASE_SOLANA: { - flow_level.level_three = RECV_TXN_CONFIRM_PASSPHRASE_SOLANA; - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_SOLANA: { - snprintf(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase), - "%s", - flow_level.screen_input.input_text); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = RECV_TXN_CHECK_PIN_SOLANA; - } break; - - case RECV_TXN_CHECK_PIN_SOLANA: { - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = RECV_TXN_ENTER_PIN_SOLANA; - } else { - flow_level.level_three = RECV_TXN_TAP_CARD_SOLANA; - } - } break; - - case RECV_TXN_ENTER_PIN_SOLANA: { - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet_credential_data.password_single_hash); - sha256_Raw(wallet_credential_data.password_single_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = RECV_TXN_TAP_CARD_SOLANA; - } break; - - case RECV_TXN_TAP_CARD_SOLANA: { - tap_card_data.desktop_control = true; - tap_threshold_cards_for_reconstruction_flow_controller(1); - } break; - - case RECV_TXN_TAP_CARD_SEND_CMD_SOLANA: { - flow_level.level_three = RECV_TXN_READ_DEVICE_SHARE_SOLANA; - } break; - - case RECV_TXN_READ_DEVICE_SHARE_SOLANA: - wallet_shamir_data.share_x_coords[1] = 5; - get_flash_wallet_share_by_name((const char *)wallet.wallet_name, - wallet_shamir_data.mnemonic_shares[1]); - memcpy(wallet_shamir_data.share_encryption_data[1], - wallet_shamir_data.share_encryption_data[0], - PADDED_NONCE_SIZE + WALLET_MAC_SIZE); - flow_level.level_three = RECV_TXN_DERIVE_ADD_SCREEN_SOLANA; - break; - - case RECV_TXN_DERIVE_ADD_SCREEN_SOLANA: { - flow_level.level_three = RECV_TXN_DERIVE_ADD_SOLANA; - } break; - - case RECV_TXN_DERIVE_ADD_SOLANA: { - uint8_t secret[BLOCK_SIZE]; - if (WALLET_IS_PIN_SET(wallet.wallet_info)) - decrypt_shares(); - recover_secret_from_shares(BLOCK_SIZE, - MINIMUM_NO_OF_SHARES, - wallet_shamir_data.mnemonic_shares, - wallet_shamir_data.share_x_coords, - secret); - memzero(wallet_shamir_data.mnemonic_shares, - sizeof(wallet_shamir_data.mnemonic_shares)); - mnemonic_clear(); - const char *mnemo = - mnemonic_from_data(secret, wallet.number_of_mnemonics * 4 / 3); - HDNode node; - uint8_t seed[64] = {0}; - - memzero(seed, sizeof(seed)); - - mnemonic_to_seed(mnemo, wallet_credential_data.passphrase, seed, NULL); - mnemonic_clear(); - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - - uint32_t path[] = { - BYTE_ARRAY_TO_UINT32(receive_transaction_data.purpose), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.coin_index), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.account_index), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.change_index), - BYTE_ARRAY_TO_UINT32(receive_transaction_data.address_index), - }; - size_t depth = - sol_get_derivation_depth(receive_transaction_data.address_tag); - derive_hdnode_from_path(path, depth, ED25519_NAME, seed, &node); - size_t public_key_size = sizeof(receive_transaction_data.solana_address); - memzero(receive_transaction_data.solana_address, - sizeof(receive_transaction_data.solana_address)); - b58enc(receive_transaction_data.solana_address, - &public_key_size, - (char *)(node.public_key + 1), - 32); - memzero(path, sizeof(path)); - - flow_level.level_three = RECV_TXN_DISPLAY_ADDR_SOLANA; - } break; - - case RECV_TXN_DISPLAY_ADDR_SOLANA: { - uint8_t data[1 + sizeof(receive_transaction_data.solana_address)]; - data[0] = 1; // confirmation byte - memcpy(data + 1, - receive_transaction_data.solana_address, - sizeof(receive_transaction_data.solana_address)); - transmit_data_to_app(RECV_TXN_USER_VERIFIED_ADDRESS, data, sizeof(data)); - reset_flow_level(); - } break; - - default: - break; - } - - return; -} diff --git a/src/level_four/core/controller/send_transaction_controller_b_eth.c b/src/level_four/core/controller/send_transaction_controller_b_eth.c deleted file mode 100644 index c0bac96b2..000000000 --- a/src/level_four/core/controller/send_transaction_controller_b_eth.c +++ /dev/null @@ -1,136 +0,0 @@ -/** - * @file send_transaction_controller_b_eth.c - * @author Cypherock X1 Team - * @brief Send transaction back controller for ETH. - * Handles post event (only back/cancel events) operations for send - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" - -extern Wallet_credential_data wallet_credential_data; -void send_transaction_controller_b_eth() { - switch (flow_level.level_three) { - case SEND_TXN_VERIFY_COIN_ETH: { - comm_reject_request(SEND_TXN_REQ_UNSIGNED_TXN, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_VERIFY_TXN_NONCE_ETH: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 4); - reset_flow_level(); - counter.next_event_flag = true; - } - - case SEND_TXN_CALCULATE_AMOUNT_ETH: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 2); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_VERIFY_CONTRACT_ADDRESS: - case SEND_TXN_VERIFY_BLIND_SIGNING_ETH: - case SEND_TXN_VERIFY_DERIVATION_PATH: - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_ETH: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_VERIFY_RECEIPT_AMOUNT_ETH: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 2); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_VERIFY_RECEIPT_FEES_ETH: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 3); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_DISPLAY_INFO_ETH: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 4); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_ENTER_PIN_ETH: { - comm_reject_request(USER_REJECT_PIN_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case SEND_TXN_ENTER_PASSPHRASE_ETH: { - comm_reject_request(USER_REJECTED_PASSPHRASE_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case SEND_TXN_CONFIRM_PASSPHRASE_ETH: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - flow_level.level_three = SEND_TXN_ENTER_PASSPHRASE_ETH; - } break; - - default: - break; - } -} \ No newline at end of file diff --git a/src/level_four/core/controller/send_transaction_controller_b_solana.c b/src/level_four/core/controller/send_transaction_controller_b_solana.c deleted file mode 100644 index f3cff547e..000000000 --- a/src/level_four/core/controller/send_transaction_controller_b_solana.c +++ /dev/null @@ -1,122 +0,0 @@ -/** - * @file send_transaction_controller_b_solana.c - * @author Cypherock X1 Team - * @brief Send transaction back controller for SOLANA. - * Handles post event (only back/cancel events) operations for send - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" - -extern Wallet_credential_data wallet_credential_data; -void send_transaction_controller_b_solana() { - switch (flow_level.level_three) { - case SEND_TXN_VERIFY_COIN_SOLANA: { - comm_reject_request(SEND_TXN_REQ_UNSIGNED_TXN, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_CALCULATE_AMOUNT_SOLANA: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 2); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_VERIFY_CONTRACT_ADDRESS: - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_SOLANA: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_VERIFY_RECEIPT_AMOUNT_SOLANA: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 2); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_VERIFY_RECEIPT_FEES_SOLANA: { - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 3); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SEND_TXN_ENTER_PIN_SOLANA: { - comm_reject_request(USER_REJECT_PIN_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case SEND_TXN_ENTER_PASSPHRASE_SOLANA: { - comm_reject_request(USER_REJECTED_PASSPHRASE_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case SEND_TXN_CONFIRM_PASSPHRASE_SOLANA: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - flow_level.level_three = SEND_TXN_ENTER_PASSPHRASE_SOLANA; - } break; - - default: - break; - } -} \ No newline at end of file diff --git a/src/level_four/core/controller/send_transaction_controller_eth.c b/src/level_four/core/controller/send_transaction_controller_eth.c deleted file mode 100644 index 9af38ae6b..000000000 --- a/src/level_four/core/controller/send_transaction_controller_eth.c +++ /dev/null @@ -1,267 +0,0 @@ -/** - * @file send_transaction_controller_eth.c - * @author Cypherock X1 Team - * @brief Send transaction next controller for ETH. - * Handles post event (only next events) operations for send - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "sha2.h" -#include "shamir_wrapper.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern Wallet_shamir_data wallet_shamir_data; -extern Wallet_credential_data wallet_credential_data; - -extern lv_task_t *timeout_task; - -evm_unsigned_txn eth_unsigned_txn_ptr = { - .nonce_size = {0}, - .nonce = {0}, - .gas_price_size = {0}, - .gas_price = {0}, - .gas_limit_size = {0}, - .gas_limit = {0}, - .to_address = {0}, - .value_size = {0}, - .value = {0}, - .data_size = 0, - .data = NULL, - .chain_id_size = {0}, - .chain_id = {0}, - .dummy_r = {0}, - .dummy_s = {0}, -}; -uint8_t *eth_unsigned_txn_byte_array = NULL; -uint16_t eth_unsigned_txn_len; - -extern ui_display_node *current_display_node; -extern bool evm_is_token_whitelisted; - -void send_transaction_controller_eth() { - switch (flow_level.level_three) { - case SEND_TXN_VERIFY_COIN_ETH: { - uint8_t arr[3] = {0x01, 0x1f, 0x40}; - transmit_data_to_app(SEND_TXN_REQ_UNSIGNED_TXN, arr, sizeof(arr)); - flow_level.level_three = SEND_TXN_UNSIGNED_TXN_WAIT_SCREEN_ETH; - } break; - - case SEND_TXN_UNSIGNED_TXN_WAIT_SCREEN_ETH: { - uint8_t *data_array = NULL; - uint16_t msg_size = 0; - if (get_usb_msg_by_cmd_type( - SEND_TXN_UNSIGNED_TXN, &data_array, &msg_size)) { - eth_unsigned_txn_byte_array = (uint8_t *)cy_malloc(msg_size); - eth_unsigned_txn_len = msg_size; - memcpy(eth_unsigned_txn_byte_array, data_array, msg_size); - - clear_message_received_data(); - flow_level.level_three = SEND_TXN_UNSIGNED_TXN_RECEIVED_ETH; - } - } break; - - case SEND_TXN_VERIFY_BLIND_SIGNING_ETH: { - flow_level.level_three = SEND_TXN_VERIFY_DERIVATION_PATH; - } break; - - case SEND_TXN_VERIFY_DERIVATION_PATH: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_ETH; - } break; - - case SEND_TXN_VERIFY_CONTRACT_ADDRESS: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_ETH; - } break; - - case SEND_TXN_VERIFY_TXN_NONCE_ETH: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_ETH; - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_ETH: { - flow_level.level_three = SEND_TXN_CALCULATE_AMOUNT_ETH; - } break; - - case SEND_TXN_VERIFY_RECEIPT_AMOUNT_ETH: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_FEES_ETH; - } break; - - case SEND_TXN_VERIFY_RECEIPT_FEES_ETH: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_ETH; - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_ETH: { - flow_level.level_three = SEND_TXN_DISPLAY_INFO_ETH; - } break; - - case SEND_TXN_DISPLAY_INFO_ETH: { - if (current_display_node == NULL) { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - if (WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = SEND_TXN_ENTER_PASSPHRASE_ETH; - } else { - flow_level.level_three = SEND_TXN_CHECK_PIN_ETH; - } - } else { - current_display_node = current_display_node->next; - } - } break; - - case SEND_TXN_ENTER_PASSPHRASE_ETH: { - flow_level.level_three = SEND_TXN_CONFIRM_PASSPHRASE_ETH; - } break; - - case SEND_TXN_CONFIRM_PASSPHRASE_ETH: { - snprintf(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase), - "%s", - flow_level.screen_input.input_text); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = SEND_TXN_CHECK_PIN_ETH; - } break; - - case SEND_TXN_CHECK_PIN_ETH: { - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = SEND_TXN_ENTER_PIN_ETH; - } else { - flow_level.level_three = SEND_TXN_TAP_CARD_ETH; - } - - } break; - - case SEND_TXN_ENTER_PIN_ETH: { - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet_credential_data.password_single_hash); - sha256_Raw(wallet_credential_data.password_single_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = SEND_TXN_TAP_CARD_ETH; - } break; - - case SEND_TXN_TAP_CARD_ETH: { - tap_card_data.desktop_control = true; - tap_threshold_cards_for_reconstruction_flow_controller(1); - } break; - - case SEND_TXN_TAP_CARD_SEND_CMD_ETH: { - flow_level.level_three = SEND_TXN_READ_DEVICE_SHARE_ETH; - } break; - - case SEND_TXN_READ_DEVICE_SHARE_ETH: - wallet_shamir_data.share_x_coords[1] = 5; - get_flash_wallet_share_by_name((const char *)wallet.wallet_name, - wallet_shamir_data.mnemonic_shares[1]); - memcpy(wallet_shamir_data.share_encryption_data[1], - wallet_shamir_data.share_encryption_data[0], - PADDED_NONCE_SIZE + WALLET_MAC_SIZE); - flow_level.level_three = SEND_TXN_SIGN_TXN_ETH; - break; - - case SEND_TXN_SIGN_TXN_ETH: { - uint8_t secret[BLOCK_SIZE]; - if (WALLET_IS_PIN_SET(wallet.wallet_info)) - decrypt_shares(); - recover_secret_from_shares(BLOCK_SIZE, - MINIMUM_NO_OF_SHARES, - wallet_shamir_data.mnemonic_shares, - wallet_shamir_data.share_x_coords, - secret); - mnemonic_clear(); - const char *mnemo = - mnemonic_from_data(secret, wallet.number_of_mnemonics * 4 / 3); - ASSERT(mnemo != NULL); - - uint8_t sig[65]; - sig_unsigned_byte_array( - eth_unsigned_txn_byte_array, - eth_unsigned_txn_len, - (const txn_metadata *)&var_send_transaction_data.transaction_metadata, - mnemo, - wallet_credential_data.passphrase, - sig); - transmit_data_to_app(SEND_TXN_SENDING_SIGNED_TXN, sig, 65); - mnemonic_clear(); - memzero(secret, sizeof(secret)); - memzero(wallet_shamir_data.mnemonic_shares, - sizeof(wallet_shamir_data.mnemonic_shares)); - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - - flow_level.level_three = SEND_TXN_WAITING_SCREEN_ETH; - } break; - - case SEND_TXN_WAITING_SCREEN_ETH: - instruction_scr_destructor(); - lv_obj_clean(lv_scr_act()); - flow_level.level_three = SEND_TXN_FINAL_SCREEN_ETH; - break; - - case SEND_TXN_FINAL_SCREEN_ETH: - reset_flow_level(); - break; - - default: - break; - } -} diff --git a/src/level_four/core/controller/send_transaction_controller_solana.c b/src/level_four/core/controller/send_transaction_controller_solana.c deleted file mode 100644 index 66b932b20..000000000 --- a/src/level_four/core/controller/send_transaction_controller_solana.c +++ /dev/null @@ -1,282 +0,0 @@ -/** - * @file send_transaction_controller_solana.c - * @author Cypherock X1 Team - * @brief Send transaction next controller for SOLANA. - * Handles post event (only next events) operations for send - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "sha2.h" -#include "shamir_wrapper.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern Wallet_shamir_data wallet_shamir_data; -extern Wallet_credential_data wallet_credential_data; - -extern lv_task_t *timeout_task; - -solana_unsigned_txn solana_unsigned_txn_ptr; -uint8_t *solana_unsigned_txn_byte_array = NULL; -uint16_t solana_unsigned_txn_len; - -void send_transaction_controller_solana() { - switch (flow_level.level_three) { - case SEND_TXN_VERIFY_COIN_SOLANA: { - uint8_t arr[3] = {0x01, 0x1f, 0x40}; - transmit_data_to_app(SEND_TXN_REQ_UNSIGNED_TXN, arr, sizeof(arr)); - flow_level.level_three = SEND_TXN_UNSIGNED_TXN_WAIT_SCREEN_SOLANA; - } break; - - case SEND_TXN_UNSIGNED_TXN_WAIT_SCREEN_SOLANA: { - uint8_t *data_array = NULL; - uint16_t msg_size = 0; - if (get_usb_msg_by_cmd_type( - SEND_TXN_UNSIGNED_TXN, &data_array, &msg_size)) { - solana_unsigned_txn_byte_array = (uint8_t *)cy_malloc(msg_size); - solana_unsigned_txn_len = msg_size; - memcpy(solana_unsigned_txn_byte_array, data_array, msg_size); - - int status = - solana_byte_array_to_unsigned_txn(solana_unsigned_txn_byte_array, - solana_unsigned_txn_len, - &solana_unsigned_txn_ptr); - - clear_message_received_data(); - flow_level.level_three = SEND_TXN_UNSIGNED_TXN_RECEIVED_SOLANA; - - if (status == SOL_OK) - status = solana_validate_unsigned_txn(&solana_unsigned_txn_ptr); - - if (status != SOL_OK) { - LOG_ERROR("Solana error code: %d", status); - instruction_scr_destructor(); - mark_error_screen(ui_text_worng_eth_transaction); - comm_reject_request(SEND_TXN_USER_VERIFIES_ADDRESS, 0); - reset_flow_level(); - } - } - } break; - - case SEND_TXN_UNSIGNED_TXN_RECEIVED_SOLANA: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_SOLANA; - } break; - - case SEND_TXN_VERIFY_CONTRACT_ADDRESS: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_SOLANA; - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_SOLANA: { - flow_level.level_three = SEND_TXN_CALCULATE_AMOUNT_SOLANA; - } break; - - case SEND_TXN_CALCULATE_AMOUNT_SOLANA: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_AMOUNT_SOLANA; - } break; - - case SEND_TXN_VERIFY_RECEIPT_AMOUNT_SOLANA: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_FEES_SOLANA; - } break; - - case SEND_TXN_VERIFY_RECEIPT_FEES_SOLANA: { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_SOLANA; - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_SOLANA: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - if (WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = SEND_TXN_ENTER_PASSPHRASE_SOLANA; - } else { - flow_level.level_three = SEND_TXN_CHECK_PIN_SOLANA; - } - } break; - - case SEND_TXN_ENTER_PASSPHRASE_SOLANA: { - flow_level.level_three = SEND_TXN_CONFIRM_PASSPHRASE_SOLANA; - } break; - - case SEND_TXN_CONFIRM_PASSPHRASE_SOLANA: { - snprintf(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase), - "%s", - flow_level.screen_input.input_text); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = SEND_TXN_CHECK_PIN_SOLANA; - } break; - - case SEND_TXN_CHECK_PIN_SOLANA: { - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = SEND_TXN_ENTER_PIN_SOLANA; - } else { - flow_level.level_three = SEND_TXN_TAP_CARD_SOLANA; - } - - } break; - - case SEND_TXN_ENTER_PIN_SOLANA: { - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet_credential_data.password_single_hash); - sha256_Raw(wallet_credential_data.password_single_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = SEND_TXN_TAP_CARD_SOLANA; - } break; - - case SEND_TXN_TAP_CARD_SOLANA: { - tap_card_data.desktop_control = true; - tap_threshold_cards_for_reconstruction_flow_controller(1); - } break; - - case SEND_TXN_TAP_CARD_SEND_CMD_SOLANA: { - flow_level.level_three = SEND_TXN_UPDATE_BLOCKHASH_SOLANA; - uint8_t arr[1] = {1}; - transmit_data_to_app(SEND_TXN_UNSIGNED_TXN, arr, sizeof(arr)); - } break; - - case SEND_TXN_UPDATE_BLOCKHASH_SOLANA: { - uint8_t *blockhash_received = NULL; - uint16_t blockhash_msg_size = 0; - uint8_t solana_latest_blockhash[SOLANA_BLOCKHASH_LENGTH] = {0}; - - if (get_usb_msg_by_cmd_type(SEND_TXN_PRE_SIGNING_DATA, - &blockhash_received, - &blockhash_msg_size)) { - if (blockhash_msg_size != SOLANA_BLOCKHASH_LENGTH) { - comm_reject_invalid_cmd(); - reset_flow_level(); - } - memcpy(solana_latest_blockhash, - blockhash_received, - SOLANA_BLOCKHASH_LENGTH); - clear_message_received_data(); - - int status = solana_update_blockhash_in_byte_array( - solana_unsigned_txn_byte_array, solana_latest_blockhash); - if (status != SOL_OK) { - LOG_ERROR("SOL: %d", status); - comm_reject_request(SEND_TXN_PRE_SIGNING_DATA, 0); - reset_flow_level(); - } - flow_level.level_three = SEND_TXN_READ_DEVICE_SHARE_SOLANA; - } - - } break; - - case SEND_TXN_READ_DEVICE_SHARE_SOLANA: - wallet_shamir_data.share_x_coords[1] = 5; - get_flash_wallet_share_by_name((const char *)wallet.wallet_name, - wallet_shamir_data.mnemonic_shares[1]); - memcpy(wallet_shamir_data.share_encryption_data[1], - wallet_shamir_data.share_encryption_data[0], - PADDED_NONCE_SIZE + WALLET_MAC_SIZE); - flow_level.level_three = SEND_TXN_SIGN_TXN_SOLANA; - break; - - case SEND_TXN_SIGN_TXN_SOLANA: { - uint8_t secret[BLOCK_SIZE]; - if (WALLET_IS_PIN_SET(wallet.wallet_info)) - decrypt_shares(); - recover_secret_from_shares(BLOCK_SIZE, - MINIMUM_NO_OF_SHARES, - wallet_shamir_data.mnemonic_shares, - wallet_shamir_data.share_x_coords, - secret); - mnemonic_clear(); - const char *mnemo = - mnemonic_from_data(secret, wallet.number_of_mnemonics * 4 / 3); - ASSERT(mnemo != NULL); - - uint8_t sig[64]; - solana_sig_unsigned_byte_array( - solana_unsigned_txn_byte_array, - solana_unsigned_txn_len, - (const txn_metadata *)&var_send_transaction_data.transaction_metadata, - mnemo, - wallet_credential_data.passphrase, - sig); - transmit_data_to_app(SEND_TXN_SENDING_SIGNED_TXN, sig, 64); - mnemonic_clear(); - memzero(secret, sizeof(secret)); - memzero(wallet_shamir_data.mnemonic_shares, - sizeof(wallet_shamir_data.mnemonic_shares)); - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - - flow_level.level_three = SEND_TXN_WAITING_SCREEN_SOLANA; - } break; - - case SEND_TXN_WAITING_SCREEN_SOLANA: - instruction_scr_destructor(); - flow_level.level_three = SEND_TXN_FINAL_SCREEN_SOLANA; - break; - - case SEND_TXN_FINAL_SCREEN_SOLANA: - reset_flow_level(); - break; - - default: - break; - } -} diff --git a/src/level_four/core/controller/sign_message_controller_eth.c b/src/level_four/core/controller/sign_message_controller_eth.c deleted file mode 100644 index 73f1ffe57..000000000 --- a/src/level_four/core/controller/sign_message_controller_eth.c +++ /dev/null @@ -1,229 +0,0 @@ -/** - * @file sign_message_controller_eth.c - * @author Cypherock X1 Team - * @brief Sign message next controller for ETH. - * Handles post event (only next events) operations for send - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "sha2.h" -#include "shamir_wrapper.h" -#include "ui_confirmation.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern Wallet_shamir_data wallet_shamir_data; -extern Wallet_credential_data wallet_credential_data; - -extern lv_task_t *timeout_task; - -extern MessageData msg_data; -extern ui_display_node *current_display_node; - -void sign_message_controller_eth() { - switch (flow_level.level_three) { - case SIGN_MSG_VERIFY_COIN_ETH: { - uint8_t arr[3] = {0x01, 0x1f, 0x40}; - transmit_data_to_app(SIGN_MSG_RAW_MSG, arr, sizeof(arr)); - flow_level.level_three = SIGN_MSG_RAW_MSG_WAIT_SCREEN_ETH; - eth_init_msg_data( - &msg_data); // initialize variables and decoding functions - } break; - - case SIGN_MSG_RAW_MSG_WAIT_SCREEN_ETH: { - uint8_t *data_array = NULL; - uint16_t msg_size = 0; - if (get_usb_msg_by_cmd_type(SIGN_MSG_RAW_MSG, &data_array, &msg_size)) { - int status = 0; - status = eth_byte_array_to_msg(data_array, msg_size, &msg_data); - - clear_message_received_data(); - flow_level.level_three = SIGN_MSG_DISPLAY_INFO_ETH; - - if (status != 0) { - instruction_scr_destructor(); - mark_error_screen(ui_text_worng_eth_transaction); - comm_reject_request(SIGN_MSG_START, 0); - reset_flow_level(); - } - - // eth_init_display_nodes(¤t_display_node, &msg_data); - ASSERT(current_display_node != NULL); - } - } break; - - case SIGN_MSG_DISPLAY_INFO_ETH: { - if (current_display_node == NULL) - flow_level.level_three = SIGN_MSG_CHECK_PASSPHRASE_ETH; - else - current_display_node = current_display_node->next; - } break; - - case SIGN_MSG_CHECK_PASSPHRASE_ETH: { - instruction_scr_destructor(); - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - if (WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = SIGN_MSG_ENTER_PASSPHRASE_ETH; - } else { - flow_level.level_three = SIGN_MSG_CHECK_PIN_ETH; - } - } break; - - case SIGN_MSG_ENTER_PASSPHRASE_ETH: { - flow_level.level_three = SIGN_MSG_CONFIRM_PASSPHRASE_ETH; - } break; - - case SIGN_MSG_CONFIRM_PASSPHRASE_ETH: { - snprintf(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase), - "%s", - flow_level.screen_input.input_text); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = SIGN_MSG_CHECK_PIN_ETH; - } break; - - case SIGN_MSG_CHECK_PIN_ETH: { - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = SIGN_MSG_ENTER_PIN_ETH; - } else { - flow_level.level_three = SIGN_MSG_TAP_CARD_ETH; - } - - } break; - - case SIGN_MSG_ENTER_PIN_ETH: { - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet_credential_data.password_single_hash); - sha256_Raw(wallet_credential_data.password_single_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = SIGN_MSG_TAP_CARD_ETH; - } break; - - case SIGN_MSG_TAP_CARD_ETH: { - tap_card_data.desktop_control = true; - tap_threshold_cards_for_reconstruction_flow_controller(1); - } break; - - case SIGN_MSG_TAP_CARD_SEND_CMD_ETH: { - flow_level.level_three = SIGN_MSG_READ_DEVICE_SHARE_ETH; - } break; - - case SIGN_MSG_READ_DEVICE_SHARE_ETH: - wallet_shamir_data.share_x_coords[1] = 5; - get_flash_wallet_share_by_name((const char *)wallet.wallet_name, - wallet_shamir_data.mnemonic_shares[1]); - memcpy(wallet_shamir_data.share_encryption_data[1], - wallet_shamir_data.share_encryption_data[0], - PADDED_NONCE_SIZE + WALLET_MAC_SIZE); - flow_level.level_three = SIGN_MSG_SIGN_TXN_ETH; - break; - - case SIGN_MSG_SIGN_TXN_ETH: { - uint8_t secret[BLOCK_SIZE]; - if (WALLET_IS_PIN_SET(wallet.wallet_info)) - decrypt_shares(); - recover_secret_from_shares(BLOCK_SIZE, - MINIMUM_NO_OF_SHARES, - wallet_shamir_data.mnemonic_shares, - wallet_shamir_data.share_x_coords, - secret); - mnemonic_clear(); - const char *mnemo = - mnemonic_from_data(secret, wallet.number_of_mnemonics * 4 / 3); - ASSERT(mnemo != NULL); - - uint8_t sig[65] = {0}; - - eth_sign_msg_data( - &msg_data, - (const txn_metadata *)&var_send_transaction_data.transaction_metadata, - mnemo, - wallet_credential_data.passphrase, - sig); - transmit_data_to_app(SIGN_MSG_SEND_SIG, sig, 65); - mnemonic_clear(); - memzero(secret, sizeof(secret)); - memzero(wallet_shamir_data.mnemonic_shares, - sizeof(wallet_shamir_data.mnemonic_shares)); - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - - flow_level.level_three = SIGN_MSG_WAITING_SCREEN_ETH; - } break; - - case SIGN_MSG_WAITING_SCREEN_ETH: - instruction_scr_destructor(); - lv_obj_clean(lv_scr_act()); - flow_level.level_three = SIGN_MSG_FINAL_SCREEN_ETH; - break; - - case SIGN_MSG_FINAL_SCREEN_ETH: - reset_flow_level(); - break; - - default: - break; - } -} diff --git a/src/level_four/core/controller/sign_messgae_controller_b_eth.c b/src/level_four/core/controller/sign_messgae_controller_b_eth.c deleted file mode 100644 index c4709fc05..000000000 --- a/src/level_four/core/controller/sign_messgae_controller_b_eth.c +++ /dev/null @@ -1,103 +0,0 @@ -/** - * @file sign_message_controller_b_eth.c - * @author Cypherock X1 Team - * @brief back controller for ETH. - * Handles post event (only back/cancel events) operations for send - *transaction flow initiated by desktop app. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "controller_level_four.h" - -extern Wallet_credential_data wallet_credential_data; -void sign_message_controller_b_eth() { - switch (flow_level.level_three) { - case SIGN_MSG_VERIFY_COIN_ETH: { - comm_reject_request(SIGN_MSG_START, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SIGN_MSG_DISPLAY_INFO_ETH: { - comm_reject_request(SIGN_MSG_START, 0); - reset_flow_level(); - counter.next_event_flag = true; - } break; - - case SIGN_MSG_ENTER_PIN_ETH: { - comm_reject_request(USER_REJECT_PIN_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case SIGN_MSG_ENTER_PASSPHRASE_ETH: { - comm_reject_request(USER_REJECTED_PASSPHRASE_INPUT, 0); - reset_flow_level(); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - counter.next_event_flag = true; - } break; - - case SIGN_MSG_CONFIRM_PASSPHRASE_ETH: { - memzero(wallet_credential_data.passphrase, - sizeof(wallet_credential_data.passphrase)); - flow_level.level_three = SIGN_MSG_ENTER_PASSPHRASE_ETH; - } break; - - default: - break; - } -} \ No newline at end of file diff --git a/src/level_four/core/controller/verify_wallet_controller.c b/src/level_four/core/controller/verify_wallet_controller.c deleted file mode 100644 index 875fd5146..000000000 --- a/src/level_four/core/controller/verify_wallet_controller.c +++ /dev/null @@ -1,113 +0,0 @@ -/** - * @file verify_wallet_controller.c - * @author Cypherock X1 Team - * @brief Verify wallet next controller. - * Handles post event (only next events) operations for verify wallet - *flow - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "card_action_controllers.h" -#include "card_flow_verify_wallet.h" -#include "controller_level_four.h" -#include "controller_tap_cards.h" -#include "flash_api.h" -#include "sha2.h" - -extern Wallet_credential_data wallet_credential_data; - -void verify_wallet_controller() { - switch (flow_level.level_three) { - case VERIFY_WALLET_START: - if (WALLET_IS_PIN_SET(wallet.wallet_info)) - flow_level.level_three = VERIFY_WALLET_PIN_INPUT; - else - flow_level.level_three = VERIFY_WALLET_TAP_CARDS_FLOW; - break; - - case VERIFY_WALLET_PIN_INPUT: - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet_credential_data.password_single_hash); - sha256_Raw(wallet_credential_data.password_single_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = VERIFY_WALLET_TAP_CARDS_FLOW; - break; - - case VERIFY_WALLET_TAP_CARDS_FLOW: - card_flow_verify_wallet(); - break; - - case VERIFY_WALLET_DATA: { - flow_level.level_three = (verify_card_share_data() == 1) - ? VERIFY_WALLET_SUCCESS - : VERIFY_WALLET_DELETE; - } break; - - case VERIFY_WALLET_SUCCESS: - reset_flow_level(); - break; - - case VERIFY_WALLET_DELETE: - mark_error_screen(ui_text_wallet_verification_failed_in_creation); - flow_level.level_three = 1; - break; - - default: - break; - } -} diff --git a/src/level_four/core/controller/verify_wallet_controller_b.c b/src/level_four/core/controller/verify_wallet_controller_b.c deleted file mode 100644 index 4ad05e20d..000000000 --- a/src/level_four/core/controller/verify_wallet_controller_b.c +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file verify_wallet_controller_b.c - * @author Cypherock X1 Team - * @brief Verify wallet back controller. - * Handles post event (only back/cancel events) operations for verify - *wallet. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "controller_level_four.h" - -void verify_wallet_controller_b() { - switch (flow_level.level_three) { - case VERIFY_WALLET_DELETE: { - reset_flow_level(); - break; - } - - default: - flow_level.level_three = VERIFY_WALLET_DELETE; - break; - } -} \ No newline at end of file diff --git a/src/level_four/core/controller/wallet_locked_controller_b.c b/src/level_four/core/controller/wallet_locked_controller_b.c deleted file mode 100644 index e8b1543ec..000000000 --- a/src/level_four/core/controller/wallet_locked_controller_b.c +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @file wallet_locked_controller_b.c - * @author Cypherock X1 Team - * @brief Wallet unlock next controller. - * Handles post event (only back/cancel events) operations for unlock - *wallet. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "controller_level_four.h" - -// wallet_locked_controller_b -void wallet_locked_controller_b() { - switch (flow_level.level_three) { - case WALLET_LOCKED_MESSAGE: { - reset_flow_level(); - counter.next_event_flag = true; - } break; - case WALLET_LOCKED_ENTER_PIN: { - reset_flow_level(); - counter.next_event_flag = true; - } break; - default: - break; - } -} \ No newline at end of file diff --git a/src/level_four/core/tasks/card_upgrade_tasks.c b/src/level_four/core/tasks/card_upgrade_tasks.c deleted file mode 100644 index 67a72e0ce..000000000 --- a/src/level_four/core/tasks/card_upgrade_tasks.c +++ /dev/null @@ -1,86 +0,0 @@ -/** - * @file card_upgrade_tasks.c - * @author Cypherock X1 Team - * @brief Card upgrade task. - * This file contains the card upgrade task. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "tasks_level_four.h" -#include "ui_instruction.h" - -extern Flow_level flow_level; -extern Counter counter; -extern Wallet wallet; -void card_upgrade_task() { -#ifdef DEV_BUILD - switch (flow_level.level_three) { - case CARD_UPGRADE_TAP_CARD_MESSAGE: - instruction_scr_init(ui_text_tap_card_to_start, NULL); - mark_event_over(); - break; - - case CARD_UPGRADE_SELECT_CARD: - mark_event_over(); - break; - - case CARD_UPGRADE_FORWARD_MESSAGE: - mark_event_over(); - break; - - default: - break; - } -#endif -} diff --git a/src/level_four/core/tasks/initial_device_provision_tasks.c b/src/level_four/core/tasks/initial_device_provision_tasks.c deleted file mode 100644 index 6381db1d3..000000000 --- a/src/level_four/core/tasks/initial_device_provision_tasks.c +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file initial_device_provision_tasks.c - * @author Cypherock X1 Team - * @brief Device provision task (initial). - * This file contains the implementation of the device provision task - *for initial application. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_level_four.h" -#include "tasks_level_four.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_menu.h" -#include "ui_message.h" - -void task_device_provision() { -#if X1WALLET_INITIAL - switch (flow_level.level_three) { - case GENERATE_PROVSION_DATA: { - ui_text_slideshow_init(ui_text_device_provisioning, 5, 500, false); - mark_event_over(); - } break; - - case PROVISION_STATUS_WAIT: - case PROVISION_SAVE_EXT_KEYS: { - mark_event_over(); - } break; - - case PROVISION_UNSUCCESSFUL: { - lv_obj_clean(lv_scr_act()); - delay_scr_init(ui_text_provision_fail, DELAY_TIME); - } break; - - default: - break; - } -#endif -} \ No newline at end of file diff --git a/src/level_four/core/tasks/receive_transaction_tasks_eth.c b/src/level_four/core/tasks/receive_transaction_tasks_eth.c deleted file mode 100644 index 35d8a8fd7..000000000 --- a/src/level_four/core/tasks/receive_transaction_tasks_eth.c +++ /dev/null @@ -1,172 +0,0 @@ -/** - * @file receive_transaction_tasks_eth.c - * @author Cypherock X1 Team - * @brief Receive transaction task for ETH. - * This file contains the implementation of the receive transaction - *task for ETH. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "constant_texts.h" -#include "controller_level_four.h" -#include "flash_api.h" -#include "harmony.h" -#include "segwit_addr.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_menu.h" -#include "utils.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *PASSPHRASE; - -extern Receive_Transaction_Data receive_transaction_data; - -void receive_transaction_tasks_eth() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_ETH: { - mark_event_over(); - } break; - - case RECV_TXN_ENTER_PASSPHRASE_ETH: { - if (!WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = ADD_COINS_VERIFY; - break; - } - input_text_init(PASSPHRASE, - 26, - ui_text_enter_passphrase, - 0, - DATA_TYPE_PASSPHRASE, - 64); - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_ETH: { - char display[65]; - snprintf( - display, sizeof(display), "%s", flow_level.screen_input.input_text); - address_scr_init(ui_text_confirm_passphrase, display, false); - memzero(display, sizeof(display)); - } break; - - case RECV_TXN_CHECK_PIN_ETH: { - mark_event_over(); - } break; - - case RECV_TXN_ENTER_PIN_ETH: { - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - } break; - - case RECV_TXN_TAP_CARD_ETH: { - // TODO: Use tap_threshold_cards_for_reconstruction instead - retrieve_key_from_card(); - } break; - - case RECV_TXN_TAP_CARD_SEND_CMD_ETH: { - mark_event_over(); - } break; - - case RECV_TXN_READ_DEVICE_SHARE_ETH: { - mark_event_over(); - } break; - - case RECV_TXN_DERIVE_ADD_SCREEN_ETH: { - instruction_scr_init("", NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case RECV_TXN_DERIVE_ADD_ETH: { - mark_event_over(); - } break; - - case RECV_TXN_DISPLAY_ADDR_ETH: { - instruction_scr_destructor(); - char display[70]; - char address_s[sizeof(receive_transaction_data.address)] = { - '0', 'x', '\0'}; - uint64_t chain_id = receive_transaction_data.network_chain_id; - if (chain_id != HARMONY_MAINNET_CHAIN) - byte_array_to_hex_string( - receive_transaction_data.eth_pubkeyhash, - sizeof(receive_transaction_data.eth_pubkeyhash), - address_s + 2, - sizeof(address_s) - 2); - else - bech32_addr_encode(address_s, - "one", - receive_transaction_data.eth_pubkeyhash, - sizeof(receive_transaction_data.eth_pubkeyhash)); - strncpy(receive_transaction_data.address, - address_s, - sizeof(receive_transaction_data.address)); - snprintf(display, sizeof(display), "%s%s", ui_text_20_spaces, address_s); - address_scr_init(ui_text_receive_on, display, true); // add 0x prefix - } break; - - default: - break; - } - - return; -} diff --git a/src/level_four/core/tasks/receive_transaction_tasks_near.c b/src/level_four/core/tasks/receive_transaction_tasks_near.c deleted file mode 100644 index e1dcfb438..000000000 --- a/src/level_four/core/tasks/receive_transaction_tasks_near.c +++ /dev/null @@ -1,247 +0,0 @@ -/** - * @file receive_transaction_tasks_near.c - * @author Cypherock X1 Team - * @brief Receive transaction for NEAR - * This file contains the implementation of the receive transaction for - *NEAR. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "constant_texts.h" -#include "controller_level_four.h" -#include "flash_api.h" -#include "near_context.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_menu.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *PASSPHRASE; - -extern lv_task_t *timeout_task; - -extern Receive_Transaction_Data receive_transaction_data; - -void receive_transaction_tasks_near() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_NEAR: { - mark_event_over(); - } break; - - case RECV_TXN_ENTER_PASSPHRASE_NEAR: { - if (!WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = ADD_COINS_VERIFY; - break; - } - input_text_init(PASSPHRASE, - 26, - ui_text_enter_passphrase, - 0, - DATA_TYPE_PASSPHRASE, - 64); - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_NEAR: { - char display[65]; - snprintf( - display, sizeof(display), "%s", flow_level.screen_input.input_text); - address_scr_init(ui_text_confirm_passphrase, display, false); - memzero(display, sizeof(display)); - } break; - - case RECV_TXN_CHECK_PIN_NEAR: { - mark_event_over(); - } break; - - case RECV_TXN_ENTER_PIN_NEAR: { - // TODO: Redundant check - if (!WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = RECV_TXN_CHECK_PIN_NEAR; - break; - } - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - } break; - - case RECV_TXN_TAP_CARD_NEAR: { - // TODO: Shorten func name - tap_threshold_cards_for_reconstruction(); - } break; - - case RECV_TXN_TAP_CARD_SEND_CMD_NEAR: { - mark_event_over(); - } break; - - case RECV_TXN_READ_DEVICE_SHARE_NEAR: { - mark_event_over(); - } break; - - case RECV_TXN_DERIVE_ADD_SCREEN_NEAR: { - instruction_scr_init("", NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case RECV_TXN_DERIVE_ADD_NEAR: { - mark_event_over(); - } break; - - case RECV_TXN_WAIT_FOR_LINK_NEAR: { - instruction_scr_change_text(ui_text_waiting_for_desktop, true); - mark_event_over(); - } break; - - case RECV_TXN_DISPLAY_ACC_NEAR: { - char display[110]; - snprintf(display, - sizeof(display), - "%s%s%s", - ui_text_20_spaces, - ui_text_20_spaces, - receive_transaction_data.near_registered_account); - address_scr_init(ui_text_new_account_id, display, true); - } break; - - case RECV_TXN_DISPLAY_ADDR_NEAR: { - char display[110]; - char heading[20] = {0}; - snprintf(heading, sizeof(heading), "%s", ui_text_receive_on); - char address_s[2 * sizeof(receive_transaction_data.near_pubkey) + 1] = - "ed25519:"; - if (receive_transaction_data.near_account_type == 1) { - if (receive_transaction_data.near_acc_found) { - memcpy(address_s, - receive_transaction_data.near_registered_account, - sizeof(receive_transaction_data.near_registered_account)); - } else { - size_t sz = sizeof(address_s) - 8; - b58enc(address_s + 8, &sz, receive_transaction_data.near_pubkey, 32); - snprintf(heading, sizeof(heading), "%s", ui_text_new_public_key); - } - } else { - byte_array_to_hex_string(receive_transaction_data.near_pubkey, - sizeof(receive_transaction_data.near_pubkey), - address_s, - sizeof(address_s)); - } - snprintf(display, - sizeof(display), - "%s%s%s", - ui_text_20_spaces, - ui_text_20_spaces, - address_s); - - address_scr_init(heading, display, true); - - } break; - - case RECV_TXN_WAIT_FOR_REPLACE_NEAR_SCREEN: { - instruction_scr_init(ui_text_waiting_for_desktop, NULL); - mark_event_over(); - } break; - - case RECV_TXN_WAIT_FOR_REPLACE_NEAR: { - mark_event_over(); - } break; - - case RECV_TXN_SELECT_REPLACE_ACC_NEAR: { - char *acc_id[NEAR_REGISTERED_ACCOUNT_COUNT] = {0}; - - near_deserialize_account_ids(coin_specific_data.coin_data, - NEAR_COIN_DATA_MAX_LEN, - acc_id, - receive_transaction_data.near_acc_count); - - menu_init((const char **)acc_id, - NEAR_REGISTERED_ACCOUNT_COUNT, - ui_text_replace_account, - true); - - } break; - - case RECV_TXN_VERIFY_SAVE_ACC_NEAR: { - receive_transaction_data.near_acc_index = - flow_level.screen_input.list_choice - 1; - - char *acc_id[NEAR_REGISTERED_ACCOUNT_COUNT] = {0}; - - near_deserialize_account_ids(coin_specific_data.coin_data, - NEAR_COIN_DATA_MAX_LEN, - acc_id, - receive_transaction_data.near_acc_count); - - address_scr_init(ui_text_confirm_account, - acc_id[receive_transaction_data.near_acc_index], - false); - - } break; - - case RECV_TXN_FINAL_SCREEN_NEAR: { - // this exists to handle multiple exit points in near's receive flow - mark_event_over(); - } break; - - default: - break; - } - return; -} diff --git a/src/level_four/core/tasks/receive_transaction_tasks_solana.c b/src/level_four/core/tasks/receive_transaction_tasks_solana.c deleted file mode 100644 index cce3b3671..000000000 --- a/src/level_four/core/tasks/receive_transaction_tasks_solana.c +++ /dev/null @@ -1,156 +0,0 @@ -/** - * @file receive_transaction_tasks_solana.c - * @author Cypherock X1 Team - * @brief Receive transaction task for SOLANA. - * This file contains the implementation of the receive transaction - *task for SOLANA. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "communication.h" -#include "constant_texts.h" -#include "controller_level_four.h" -#include "flash_api.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_menu.h" -#include "utils.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *PASSPHRASE; - -extern Receive_Transaction_Data receive_transaction_data; - -void receive_transaction_tasks_solana() { - switch (flow_level.level_three) { - case RECV_TXN_FIND_XPUB_SOLANA: { - mark_event_over(); - } break; - - case RECV_TXN_ENTER_PASSPHRASE_SOLANA: { - if (!WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = ADD_COINS_VERIFY; - break; - } - input_text_init(PASSPHRASE, - 26, - ui_text_enter_passphrase, - 0, - DATA_TYPE_PASSPHRASE, - 64); - } break; - - case RECV_TXN_CONFIRM_PASSPHRASE_SOLANA: { - char display[65] = {0}; - snprintf( - display, sizeof(display), "%s", flow_level.screen_input.input_text); - address_scr_init(ui_text_confirm_passphrase, display, false); - memzero(display, sizeof(display)); - } break; - - case RECV_TXN_CHECK_PIN_SOLANA: { - mark_event_over(); - } break; - - case RECV_TXN_ENTER_PIN_SOLANA: { - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - } break; - - case RECV_TXN_TAP_CARD_SOLANA: { - retrieve_key_from_card(); - } break; - - case RECV_TXN_TAP_CARD_SEND_CMD_SOLANA: { - mark_event_over(); - } break; - - case RECV_TXN_READ_DEVICE_SHARE_SOLANA: { - mark_event_over(); - } break; - - case RECV_TXN_DERIVE_ADD_SCREEN_SOLANA: { - instruction_scr_init(ui_text_processing, NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case RECV_TXN_DERIVE_ADD_SOLANA: { - mark_event_over(); - } break; - - case RECV_TXN_DISPLAY_ADDR_SOLANA: { - instruction_scr_destructor(); - char display[70] = {0}; - snprintf(display, - sizeof(display), - "%s%s", - ui_text_20_spaces, - receive_transaction_data.solana_address); - address_scr_init(ui_text_receive_on, display, true); - } break; - - default: - break; - } - - return; -} diff --git a/src/level_four/core/tasks/send_transaction_tasks_eth.c b/src/level_four/core/tasks/send_transaction_tasks_eth.c deleted file mode 100644 index ae0685458..000000000 --- a/src/level_four/core/tasks/send_transaction_tasks_eth.c +++ /dev/null @@ -1,326 +0,0 @@ -/** - * @file send_transaction_tasks_eth.c - * @author Cypherock X1 Team - * @brief Send transaction for ETH. - * This file contains functions to send transaction for ETH. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_level_four.h" -#include "eth.h" -#include "harmony.h" -#include "math.h" -#include "segwit_addr.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_message.h" -#include "ui_scroll_page.h" -#include "utils.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *PASSPHRASE; - -extern lv_task_t *timeout_task; -extern ui_display_node *current_display_node; - -void send_transaction_tasks_eth() { - switch (flow_level.level_three) { - case SEND_TXN_VERIFY_COIN_ETH: { - instruction_scr_init("", NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SEND_TXN_UNSIGNED_TXN_WAIT_SCREEN_ETH: { - mark_event_over(); - } break; - - case SEND_TXN_VERIFY_CONTRACT_ADDRESS: { - char address[43]; - address[0] = '0'; - address[1] = 'x'; - char top_heading[55]; - char display[70]; - - instruction_scr_destructor(); - byte_array_to_hex_string(eth_unsigned_txn_ptr.to_address, - 20, - address + 2, - sizeof(address) - 2); - snprintf(top_heading, sizeof(top_heading), "%s", ui_text_verify_contract); - snprintf(display, sizeof(display), "%s%s", ui_text_20_spaces, address); - address_scr_init(top_heading, display, true); - } break; - - case SEND_TXN_VERIFY_TXN_NONCE_ETH: { - char nonce_hex_str[ETH_NONCE_SIZE_BYTES * 2 + 1] = {'\0'}; - uint8_t nonce_dec_str[ETH_NONCE_SIZE_BYTES * 3] = {0}; - uint16_t nonce_dec_len = sizeof(nonce_dec_str), nonce_hex_len; - int index, offset; - nonce_hex_len = - byte_array_to_hex_string(eth_unsigned_txn_ptr.nonce, - eth_unsigned_txn_ptr.nonce_size[0], - nonce_hex_str, - sizeof(nonce_hex_str)); - convertbase16tobase10( - nonce_hex_len - 1, nonce_hex_str, nonce_dec_str, nonce_dec_len); - // Loop till 2nd last index; to handle "0" nonce value by generalising for - // 1 digit nonce values - for (index = 0; index < nonce_dec_len - 1; index++) - if (nonce_dec_str[index] != 0) - break; - for (offset = index; index < nonce_dec_len; index++) - nonce_dec_str[index - offset] = nonce_dec_str[index] + '0'; - ASSERT((index > offset) && ((index - offset) < nonce_dec_len)); - nonce_dec_str[index - offset] = '\0'; - instruction_scr_destructor(); - address_scr_init("Verify nonce", (char *)nonce_dec_str, false); - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_ETH: { - instruction_scr_destructor(); - char address[43]; - address[0] = '0'; - address[1] = 'x'; - char top_heading[225]; - uint8_t address_bytes[20]; - char display[70]; - uint64_t chain_id = - var_send_transaction_data.transaction_metadata.network_chain_id; - uint8_t is_harmony_hrp = - var_send_transaction_data.transaction_metadata.is_harmony_address; - - instruction_scr_destructor(); - if (is_harmony_hrp == 0 || (chain_id != HARMONY_MAINNET_CHAIN)) - byte_array_to_hex_string(address_bytes, - sizeof(address_bytes), - address + 2, - sizeof(address) - 2); - else - bech32_addr_encode( - address, "one", address_bytes, sizeof(address_bytes)); - snprintf(top_heading, sizeof(top_heading), "%s", ""); - snprintf(display, sizeof(display), "%s%s", ui_text_20_spaces, address); - address_scr_init(top_heading, display, true); - } break; - - case SEND_TXN_CALCULATE_AMOUNT_ETH: { - instruction_scr_init("", NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SEND_TXN_VERIFY_RECEIPT_AMOUNT_ETH: { - char amount_string[65] = {'\0'}, amount_decimal_string[30] = {'\0'}; - char display[110] = {'\0'}; - memzero(amount_string, sizeof(amount_string)); - uint8_t len = 0, i = 0, j = 0; - - uint8_t decimal_val_s[ETH_VALUE_SIZE_BYTES * 3] = {0}; - if (sizeof(decimal_val_s) / sizeof(decimal_val_s[0]) > UINT8_MAX) { - LOG_ERROR("0xxx#"); - break; - } - const uint8_t dec_val_len = - sizeof(decimal_val_s) / - sizeof(decimal_val_s[0]); // logbase10(2pow256) roughly equals 78 - convertbase16tobase10(len, amount_string, decimal_val_s, dec_val_len); - bool pre_dec_digit = false, post_dec_digit = false; - uint8_t offset = 0; - log_hex_array("eth value: ", (uint8_t *)amount_string, len); - uint8_t point_index = dec_val_len - 0; - i = 0; - j = dec_val_len - 1; - - while (i <= j) { - if (i == point_index && post_dec_digit) { - if (!pre_dec_digit) { - offset += snprintf(amount_decimal_string + offset, - sizeof(amount_decimal_string) - offset, - "0"); - } - offset += snprintf(amount_decimal_string + offset, - sizeof(amount_decimal_string) - offset, - "."); - } - if (j >= point_index) { - if (!decimal_val_s[j] && !post_dec_digit) { - j--; - } else if (decimal_val_s[j]) { - post_dec_digit = true; - } - } - if (decimal_val_s[i] || i == point_index) { - pre_dec_digit = true; - } - if (pre_dec_digit || decimal_val_s[i]) { - // attach non zero leading value detected or decimal digits till - // j(should be the last non zero decimal digit index). - offset += snprintf(amount_decimal_string + offset, - sizeof(amount_decimal_string) - offset, - "%d", - decimal_val_s[i]); - } - i++; - } - if (!post_dec_digit && !pre_dec_digit) { - snprintf(amount_decimal_string, sizeof(amount_decimal_string) - 1, "0"); - } - - instruction_scr_destructor(); - confirm_scr_init(display); - } break; - - case SEND_TXN_VERIFY_RECEIPT_FEES_ETH: { - char display[125] = {0}, fee[30] = {0}; - - instruction_scr_destructor(); - eth_get_fee_string(ð_unsigned_txn_ptr, fee, sizeof(fee), ETH_DECIMAL); - snprintf(display, sizeof(display), UI_TEXT_SEND_TXN_FEE, fee, ""); - confirm_scr_init(display); - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_ETH: { - mark_event_over(); - } break; - - case SEND_TXN_DISPLAY_INFO_ETH: { - instruction_scr_destructor(); - if (current_display_node == NULL) - mark_event_over(); - else - ui_scrollable_page(current_display_node->title, - current_display_node->value, - MENU_SCROLL_HORIZONTAL, - false); - } break; - - case SEND_TXN_ENTER_PASSPHRASE_ETH: { - if (!WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_ETH; - break; - } - input_text_init(PASSPHRASE, - 26, - ui_text_enter_passphrase, - 0, - DATA_TYPE_PASSPHRASE, - 64); - - } break; - - case SEND_TXN_CONFIRM_PASSPHRASE_ETH: { - char display[65]; - snprintf( - display, sizeof(display), "%s", flow_level.screen_input.input_text); - address_scr_init(ui_text_confirm_passphrase, display, false); - memzero(display, sizeof(display)); - } break; - - case SEND_TXN_CHECK_PIN_ETH: { - mark_event_over(); - } break; - - case SEND_TXN_ENTER_PIN_ETH: { - if (!WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = SEND_TXN_CHECK_PIN_ETH; - break; - } - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - - } break; - - case SEND_TXN_TAP_CARD_ETH: { - tap_threshold_cards_for_reconstruction(); - } break; - - case SEND_TXN_TAP_CARD_SEND_CMD_ETH: { - instruction_scr_init("", NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SEND_TXN_READ_DEVICE_SHARE_ETH: { - mark_event_over(); - } break; - - case SEND_TXN_SIGN_TXN_ETH: { - mark_event_over(); - } break; - - case SEND_TXN_WAITING_SCREEN_ETH: { - mark_event_over(); - } break; - - case SEND_TXN_FINAL_SCREEN_ETH: - delay_scr_init(ui_text_exported_signed_transaction_to_desktop, - DELAY_TIME); - CY_Reset_Not_Allow(true); - break; - - default: - break; - } -} diff --git a/src/level_four/core/tasks/send_transaction_tasks_solana.c b/src/level_four/core/tasks/send_transaction_tasks_solana.c deleted file mode 100644 index 874160d68..000000000 --- a/src/level_four/core/tasks/send_transaction_tasks_solana.c +++ /dev/null @@ -1,260 +0,0 @@ -/** - * @file send_transaction_tasks_solana.c - * @author Cypherock X1 Team - * @brief Send transaction for SOLANA. - * This file contains functions to send transaction for SOLANA. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_level_four.h" -#include "int-util.h" -#include "math.h" -#include "solana.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_message.h" -#include "utils.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *PASSPHRASE; - -extern lv_task_t *timeout_task; - -void send_transaction_tasks_solana() { - switch (flow_level.level_three) { - case SEND_TXN_VERIFY_COIN_SOLANA: { - instruction_scr_init(ui_text_processing, NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SEND_TXN_UNSIGNED_TXN_WAIT_SCREEN_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_UNSIGNED_TXN_RECEIVED_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_VERIFY_CONTRACT_ADDRESS: { - mark_event_over(); - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_SOLANA: { - instruction_scr_destructor(); - char address[45] = {0}; - char top_heading[225] = {0}; - char display[70] = {0}; - - instruction_scr_destructor(); - size_t address_size = sizeof(address); - b58enc(address, - &address_size, - solana_unsigned_txn_ptr.instruction.program.transfer - .recipient_account, - SOLANA_ACCOUNT_ADDRESS_LENGTH); - snprintf(top_heading, sizeof(top_heading), "%s", ui_text_verify_address); - snprintf(display, sizeof(display), "%s%s", ui_text_20_spaces, address); - address_scr_init(top_heading, display, true); - } break; - - case SEND_TXN_CALCULATE_AMOUNT_SOLANA: { - instruction_scr_init(ui_text_processing, NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SEND_TXN_VERIFY_RECEIPT_AMOUNT_SOLANA: { - char amount_string[40] = {'\0'}, amount_decimal_string[30] = {'\0'}; - char display[110] = {'\0'}; - uint8_t be_lamports[8] = {0}; - int i = 8; - while (i--) - be_lamports[i] = - solana_unsigned_txn_ptr.instruction.program.transfer.lamports >> - 8 * (7 - i); - byte_array_to_hex_string( - be_lamports, 8, amount_string, sizeof(amount_string)); - if (!convert_byte_array_to_decimal_string(16, - solana_get_decimal(), - amount_string, - amount_decimal_string, - sizeof(amount_decimal_string))) - break; - instruction_scr_destructor(); - snprintf(display, - sizeof(display), - UI_TEXT_VERIFY_AMOUNT, - amount_decimal_string, - ""); - confirm_scr_init(display); - } break; - - case SEND_TXN_VERIFY_RECEIPT_FEES_SOLANA: { - char amount_string[40] = {'\0'}, amount_decimal_string[30] = {'\0'}; - char display[110] = {'\0'}; - byte_array_to_hex_string((const uint8_t *)var_send_transaction_data - .transaction_metadata.transaction_fees, - 8, - amount_string, - sizeof(amount_string)); - uint8_t decimal_val_s[32 * 3] = {0}; - - if (sizeof(decimal_val_s) / sizeof(decimal_val_s[0]) > UINT8_MAX) { - LOG_ERROR("0xxx#"); - break; - } - - if (!convert_byte_array_to_decimal_string(16, - solana_get_decimal(), - amount_string, - amount_decimal_string, - sizeof(amount_decimal_string))) - break; - instruction_scr_destructor(); - snprintf(display, - sizeof(display), - UI_TEXT_VERIFY_AMOUNT, - amount_decimal_string, - ""); - confirm_scr_init(display); - } break; - - case SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_ENTER_PASSPHRASE_SOLANA: { - if (!WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = - SEND_TXN_VERIFY_RECEIPT_ADDRESS_SEND_CMD_SOLANA; - break; - } - input_text_init(PASSPHRASE, - 26, - ui_text_enter_passphrase, - 0, - DATA_TYPE_PASSPHRASE, - 64); - - } break; - - case SEND_TXN_CONFIRM_PASSPHRASE_SOLANA: { - char display[65]; - snprintf( - display, sizeof(display), "%s", flow_level.screen_input.input_text); - address_scr_init(ui_text_confirm_passphrase, display, false); - memzero(display, sizeof(display)); - } break; - - case SEND_TXN_CHECK_PIN_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_ENTER_PIN_SOLANA: { - if (!WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = SEND_TXN_CHECK_PIN_SOLANA; - break; - } - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - - } break; - - case SEND_TXN_TAP_CARD_SOLANA: { - tap_threshold_cards_for_reconstruction(); - } break; - - case SEND_TXN_TAP_CARD_SEND_CMD_SOLANA: { - instruction_scr_init(ui_text_processing, NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SEND_TXN_UPDATE_BLOCKHASH_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_READ_DEVICE_SHARE_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_SIGN_TXN_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_WAITING_SCREEN_SOLANA: { - mark_event_over(); - } break; - - case SEND_TXN_FINAL_SCREEN_SOLANA: - delay_scr_init(ui_text_exported_signed_transaction_to_desktop, - DELAY_TIME); - CY_Reset_Not_Allow(true); - break; - - default: - break; - } -} diff --git a/src/level_four/core/tasks/sign_message_tasks_eth.c b/src/level_four/core/tasks/sign_message_tasks_eth.c deleted file mode 100644 index 8f25ccacd..000000000 --- a/src/level_four/core/tasks/sign_message_tasks_eth.c +++ /dev/null @@ -1,178 +0,0 @@ -/** - * @file sign_message_tasks_eth.c - * @author Cypherock X1 Team - * @brief Sign message for ETH. - * This file contains functions to send transaction for ETH. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_level_four.h" -#include "int-util.h" -#include "math.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_message.h" -#include "ui_scroll_page.h" -#include "utils.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *PASSPHRASE; - -extern lv_task_t *timeout_task; -extern ui_display_node *current_display_node; - -void sign_message_tasks_eth() { - switch (flow_level.level_three) { - case SIGN_MSG_VERIFY_COIN_ETH: { - instruction_scr_init("", NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SIGN_MSG_RAW_MSG_WAIT_SCREEN_ETH: { - mark_event_over(); - } break; - - case SIGN_MSG_DISPLAY_INFO_ETH: { - instruction_scr_destructor(); - if (current_display_node == NULL) - mark_event_over(); - else - ui_scrollable_page(current_display_node->title, - current_display_node->value, - MENU_SCROLL_HORIZONTAL, - false); - } break; - - case SIGN_MSG_CHECK_PASSPHRASE_ETH: { - mark_event_over(); - } break; - - case SIGN_MSG_ENTER_PASSPHRASE_ETH: { - if (!WALLET_IS_PASSPHRASE_SET(wallet.wallet_info)) { - flow_level.level_three = SIGN_MSG_CHECK_PIN_ETH; - break; - } - input_text_init(PASSPHRASE, - 26, - ui_text_enter_passphrase, - 0, - DATA_TYPE_PASSPHRASE, - 64); - - } break; - - case SIGN_MSG_CONFIRM_PASSPHRASE_ETH: { - char display[65]; - snprintf( - display, sizeof(display), "%s", flow_level.screen_input.input_text); - address_scr_init(ui_text_confirm_passphrase, display, false); - memzero(display, sizeof(display)); - } break; - - case SIGN_MSG_CHECK_PIN_ETH: { - mark_event_over(); - } break; - - case SIGN_MSG_ENTER_PIN_ETH: { - if (!WALLET_IS_PIN_SET(wallet.wallet_info)) { - flow_level.level_three = SIGN_MSG_CHECK_PIN_ETH; - break; - } - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - - } break; - - case SIGN_MSG_TAP_CARD_ETH: { - tap_threshold_cards_for_reconstruction(); - } break; - - case SIGN_MSG_TAP_CARD_SEND_CMD_ETH: { - instruction_scr_init("", NULL); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case SIGN_MSG_READ_DEVICE_SHARE_ETH: { - mark_event_over(); - } break; - - case SIGN_MSG_SIGN_TXN_ETH: { - mark_event_over(); - } break; - - case SIGN_MSG_WAITING_SCREEN_ETH: { - mark_event_over(); - } break; - - case SIGN_MSG_FINAL_SCREEN_ETH: - delay_scr_init(ui_text_exported_signed_transaction_to_desktop, - DELAY_TIME); - CY_Reset_Not_Allow(true); - break; - - default: - break; - } -} diff --git a/src/level_four/core/tasks/tasks_level_four.h b/src/level_four/core/tasks/tasks_level_four.h deleted file mode 100644 index d3ba89b50..000000000 --- a/src/level_four/core/tasks/tasks_level_four.h +++ /dev/null @@ -1,123 +0,0 @@ -/** - * @file tasks_level_four.h - * @author Cypherock X1 Team - * @brief Header for level four tasks. - * This file contains all the functions prototypes for level four - * tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ -#ifndef TASKS_LEVEL_FOUR_H -#define TASKS_LEVEL_FOUR_H - -#pragma once - -#include "coin_utils.h" -#include "controller_main.h" -#include "eth.h" -#include "tasks.h" - -extern evm_unsigned_txn eth_unsigned_txn_ptr; -extern uint8_t challenge_no[32]; - -/** - * @brief This task is executed for processing and signing unsigned transaction - * of Ethereum. - * @details - * - * @see - * @since v1.0.0 - */ -void send_transaction_tasks_eth(); - -/** - * @brief This task is executed for processing and signing unsigned transaction - * of Ethereum. - * - */ -void sign_message_tasks_eth(); - -/** - * @brief This task is executed for processing and signing unsigned transaction. - */ -void send_transaction_tasks_solana(); - -/** - * @brief This task is executed for generating address using xpub for Ethereum. - * @details - * - * @see - * @since v1.0.0 - */ -void receive_transaction_tasks_eth(); - -/** - * @brief This task is executed for handling near registered accounts and - * generating near implicit account. - * @details - * - * @see - * @since v1.0.0 - */ -void receive_transaction_tasks_near(); - -/** - * @brief This task is executed for generating solana address using the public - * key - * @details - * - * @see - * @since v1.0.0 - */ -void receive_transaction_tasks_solana(); - -/** - * @brief This task is executed for verifying wallet added or restored - * on the device and cards. - * @details - * - * @see - * @since v1.0.0 - */ -void verify_wallet_tasks(); - -/** - * @brief Device provision task handler - * @details - * - * @see - * @since v1.0.0 - */ -void task_device_provision(); - -/** - * @brief This task is executed when the name of a wallet is clicked - * and it is locked. - * @details - * - * @see - * @since v1.0.0 - */ -void wallet_locked_task(); - -/** - * @brief This task is executed for verifying card. - * @details - * - * @see - * @since v1.0.0 - */ -void verify_card_task(); - -/** - * @brief This task is executed for upgrading cards. - * @details - * - * @see - * @since v1.0.0 - */ -void card_upgrade_task(); - -#endif \ No newline at end of file diff --git a/src/level_four/core/tasks/verify_wallet_task.c b/src/level_four/core/tasks/verify_wallet_task.c deleted file mode 100644 index 81018b3b0..000000000 --- a/src/level_four/core/tasks/verify_wallet_task.c +++ /dev/null @@ -1,134 +0,0 @@ -/** - * @file verify_wallet_task.c - * @author Cypherock X1 Team - * @brief Verify wallet task. - * This file contains the implementation of the verify wallet task. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "bip39.h" -#include "controller_main.h" -#include "flash_api.h" -#include "shamir_wrapper.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_list.h" -#include "ui_message.h" -#include "ui_multi_instruction.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; - -extern Wallet_shamir_data wallet_shamir_data; -extern Wallet_credential_data wallet_credential_data; - -void verify_wallet_tasks() { - switch (flow_level.level_three) { - case VERIFY_WALLET_START: - mark_event_over(); - break; - - case VERIFY_WALLET_PIN_INPUT: - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - break; - - case VERIFY_WALLET_TAP_CARDS_FLOW: - tap_cards_for_verification_flow(); - break; - - case VERIFY_WALLET_DATA: { - instruction_scr_init(ui_text_processing, ""); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - } break; - - case VERIFY_WALLET_SUCCESS: { - instruction_scr_destructor(); - const char *messages[6] = { - ui_text_verification_is_now_complete_messages[0], - ui_text_verification_is_now_complete_messages[1], - ui_text_verification_is_now_complete_messages[2], - ui_text_verification_is_now_complete_messages[4], - ui_text_verification_is_now_complete_messages[5], - NULL}; - uint8_t count = 5; - - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - messages[3] = ui_text_verification_is_now_complete_messages[3]; - messages[4] = ui_text_verification_is_now_complete_messages[4]; - messages[5] = ui_text_verification_is_now_complete_messages[5]; - count = 6; - } - - multi_instruction_init(messages, count, DELAY_LONG_STRING, true); - } break; - - case VERIFY_WALLET_DELETE: - instruction_scr_destructor(); - address_scr_init(ui_text_verification_cancelled, - (char *)ui_text_delete_this_wallet, - false); - break; - - default: - break; - } -} diff --git a/src/level_four/core/tasks/wallet_locked_tasks.c b/src/level_four/core/tasks/wallet_locked_tasks.c deleted file mode 100644 index 1ef6b66dd..000000000 --- a/src/level_four/core/tasks/wallet_locked_tasks.c +++ /dev/null @@ -1,129 +0,0 @@ -/** - * @file wallet_locked_tasks.c - * @author Cypherock X1 Team - * @brief Wallet unlock task. - * This file contains the implementation of wallet unlock task. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "pow.h" -#include "pow_utilities.h" -#include "tasks_level_four.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_text_slideshow.h" - -extern Flow_level flow_level; -extern Counter counter; -extern Wallet wallet; -extern char *ALPHA_NUMERIC; - -void wallet_locked_task() { - switch (flow_level.level_three) { - case WALLET_LOCKED_MESSAGE: { - char slideshow[2][MAX_NUM_OF_CHARS_IN_A_SLIDE]; - uint8_t wallet_index; - - get_index_by_name((const char *)wallet.wallet_name, &wallet_index); - - convert_secs_to_time(get_wallet_time_to_unlock(wallet_index), - (char *)wallet.wallet_name, - slideshow[0]); - snprintf(slideshow[1], - sizeof(slideshow[1]), - "Multiple incorrect attempts may block %s", - wallet.wallet_name); - char *temp[3] = { - slideshow[0], (char *)ui_text_do_not_detach_device, slideshow[1]}; - ui_text_slideshow_init((const char **)temp, 3, DELAY_TIME, false); - start_proof_of_work_task((const char *)wallet.wallet_name); - - } break; - - case WALLET_LOCKED_ENTER_PIN: - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - break; - - case WALLET_LOCKED_TAP_CARD_FRONTEND: { - Flash_Wallet *flash_wallet; - get_flash_wallet_by_name((const char *)wallet.wallet_name, &flash_wallet); - - char msg[32]; - snprintf(msg, - sizeof(msg), - UI_TEXT_TAP_CARD, - decode_card_number(flash_wallet->challenge.card_locked)); - - instruction_scr_init(msg, NULL); - mark_event_over(); - } break; - - case WALLET_LOCKED_TAP_CARD_BACKEND: - mark_event_over(); - break; - - case WALLET_LOCKED_SUCCESS: { - char msg[50]; - snprintf(msg, - sizeof(msg), - "Correct PIN! %s is now unlocked", - wallet.wallet_name); - delay_scr_init(msg, DELAY_TIME); - } break; - - default: - break; - } -} \ No newline at end of file diff --git a/src/level_four/tap_cards/controller/card_action_controllers.h b/src/level_four/tap_cards/controller/card_action_controllers.h deleted file mode 100644 index 682fbc993..000000000 --- a/src/level_four/tap_cards/controller/card_action_controllers.h +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @file card_action_controllers.h - * @author Cypherock X1 Team - * @brief Header for card action controllers. - * This file contains the declaration of the card action controllers. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ -#ifndef CONTROLLER_CARD_ACTIONS -#define CONTROLLER_CARD_ACTIONS -#include - -void readback_share_from_card(uint8_t xcor); - -int verify_card_share_data(); - -#endif \ No newline at end of file diff --git a/src/level_four/tap_cards/controller/controller_tap_cards.c b/src/level_four/tap_cards/controller/controller_tap_cards.c deleted file mode 100644 index dcf1c57ac..000000000 --- a/src/level_four/tap_cards/controller/controller_tap_cards.c +++ /dev/null @@ -1,305 +0,0 @@ -/** - * @file controller_tap_cards.c - * @author Cypherock X1 Team - * @brief Tap card next controller. - * This file contains the functions to control the tap card next - *controller. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "controller_tap_cards.h" - -#include "app_error.h" -#include "nfc.h" -#include "tasks.h" -#include "ui_instruction.h" - -NFC_connection_data tap_card_data; - -bool tap_card_applet_connection() { - uint8_t acceptable_cards; - tap_card_data.recovery_mode = 0; - if (tap_card_data.desktop_control) { - nfc_set_early_exit_handler(&cy_exit_flow); - CY_Reset_Not_Allow(false); - } else { - nfc_set_early_exit_handler(NULL); - } - if (!tap_card_data.card_absent_retries) { - tap_card_data.card_absent_retries = 100; - } - - while (1) { - if (nfc_select_card() != - STM_SUCCESS) // Stuck here until card is detected - return false; - - instruction_scr_change_text(ui_text_card_detected, true); - - acceptable_cards = tap_card_data.acceptable_cards; - tap_card_data.status = nfc_select_applet(tap_card_data.family_id, - &tap_card_data.acceptable_cards, - NULL, - tap_card_data.card_key_id, - &tap_card_data.recovery_mode); - - /* Card is in recovery mode. This is a critical situation. Instruct user to - * safely recover/export wallets to different set of cards in limited - * attempts. NOTE: Errors such as invalid card & invalid family id have - * higher priority than this. - */ - if (tap_card_data.recovery_mode == 1) - mark_error_screen(ui_critical_card_health_migrate_data); - - /* The tapped_card information should be persistent, as it is used at later - * stage in the flow For example, in the second half of card-verification, - * the card tapped in first half becomes the acceptable card for that half. - * It is the knowledge of previous round of card tapping, hence it's update - * should happen only here or at the fresh start of a card tap flow. */ - tap_card_data.tapped_card = - (acceptable_cards ^ tap_card_data.acceptable_cards); - - if (tap_card_data.status == SW_NO_ERROR) { -#if X1WALLET_MAIN - tap_card_data.keystore_index = - get_paired_card_index(tap_card_data.card_key_id); - if (false) { - tap_card_take_to_pairing(); - return false; - } -#endif - const uint8_t *pairing_key = - get_keystore_pairing_key(tap_card_data.keystore_index); - if (tap_card_data.keystore_index >= 0) - init_session_keys(pairing_key, pairing_key + 32, NULL); - return true; - } else if (tap_card_data.status == SW_CONDITIONS_NOT_SATISFIED) { - mark_error_screen(ui_text_wrong_card_sequence); - } else if (tap_card_data.status == SW_FILE_INVALID) { - mark_error_screen(ui_text_family_id_mismatch); - } else if (tap_card_data.status == SW_FILE_NOT_FOUND) { - mark_error_screen(ui_text_corrupted_card_contact_support); - reset_flow_level(); - } else if (tap_card_data.status == SW_INCOMPATIBLE_APPLET) { - mark_error_screen(ui_text_incompatible_card_version); - reset_flow_level(); - } else { - tap_card_data.tapped_card = 0; - tap_card_data.acceptable_cards = acceptable_cards; - if ((tap_card_data.status == NFC_CARD_ABSENT) || - (nfc_diagnose_card_presence() != 0)) { - instruction_scr_change_text(ui_text_card_removed_fast, true); - if ((!--tap_card_data.card_absent_retries)) { - tap_card_data.status = NFC_CARD_ABSENT; - mark_error_screen(ui_text_card_freq_discon_fault); - } - } else if (!(--tap_card_data.retries)) { - mark_error_screen(ui_text_unknown_error_contact_support); - reset_flow_level(); - } else if ((tap_card_data.status & NFC_ERROR_BASE) == NFC_ERROR_BASE) { - instruction_scr_change_text(ui_text_card_align_with_device_screen, - true); - nfc_deselect_card(); - } - } - LOG_ERROR("err (0x%04X)\n", tap_card_data.status); - - if (flow_level.show_error_screen) { - buzzer_start(BUZZER_DURATION); - if (counter.level != - LEVEL_ONE) { // flow not reset, we wanna retry after prompting user - flow_level.level_three = tap_card_data.lvl3_retry_point; - flow_level.level_four = tap_card_data.lvl4_retry_point; - } else { // flow is reset, convey to desktop if needed - if (tap_card_data.desktop_control) - comm_reject_request(tap_card_data.active_cmd_type, 0); - } - instruction_scr_destructor(); - return false; - } - } -} - -bool tap_card_handle_applet_errors() { - LOG_ERROR("err (0x%04X)\n", tap_card_data.status); - switch (tap_card_data.status) { - case SW_NO_ERROR: - return true; - case SW_SECURITY_CONDITIONS_NOT_SATISFIED: - mark_error_screen(ui_text_security_conditions_not_met); - reset_flow_level(); - break; - case SW_NOT_PAIRED: - invalidate_keystore(); - tap_card_take_to_pairing(); - return true; - case SW_CONDITIONS_NOT_SATISFIED: - break; - case SW_WRONG_DATA: - mark_error_screen(ui_text_card_invalid_apdu_length); - reset_flow_level(); - break; - case SW_FILE_FULL: - mark_error_screen(ui_text_card_is_full); - reset_flow_level(); - break; - case SW_RECORD_NOT_FOUND: - tap_card_data.active_cmd_type = WALLET_DOES_NOT_EXISTS_ON_CARD; - mark_error_screen(ui_text_wallet_doesnt_exists_on_this_card); - reset_flow_level(); - break; - case SW_TRANSACTION_EXCEPTION: - mark_error_screen(ui_text_card_transaction_exception); - reset_flow_level(); - break; - case SW_NULL_POINTER_EXCEPTION: - mark_error_screen(ui_text_card_null_pointer_exception); - reset_flow_level(); - break; - case SW_OUT_OF_BOUNDARY: - mark_error_screen(ui_text_card_out_of_boundary_exception); - reset_flow_level(); - break; - case SW_INVALID_INS: - mark_error_screen(ui_text_card_error_contact_support); - reset_flow_level(); - break; - case SW_INS_BLOCKED: - mark_error_screen(ui_critical_card_health_migrate_data); - reset_flow_level(); - break; - default: - if ((tap_card_data.status & 0xFF00) == POW_SW_WALLET_LOCKED) { - uint8_t target[SHA256_SIZE], random_number[POW_RAND_NUMBER_SIZE]; - - tap_card_data.status = - nfc_get_challenge(wallet.wallet_name, target, random_number); - - mark_error_screen(ui_text_wrong_wallet_is_now_locked); - // if (tap_card_data.status == SW_NO_ERROR) - // add_challenge_flash((const char *)wallet.wallet_name, - // target, - // random_number, - // tap_card_data.tapped_card); - tap_card_data.lvl3_retry_point = WALLET_LOCKED_MESSAGE; - flow_level.level_one = LEVEL_TWO_OLD_WALLET; - flow_level.level_two = LEVEL_THREE_WALLET_LOCKED; - decrease_level_counter(); - if (tap_card_data.desktop_control) { - comm_reject_request(WALLET_IS_LOCKED, 0); - CY_Set_External_Triggered(false); - } - } else if ((tap_card_data.status & 0xFF00) == SW_CORRECT_LENGTH_00) { - char error_text[40]; - snprintf(error_text, - sizeof(error_text), - "Incorrect PIN!\n%d attempt(s) remaining", - tap_card_data.status & 0xFF); - mark_error_screen(error_text); - tap_card_data.lvl3_retry_point = flow_level.level_three - 1; - tap_card_data.lvl4_retry_point = 1; - } else if ((tap_card_data.status & 0xFF00) == SW_CRYPTO_EXCEPTION) { - mark_error_screen(ui_text_card_crypto_exception); - reset_flow_level(); - } else { - tap_card_data.tapped_card = 0; - if ((tap_card_data.status == NFC_CARD_ABSENT) || - (nfc_diagnose_card_presence() != 0)) { - instruction_scr_change_text(ui_text_card_removed_fast, true); - if ((!--tap_card_data.card_absent_retries)) { - tap_card_data.status = NFC_CARD_ABSENT; - mark_error_screen(ui_text_card_freq_discon_fault); - } - } else if (!(--tap_card_data.retries)) { - mark_error_screen(ui_text_unknown_error_contact_support); - reset_flow_level(); - } else if ((tap_card_data.status & NFC_ERROR_BASE) == NFC_ERROR_BASE) { - instruction_scr_change_text(ui_text_card_align_with_device_screen, - true); - nfc_deselect_card(); - } - } - break; - } - - if (flow_level.show_error_screen) { - buzzer_start(BUZZER_DURATION); - if (counter.level != - LEVEL_ONE) { // flow not reset, we want to retry after prompting user - flow_level.level_three = tap_card_data.lvl3_retry_point; - flow_level.level_four = tap_card_data.lvl4_retry_point; - } else { // flow is reset, convey to desktop if needed - if (tap_card_data.desktop_control) - comm_reject_request(tap_card_data.active_cmd_type, 0); - } - instruction_scr_destructor(); - return true; - } - - // probably comm failure; guess is NFC teardown; reconnect with applet - // silently retry to connect; can't connect here, cards_state is important - return false; -} - -void tap_card_take_to_pairing() { -#if X1WALLET_MAIN - buzzer_start(BUZZER_DURATION); - mark_error_screen(ui_text_device_and_card_not_paired); - reset_flow_level(); - counter.level = LEVEL_THREE; - flow_level.level_one = LEVEL_TWO_ADVANCED_SETTINGS; - if (tap_card_data.desktop_control) - comm_reject_request(tap_card_data.active_cmd_type, 0); - instruction_scr_destructor(); -#endif -} diff --git a/src/level_four/tap_cards/controller/controller_tap_cards.h b/src/level_four/tap_cards/controller/controller_tap_cards.h deleted file mode 100644 index 782281136..000000000 --- a/src/level_four/tap_cards/controller/controller_tap_cards.h +++ /dev/null @@ -1,202 +0,0 @@ -/** - * @file controller_tap_cards.h - * @author Cypherock X1 Team - * @brief Header for tap card controllers. - * This file contains the declaration of the tap card controllers. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef CONTROLLER_TAP_CARDS_H -#define CONTROLLER_TAP_CARDS_H - -#include "buzzer.h" -#include "controller_main.h" -#include "nfc.h" -#include "sha2.h" -#include "stdbool.h" - -/** - * @brief - * @details - * - * @see - * @since v1.0.0 - * - * @note - */ -typedef struct NFC_connection_data { - uint8_t desktop_control; // TODO: Remove deprecated - uint8_t active_cmd_type; // TODO: Remove deprecated - int8_t keystore_index; - uint8_t acceptable_cards; - uint8_t tapped_card; - uint8_t lvl3_retry_point; // TODO: Remove deprecated - uint8_t lvl4_retry_point; // TODO: Remove deprecated - uint8_t resume_point; // TODO: Remove deprecated - uint8_t retries; - uint8_t family_id[FAMILY_ID_SIZE + - 2]; // TODO: Review(need to find reason for extra byte) - uint8_t card_key_id[4]; - bool pairing_error; - uint8_t recovery_mode; - uint8_t card_absent_retries; - uint8_t *card_version; - bool init_session_keys; - ISO7816 status; -} NFC_connection_data; - -extern NFC_connection_data tap_card_data; - -/** - * @brief Identifies a JavaCard in the field and triggers handshake and X1 - * Applet invocation. - * @details The function handles the JavaCard identification and handshake with - * the X1 Applet. It also identifies certain states of the card and triggers the - * appropriate action if possible. Other critical errors are handled and - * reported in the UI.
This function is responsible for initializing the - * NFC SecureChannel session with the appropriate IV and key.
For scenarios - * like using a X1 Card from a different set or not using the requested card, - * the function informs the user about the situation and continues to retry. - * This happens without any limit on the retry attempts.
If the X1 Card is - * absent right after the handshake, then the user is asked to tap and hold till - * a feedback is received from the buzzer. - * - * @return bool true, false - * @retval true if the card is identified and the handshake is successful. - * @retval false if the card is not identified or the handshake fails. - * - * @see NFC_connection_data, nfc_select_card(), nfc_select_applet(), - * tap_card_handle_applet_errors() - * @since v1.0.0 - * - * @note The tap_card_data structure needs to be initialized accordingly before - * calling this function. - */ -bool tap_card_applet_connection(); - -/** - * @brief A common handler for the X1 Applet and the NFC communication errors. - * @details This is a one place error handler. The application can make a call - * to this for handling the errors, if the application does not receive an - * expected response from the X1 Applet.
The function checks the status - * member of tap_card_data for the error code. This function is supposed to be - * called after making a call to any of the nfc functions. Based on the status, - * the function performs the appropriate action which can be either displaying - * a message to the user, or exiting the process, or retrying or a combination - * of these.
For certain types of errors, the function decrements its retry - * counter. If the counter is zero, then the function exits the process and the - * non-critical error is now considered as critical which is indicated by true. - * - * @return boolean true, false - * @retval true if the error is handled. Application need not retry. - * @retval false if the error is not critical. Application can retry right away. - * - * @see NFC_connection_data, nfc_select_card(), nfc_select_applet(), - * tap_card_applet_connection() - * @since v1.0.0 - * - * @note The tap_card_data structure should be used to store the errors. - * Otherwise the behavior is undefined. - */ -bool tap_card_handle_applet_errors(); - -/** - * @brief - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void tap_cards_for_write_and_verify_flow_controller(); - -/** - * @brief - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void tap_threshold_cards_for_reconstruction_flow_controller(uint8_t threshold); - -/** - * @brief - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void delete_from_cards_controller(); - -/** - * @brief - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void controller_update_card_id(); - -/** - * @brief - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void retrieve_key_from_card_flow_controller(); - -/** - * @brief - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void tap_card_take_to_pairing(); - -#endif diff --git a/src/level_four/tap_cards/controller/retrieve_key_from_card_controllers.c b/src/level_four/tap_cards/controller/retrieve_key_from_card_controllers.c deleted file mode 100644 index eadf42874..000000000 --- a/src/level_four/tap_cards/controller/retrieve_key_from_card_controllers.c +++ /dev/null @@ -1,127 +0,0 @@ -/** - * @file retrieve_key_from_card_controllers.c - * @author Cypherock X1 Team - * @brief Retrieve key from card. - * This file contains the functions to retrieve the key from the card. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "apdu.h" -#include "communication.h" -#include "constant_texts.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "flash_api.h" -#include "nfc.h" -#include "tasks.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern int error_occurred_remaining_tries; -extern Wallet_shamir_data wallet_shamir_data; - -static void _tap_card_backend(uint8_t xcor); -static void _handle_retrieve_wallet_success(uint8_t xcor); - -void retrieve_key_from_card_flow_controller() { - switch (flow_level.level_four) { - case TAP_CARD_ONE_FRONTEND: - tap_card_data.tapped_card = 0; - flow_level.level_four = TAP_CARD_ONE_BACKEND; - break; - - case TAP_CARD_ONE_BACKEND: - _tap_card_backend(0); - break; - default: - break; - } -} - -static void _tap_card_backend(uint8_t xcor) { - tap_card_data.retries = 5; - - while (!CY_Read_Reset_Flow()) { - tap_card_data.acceptable_cards = 15; - memcpy(tap_card_data.family_id, get_family_id(), FAMILY_ID_SIZE); - tap_card_data.lvl3_retry_point = flow_level.level_three; - tap_card_data.lvl4_retry_point = flow_level.level_four - 1; - if (xcor == 0) - tap_card_data.tapped_card = 0; - if (!tap_card_applet_connection()) - return; - tap_card_data.status = nfc_retrieve_wallet(&wallet); - - if (tap_card_data.status == SW_NO_ERROR) { - _handle_retrieve_wallet_success(xcor); - buzzer_start(BUZZER_DURATION); - instruction_scr_destructor(); - break; - } else if (tap_card_handle_applet_errors()) { - break; - } - } -} - -static void _handle_retrieve_wallet_success(uint8_t xcor) { - memcpy(wallet_shamir_data.mnemonic_shares[xcor], - wallet.wallet_share_with_mac_and_nonce, - BLOCK_SIZE); - memzero(wallet.wallet_share_with_mac_and_nonce, - sizeof(wallet.wallet_share_with_mac_and_nonce)); - - wallet_shamir_data.share_x_coords[xcor] = wallet.xcor; - - flow_level.level_three++; - flow_level.level_four = 1; -} diff --git a/src/level_four/tap_cards/controller/tap_one_card_controllers.c b/src/level_four/tap_cards/controller/tap_one_card_controllers.c deleted file mode 100644 index d9422f5a9..000000000 --- a/src/level_four/tap_cards/controller/tap_one_card_controllers.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - * @file tap_one_card_controllers.c - * @author Cypherock X1 Team - * @brief Tap one card controller. - * This file contains the implementation of the tap one card - *controllers. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "apdu.h" -#include "communication.h" -#include "constant_texts.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "flash_api.h" -#include "nfc.h" -#include "pow_utilities.h" -#include "tasks.h" -#include "ui_delay.h" -#include "ui_instruction.h" -#include "utils.h" - -void controller_update_card_id() { - switch (flow_level.level_three) { - case 1: - flow_level.level_three++; - break; - - case 2: - flow_level.level_three++; - break; - - case 3: { - uint8_t send_apdu[10] = {0x00, 0xC7, 0x00, 0x00, 0x05}; - hex_string_to_byte_array( - flow_level.screen_input.input_text, 2 * CARD_ID_SIZE, send_apdu + 5); - - uint8_t recv_apdu[255]; - uint16_t recv_len = 236; - while (1) { - // todo log - nfc_select_card(); // Stuck here until card is detected - // todo log - uint8_t no_restrictions[6] = {DEFAULT_VALUE_IN_FLASH, - DEFAULT_VALUE_IN_FLASH, - DEFAULT_VALUE_IN_FLASH, - DEFAULT_VALUE_IN_FLASH}; - uint8_t all_cards = 15; - nfc_select_applet(no_restrictions, &all_cards, NULL, NULL, NULL); - - if (nfc_exchange_apdu( - send_apdu, sizeof(send_apdu), recv_apdu, &recv_len) == - STM_SUCCESS) { - flow_level.level_three++; - break; - } - } - lv_obj_clean(lv_scr_act()); - } break; - case 4: - reset_flow_level(); - break; - default: - break; - } -} diff --git a/src/level_four/tap_cards/tasks/reconstruct_from_four_cards_to_verify_tasks.c b/src/level_four/tap_cards/tasks/reconstruct_from_four_cards_to_verify_tasks.c deleted file mode 100644 index a03f3c14b..000000000 --- a/src/level_four/tap_cards/tasks/reconstruct_from_four_cards_to_verify_tasks.c +++ /dev/null @@ -1,99 +0,0 @@ -/** - * @file reconstruct_from_four_cards_to_verify_tasks.c - * @author Cypherock X1 Team - * @brief Reconstruct from all cards. - * This file contains the implementation of the function to perform the - * reconstruction of the secret from the four shares of the cards. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_main.h" -#include "stdint.h" -#include "tasks.h" -#include "tasks_tap_cards.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; - -void tap_cards_for_verification_flow() { - char display[40]; - - switch (flow_level.level_four) { - case TAP_CARD_ONE_FRONTEND: - case TAP_CARD_TWO_FRONTEND: - case TAP_CARD_THREE_FRONTEND: - case TAP_CARD_FOUR_FRONTEND: - snprintf(display, - sizeof(display), - UI_TEXT_TAP_CARD, - ((flow_level.level_four - 1) >> 1) + 1); - instruction_scr_init(ui_text_place_card_below, display); - mark_event_over(); - break; - - case TAP_CARD_ONE_BACKEND: - case TAP_CARD_TWO_BACKEND: - case TAP_CARD_THREE_BACKEND: - case TAP_CARD_FOUR_BACKEND: - mark_event_over(); - break; - - default: - message_scr_init(ui_text_something_went_wrong); - break; - } -} diff --git a/src/level_four/tap_cards/tasks/reconstruct_from_threshold_cards_tasks.c b/src/level_four/tap_cards/tasks/reconstruct_from_threshold_cards_tasks.c deleted file mode 100644 index 07837e5d6..000000000 --- a/src/level_four/tap_cards/tasks/reconstruct_from_threshold_cards_tasks.c +++ /dev/null @@ -1,71 +0,0 @@ -/** - * @file reconstruct_from_threshold_cards_tasks.c - * @author Cypherock X1 Team - * @brief Reconstruct from threshold. - * Short description of the file - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_main.h" -#include "tasks.h" -#include "tasks_tap_cards.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; - -void tap_threshold_cards_for_reconstruction() { -} diff --git a/src/level_four/tap_cards/tasks/retrieve_key_from_card_tasks.c b/src/level_four/tap_cards/tasks/retrieve_key_from_card_tasks.c deleted file mode 100644 index f1f8c4551..000000000 --- a/src/level_four/tap_cards/tasks/retrieve_key_from_card_tasks.c +++ /dev/null @@ -1,84 +0,0 @@ -/** - * @file retrieve_key_from_card_tasks.c - * @author Cypherock X1 Team - * @brief Retrieve key task. - * This file contains the retrieve key task. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_main.h" -#include "tasks.h" -#include "tasks_tap_cards.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; - -void retrieve_key_from_card() { - switch (flow_level.level_four) { - case TAP_CARD_ONE_FRONTEND: - instruction_scr_init(ui_text_tap_1_2_cards, NULL); - mark_event_over(); - break; - - case TAP_CARD_ONE_BACKEND: - mark_event_over(); - break; - - default: - break; - } -} diff --git a/src/level_four/tap_cards/tasks/tap_one_card_tasks.c b/src/level_four/tap_cards/tasks/tap_one_card_tasks.c deleted file mode 100644 index ebe34e503..000000000 --- a/src/level_four/tap_cards/tasks/tap_one_card_tasks.c +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file tap_one_card_tasks.c - * @author Cypherock X1 Team - * @brief Tap one card task. - * This file contains the implementation of the tap one card tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "apdu.h" -#include "buzzer.h" -#include "communication.h" -#include "constant_texts.h" -#include "controller_main.h" -#include "flash_api.h" -#include "flash_if.h" -#include "nfc.h" -#include "pow_utilities.h" -#include "tasks.h" -#include "tasks_tap_cards.h" -#include "ui_delay.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_message.h" -#include "utils.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *HEX; - -void tasks_update_card_id() { - switch (flow_level.level_three) { - case 1: { - input_text_init(HEX, 0, ui_text_family_id_hex, 10, DATA_TYPE_TEXT, 8); - } - - break; - - case 2: { - instruction_scr_init(ui_text_tap_a_card, NULL); - mark_event_over(); - } break; - - case 3: { - mark_event_over(); - } break; - - case 4: - message_scr_init(ui_text_successfull); - break; - - default: - break; - } -} diff --git a/src/level_four/tap_cards/tasks/tasks_tap_cards.h b/src/level_four/tap_cards/tasks/tasks_tap_cards.h deleted file mode 100644 index e9b8fe66d..000000000 --- a/src/level_four/tap_cards/tasks/tasks_tap_cards.h +++ /dev/null @@ -1,97 +0,0 @@ -/** - * @file tasks_tap_cards.h - * @author Cypherock X1 Team - * @brief Header for tap card tasks. - * This file contains all the functions prototypes for the tap card - * tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef TASKS_TAP_CARDS_H -#define TASKS_TAP_CARDS_H - -/** - * @brief Task for writing on the card flow , used to add wallet or restore - * wallet on cards - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void tap_cards_for_write_flow(); - -/** - * @brief Task for verification of the card - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void tap_cards_for_verification_flow(); - -/** - * @brief Task to retrieve wallet from card - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void tap_threshold_cards_for_reconstruction(); - -/** - * @brief Task to update card id - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void tasks_update_card_id(); - -/** - * @brief Task to retrieve key from id - * @details - * - * @param - * - * @return - * @retval - * - * @see - * @since v1.0.0 - * - * @note - */ -void retrieve_key_from_card(); - -#endif \ No newline at end of file diff --git a/src/level_four/tap_cards/tasks/write_to_cards_tasks.c b/src/level_four/tap_cards/tasks/write_to_cards_tasks.c deleted file mode 100644 index 12f1a2901..000000000 --- a/src/level_four/tap_cards/tasks/write_to_cards_tasks.c +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @file write_to_cards_tasks.c - * @author Cypherock X1 Team - * @brief Write to cards. - * This file contains the task handler to write to cards. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_main.h" -#include "flash_api.h" -#include "nfc.h" -#include "stdint.h" -#include "tasks.h" -#include "tasks_tap_cards.h" -#include "ui_instruction.h" -#include "ui_message.h" - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; - -void tap_cards_for_write_flow() { - switch (flow_level.level_four) { - case CARD_ONE_FRONTEND: - case CARD_TWO_FRONTEND: - case CARD_THREE_FRONTEND: - case CARD_FOUR_FRONTEND: { - char display[40]; - snprintf(display, - sizeof(display), - UI_TEXT_TAP_CARD, - ((flow_level.level_four - 1) / 3) + 1); - instruction_scr_init(ui_text_place_card_below, display); - mark_event_over(); - } break; - - case CARD_ONE_READBACK: - case CARD_TWO_READBACK: - case CARD_THREE_READBACK: - case CARD_FOUR_READBACK: { - char display[40]; - instruction_scr_destructor(); - snprintf(display, - sizeof(display), - UI_TEXT_TAP_CARD, - flow_level.level_four / 3); - instruction_scr_init(ui_text_place_card_below, display); - if (nfc_wait_for_card(DEFAULT_NFC_TG_INIT_TIME) != STM_SUCCESS) - instruction_scr_change_text(ui_text_card_removed_fast, true); - } - case CARD_ONE_WRITE: - case CARD_TWO_WRITE: - case CARD_THREE_WRITE: - case CARD_FOUR_WRITE: - mark_event_over(); - break; - - default: - LOG_CRITICAL("xx30"); - reset_flow_level(); - message_scr_init(ui_text_something_went_wrong); - break; - } -} diff --git a/src/level_three/add_wallet/controller/controller_add_wallet.h b/src/level_three/add_wallet/controller/controller_add_wallet.h deleted file mode 100644 index 3992d6e7c..000000000 --- a/src/level_three/add_wallet/controller/controller_add_wallet.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file controller_add_wallet.h - * @author Cypherock X1 Team - * @brief Header for add wallet controllers. - * Houses the declarations of controllers for add wallet tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef CONTROLLER_ADD_WALLET_H -#define CONTROLLER_ADD_WALLET_H - -#include "controller_main.h" - -/** - * @brief Controller to add arbitrary data wallet flow - * @details - * - * @see - * @since v1.0.0 - */ -void arbitrary_data_controller(); - -/** - * @brief Back button controller for arbitrary data wallet flow - * @details - * - * @see - * @since v1.0.0 - */ -void arbitrary_data_controller_b(); - -#endif \ No newline at end of file diff --git a/src/level_three/add_wallet/controller/controller_arbitrary_data.c b/src/level_three/add_wallet/controller/controller_arbitrary_data.c deleted file mode 100644 index 7d328f13c..000000000 --- a/src/level_three/add_wallet/controller/controller_arbitrary_data.c +++ /dev/null @@ -1,253 +0,0 @@ -/** - * @file controller_arbitrary_data.c - * @author Cypherock X1 Team - * @brief Arbitrary data next controller. - * Handles post event (only next events) operations for arbitrary data - *flow. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "bip39.h" -#include "card_action_controllers.h" -#include "card_flow_create_wallet.h" -#include "constant_texts.h" -#include "controller_add_wallet.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "sha2.h" -#include "shamir_wrapper.h" -#include "tasks.h" -#include "ui_message.h" -#include "wallet_utilities.h" - -extern Wallet_credential_data wallet_credential_data; -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; - -extern Flash_Wallet wallet_for_flash; -extern char arbitrary_data[4096 / 8 + 1]; - -#ifdef USE_ARBITRARY_DATA -static void restore_wallet_enter_mnemonics_flow_controller() { - if (flow_level.level_four <= wallet.number_of_mnemonics) { - snprintf( - wallet_credential_data.mnemonics[flow_level.level_four - 1], - sizeof(wallet_credential_data.mnemonics[flow_level.level_four - 1]), - "%s", - mnemonic_get_word(flow_level.screen_input.list_choice)); - flow_level.level_four++; - } else { - flow_level.level_three++; - } -} -#endif - -void arbitrary_data_controller() { - switch (flow_level.level_three) { - case ARBITRARY_DATA_NAME_INPUT: { - flow_level.level_three = ARBITRARY_DATA_NAME_CONFIRM; - } break; - case ARBITRARY_DATA_NAME_CONFIRM: { - uint8_t dummy; - if (get_index_by_name(flow_level.screen_input.input_text, &dummy) == - SUCCESS_) { - // wallet already exists - mark_error_screen(ui_text_wallet_name_exists); - } else { - flow_level.level_three = RESTORE_WALLET_PIN_INSTRUCTIONS_1; - snprintf((char *)wallet_for_flash.wallet_name, - sizeof(wallet_for_flash.wallet_name), - "%s", - flow_level.screen_input.input_text); - snprintf((char *)wallet.wallet_name, - sizeof(wallet.wallet_name), - "%s", - flow_level.screen_input.input_text); - } - } break; - case RESTORE_WALLET_PIN_INSTRUCTIONS_1: { - flow_level.level_three = RESTORE_WALLET_PIN_INSTRUCTIONS_2; - } break; - - case RESTORE_WALLET_PIN_INSTRUCTIONS_2: { - flow_level.level_three = ARBITRARY_DATA_SKIP_PIN; - } break; - - case ARBITRARY_DATA_SKIP_PIN: { - flow_level.level_three = ARBITRARY_DATA_PIN_INPUT; - WALLET_SET_PIN(wallet_for_flash.wallet_info); - WALLET_SET_PIN(wallet.wallet_info); - } break; - - case ARBITRARY_DATA_PIN_INPUT: { - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - wallet.password_double_hash); - sha256_Raw(wallet.password_double_hash, - SHA256_DIGEST_LENGTH, - wallet.password_double_hash); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - flow_level.level_three = ARBITRARY_DATA_PIN_CONFIRM; - } break; - - case ARBITRARY_DATA_PIN_CONFIRM: { - uint8_t CONFIDENTIAL temp[SHA256_DIGEST_LENGTH] = {0}; - - ASSERT(temp != NULL); - sha256_Raw((uint8_t *)flow_level.screen_input.input_text, - strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)), - temp); - sha256_Raw(temp, SHA256_DIGEST_LENGTH, temp); - if (memcmp(wallet.password_double_hash, temp, SHA256_DIGEST_LENGTH) == - 0) { - flow_level.level_three = ARBITRARY_DATA_ENTER_DATA_INSTRUCTION; - } else { - mark_error_screen(ui_text_pin_incorrect_re_enter); - flow_level.level_three = ARBITRARY_DATA_PIN_INPUT; - } - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - memzero(temp, sizeof(temp)); - } break; - - case ARBITRARY_DATA_ENTER_DATA_INSTRUCTION: { - flow_level.level_three = ARBITRARY_DATA_ENTER_DATA; - - } break; - - case ARBITRARY_DATA_ENTER_DATA: { - flow_level.level_three = ARBITRARY_DATA_CONFIRM_DATA; - } break; - - case ARBITRARY_DATA_CONFIRM_DATA: { - flow_level.level_three = ARBITRARY_DATA_CREATING_WAIT_SCREEN; - } break; - - case ARBITRARY_DATA_CREATING_WAIT_SCREEN: { - flow_level.level_three = ARBITRARY_DATA_CREATE; - } break; - - case ARBITRARY_DATA_CREATE: { - uint8_t wallet_index, temp_wallet_id[WALLET_ID_SIZE]; - - sha256_Raw((const uint8_t *)arbitrary_data, - strnlen(arbitrary_data, sizeof(arbitrary_data)), - temp_wallet_id); - sha256_Raw(temp_wallet_id, SHA256_DIGEST_LENGTH, temp_wallet_id); - - if ((get_first_matching_index_by_id(temp_wallet_id, &wallet_index) == - DOESNT_EXIST)) { - memcpy(wallet_for_flash.wallet_id, temp_wallet_id, WALLET_ID_SIZE); - memcpy(wallet.wallet_id, wallet_for_flash.wallet_id, WALLET_ID_SIZE); - wallet.arbitrary_data_size = - strnlen(arbitrary_data, sizeof(arbitrary_data)); - WALLET_SET_ARBITRARY_DATA(wallet.wallet_info); - WALLET_SET_ARBITRARY_DATA(wallet_for_flash.wallet_info); - - convert_to_shares(wallet.arbitrary_data_size, - (uint8_t *)arbitrary_data, - wallet.total_number_of_shares, - wallet.minimum_number_of_shares, - wallet_shamir_data.arbitrary_data_shares); - memzero(arbitrary_data, sizeof(arbitrary_data)); - flow_level.level_three = ARBITRARY_DATA_TAP_CARDS; - flow_level.level_four = 1; - flow_level.level_five = 1; - } else { - mark_error_screen(ui_text_wallet_with_same_mnemo_exists); - flow_level.level_three = ARBITRARY_DATA_ENTER_DATA_INSTRUCTION; - flow_level.level_four = 1; - flow_level.level_five = 1; - } - } break; - - case ARBITRARY_DATA_TAP_CARDS: - card_flow_create_wallet(); - break; - - case ARBITRARY_DATA_VERIFY_SHARES: - flow_level.level_three = verify_card_share_data() == 1 - ? ARBITRARY_DATA_SUCCESS_MESSAGE - : ARBITRARY_DATA_FAILED_MESSAGE; - memzero(wallet.password_double_hash, sizeof(wallet.password_double_hash)); - memzero(wallet.wallet_share_with_mac_and_nonce, - sizeof(wallet.wallet_share_with_mac_and_nonce)); - memzero(wallet.arbitrary_data_share, sizeof(wallet.arbitrary_data_share)); - memzero(wallet.checksum, sizeof(wallet.checksum)); - memzero(wallet.key, sizeof(wallet.key)); - memzero(wallet.beneficiary_key, sizeof(wallet.beneficiary_key)); - memzero(wallet.iv_for_beneficiary_key, - sizeof(wallet.iv_for_beneficiary_key)); - break; - - case ARBITRARY_DATA_SUCCESS_MESSAGE: - reset_flow_level(); - break; - - case ARBITRARY_DATA_FAILED_MESSAGE: - flow_level.level_one = LEVEL_TWO_OLD_WALLET; - flow_level.level_three = 1; - flow_level.level_four = 1; - break; - - default: - message_scr_init(ui_text_something_went_wrong); - reset_flow_level(); - break; - } - return; -} diff --git a/src/level_three/add_wallet/controller/controller_arbitrary_data_b.c b/src/level_three/add_wallet/controller/controller_arbitrary_data_b.c deleted file mode 100644 index c24f7c2c7..000000000 --- a/src/level_three/add_wallet/controller/controller_arbitrary_data_b.c +++ /dev/null @@ -1,98 +0,0 @@ -/** - * @file controller_arbitrary_data_b.c - * @author Cypherock X1 Team - * @brief Arbitrary data back controller. - * Handles post event (only back/cancel events) operations for - *arbitrary data flow. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "controller_add_wallet.h" -#include "controller_main.h" -// Atul #include "crys_hash.h" -#include "flash_api.h" -#include "tasks.h" - -extern Flash_Wallet wallet_for_flash; - -void arbitrary_data_controller_b() { - switch (flow_level.level_three) { - case ARBITRARY_DATA_NAME_CONFIRM: { - flow_level.level_three = ARBITRARY_DATA_NAME_INPUT; - } break; - - case ARBITRARY_DATA_SKIP_PIN: { - flow_level.level_three = ARBITRARY_DATA_ENTER_DATA_INSTRUCTION; - WALLET_UNSET_PIN(wallet_for_flash.wallet_info); - WALLET_UNSET_PIN(wallet.wallet_info); - } break; - case ARBITRARY_DATA_PIN_INPUT: { - flow_level.level_three = ARBITRARY_DATA_SKIP_PIN; - } break; - case ARBITRARY_DATA_PIN_CONFIRM: { - flow_level.level_three = ARBITRARY_DATA_PIN_INPUT; - } break; - - case ARBITRARY_DATA_ENTER_DATA: { - flow_level.level_three = ARBITRARY_DATA_PIN_INPUT; - } break; - - case ARBITRARY_DATA_CONFIRM_DATA: { - flow_level.level_three = ARBITRARY_DATA_ENTER_DATA_INSTRUCTION; - } break; - - default: { - reset_flow_level(); - } - } -} \ No newline at end of file diff --git a/src/level_three/add_wallet/tasks/tasks_add_wallet.h b/src/level_three/add_wallet/tasks/tasks_add_wallet.h deleted file mode 100644 index 0a6d6248e..000000000 --- a/src/level_three/add_wallet/tasks/tasks_add_wallet.h +++ /dev/null @@ -1,38 +0,0 @@ -/** - * @file tasks_add_wallet.h - * @author Cypherock X1 Team - * @brief Header for add wallet tasks. - * This file contains all the functions prototypes for the add wallet - * tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ -/** - * @file task_new_wallet.h - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2020-05-27 - * - * @copyright Copyright (c) 2020 - * - */ - -#ifndef TASKS_ADD_WALLET_H -#define TASKS_ADD_WALLET_H - -#include "controller_main.h" -#include "tasks.h" - -/** - * @brief Task to create a wallet to add arbitrary data - * @details - * - * @see - * @since v1.0.0 - */ -void tasks_arbitrary_data(); - -#endif \ No newline at end of file diff --git a/src/level_three/add_wallet/tasks/tasks_arbitrary_data.c b/src/level_three/add_wallet/tasks/tasks_arbitrary_data.c deleted file mode 100644 index 226523349..000000000 --- a/src/level_three/add_wallet/tasks/tasks_arbitrary_data.c +++ /dev/null @@ -1,226 +0,0 @@ -/** - * @file tasks_arbitrary_data.c - * @author Cypherock X1 Team - * @brief Arbitrary data tasks. - * This file contains the implementation of the tasks that are used to - *create arbitrary data. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "constant_texts.h" -#include "controller_main.h" -#include "shamir_wrapper.h" -#include "stdint.h" -#include "tasks.h" -#include "tasks_add_wallet.h" -#include "tasks_tap_cards.h" -#include "ui_address.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_input_mnemonics.h" -#include "ui_input_text.h" -#include "ui_instruction.h" -#include "ui_list.h" -#include "ui_menu.h" -#include "ui_message.h" -#include "ui_multi_instruction.h" -#include "ui_text_slideshow.h" -#include "wallet.h" - -extern char arbitrary_data[4096 / 8 + 1]; - -extern char *ALPHABET; -extern char *ALPHA_NUMERIC; -extern char *NUMBERS; -extern char *PASSPHRASE; - -#ifdef USE_ARBITRARY_DATA -static void restore_wallet_enter_mnemonics_flow() { - if (flow_level.level_four <= wallet.number_of_mnemonics) { - char heading[20]; - snprintf( - heading, sizeof(heading), UI_TEXT_ENTER_WORD, flow_level.level_four); - ui_mnem_init(heading); - } else { - // todo check if mnemonics is correct - mark_event_over(); - } -} -#endif - -void tasks_arbitrary_data() { - if (flow_level.show_error_screen) { - message_scr_init(flow_level.error_screen_text); - return; - } - - switch (flow_level.level_three) { - case ARBITRARY_DATA_NAME_INPUT: { - input_text_init(WALLET_NAME_CHARSET, - 0, - ui_text_enter_wallet_name, - 2, - DATA_TYPE_TEXT, - 15); - } break; - - case ARBITRARY_DATA_NAME_CONFIRM: { - char display[65]; - snprintf( - display, sizeof(display), "%s", flow_level.screen_input.input_text); - address_scr_init(ui_text_confirm_wallet_name, display, false); - } break; - - case RESTORE_WALLET_PIN_INSTRUCTIONS_1: { - char display[65]; - if (strnlen(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)) <= 15) - snprintf( - display, sizeof(display), UI_TEXT_PIN_INS1, wallet.wallet_name); - else - snprintf(display, sizeof(display), UI_TEXT_PIN_INS1, "this wallet"); - delay_scr_init(display, DELAY_TIME); - } break; - - case RESTORE_WALLET_PIN_INSTRUCTIONS_2: { - delay_scr_init(ui_wallet_pin_instruction_2, DELAY_TIME); - } break; - - case ARBITRARY_DATA_SKIP_PIN: { - confirm_scr_init(ui_text_do_you_want_to_set_pin); - confirm_scr_focus_cancel(); - } break; - - case ARBITRARY_DATA_PIN_INPUT: { - input_text_init( - ALPHA_NUMERIC, 26, ui_text_enter_pin, 4, DATA_TYPE_PIN, 8); - } break; - - case ARBITRARY_DATA_PIN_CONFIRM: { - input_text_init( - ALPHA_NUMERIC, 26, ui_text_confirm_pin, 4, DATA_TYPE_PIN, 8); - } break; - - case ARBITRARY_DATA_ENTER_DATA_INSTRUCTION: { - message_scr_init(ui_text_now_enter_your_data); - - } break; - - case ARBITRARY_DATA_ENTER_DATA: { - input_text_init( - PASSPHRASE, 26, ui_text_enter_data, 0, DATA_TYPE_PASSPHRASE, 255); - } break; - - case ARBITRARY_DATA_CONFIRM_DATA: { - snprintf(arbitrary_data, - sizeof(arbitrary_data), - "%s", - flow_level.screen_input.input_text); - memzero(flow_level.screen_input.input_text, - sizeof(flow_level.screen_input.input_text)); - address_scr_init(ui_text_confirm_data, arbitrary_data, false); - } break; - - case ARBITRARY_DATA_CREATING_WAIT_SCREEN: { - instruction_scr_init(ui_text_processing, NULL); - mark_event_over(); - } break; - - case ARBITRARY_DATA_CREATE: { - instruction_scr_destructor(); - mark_event_over(); - } break; - - case ARBITRARY_DATA_TAP_CARDS: { - tap_cards_for_write_flow(); - } break; - - case ARBITRARY_DATA_VERIFY_SHARES: - instruction_scr_init(ui_text_processing, ""); - instruction_scr_change_text(ui_text_processing, true); - BSP_DelayMs(DELAY_SHORT); - mark_event_over(); - break; - - case ARBITRARY_DATA_SUCCESS_MESSAGE: { - instruction_scr_destructor(); - const char *messages[6] = { - ui_text_verification_is_now_complete_messages[0], - ui_text_verification_is_now_complete_messages[1], - ui_text_verification_is_now_complete_messages[2], - ui_text_verification_is_now_complete_messages[4], - ui_text_verification_is_now_complete_messages[5], - NULL}; - uint8_t count = 5; - - if (WALLET_IS_PIN_SET(wallet.wallet_info)) { - messages[3] = ui_text_verification_is_now_complete_messages[3]; - messages[4] = ui_text_verification_is_now_complete_messages[4]; - messages[5] = ui_text_verification_is_now_complete_messages[5]; - count = 6; - } - - multi_instruction_init(messages, count, DELAY_LONG_STRING, true); - } break; - - case ARBITRARY_DATA_FAILED_MESSAGE: { - instruction_scr_destructor(); - message_scr_init(ui_text_creation_failed_delete_wallet); - } break; - - default: { - message_scr_init(ui_text_something_went_wrong); - } break; - } - return; -} diff --git a/src/level_three/advanced_settings/controller/advanced_settings_controller.c b/src/level_three/advanced_settings/controller/advanced_settings_controller.c deleted file mode 100644 index ffcd0f6e6..000000000 --- a/src/level_three/advanced_settings/controller/advanced_settings_controller.c +++ /dev/null @@ -1,95 +0,0 @@ -/** - * @file advanced_settings_controller.c - * @author Cypherock X1 Team - * @brief Advanced settings next controller. - * Handles post event (only next events) operations for advanced - *settings flow. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include - -#include "application_startup.h" -#include "controller_advanced_settings.h" -#include "controller_level_four.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "tasks.h" - -extern lv_task_t *timeout_task; - -void level_three_advanced_settings_controller() { - switch (flow_level.level_two) { -#if X1WALLET_MAIN -#ifdef DEV_BUILD - case LEVEL_THREE_UPDATE_CARD_ID: { - controller_update_card_id(); - } break; - - case LEVEL_THREE_CARD_UPGRADE: - card_upgrade_controller(); - break; -#endif -#endif -#if X1WALLET_INITIAL - case LEVEL_THREE_START_DEVICE_PROVISION: { - device_provision_controller(); - } break; -#elif X1WALLET_MAIN -#else -#error Specify what to build (X1WALLET_INITIAL or X1WALLET_MAIN) -#endif - default: - break; - } -} diff --git a/src/level_three/advanced_settings/controller/controller_advanced_settings.h b/src/level_three/advanced_settings/controller/controller_advanced_settings.h deleted file mode 100644 index 77d0f032c..000000000 --- a/src/level_three/advanced_settings/controller/controller_advanced_settings.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * @file controller_advanced_settings.h - * @author Cypherock X1 Team - * @brief Header for advanced settings controller. - * This file contains the prototypes of the functions used to control - * the advanced settings. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef CONTROLLER_ADV_SETTINGS_H -#define CONTROLLER_ADV_SETTINGS_H - -#pragma once - -#include "controller_main.h" -#include "tasks.h" - -/** - * @brief Controller for post-event processing of advanced settings tasks. - * @details This function is used to control the flow of the advanced settings - * controller and is responsible for transition from one state to an appropriate - * state based on the user's input (as communication via lvgl's UI components). - * - * @see LEVEL_THREE_ADVANCED_SETTINGS_TASKS, initial_verify_card_controller(), - * level_three_advanced_settings_tasks(), - * get_usb_msg_by_cmd_type(), device_provision_controller(), - * tap_card_pair_card_controller() - * @since v1.0.0 - */ -void level_three_advanced_settings_controller(); - -#endif \ No newline at end of file diff --git a/src/level_three/advanced_settings/tasks/advanced_settings_tasks.c b/src/level_three/advanced_settings/tasks/advanced_settings_tasks.c deleted file mode 100644 index b80a28fa0..000000000 --- a/src/level_three/advanced_settings/tasks/advanced_settings_tasks.c +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file advanced_settings_tasks.c - * @author Cypherock X1 Team - * @brief Advanced settings task. - * This file contains the pre-processing & rendering of the advanced - *settings task. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "board.h" -#include "constant_texts.h" -#include "controller_level_four.h" -#include "controller_main.h" -#include "controller_tap_cards.h" -#include "tasks.h" -#include "tasks_level_four.h" -#include "tasks_tap_cards.h" -#include "ui_confirmation.h" -#include "ui_delay.h" -#include "ui_instruction.h" -#include "ui_message.h" -#include "ui_multi_instruction.h" -#include "utils.h" - -extern lv_task_t *timeout_task; - -extern const char *GIT_REV; -extern const char *GIT_TAG; -extern const char *GIT_BRANCH; - -void level_three_advanced_settings_tasks() { - switch (flow_level.level_two) { -#if X1WALLET_MAIN -#ifdef DEV_BUILD - case LEVEL_THREE_UPDATE_CARD_ID: { - tasks_update_card_id(); - } break; - - case LEVEL_THREE_CARD_UPGRADE: - card_upgrade_task(); - break; -#endif -#endif -#if X1WALLET_INITIAL - case LEVEL_THREE_START_DEVICE_PROVISION: { - task_device_provision(); - } break; -#elif X1WALLET_MAIN -#else -#error Specify what to build (X1WALLET_INITIAL or X1WALLET_MAIN) -#endif - default: - break; - } -} diff --git a/src/level_three/advanced_settings/tasks/tasks_advanced_settings.h b/src/level_three/advanced_settings/tasks/tasks_advanced_settings.h deleted file mode 100644 index 73a60d04c..000000000 --- a/src/level_three/advanced_settings/tasks/tasks_advanced_settings.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file tasks_advanced_settings.h - * @author Cypherock X1 Team - * @brief Header for advanced settings tasks. - * This file contains the prototypes of the functions used to manage - * the advanced settings tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef TASKS_ADVANCED_SETTINGS_H -#define TASKS_ADVANCED_SETTINGS_H - -#pragma once - -#include "controller_main.h" -#include "tasks.h" - -/** - * @brief This function is used to manage the pre-processing & rendering in - * advanced settings tasks. - * @details All the settings features are managed here. Some of the desktop - * triggered requests are also managed here such as export of logs, firmware - * upgrade, card verification along with card pairing. - * - * @see LEVEL_THREE_ADVANCED_SETTINGS_TASKS, initial_verify_card_task(), - * verify_card_task(), task_device_provision() - * @since v1.0.0 - */ -void level_three_advanced_settings_tasks(); - -#endif \ No newline at end of file diff --git a/src/level_three/old_wallet/controller/controller_old_wallet.c b/src/level_three/old_wallet/controller/controller_old_wallet.c deleted file mode 100644 index 533909d60..000000000 --- a/src/level_three/old_wallet/controller/controller_old_wallet.c +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file controller_old_wallet.c - * @author Cypherock X1 Team - * @brief Old wallet next controller. - * Handles post event (only next events) operations for old wallet - *flow. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "controller_old_wallet.h" - -#include "controller_level_four.h" -#include "controller_main.h" -#include "tasks.h" - -void level_three_old_wallet_controller() { -#if X1WALLET_MAIN == 1 - switch (flow_level.level_two) { - case LEVEL_THREE_SEND_TRANSACTION_ETH: { - send_transaction_controller_eth(); - } break; - - case LEVEL_THREE_SIGN_MESSAGE_ETH: { - sign_message_controller_eth(); - } break; - - case LEVEL_THREE_SEND_TRANSACTION_SOLANA: { - send_transaction_controller_solana(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_ETH: { - receive_transaction_controller_eth(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_NEAR: { - receive_transaction_controller_near(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_SOLANA: { - receive_transaction_controller_solana(); - } break; - - case LEVEL_THREE_WALLET_LOCKED: { - // wallet_locked_controller(); - } break; - - case LEVEL_THREE_VERIFY_WALLET: { - verify_wallet_controller(); - } break; - case LEVEL_THREE_SYNC_WALLET: { - } break; - default: - break; - } - return; -#endif -} diff --git a/src/level_three/old_wallet/controller/controller_old_wallet.h b/src/level_three/old_wallet/controller/controller_old_wallet.h deleted file mode 100644 index f1aeb49fa..000000000 --- a/src/level_three/old_wallet/controller/controller_old_wallet.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * @file controller_old_wallet.h - * @author Cypherock X1 Team - * @brief Header for old wallet controller. - * This file contains the old wallet controller. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef CONTROLLER_OLD_WALLET_H -#define CONTROLLER_OLD_WALLET_H - -#pragma once - -#include "controller_main.h" - -/** - * @brief Controller to handle post event processing of the delete wallet flow. - * @details The function deletes the wallet from the device removing both the - * basic information along with the device's share. - * - * @see DELETE_WALLET_TASKS, delete_from_cards_controller(), - * delete_wallet_share_from_sec_flash(), delete_wallet_from_flash(), - * delete_wallet_task() - * @since v1.0.0 - * - * @note The wallet entry is erased only after the wallet has been deleted from - * all the cards. - */ -void delete_wallet_controller(); - -/** - * @brief Controller to branch through the application state for processing the - * exact active flow. - * @details This controller is only responsible for branching through the - * application state and processing the exact active flow. No actual processing - * is done here. - * - * @see LEVEL_THREE_OLD_WALLET_TASKS, view_seed_controller(), - * delete_wallet_controller(), export_wallet_controller(), - * add_coin_controller(), send_transaction_controller_eth(), - * receive_transaction_controller_eth(), wallet_locked_controller(), - * verify_wallet_controller(), level_three_old_wallet_tasks() - * @since v1.0.0 - */ -void level_three_old_wallet_controller(); - -/** - * @brief Back button controller for level three old wallet flow. - * @details This controller is only responsible for branching through the - * application state and processing the exact active flow. No actual processing - * is done here. - * - * @see LEVEL_THREE_OLD_WALLET_TASKS, - * verify_wallet_controller_b(), wallet_locked_controller_b(), - * receive_transaction_controller_b_eth(), - * send_transaction_controller_b_eth(), - * level_three_old_wallet_tasks() - * @since v1.0.0 - */ -void level_three_old_wallet_controller_b(); - -#endif \ No newline at end of file diff --git a/src/level_three/old_wallet/controller/controller_old_wallet_b.c b/src/level_three/old_wallet/controller/controller_old_wallet_b.c deleted file mode 100644 index 87f2721dd..000000000 --- a/src/level_three/old_wallet/controller/controller_old_wallet_b.c +++ /dev/null @@ -1,107 +0,0 @@ -/** - * @file controller_old_wallet_b.c - * @author Cypherock X1 Team - * @brief Old wallet back controller. - * Handles post event (only back/cancel events) operations for old - *wallet flow. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "controller_level_four.h" -#include "controller_main.h" -#include "controller_old_wallet.h" -#include "tasks.h" - -void level_three_old_wallet_controller_b() { - switch (flow_level.level_two) { - case LEVEL_THREE_SEND_TRANSACTION_ETH: { - send_transaction_controller_b_eth(); - } break; - - case LEVEL_THREE_SIGN_MESSAGE_ETH: { - sign_message_controller_b_eth(); - } break; - - case LEVEL_THREE_SEND_TRANSACTION_SOLANA: { - send_transaction_controller_b_solana(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_ETH: { - receive_transaction_controller_b_eth(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_NEAR: { - receive_transaction_controller_b_near(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_SOLANA: { - receive_transaction_controller_b_solana(); - } break; - - case LEVEL_THREE_WALLET_LOCKED: { - wallet_locked_controller_b(); - break; - } - - case LEVEL_THREE_VERIFY_WALLET: { - verify_wallet_controller_b(); - } break; - - case LEVEL_THREE_SYNC_WALLET: { - } break; - - default: - break; - } - return; -} diff --git a/src/level_three/old_wallet/tasks/tasks_old_wallet.c b/src/level_three/old_wallet/tasks/tasks_old_wallet.c deleted file mode 100644 index 3f94096aa..000000000 --- a/src/level_three/old_wallet/tasks/tasks_old_wallet.c +++ /dev/null @@ -1,115 +0,0 @@ -/** - * @file tasks_old_wallet.c - * @author Cypherock X1 Team - * @brief Old wallet task. - * Handles pre-processing & display updates for old wallet tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - ****************************************************************************** - * @attention - * - * (c) Copyright 2022 by HODL TECH PTE LTD - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject - * to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF - * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * - * "Commons Clause" License Condition v1.0 - * - * The Software is provided to you by the Licensor under the License, - * as defined below, subject to the following condition. - * - * Without limiting other conditions in the License, the grant of - * rights under the License will not include, and the License does not - * grant to you, the right to Sell the Software. - * - * For purposes of the foregoing, "Sell" means practicing any or all - * of the rights granted to you under the License to provide to third - * parties, for a fee or other consideration (including without - * limitation fees for hosting or consulting/ support services related - * to the Software), a product or service whose value derives, entirely - * or substantially, from the functionality of the Software. Any license - * notice or attribution required by the License must also include - * this Commons Clause License Condition notice. - * - * Software: All X1Wallet associated files. - * License: MIT - * Licensor: HODL TECH PTE LTD - * - ****************************************************************************** - */ -#include "tasks_old_wallet.h" - -#include "constant_texts.h" -#include "controller_main.h" -#include "tasks.h" -#include "tasks_level_four.h" - -void level_three_old_wallet_tasks() { - // Check if desktop sent an abort command (view seed and delete wallet are not - // initiated by desktop, therefore excluded here) - if (flow_level.level_two != LEVEL_THREE_WALLET_LOCKED && - flow_level.level_two != LEVEL_THREE_VERIFY_WALLET && - CY_Read_Reset_Flow()) { - mark_error_screen(ui_text_aborted); - reset_flow_level(); - return; - } - - switch (flow_level.level_two) { - case LEVEL_THREE_SEND_TRANSACTION_ETH: { - send_transaction_tasks_eth(); - } break; - - case LEVEL_THREE_SIGN_MESSAGE_ETH: { - sign_message_tasks_eth(); - } break; - - case LEVEL_THREE_SEND_TRANSACTION_SOLANA: { - send_transaction_tasks_solana(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_ETH: { - receive_transaction_tasks_eth(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_NEAR: { - receive_transaction_tasks_near(); - } break; - - case LEVEL_THREE_RECEIVE_TRANSACTION_SOLANA: { - receive_transaction_tasks_solana(); - } break; - - case LEVEL_THREE_WALLET_LOCKED: - wallet_locked_task(); - break; - - case LEVEL_THREE_VERIFY_WALLET: - verify_wallet_tasks(); - break; - case LEVEL_THREE_SYNC_WALLET: { - } break; - default: - break; - } - return; -} diff --git a/src/level_three/old_wallet/tasks/tasks_old_wallet.h b/src/level_three/old_wallet/tasks/tasks_old_wallet.h deleted file mode 100644 index fb2887602..000000000 --- a/src/level_three/old_wallet/tasks/tasks_old_wallet.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @file tasks_old_wallet.h - * @author Cypherock X1 Team - * @brief Header for old wallet tasks. - * This file contains all the prototypes for the old wallet tasks. - * @copyright Copyright (c) 2022 HODL TECH PTE LTD - *
You may obtain a copy of license at https://mitcc.org/ - * - */ - -#ifndef TASKS_OLD_WALLET_H -#define TASKS_OLD_WALLET_H - -#pragma once - -#include "controller_main.h" - -/** - * @brief Handles all the possible operations on the old wallets. - * @details This function handles all the possible operations on the old wallets - * such as view seed, delete/unlock/verify wallet and other desktop triggered - * operations such export wallet, send/receive transactions. - * - * @see view_seed_task(), wallet_locked_task(), - * verify_wallet_task(), - * send_transaction_tasks_eth(), receive_transaction_tasks_eth(), - * LEVEL_THREE_OLD_WALLET_TASKS, Flow_level.level_two, - * level_three_old_wallet_controller_b() level_three_old_wallet_controller() - * @since v1.0.0 - */ -void level_three_old_wallet_tasks(); - -#endif \ No newline at end of file diff --git a/src/settings/factory_reset.c b/src/settings/factory_reset.c index 51c831564..5c0e4bb0a 100644 --- a/src/settings/factory_reset.c +++ b/src/settings/factory_reset.c @@ -339,7 +339,7 @@ void clear_device_data(void) { return; } - if (!core_scroll_page(NULL, ui_text_confirm_factory_reset, NULL)) { + if (!core_scroll_page(NULL, ui_text_confirm_clear_device_data, NULL)) { return; } diff --git a/src/wallet/create_new_wallet_flow.c b/src/wallet/create_new_wallet_flow.c index b455012e2..d1bac1297 100644 --- a/src/wallet/create_new_wallet_flow.c +++ b/src/wallet/create_new_wallet_flow.c @@ -61,12 +61,14 @@ *****************************************************************************/ #include "create_new_wallet_flow.h" +#include "bip39.h" #include "card_flow_create_wallet.h" #include "constant_texts.h" #include "core_error.h" #include "crypto_random.h" #include "flash_api.h" #include "flash_if.h" +#include "options.h" #include "sha2.h" #include "shamir_wrapper.h" #include "ui_core_confirm.h" diff --git a/src/wallet/reconstruct_wallet_flow.c b/src/wallet/reconstruct_wallet_flow.c index a9a844872..72231c01c 100644 --- a/src/wallet/reconstruct_wallet_flow.c +++ b/src/wallet/reconstruct_wallet_flow.c @@ -61,6 +61,7 @@ *****************************************************************************/ #include "reconstruct_wallet_flow.h" +#include "bip39.h" #include "card_flow_reconstruct_wallet.h" #include "common_error.h" #include "constant_texts.h" diff --git a/src/wallet/restore_seed_phrase_flow.c b/src/wallet/restore_seed_phrase_flow.c index c7d1b4b6d..39ab4ca18 100644 --- a/src/wallet/restore_seed_phrase_flow.c +++ b/src/wallet/restore_seed_phrase_flow.c @@ -62,6 +62,7 @@ #include "constant_texts.h" #include "core_error.h" #include "flash_if.h" +#include "options.h" #include "sha2.h" #include "shamir_wrapper.h" #include "ui_core_confirm.h" diff --git a/src/wallet/view_seed_flow.c b/src/wallet/view_seed_flow.c index 6b9316de1..ce97c63c2 100644 --- a/src/wallet/view_seed_flow.c +++ b/src/wallet/view_seed_flow.c @@ -59,8 +59,10 @@ /***************************************************************************** * INCLUDES *****************************************************************************/ +#include "bip32.h" #include "constant_texts.h" #include "core_error.h" +#include "options.h" #include "reconstruct_wallet_flow.h" #include "ui_core_confirm.h" #include "ui_multi_instruction.h" diff --git a/src/wallet/wallet_unlock_flow.c b/src/wallet/wallet_unlock_flow.c index 0d9c39df8..323c84ab4 100644 --- a/src/wallet/wallet_unlock_flow.c +++ b/src/wallet/wallet_unlock_flow.c @@ -62,6 +62,7 @@ #include "wallet_unlock_flow.h" #include "card_operations.h" +#include "card_unlock_wallet.h" #include "constant_texts.h" #include "core_error.h" #include "flash_api.h" diff --git a/tests/apps/evm_app/evm_sign_msg_tests.c b/tests/apps/evm_app/evm_sign_msg_tests.c index 4fe0678c5..afb1f0ac0 100644 --- a/tests/apps/evm_app/evm_sign_msg_tests.c +++ b/tests/apps/evm_app/evm_sign_msg_tests.c @@ -98,6 +98,114 @@ TEST_TEAR_DOWN(evm_sign_msg_test) { ctx.msg_data = NULL; } +TEST(evm_sign_msg_test, evm_sign_msg_test_empty_typed_data_hash) { + evm_query_t query = { + .which_request = 3, + .sign_msg = { + .which_request = 1, + .initiate = {.derivation_path_count = 5, + .derivation_path = {NON_SEGWIT, ETHEREUM, BITCOIN, 0, 0}, + .wallet_id = {}, + .message_type = EVM_SIGN_MSG_TYPE_SIGN_TYPED_DATA, + .total_msg_size = 121}}}; + uint8_t buffer[1024]; + uint8_t digest[SHA256_DIGEST_LENGTH] = {0}; + uint8_t expected_digest[SHA256_DIGEST_LENGTH] = { + 48, 26, 80, 178, 145, 211, 60, 225, 232, 233, 6, + 78, 63, 106, 108, 81, 217, 2, 236, 34, 137, 43, + 80, 213, 138, 191, 99, 87, 198, 164, 85, 65}; + + // Set init query to ctx buffer + memcpy(&ctx.init, + &query.sign_msg.initiate, + sizeof(evm_sign_msg_initiate_request_t)); + + // Prepare typed data from msg_data + char *string = + "0a3a0a06646f6d61696e1007220c454950373132446f6d61696e322020bcc3f8105eea47" + "d067386e42e60246e89393cd61c512edd1e87688890fb914123b0a076d65737361676510" + "07220c454950373132446f6d61696e322020bcc3f8105eea47d067386e42e60246e89393" + "cd61c512edd1e87688890fb914"; + ctx.msg_data = buffer; + hex_string_to_byte_array(string, ctx.init.total_msg_size * 2, buffer); + pb_istream_t istream = + pb_istream_from_buffer(ctx.msg_data, ctx.init.total_msg_size); + bool result = + pb_decode(&istream, EVM_SIGN_TYPED_DATA_STRUCT_FIELDS, &(ctx.typed_data)); + +#ifdef EVM_SIGN_TYPED_DATA_DISPLAY_TEST + // Display the typed data + ui_display_node *display_node = NULL; + evm_init_typed_data_display_node(&display_node, &(ctx.typed_data)); + while (NULL != display_node) { + core_scroll_page(display_node->title, display_node->value, evm_send_error); + display_node = display_node->next; + } +#endif + TEST_ASSERT_TRUE(result); + TEST_ASSERT_TRUE(evm_get_msg_data_digest(&ctx, digest)); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_digest, digest, SHA256_DIGEST_LENGTH); + + pb_release(EVM_SIGN_TYPED_DATA_STRUCT_FIELDS, &(ctx.typed_data)); +} + +TEST(evm_sign_msg_test, evm_sign_msg_test_domain_only_typed_data_hash) { + evm_query_t query = { + .which_request = 3, + .sign_msg = { + .which_request = 1, + .initiate = {.derivation_path_count = 5, + .derivation_path = {NON_SEGWIT, ETHEREUM, BITCOIN, 0, 0}, + .wallet_id = {}, + .message_type = EVM_SIGN_MSG_TYPE_SIGN_TYPED_DATA, + .total_msg_size = 355}}}; + uint8_t buffer[1024]; + uint8_t digest[SHA256_DIGEST_LENGTH] = {0}; + uint8_t expected_digest[SHA256_DIGEST_LENGTH] = { + 116, 118, 39, 55, 210, 218, 151, 77, 201, 234, 163, + 106, 199, 100, 63, 130, 38, 147, 175, 116, 232, 98, + 80, 99, 235, 157, 156, 36, 198, 0, 10, 52}; + + // Set init query to ctx buffer + memcpy(&ctx.init, + &query.sign_msg.initiate, + sizeof(evm_sign_msg_initiate_request_t)); + + // Prepare typed data from msg_data + char *string = + "0aa3020a06646f6d61696e10071805220c454950373132446f6d61696e3220d87cd6ef79" + "d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac564723a1a0a046e616d6510" + "0318062206737472696e672a065472657a6f723a220a0776657273696f6e1003180b2206" + "737472696e672a0b546573742076302e302e303a360a07636861696e4964182022077569" + "6e743235362a200000000000000000000000000000000000000000000000000000000000" + "0000013a360a11766572696679696e67436f6e7472616374100518142207616464726573" + "732a14cccccccccccccccccccccccccccccccccccccccc3a350a0473616c741002182022" + "07627974657333322a200123456789abcdef0123456789abcdef0123456789abcdef0123" + "456789abcdef123b0a076d6573736167651007220c454950373132446f6d61696e3220d8" + "7cd6ef79d4e2b95e15ce8abf732db51ec771f1ca2edccf22a46c729ac56472"; + ctx.msg_data = buffer; + hex_string_to_byte_array(string, ctx.init.total_msg_size * 2, buffer); + pb_istream_t istream = + pb_istream_from_buffer(ctx.msg_data, ctx.init.total_msg_size); + bool result = + pb_decode(&istream, EVM_SIGN_TYPED_DATA_STRUCT_FIELDS, &(ctx.typed_data)); + +#ifdef EVM_SIGN_TYPED_DATA_DISPLAY_TEST + // Display the typed data + ui_display_node *display_node = NULL; + evm_init_typed_data_display_node(&display_node, &(ctx.typed_data)); + while (NULL != display_node) { + core_scroll_page(display_node->title, display_node->value, evm_send_error); + display_node = display_node->next; + } +#endif + TEST_ASSERT_TRUE(result); + TEST_ASSERT_TRUE(evm_get_msg_data_digest(&ctx, digest)); + TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_digest, digest, SHA256_DIGEST_LENGTH); + + pb_release(EVM_SIGN_TYPED_DATA_STRUCT_FIELDS, &(ctx.typed_data)); +} + TEST(evm_sign_msg_test, evm_sign_msg_test_typed_data_hash) { evm_query_t query = { .which_request = 3, diff --git a/tests/common/util/utils_tests.c b/tests/common/util/utils_tests.c index 97812bd27..a5943e008 100644 --- a/tests/common/util/utils_tests.c +++ b/tests/common/util/utils_tests.c @@ -142,9 +142,14 @@ TEST(utils_tests, escape_string_symbol) { } TEST(utils_tests, escape_string_ascii) { - // message: "ASCII sample text" - char utf_8_string[] = "ASCII sample text"; - const char expected_string[] = "ASCII sample text"; + // message: + // "ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n0123456789 + // !\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~" + char utf_8_string[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nabcdefghijklmnopqrstuvwx" + "yz\n0123456789\r !\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~"; + const char expected_string[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZ\r\nabcdefghijklmnopqrstuvwxyz\n0123456789\r " + "!\"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~"; char actual_string[300] = ""; uint8_t result = string_to_escaped_string( diff --git a/tests/unit_test_lists.c b/tests/unit_test_lists.c index dbf2dc477..5d249bb86 100644 --- a/tests/unit_test_lists.c +++ b/tests/unit_test_lists.c @@ -184,6 +184,9 @@ TEST_GROUP_RUNNER(evm_txn_test) { } TEST_GROUP_RUNNER(evm_sign_msg_test) { + RUN_TEST_CASE(evm_sign_msg_test, evm_sign_msg_test_empty_typed_data_hash); + RUN_TEST_CASE(evm_sign_msg_test, + evm_sign_msg_test_domain_only_typed_data_hash); RUN_TEST_CASE(evm_sign_msg_test, evm_sign_msg_test_typed_data_hash); RUN_TEST_CASE(evm_sign_msg_test, evm_sign_msg_test_personal_sign_hash); RUN_TEST_CASE(evm_sign_msg_test, evm_sign_msg_test_eth_sign_hash); diff --git a/version.txt b/version.txt index 8c81063b9..aa43637ec 100755 --- a/version.txt +++ b/version.txt @@ -1,3 +1,3 @@ -firmware version=000:006:000:003 +firmware version=000:006:001:004 hardware version=000:001:000:000 magic number=45227A01