Exemplo n.º 1
0
void fsm_msgApplySettings(ApplySettings *msg)
{
	if (msg->has_label && msg->has_language) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change label to", msg->label, "and language to", msg->language, "?");
	} else
	if (msg->has_label) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change label to", msg->label, "?", NULL, NULL);
	} else
	if (msg->has_language) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change language to", msg->language, "?", NULL, NULL);
	} else {
		fsm_sendFailure(FailureType_Failure_SyntaxError, "No setting provided");
		return;
	}
	if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
		fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
		layoutHome();
		return;
	}
	if (!protectPin(true)) {
		layoutHome();
		return;
	}
	if (msg->has_label) {
		storage_setLabel(msg->label);
	}
	if (msg->has_language) {
		storage_setLanguage(msg->language);
	}
	storage_commit();
	fsm_sendSuccess("Settings applied");
	layoutHome();
}
Exemplo n.º 2
0
void next_word(void) {
	word_pos = word_order[word_index];
	if (word_pos == 0) {
		const char * const *wl = mnemonic_wordlist();
		strlcpy(fake_word, wl[random_uniform(2048)], sizeof(fake_word));
		layoutDialogSwipe(DIALOG_ICON_INFO, NULL, NULL, NULL, "Please enter the word", NULL, fake_word, NULL, "on your computer", NULL);
	} else {
		fake_word[0] = 0;
		char desc[] = "##th word";
		if (word_pos < 10) {
			desc[0] = ' ';
		} else {
			desc[0] = '0' + word_pos / 10;
		}
		desc[1] = '0' + word_pos % 10;
		if (word_pos == 1 || word_pos == 21) {
			desc[2] = 's'; desc[3] = 't';
		} else
		if (word_pos == 2 || word_pos == 22) {
			desc[2] = 'n'; desc[3] = 'd';
		} else
		if (word_pos == 3 || word_pos == 23) {
			desc[2] = 'r'; desc[3] = 'd';
		}
		layoutDialogSwipe(DIALOG_ICON_INFO, NULL, NULL, NULL, "Please enter the", NULL, (word_pos < 10 ? desc + 1 : desc), NULL, "of your mnemonic", NULL);
	}
	WordRequest resp;
	memset(&resp, 0, sizeof(WordRequest));
	msg_write(MessageType_MessageType_WordRequest, &resp);
}
Exemplo n.º 3
0
void fsm_msgApplySettings(ApplySettings *msg)
{
	if (msg->has_label) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change label to", msg->label, "?", NULL, NULL);
		if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
			layoutHome();
			return;
		}
	}
	if (msg->has_language) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change language to", msg->language, "?", NULL, NULL);
		if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
			layoutHome();
			return;
		}
	}
	if (msg->has_use_passphrase) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", msg->use_passphrase ? "enable passphrase" : "disable passphrase", "encryption?", NULL, NULL, NULL);
		if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
			layoutHome();
			return;
		}
	}
	if (msg->has_homescreen) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change the home", "screen ?", NULL, NULL, NULL);
		if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "Apply settings cancelled");
			layoutHome();
			return;
		}
	}
	if (!msg->has_label && !msg->has_language && !msg->has_use_passphrase && !msg->has_homescreen) {
		fsm_sendFailure(FailureType_Failure_SyntaxError, "No setting provided");
		return;
	}
	if (!protectPin(true)) {
		layoutHome();
		return;
	}
	if (msg->has_label) {
		storage_setLabel(msg->label);
	}
	if (msg->has_language) {
		storage_setLanguage(msg->language);
	}
	if (msg->has_use_passphrase) {
		storage_setPassphraseProtection(msg->use_passphrase);
	}
	if (msg->has_homescreen) {
		storage_setHomescreen(msg->homescreen.bytes, msg->homescreen.size);
	}
	storage_commit();
	fsm_sendSuccess("Settings applied");
	layoutHome();
}
Exemplo n.º 4
0
void layoutVerifyMessage(const uint8_t *msg, uint32_t len)
{
	const char **str;
	if (!is_valid_ascii(msg, len)) {
		str = split_message_hex(msg, len);
		layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Confirm"),
			_("Verified binary message"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	} else {
		str = split_message(msg, len, 20);
		layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Confirm"),
			_("Verified message"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	}
}
Exemplo n.º 5
0
void layoutSignMessage(const uint8_t *msg, uint32_t len)
{
	const char **str;
	if (!is_valid_ascii(msg, len)) {
		str = split_message_hex(msg, len);
		layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
			_("Sign binary message?"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	} else {
		str = split_message(msg, len, 20);
		layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
			_("Sign message?"),
			str[0], str[1], str[2], str[3], NULL, NULL);
	}
}
Exemplo n.º 6
0
void layoutLiskVerifyAddress(const char *address) {
  const char **str =
      split_message((const uint8_t *)address, strlen(address), 10);
  layoutDialogSwipe(&bmp_icon_info, _("Cancel"), _("Confirm"),
                    _("Confirm address?"), _("Message signed by:"), str[0],
                    str[1], NULL, NULL, NULL);
}
Exemplo n.º 7
0
void fsm_msgLoadDevice(LoadDevice *msg)
{
	if (storage_isInitialized()) {
		fsm_sendFailure(FailureType_Failure_UnexpectedMessage, "Device is already initialized. Use Wipe first.");
		return;
	}

	layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "I take the risk", NULL, "Loading private seed", "is not recommended.", "Continue only if you", "know what you are", "doing!", NULL);
	if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
		fsm_sendFailure(FailureType_Failure_ActionCancelled, "Load cancelled");
		layoutHome();
		return;
	}

	if (msg->has_mnemonic && !(msg->has_skip_checksum && msg->skip_checksum) ) {
		if (!mnemonic_check(msg->mnemonic)) {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "Mnemonic with wrong checksum provided");
			layoutHome();
			return;
		}
	}

	storage_loadDevice(msg);
	storage_commit();
	fsm_sendSuccess("Device loaded");
	layoutHome();
}
Exemplo n.º 8
0
void layoutDecryptMessage(const uint8_t *msg, uint32_t len, const char *address)
{
	const char **str = split_message(msg, len, 16);
	layoutDialogSwipe(&bmp_icon_info, NULL, _("OK"),
		address ? _("Decrypted signed message") : _("Decrypted message"),
		str[0], str[1], str[2], str[3], NULL, NULL);
}
Exemplo n.º 9
0
void layoutEncryptMessage(const uint8_t *msg, uint32_t len, bool signing)
{
	const char **str = split_message(msg, len, 16);
	layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
		signing ? _("Encrypt+Sign message?") : _("Encrypt message?"),
		str[0], str[1], str[2], str[3], NULL, NULL);
}
Exemplo n.º 10
0
void layoutCipherKeyValue(bool encrypt, const char *key)
{
	const char **str = split_message((const uint8_t *)key, strlen(key), 16);
	layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"),
		encrypt ? _("Encrypt value of this key?") : _("Decrypt value of this key?"),
		str[0], str[1], str[2], str[3], NULL, NULL);
}
Exemplo n.º 11
0
void fsm_msgPing(Ping *msg)
{
	RESP_INIT(Success);

	if (msg->has_button_protection && msg->button_protection) {
		layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "answer to ping?", NULL, NULL, NULL, NULL);
		if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "Ping cancelled");
			layoutHome();
			return;
		}
	}

	if (msg->has_pin_protection && msg->pin_protection) {
		if (!protectPin(true)) {
			layoutHome();
			return;
		}
	}

	if (msg->has_passphrase_protection && msg->passphrase_protection) {
		if (!protectPassphrase()) {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "Ping cancelled");
			return;
		}
	}

	if (msg->has_message) {
		resp->has_message = true;
		memcpy(&(resp->message), &(msg->message), sizeof(resp->message));
	}
	msg_write(MessageType_MessageType_Success, resp);
	layoutHome();
}
Exemplo n.º 12
0
void layoutRequireConfirmTx(char *recipient_id, uint64_t amount) {
  char formated_amount[MAX_LISK_VALUE_SIZE];
  const char **str =
      split_message((const uint8_t *)recipient_id, strlen(recipient_id), 16);
  lisk_format_value(amount, formated_amount);
  layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
                    _("Confirm sending"), formated_amount, _("to:"), str[0],
                    str[1], NULL);
}
Exemplo n.º 13
0
void layoutRequireConfirmDelegateRegistration(LiskTransactionAsset *asset) {
  if (asset->has_delegate && asset->delegate.has_username) {
    const char **str = split_message((const uint8_t *)asset->delegate.username,
                                     strlen(asset->delegate.username), 20);
    layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
                      _("Confirm transaction"), _("Do you really want to"),
                      _("register a delegate?"), str[0], str[1], NULL);
  }
}
Exemplo n.º 14
0
void layoutRequireConfirmFee(uint64_t fee, uint64_t amount) {
  char formated_amount[MAX_LISK_VALUE_SIZE];
  char formated_fee[MAX_LISK_VALUE_SIZE];
  lisk_format_value(amount, formated_amount);
  lisk_format_value(fee, formated_fee);
  layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
                    _("Confirm transaction"), formated_amount, _("fee:"),
                    formated_fee, NULL, NULL);
}
Exemplo n.º 15
0
void fsm_msgChangePin(ChangePin *msg)
{
	bool removal = msg->has_remove && msg->remove;
	if (removal) {
		if (storage_hasPin()) {
			layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "remove current PIN?", NULL, NULL, NULL, NULL);
		} else {
			fsm_sendSuccess("PIN removed");
			return;
		}
	} else {
		if (storage_hasPin()) {
			layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "change current PIN?", NULL, NULL, NULL, NULL);
		} else {
			layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "set new PIN?", NULL, NULL, NULL, NULL);
		}
	}
	if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
		fsm_sendFailure(FailureType_Failure_ActionCancelled, removal ? "PIN removal cancelled" : "PIN change cancelled");
		layoutHome();
		return;
	}
	if (!protectPin(false)) {
		layoutHome();
		return;
	}
	if (removal) {
		storage_setPin(0);
		fsm_sendSuccess("PIN removed");
	} else {
		if (protectChangePin()) {
			fsm_sendSuccess("PIN changed");
		} else {
			fsm_sendFailure(FailureType_Failure_ActionCancelled, "PIN change failed");
		}
	}
	layoutHome();
}
Exemplo n.º 16
0
void layoutPublicKey(const uint8_t *pubkey)
{
	char desc[16];
	strlcpy(desc, "Public Key: 00", sizeof(desc));
	if (pubkey[0] == 1) {
		/* ed25519 public key */
		// pass - leave 00
	} else {
		data2hex(pubkey, 1, desc + 12);
	}
	const char **str = split_message_hex(pubkey + 1, 32 * 2);
	layoutDialogSwipe(&bmp_icon_question, NULL, _("Continue"), NULL,
		desc, str[0], str[1], str[2], str[3], NULL);
}
Exemplo n.º 17
0
void layoutFeeOverThreshold(const CoinInfo *coin, uint64_t fee)
{
	char str_fee[32];
	bn_format_uint64(fee, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0, false, str_fee, sizeof(str_fee));
	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		_("Confirm"),
		NULL,
		_("Fee"),
		str_fee,
		_("is unexpectedly high."),
		NULL,
		_("Send anyway?"),
		NULL
	);
}
Exemplo n.º 18
0
void layoutConfirmTx(const CoinInfo *coin, uint64_t amount_out, uint64_t amount_fee)
{
	char str_out[32], str_fee[32];
	bn_format_uint64(amount_out, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0, false, str_out, sizeof(str_out));
	bn_format_uint64(amount_fee, NULL, coin->coin_shortcut, BITCOIN_DIVISIBILITY, 0, false, str_fee, sizeof(str_fee));
	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		_("Confirm"),
		NULL,
		_("Really send"),
		str_out,
		_("from your wallet?"),
		_("Fee included:"),
		str_fee,
		NULL
	);
}
Exemplo n.º 19
0
void fsm_msgWipeDevice(WipeDevice *msg)
{
	(void)msg;
	layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "wipe the device?", NULL, "All data will be lost.", NULL, NULL);
	if (!protectButton(ButtonRequestType_ButtonRequest_WipeDevice, false)) {
		fsm_sendFailure(FailureType_Failure_ActionCancelled, "Wipe cancelled");
		layoutHome();
		return;
	}
	storage_reset();
	storage_reset_uuid();
	storage_commit();
	// the following does not work on Mac anyway :-/ Linux/Windows are fine, so it is not needed
	// usbReconnect(); // force re-enumeration because of the serial number change
	fsm_sendSuccess("Device wiped");
	layoutHome();
}
Exemplo n.º 20
0
void layoutNEMTransferXEM(const char *desc, uint64_t quantity, const bignum256 *multiplier, uint64_t fee) {
	char str_out[32], str_fee[32];

	nem_mosaicFormatAmount(NEM_MOSAIC_DEFINITION_XEM, quantity, multiplier, str_out, sizeof(str_out));
	nem_mosaicFormatAmount(NEM_MOSAIC_DEFINITION_XEM, fee, NULL, str_fee, sizeof(str_fee));

	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		_("Next"),
		desc,
		_("Confirm transfer of"),
		str_out,
		_("and network fee of"),
		str_fee,
		NULL,
		NULL);
}
Exemplo n.º 21
0
void layoutRequireConfirmMultisig(LiskTransactionAsset *asset) {
  char keys_group_str[25];
  char life_time_str[14];
  char min_str[8];

  bn_format_uint64(asset->multisignature.keys_group_count,
                   "Keys group length: ", NULL, 0, 0, false, keys_group_str,
                   sizeof(keys_group_str));
  bn_format_uint64(asset->multisignature.life_time, "Life time: ", NULL, 0, 0,
                   false, life_time_str, sizeof(life_time_str));
  bn_format_uint64(asset->multisignature.min, "Min: ", NULL, 0, 0, false,
                   min_str, sizeof(min_str));

  layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
                    _("Confirm transaction"), keys_group_str, life_time_str,
                    min_str, NULL, NULL);
}
Exemplo n.º 22
0
void fsm_msgGetEntropy(GetEntropy *msg)
{
	layoutDialogSwipe(DIALOG_ICON_QUESTION, "Cancel", "Confirm", NULL, "Do you really want to", "send entropy?", NULL, NULL, NULL, NULL);
	if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
		fsm_sendFailure(FailureType_Failure_ActionCancelled, "Entropy cancelled");
		layoutHome();
		return;
	}
	RESP_INIT(Entropy);
	uint32_t len = msg->size;
	if (len > 1024) {
		len = 1024;
	}
	resp->entropy.size = len;
	random_buffer(resp->entropy.bytes, len);
	msg_write(MessageType_MessageType_Entropy, resp);
	layoutHome();
}
Exemplo n.º 23
0
void reset_init(bool display_random, uint32_t _strength, bool passphrase_protection, bool pin_protection, const char *language, const char *label)
{
    if (_strength != 128 && _strength != 192 && _strength != 256) {
        fsm_sendFailure(FailureType_Failure_SyntaxError, "Invalid strength (has to be 128, 192 or 256 bits)");
        layoutHome();
        return;
    }

    strength = _strength;

    random_buffer(int_entropy, 32);

    char ent_str[4][17];
    data2hex(int_entropy     , 8, ent_str[0]);
    data2hex(int_entropy +  8, 8, ent_str[1]);
    data2hex(int_entropy + 16, 8, ent_str[2]);
    data2hex(int_entropy + 24, 8, ent_str[3]);

    if (display_random) {
        layoutDialogSwipe(DIALOG_ICON_INFO, "Cancel", "Continue", NULL, "Internal entropy:", ent_str[0], ent_str[1], ent_str[2], ent_str[3], NULL);
        if (!protectButton(ButtonRequestType_ButtonRequest_ResetDevice, false)) {
            fsm_sendFailure(FailureType_Failure_ActionCancelled, "Reset cancelled");
            layoutHome();
            return;
        }
    }

    if (pin_protection && !protectChangePin()) {
        fsm_sendFailure(FailureType_Failure_ActionCancelled, "PIN change failed");
        layoutHome();
        return;
    }

    storage.has_passphrase_protection = true;
    storage.passphrase_protection = passphrase_protection;
    storage_setLanguage(language);
    storage_setLabel(label);

    EntropyRequest resp;
    memset(&resp, 0, sizeof(EntropyRequest));
    msg_write(MessageType_MessageType_EntropyRequest, &resp);
    awaiting_entropy = true;
}
Exemplo n.º 24
0
void layoutNEMDialog(const BITMAP *icon, const char *btnNo, const char *btnYes, const char *desc, const char *line1, const char *address) {
	static char first_third[NEM_ADDRESS_SIZE / 3 + 1];
	strlcpy(first_third, address, sizeof(first_third));

	static char second_third[NEM_ADDRESS_SIZE / 3 + 1];
	strlcpy(second_third, &address[NEM_ADDRESS_SIZE / 3], sizeof(second_third));

	const char *third_third = &address[NEM_ADDRESS_SIZE * 2 / 3];

	layoutDialogSwipe(icon,
		btnNo,
		btnYes,
		desc,
		line1,
		first_third,
		second_third,
		third_third,
		NULL,
		NULL);
}
Exemplo n.º 25
0
void layoutNEMNetworkFee(const char *desc, bool confirm, const char *fee1_desc, uint64_t fee1, const char *fee2_desc, uint64_t fee2) {
	char str_fee1[32], str_fee2[32];

	nem_mosaicFormatAmount(NEM_MOSAIC_DEFINITION_XEM, fee1, NULL, str_fee1, sizeof(str_fee1));

	if (fee2_desc) {
		nem_mosaicFormatAmount(NEM_MOSAIC_DEFINITION_XEM, fee2, NULL, str_fee2, sizeof(str_fee2));
	}

	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		confirm ? _("Confirm") : _("Next"),
		desc,
		fee1_desc,
		str_fee1,
		fee2_desc,
		fee2_desc ? str_fee2 : NULL,
		NULL,
		NULL);
}
Exemplo n.º 26
0
void layoutNEMTransferMosaic(const NEMMosaicDefinition *definition, uint64_t quantity, const bignum256 *multiplier, uint8_t network) {
	char str_out[32], str_levy[32];

	nem_mosaicFormatAmount(definition, quantity, multiplier, str_out, sizeof(str_out));

	if (definition->has_levy) {
		nem_mosaicFormatLevy(definition, quantity, multiplier, network, str_levy, sizeof(str_levy));
	}

	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		_("Next"),
		definition->has_name ? definition->name : _("Mosaic"),
		_("Confirm transfer of"),
		str_out,
		definition->has_levy ? _("and levy of") : NULL,
		definition->has_levy ? str_levy : NULL,
		NULL,
		NULL);
}
Exemplo n.º 27
0
void layoutConfirmOpReturn(const uint8_t *data, uint32_t size)
{
	const char **str;
	if (!is_valid_ascii(data, size)) {
		str = split_message_hex(data, size);
	} else {
		str = split_message(data, size, 20);
	}
	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		_("Confirm"),
		NULL,
		_("Confirm OP_RETURN:"),
		str[0],
		str[1],
		str[2],
		str[3],
		NULL
	);
}
Exemplo n.º 28
0
void layoutConfirmOmni(const uint8_t *data, uint32_t size)
{
	const char *desc;
	char str_out[32];
	const uint32_t tx_type = *(const uint32_t *)(data + 4);
	if (tx_type == 0x00000000 && size == 20) {  // OMNI simple send
		desc = _("Simple send of ");
		const uint32_t currency = *(const uint32_t *)(data + 8);
		const char *suffix = "UNKN";
		switch (currency) {
			case 1:
				suffix = "OMNI";
				break;
			case 2:
				suffix = "tOMNI";
				break;
			case 3:
				suffix = "MAID";
				break;
			case 31:
				suffix = "USDT";
				break;
		}
		const uint64_t amount = *(const uint64_t *)(data + 12);
		bn_format_uint64(amount, NULL, suffix, BITCOIN_DIVISIBILITY, 0, false, str_out, sizeof(str_out));
	} else {
		desc = _("Unknown transaction");
		str_out[0] = 0;
	}
	layoutDialogSwipe(&bmp_icon_question,
		_("Cancel"),
		_("Confirm"),
		NULL,
		_("Confirm OMNI Transaction:"),
		NULL,
		desc,
		NULL,
		str_out,
		NULL
	);
}
Exemplo n.º 29
0
void layoutDecryptIdentity(const IdentityType *identity)
{
	char row_proto[8 + 11 + 1];
	char row_hostport[64 + 6 + 1];
	char row_user[64 + 8 + 1];

	if (identity->has_proto && identity->proto[0]) {
		strlcpy(row_proto, identity->proto, sizeof(row_proto));
		char *p = row_proto;
		while (*p) { *p = toupper((int)*p); p++; }
		strlcat(row_proto, _(" decrypt for:"), sizeof(row_proto));
	} else {
		strlcpy(row_proto, _("Decrypt for:"), sizeof(row_proto));
	}

	if (identity->has_host && identity->host[0]) {
		strlcpy(row_hostport, identity->host, sizeof(row_hostport));
		if (identity->has_port && identity->port[0]) {
			strlcat(row_hostport, ":", sizeof(row_hostport));
			strlcat(row_hostport, identity->port, sizeof(row_hostport));
		}
	} else {
		row_hostport[0] = 0;
	}

	if (identity->has_user && identity->user[0]) {
		strlcpy(row_user, _("user: "******"Cancel"), _("Confirm"),
		_("Do you want to decrypt?"),
		row_proto[0] ? row_proto : NULL,
		row_hostport[0] ? row_hostport : NULL,
		row_user[0] ? row_user : NULL,
		NULL,
		NULL,
		NULL);
}
Exemplo n.º 30
0
void layoutRequireConfirmCastVotes(LiskTransactionAsset *asset) {
  uint8_t plus = 0;
  uint8_t minus = 0;
  char add_votes_txt[13];
  char remove_votes_txt[16];

  for (int i = 0; i < asset->votes_count; i++) {
    if (asset->votes[i][0] == '+') {
      plus += 1;
    } else {
      minus += 1;
    }
  }

  bn_format_uint64(plus, "Add ", NULL, 0, 0, false, add_votes_txt,
                   sizeof(add_votes_txt));
  bn_format_uint64(minus, "Remove ", NULL, 0, 0, false, remove_votes_txt,
                   sizeof(remove_votes_txt));

  layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
                    _("Confirm transaction"), add_votes_txt, remove_votes_txt,
                    NULL, NULL, NULL);
}