Skip to content

Commit

Permalink
Merge pull request #498 from Cypherock/release/v0.6.256+
Browse files Browse the repository at this point in the history
Release v0.6.256+
  • Loading branch information
ujjwal-cyph authored Apr 10, 2024
2 parents 1b13a7b + b48ce65 commit 1729fdb
Show file tree
Hide file tree
Showing 113 changed files with 1,427 additions and 9,279 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/containerized-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 22 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down
12 changes: 11 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions apps/btc_family/btc_pub_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions apps/btc_family/btc_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions apps/btc_family/btc_xpub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions apps/evm_family/evm_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* INCLUDES
*****************************************************************************/

#include "eth.h"
#include "events.h"
#include "evm_api.h"
#include "evm_context.h"
Expand Down
15 changes: 12 additions & 3 deletions apps/evm_family/evm_sign_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
26 changes: 22 additions & 4 deletions apps/evm_family/evm_typed_data_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion apps/manager_app/device_authentication_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@
*/
#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"
#if USE_SIMULATOR == 0
#include "stm32l4xx_it.h"
#endif

#include "atca_basic.h"
#include "device_authentication_api.h"

#define SIGNATURE_SIZE 64
Expand Down
29 changes: 29 additions & 0 deletions apps/manager_app/device_authentication_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,45 @@
*****************************************************************************/
#include <manager/core.pb.h>

#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
Expand Down
4 changes: 3 additions & 1 deletion apps/manager_app/get_device_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions apps/manager_app/manager_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions apps/manager_app/manager_app_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 1729fdb

Please sign in to comment.