Fix spaces/tabs so that a single convention is used in each file.

pull/25/head
Andrew Kozlik 5 years ago committed by Pavol Rusnak
parent 8502ee61a3
commit 0e48a1a39a
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -27,6 +27,6 @@ uint32_t timer_ms(void) {
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
uint32_t msec = t.tv_sec * 1000 + (t.tv_nsec / 1000000);
uint32_t msec = t.tv_sec * 1000 + (t.tv_nsec / 1000000);
return msec;
}

@ -238,7 +238,7 @@ void layoutHome(void)
char label[MAX_LABEL_LEN + 1] = _("Go to trezor.io/start");
if (config_isInitialized()) {
config_getLabel(label, sizeof(label));
config_getLabel(label, sizeof(label));
}
uint8_t homescreen[HOMESCREEN_SIZE];
@ -257,12 +257,12 @@ void layoutHome(void)
}
}
bool no_backup = false;
bool unfinished_backup = false;
bool needs_backup = false;
config_getNoBackup(&no_backup);
config_getUnfinishedBackup(&unfinished_backup);
config_getNeedsBackup(&needs_backup);
bool no_backup = false;
bool unfinished_backup = false;
bool needs_backup = false;
config_getNoBackup(&no_backup);
config_getUnfinishedBackup(&unfinished_backup);
config_getNeedsBackup(&needs_backup);
if (no_backup) {
oledBox(0, 0, 127, 8, false);
oledDrawStringCenter(OLED_WIDTH / 2, 0, "SEEDLESS", FONT_STANDARD);

@ -149,34 +149,34 @@ const char *requestPin(PinMatrixRequestType type, const char *text)
secbool protectPinUiCallback(uint32_t wait, uint32_t progress)
{
(void) progress;
// Convert wait to secstr string.
char secstrbuf[] = _("________0 seconds");
char *secstr = secstrbuf + 9;
uint32_t secs = wait;
do {
secstr--;
*secstr = (secs % 10) + '0';
secs /= 10;
} while (secs > 0 && secstr >= secstrbuf);
if (wait == 1) {
// Change "seconds" to "second".
secstrbuf[16] = 0;
}
layoutDialog(&bmp_icon_info, NULL, NULL, NULL, _("Verifying PIN"), NULL, _("Please wait"), secstr, _("to continue ..."), NULL);
// Check for Cancel / Initialize.
protectAbortedByCancel = (msg_tiny_id == MessageType_MessageType_Cancel);
protectAbortedByInitialize = (msg_tiny_id == MessageType_MessageType_Initialize);
if (protectAbortedByCancel || protectAbortedByInitialize) {
msg_tiny_id = 0xFFFF;
usbTiny(0);
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return sectrue;
}
return secfalse;
(void) progress;
// Convert wait to secstr string.
char secstrbuf[] = _("________0 seconds");
char *secstr = secstrbuf + 9;
uint32_t secs = wait;
do {
secstr--;
*secstr = (secs % 10) + '0';
secs /= 10;
} while (secs > 0 && secstr >= secstrbuf);
if (wait == 1) {
// Change "seconds" to "second".
secstrbuf[16] = 0;
}
layoutDialog(&bmp_icon_info, NULL, NULL, NULL, _("Verifying PIN"), NULL, _("Please wait"), secstr, _("to continue ..."), NULL);
// Check for Cancel / Initialize.
protectAbortedByCancel = (msg_tiny_id == MessageType_MessageType_Cancel);
protectAbortedByInitialize = (msg_tiny_id == MessageType_MessageType_Initialize);
if (protectAbortedByCancel || protectAbortedByInitialize) {
msg_tiny_id = 0xFFFF;
usbTiny(0);
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return sectrue;
}
return secfalse;
}
bool protectPin(bool use_cached)
@ -187,77 +187,77 @@ bool protectPin(bool use_cached)
const char *pin = "";
if (config_hasPin()) {
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:"));
if (!pin) {
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:"));
if (!pin) {
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
}
usbTiny(1);
usbTiny(1);
bool ret = config_containsPin(pin);
usbTiny(0);
usbTiny(0);
if (!ret) {
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
}
return ret;
return ret;
}
bool protectChangePin(bool removal)
{
static CONFIDENTIAL char old_pin[MAX_PIN_LEN + 1] = "";
static CONFIDENTIAL char new_pin[MAX_PIN_LEN + 1] = "";
const char* pin = NULL;
if (config_hasPin()) {
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:"));
if (pin == NULL) {
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
strlcpy(old_pin, pin, sizeof(old_pin));
}
if (!removal) {
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_NewFirst, _("Please enter new PIN:"));
if (pin == NULL) {
memzero(old_pin, sizeof(old_pin));
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
strlcpy(new_pin, pin, sizeof(new_pin));
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_NewSecond, _("Please re-enter new PIN:"));
if (pin == NULL) {
memzero(old_pin, sizeof(old_pin));
memzero(new_pin, sizeof(new_pin));
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
if (strncmp(new_pin, pin, sizeof(new_pin)) != 0) {
memzero(old_pin, sizeof(old_pin));
memzero(new_pin, sizeof(new_pin));
fsm_sendFailure(FailureType_Failure_PinMismatch, NULL);
return false;
}
}
usbTiny(1);
bool ret = config_changePin(old_pin, new_pin);
usbTiny(0);
memzero(old_pin, sizeof(old_pin));
memzero(new_pin, sizeof(new_pin));
if (ret == false) {
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
}
return ret;
static CONFIDENTIAL char old_pin[MAX_PIN_LEN + 1] = "";
static CONFIDENTIAL char new_pin[MAX_PIN_LEN + 1] = "";
const char* pin = NULL;
if (config_hasPin()) {
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_Current, _("Please enter current PIN:"));
if (pin == NULL) {
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
strlcpy(old_pin, pin, sizeof(old_pin));
}
if (!removal) {
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_NewFirst, _("Please enter new PIN:"));
if (pin == NULL) {
memzero(old_pin, sizeof(old_pin));
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
strlcpy(new_pin, pin, sizeof(new_pin));
pin = requestPin(PinMatrixRequestType_PinMatrixRequestType_NewSecond, _("Please re-enter new PIN:"));
if (pin == NULL) {
memzero(old_pin, sizeof(old_pin));
memzero(new_pin, sizeof(new_pin));
fsm_sendFailure(FailureType_Failure_PinCancelled, NULL);
return false;
}
if (strncmp(new_pin, pin, sizeof(new_pin)) != 0) {
memzero(old_pin, sizeof(old_pin));
memzero(new_pin, sizeof(new_pin));
fsm_sendFailure(FailureType_Failure_PinMismatch, NULL);
return false;
}
}
usbTiny(1);
bool ret = config_changePin(old_pin, new_pin);
usbTiny(0);
memzero(old_pin, sizeof(old_pin));
memzero(new_pin, sizeof(new_pin));
if (ret == false) {
fsm_sendFailure(FailureType_Failure_PinInvalid, NULL);
}
return ret;
}
bool protectPassphrase(void)
{
bool passphrase_protection = false;
config_getPassphraseProtection(&passphrase_protection);
bool passphrase_protection = false;
config_getPassphraseProtection(&passphrase_protection);
if (!passphrase_protection || session_isPassphraseCached()) {
return true;
}

@ -165,13 +165,13 @@ static void recovery_done(void) {
if (!dry_run) {
// Update mnemonic on config.
if (config_setMnemonic(new_mnemonic)) {
if (!enforce_wordlist) {
// not enforcing => mark config as imported
config_setImported(true);
}
fsm_sendSuccess(_("Device recovered"));
if (!enforce_wordlist) {
// not enforcing => mark config as imported
config_setImported(true);
}
fsm_sendSuccess(_("Device recovered"));
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to store mnemonic"));
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to store mnemonic"));
}
memzero(new_mnemonic, sizeof(new_mnemonic));
} else {

@ -97,7 +97,7 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len)
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Not in Reset mode"));
return;
}
awaiting_entropy = false;
awaiting_entropy = false;
SHA256_CTX ctx;
sha256_Init(&ctx);
@ -108,21 +108,21 @@ void reset_entropy(const uint8_t *ext_entropy, uint32_t len)
memzero(int_entropy, 32);
if (skip_backup || no_backup) {
if (no_backup) {
config_setNoBackup();
} else {
config_setNeedsBackup(true);
}
if (config_setMnemonic(mnemonic)) {
fsm_sendSuccess(_("Device successfully initialized"));
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to store mnemonic"));
}
if (no_backup) {
config_setNoBackup();
} else {
config_setNeedsBackup(true);
}
if (config_setMnemonic(mnemonic)) {
fsm_sendSuccess(_("Device successfully initialized"));
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to store mnemonic"));
}
layoutHome();
} else {
reset_backup(false, mnemonic);
}
mnemonic_clear();
mnemonic_clear();
}
static char current_word[10];
@ -131,15 +131,15 @@ static char current_word[10];
void reset_backup(bool separated, const char* mnemonic)
{
if (separated) {
bool needs_backup = false;
config_getNeedsBackup(&needs_backup);
if (!needs_backup) {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Seed already backed up"));
return;
}
config_setUnfinishedBackup(true);
config_setNeedsBackup(false);
bool needs_backup = false;
config_getNeedsBackup(&needs_backup);
if (!needs_backup) {
fsm_sendFailure(FailureType_Failure_UnexpectedMessage, _("Seed already backed up"));
return;
}
config_setUnfinishedBackup(true);
config_setNeedsBackup(false);
}
for (int pass = 0; pass < 2; pass++) {
@ -173,12 +173,12 @@ void reset_backup(bool separated, const char* mnemonic)
if (separated) {
fsm_sendSuccess(_("Seed successfully backed up"));
} else {
config_setNeedsBackup(false);
if (config_setMnemonic(mnemonic)) {
fsm_sendSuccess(_("Device successfully initialized"));
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to store mnemonic"));
}
config_setNeedsBackup(false);
if (config_setMnemonic(mnemonic)) {
fsm_sendSuccess(_("Device successfully initialized"));
} else {
fsm_sendFailure(FailureType_Failure_ProcessError, _("Failed to store mnemonic"));
}
}
layoutHome();
}

@ -90,9 +90,9 @@ void check_lock_screen(void)
int main(void)
{
#if EMULATOR
memzero(HW_ENTROPY_DATA, HW_ENTROPY_LEN);
memzero(HW_ENTROPY_DATA, HW_ENTROPY_LEN);
#else
desig_get_unique_id((uint32_t*)HW_ENTROPY_DATA);
desig_get_unique_id((uint32_t*)HW_ENTROPY_DATA);
#endif
#ifndef APPVER

@ -43,7 +43,7 @@ static const uint32_t FLASH_SECTOR_TABLE[FLASH_SECTOR_COUNT + 1] = {
static secbool flash_check_success(uint32_t status)
{
return (status & (FLASH_SR_PGAERR | FLASH_SR_PGPERR | FLASH_SR_PGSERR | FLASH_SR_WRPERR)) ? secfalse : sectrue;
return (status & (FLASH_SR_PGAERR | FLASH_SR_PGPERR | FLASH_SR_PGSERR | FLASH_SR_WRPERR)) ? secfalse : sectrue;
}
void flash_init(void)
@ -58,7 +58,7 @@ secbool flash_unlock_write(void)
secbool flash_lock_write(void)
{
return flash_check_success(svc_flash_lock());
return flash_check_success(svc_flash_lock());
}
const void *flash_get_address(uint8_t sector, uint32_t offset, uint32_t size)
@ -77,16 +77,16 @@ const void *flash_get_address(uint8_t sector, uint32_t offset, uint32_t size)
secbool flash_erase(uint8_t sector)
{
ensure(flash_unlock_write(), NULL);
svc_flash_erase_sector(sector);
ensure(flash_lock_write(), NULL);
// Check whether the sector was really deleted (contains only 0xFF).
const uint32_t addr_start = FLASH_SECTOR_TABLE[sector], addr_end = FLASH_SECTOR_TABLE[sector + 1];
for (uint32_t addr = addr_start; addr < addr_end; addr += 4) {
if (*((const uint32_t *)FLASH_PTR(addr)) != 0xFFFFFFFF) {
return secfalse;
}
}
svc_flash_erase_sector(sector);
ensure(flash_lock_write(), NULL);
// Check whether the sector was really deleted (contains only 0xFF).
const uint32_t addr_start = FLASH_SECTOR_TABLE[sector], addr_end = FLASH_SECTOR_TABLE[sector + 1];
for (uint32_t addr = addr_start; addr < addr_end; addr += 4) {
if (*((const uint32_t *)FLASH_PTR(addr)) != 0xFFFFFFFF) {
return secfalse;
}
}
return sectrue;
}
@ -98,14 +98,14 @@ secbool flash_write_byte(uint8_t sector, uint32_t offset, uint8_t data)
}
if ((*address & data) != data) {
return secfalse;
return secfalse;
}
svc_flash_program(FLASH_CR_PROGRAM_X8);
*(volatile uint8_t *) address = data;
svc_flash_program(FLASH_CR_PROGRAM_X8);
*(volatile uint8_t *) address = data;
if (*address != data) {
return secfalse;
return secfalse;
}
return sectrue;
@ -123,14 +123,14 @@ secbool flash_write_word(uint8_t sector, uint32_t offset, uint32_t data)
}
if ((*address & data) != data) {
return secfalse;
return secfalse;
}
svc_flash_program(FLASH_CR_PROGRAM_X32);
*(volatile uint32_t *) address = data;
svc_flash_program(FLASH_CR_PROGRAM_X32);
*(volatile uint32_t *) address = data;
if (*address != data) {
return secfalse;
return secfalse;
}
return sectrue;

Loading…
Cancel
Save