diff --git a/storage/storage.c b/storage/storage.c index f22c35d13..acd3521e7 100644 --- a/storage/storage.c +++ b/storage/storage.c @@ -137,18 +137,12 @@ const uint8_t WIPE_CODE_EMPTY[] = {0, 0, 0, 0}; // The uint32 representation of an empty wipe code used in storage version 2. #define V2_WIPE_CODE_EMPTY 0 -// TODO: handle translation -const char *const VERIFYING_PIN_MSG = "Verifying PIN"; -const char *const PROCESSING_MSG = "Processing"; -const char *const STARTING_MSG = "Starting up"; -const char *const WRONG_PIN_MSG = "Wrong PIN"; - static secbool initialized = secfalse; static secbool unlocked = secfalse; static PIN_UI_WAIT_CALLBACK ui_callback = NULL; static uint32_t ui_total = 0; static uint32_t ui_rem = 0; -static const char *ui_message = NULL; +static enum storage_ui_message_t ui_message = NO_MSG; static uint8_t cached_keys[KEYS_SIZE] = {0}; static uint8_t *const cached_dek = cached_keys; static uint8_t *const cached_sak = cached_keys + DEK_SIZE; @@ -986,7 +980,7 @@ secbool storage_unlock(const uint8_t *pin, size_t pin_len, ui_total = PIN_DERIVE_MS; ui_rem = ui_total; if (pin_len == 0) { - if (ui_message == NULL) { + if (ui_message == NO_MSG) { ui_message = STARTING_MSG; } else { ui_message = PROCESSING_MSG; diff --git a/storage/storage.h b/storage/storage.h index dcaa8490f..18480775c 100644 --- a/storage/storage.h +++ b/storage/storage.h @@ -53,8 +53,16 @@ extern const uint8_t *PIN_EMPTY; #define STORAGE_SALT_SIZE 4 #endif +enum storage_ui_message_t { + NO_MSG = 0, + VERIFYING_PIN_MSG, + PROCESSING_MSG, + STARTING_MSG, + WRONG_PIN_MSG, +}; + typedef secbool (*PIN_UI_WAIT_CALLBACK)(uint32_t wait, uint32_t progress, - const char *message); + enum storage_ui_message_t message); void storage_init(PIN_UI_WAIT_CALLBACK callback, const uint8_t *salt, const uint16_t salt_len); diff --git a/storage/tests/c3/storage.c b/storage/tests/c3/storage.c index 203237432..3f5d18a60 100644 --- a/storage/tests/c3/storage.c +++ b/storage/tests/c3/storage.c @@ -154,17 +154,12 @@ const uint8_t WIPE_CODE_EMPTY[] = {0, 0, 0, 0}; #define GUARD_KEY_MODULUS 6311 #define GUARD_KEY_REMAINDER 15 -const char *const VERIFYING_PIN_MSG = "Verifying PIN"; -const char *const PROCESSING_MSG = "Processing"; -const char *const STARTING_MSG = "Starting up"; -const char *const WRONG_PIN_MSG = "Wrong PIN"; - static secbool initialized = secfalse; static secbool unlocked = secfalse; static PIN_UI_WAIT_CALLBACK ui_callback = NULL; static uint32_t ui_total = 0; static uint32_t ui_rem = 0; -static const char *ui_message = NULL; +static enum storage_ui_message_t ui_message = NO_MSG; static uint8_t cached_keys[KEYS_SIZE] = {0}; static uint8_t *const cached_dek = cached_keys; static uint8_t *const cached_sak = cached_keys + DEK_SIZE; @@ -1258,7 +1253,7 @@ secbool storage_unlock(const uint8_t *pin, size_t pin_len, ui_total = PIN_DERIVE_MS; ui_rem = ui_total; if (pin_len == 0) { - if (ui_message == NULL) { + if (ui_message == NO_MSG) { ui_message = STARTING_MSG; } else { ui_message = PROCESSING_MSG; diff --git a/storage/tests/c3/storage.h b/storage/tests/c3/storage.h index dcaa8490f..18480775c 100644 --- a/storage/tests/c3/storage.h +++ b/storage/tests/c3/storage.h @@ -53,8 +53,16 @@ extern const uint8_t *PIN_EMPTY; #define STORAGE_SALT_SIZE 4 #endif +enum storage_ui_message_t { + NO_MSG = 0, + VERIFYING_PIN_MSG, + PROCESSING_MSG, + STARTING_MSG, + WRONG_PIN_MSG, +}; + typedef secbool (*PIN_UI_WAIT_CALLBACK)(uint32_t wait, uint32_t progress, - const char *message); + enum storage_ui_message_t message); void storage_init(PIN_UI_WAIT_CALLBACK callback, const uint8_t *salt, const uint16_t salt_len);