Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the defined max word length to 16 to match wallet names #22

Merged
merged 8 commits into from
Apr 26, 2023
6 changes: 3 additions & 3 deletions common/coin_support/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
#define MAX_NUMBER_OF_MNEMONIC_WORDS 24

/// Max length of mnemonic word
#define MAX_MNEMONIC_WORD_LENGTH 15
#define MAX_MNEMONIC_WORD_LENGTH 16

/// Max length of passphrase entered
#define MAX_PASSPHRASE_INPUT_LENGTH 65

/// Max length of coin name (set as some MAX_MNEMONIC_WORD_LENGTH because they both use ui_list)
#define MAX_COIN_NAME_LENGTH MAX_MNEMONIC_WORD_LENGTH
/// Max length of coin name
#define MAX_COIN_NAME_LENGTH MAX_UI_LIST_CHAR_LEN


/// Returns 0 if PIN is not set else 1
Expand Down
2 changes: 1 addition & 1 deletion common/interfaces/user_interface/ui_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
static struct List_Data* data = NULL;
static struct List_Object* obj = NULL;

void list_init(const char option_list[24][15], const int number_of_options, const char* heading, bool dynamic_heading)
void list_init(const char option_list[MAX_UI_LIST_WORDS][MAX_UI_LIST_CHAR_LEN], const int number_of_options, const char* heading, bool dynamic_heading)
{
ASSERT(option_list != NULL);
ASSERT(heading != NULL);
Expand Down
9 changes: 6 additions & 3 deletions common/interfaces/user_interface/ui_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

#include "ui_common.h"

//TODO : Add constant
//TODO: Update count for higher coin list
#define MAX_UI_LIST_WORDS 24
#define MAX_UI_LIST_CHAR_LEN 16
amanCypherock marked this conversation as resolved.
Show resolved Hide resolved

/**
* @brief struct to store list data
* @details
Expand All @@ -23,7 +26,7 @@
* @note
*/
struct List_Data {
char option_list[24][15];
char option_list[MAX_UI_LIST_WORDS][MAX_UI_LIST_CHAR_LEN];
int number_of_options;
int current_index;
bool dynamic_heading;
Expand Down Expand Up @@ -65,7 +68,7 @@ struct List_Object {
*
* @note Do not use this if number of options to be displayed in list is 1.
*/
void list_init(const char option_list[24][15], int number_of_options, const char *heading, bool dynamic_heading);
void list_init(const char option_list[MAX_UI_LIST_WORDS][MAX_UI_LIST_CHAR_LEN], int number_of_options, const char *heading, bool dynamic_heading);

/**
* @brief Create UI for list
Expand Down
4 changes: 2 additions & 2 deletions common/libraries/util/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ uint32_t byte_array_to_hex_string(const uint8_t *bytes, const uint32_t byte_len,
return (i * 2 + 1);
}

void __single_to_multi_line(const char* input, const uint16_t input_len, char output[24][15])
void __single_to_multi_line(const char* input, const uint16_t input_len, char output[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH])
{
if (input == NULL || output == NULL) return;
uint16_t i = 0U;
Expand All @@ -174,7 +174,7 @@ void __single_to_multi_line(const char* input, const uint16_t input_len, char ou
}
}

void __multi_to_single_line(const char input[24][15], const uint8_t number_of_mnemonics, char* output)
void __multi_to_single_line(const char input[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH], const uint8_t number_of_mnemonics, char* output)
{
if (input == NULL || output == NULL) return;
uint8_t word_len;
Expand Down
4 changes: 2 additions & 2 deletions common/libraries/util/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ uint32_t byte_array_to_hex_string(const uint8_t *bytes, uint32_t len, char *hex_
*
* @note
*/
void __single_to_multi_line(const char *input, uint16_t input_len, char output[24][15]);
void __single_to_multi_line(const char* input, uint16_t input_len, char output[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH]);

/**
* @brief convert multi-d mnemonics to single-d array for trezor crypto functions
Expand All @@ -153,7 +153,7 @@ void __single_to_multi_line(const char *input, uint16_t input_len, char output[2
*
* @note
*/
void __multi_to_single_line(const char input[24][15], uint8_t number_of_mnemonics, char *output);
void __multi_to_single_line(const char input[MAX_NUMBER_OF_MNEMONIC_WORDS][MAX_MNEMONIC_WORD_LENGTH], uint8_t number_of_mnemonics, char *output);

/**
* @brief Converts a hex string to a byte array.
Expand Down
2 changes: 1 addition & 1 deletion src/level_four/card_health_check/cyt_card_hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void cyt_card_hc() {
message_scr_init(ui_text_no_wallets_present);
}
else if(wallet_count <= MAX_WALLETS_ALLOWED){
char choices[MAX_WALLETS_ALLOWED][15]={"","","",""}, heading[50];
char choices[MAX_WALLETS_ALLOWED][MAX_UI_LIST_CHAR_LEN]={"","","",""}, heading[50];
for(int i=0; i < wallet_count; i++){
strcpy(choices[i], (char*)wallet_list[i][0]);
}
Expand Down