1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

chore(legacy): simplify data2hex

This commit is contained in:
Pavol Rusnak 2021-01-22 20:01:32 +01:00
parent 105f203a1f
commit 0519d86451
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 6 additions and 7 deletions

View File

@ -422,7 +422,7 @@ void config_init(void) {
storage_set(KEY_UUID, config_uuid, sizeof(config_uuid)); storage_set(KEY_UUID, config_uuid, sizeof(config_uuid));
storage_set(KEY_VERSION, &CONFIG_VERSION, sizeof(CONFIG_VERSION)); storage_set(KEY_VERSION, &CONFIG_VERSION, sizeof(CONFIG_VERSION));
} }
data2hex(config_uuid, sizeof(config_uuid), config_uuid_str); data2hex((const uint8_t *)config_uuid, sizeof(config_uuid), config_uuid_str);
session_clear(false); session_clear(false);
@ -986,7 +986,7 @@ void config_wipe(void) {
} }
usbTiny(oldTiny); usbTiny(oldTiny);
random_buffer((uint8_t *)config_uuid, sizeof(config_uuid)); random_buffer((uint8_t *)config_uuid, sizeof(config_uuid));
data2hex(config_uuid, sizeof(config_uuid), config_uuid_str); data2hex((const uint8_t *)config_uuid, sizeof(config_uuid), config_uuid_str);
autoLockDelayMsCached = secfalse; autoLockDelayMsCached = secfalse;
storage_set(KEY_UUID, config_uuid, sizeof(config_uuid)); storage_set(KEY_UUID, config_uuid, sizeof(config_uuid));
storage_set(KEY_VERSION, &CONFIG_VERSION, sizeof(CONFIG_VERSION)); storage_set(KEY_VERSION, &CONFIG_VERSION, sizeof(CONFIG_VERSION));

View File

@ -32,11 +32,10 @@ void uint32hex(uint32_t num, char *str) {
} }
// converts data to hexa // converts data to hexa
void data2hex(const void *data, uint32_t len, char *str) { void data2hex(const uint8_t *data, uint32_t len, char *str) {
const uint8_t *cdata = (uint8_t *)data;
for (uint32_t i = 0; i < len; i++) { for (uint32_t i = 0; i < len; i++) {
str[i * 2] = hexdigits[(cdata[i] >> 4) & 0xF]; str[i * 2] = hexdigits[(data[i] >> 4) & 0xF];
str[i * 2 + 1] = hexdigits[cdata[i] & 0xF]; str[i * 2 + 1] = hexdigits[data[i] & 0xF];
} }
str[len * 2] = 0; str[len * 2] = 0;
} }

View File

@ -56,7 +56,7 @@ void delay(uint32_t wait);
void uint32hex(uint32_t num, char *str); void uint32hex(uint32_t num, char *str);
// converts data to hexa // converts data to hexa
void data2hex(const void *data, uint32_t len, char *str); void data2hex(const uint8_t *data, uint32_t len, char *str);
// defined in startup.s (or setup.c for emulator) // defined in startup.s (or setup.c for emulator)
extern void __attribute__((noreturn)) shutdown(void); extern void __attribute__((noreturn)) shutdown(void);