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

feat(legacy): Implement DoPreauthorized.

This commit is contained in:
Andrew Kozlik 2023-01-02 20:10:23 +01:00 committed by matejcik
parent 34dcd53135
commit 6d20fccefd
4 changed files with 26 additions and 2 deletions

View File

@ -68,6 +68,9 @@
static uint8_t msg_resp[MSG_OUT_DECODED_SIZE] __attribute__((aligned));
// Authorization message type triggered by DoPreauthorized.
static MessageType authorization_type = 0;
#define RESP_INIT(TYPE) \
TYPE *resp = (TYPE *)(void *)msg_resp; \
_Static_assert(sizeof(msg_resp) >= sizeof(TYPE), #TYPE " is too large"); \
@ -403,6 +406,7 @@ void fsm_msgRebootToBootloader(void) {
void fsm_abortWorkflows(void) {
recovery_abort();
signing_abort();
authorization_type = 0;
#if !BITCOIN_ONLY
ethereum_signing_abort();
stellar_signingAbort();

View File

@ -87,6 +87,7 @@ void fsm_msgGetOwnershipId(const GetOwnershipId *msg);
void fsm_msgGetOwnershipProof(const GetOwnershipProof *msg);
void fsm_msgAuthorizeCoinJoin(const AuthorizeCoinJoin *msg);
void fsm_msgCancelAuthorization(const CancelAuthorization *msg);
void fsm_msgDoPreauthorized(const DoPreauthorized *msg);
// crypto
void fsm_msgCipherKeyValue(const CipherKeyValue *msg);

View File

@ -700,4 +700,23 @@ void fsm_msgCancelAuthorization(const CancelAuthorization *msg) {
fsm_sendSuccess(_("Authorization cancelled"));
layoutHome();
}
}
void fsm_msgDoPreauthorized(const DoPreauthorized *msg) {
(void)msg;
RESP_INIT(PreauthorizedRequest);
CHECK_INITIALIZED
authorization_type = config_getAuthorizationType();
if (authorization_type == 0) {
fsm_sendFailure(FailureType_Failure_ProcessError,
_("No preauthorized operation"));
layoutHome();
return;
}
msg_write(MessageType_MessageType_PreauthorizedRequest, resp);
layoutHome();
}

View File

@ -4,7 +4,7 @@ endif
SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \
DebugLinkRecordScreen DebugLinkEraseSdCard DebugLinkWatchLayout \
DoPreauthorized DebugLinkLayout GetNonce SetBusy UnlockPath \
DebugLinkLayout GetNonce SetBusy UnlockPath \
TxAckInput TxAckOutput TxAckPrev TxAckPaymentRequest \
EthereumSignTypedData EthereumTypedDataStructRequest EthereumTypedDataStructAck \
EthereumTypedDataValueRequest EthereumTypedDataValueAck