1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 19:08:12 +00:00

fail sooner when the device is not initialized

This commit is contained in:
Pavol Rusnak 2015-11-19 11:03:16 +01:00
parent c71abf91a6
commit 27183323a4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

View File

@ -282,6 +282,11 @@ void fsm_msgGetPublicKey(GetPublicKey *msg)
{ {
RESP_INIT(PublicKey); RESP_INIT(PublicKey);
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
if (!protectPin(true)) { if (!protectPin(true)) {
layoutHome(); layoutHome();
return; return;
@ -363,6 +368,11 @@ void fsm_msgResetDevice(ResetDevice *msg)
void fsm_msgSignTx(SignTx *msg) void fsm_msgSignTx(SignTx *msg)
{ {
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
if (msg->inputs_count < 1) { if (msg->inputs_count < 1) {
fsm_sendFailure(FailureType_Failure_Other, "Transaction must have at least one input"); fsm_sendFailure(FailureType_Failure_Other, "Transaction must have at least one input");
layoutHome(); layoutHome();
@ -406,6 +416,10 @@ void fsm_msgTxAck(TxAck *msg)
void fsm_msgCipherKeyValue(CipherKeyValue *msg) void fsm_msgCipherKeyValue(CipherKeyValue *msg)
{ {
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
if (!msg->has_key) { if (!msg->has_key) {
fsm_sendFailure(FailureType_Failure_SyntaxError, "No key provided"); fsm_sendFailure(FailureType_Failure_SyntaxError, "No key provided");
return; return;
@ -531,6 +545,11 @@ void fsm_msgGetAddress(GetAddress *msg)
{ {
RESP_INIT(Address); RESP_INIT(Address);
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
if (!protectPin(true)) { if (!protectPin(true)) {
layoutHome(); layoutHome();
return; return;
@ -599,6 +618,11 @@ void fsm_msgSignMessage(SignMessage *msg)
{ {
RESP_INIT(MessageSignature); RESP_INIT(MessageSignature);
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
layoutSignMessage(msg->message.bytes, msg->message.size); layoutSignMessage(msg->message.bytes, msg->message.size);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) { if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Sign message cancelled"); fsm_sendFailure(FailureType_Failure_ActionCancelled, "Sign message cancelled");
@ -660,6 +684,11 @@ void fsm_msgSignIdentity(SignIdentity *msg)
{ {
RESP_INIT(SignedIdentity); RESP_INIT(SignedIdentity);
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
layoutSignIdentity(&(msg->identity), msg->has_challenge_visual ? msg->challenge_visual : 0); layoutSignIdentity(&(msg->identity), msg->has_challenge_visual ? msg->challenge_visual : 0);
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) { if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
fsm_sendFailure(FailureType_Failure_ActionCancelled, "Sign identity cancelled"); fsm_sendFailure(FailureType_Failure_ActionCancelled, "Sign identity cancelled");
@ -736,6 +765,10 @@ void fsm_msgSignIdentity(SignIdentity *msg)
void fsm_msgEncryptMessage(EncryptMessage *msg) void fsm_msgEncryptMessage(EncryptMessage *msg)
{ {
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
if (!msg->has_pubkey) { if (!msg->has_pubkey) {
fsm_sendFailure(FailureType_Failure_SyntaxError, "No public key provided"); fsm_sendFailure(FailureType_Failure_SyntaxError, "No public key provided");
return; return;
@ -792,6 +825,10 @@ void fsm_msgEncryptMessage(EncryptMessage *msg)
void fsm_msgDecryptMessage(DecryptMessage *msg) void fsm_msgDecryptMessage(DecryptMessage *msg)
{ {
if (!storage_isInitialized()) {
fsm_sendFailure(FailureType_Failure_NotInitialized, "Device not initialized");
return;
}
if (!msg->has_nonce) { if (!msg->has_nonce) {
fsm_sendFailure(FailureType_Failure_SyntaxError, "No nonce provided"); fsm_sendFailure(FailureType_Failure_SyntaxError, "No nonce provided");
return; return;