From e81bb0f85696d2604b93b71a4affc69cd72b1dcd Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 9 Feb 2022 16:47:54 +0100 Subject: [PATCH] feat(legacy): enable DebugLinkReseedRandom --- legacy/firmware/.changelog.d/2115.added | 1 + legacy/firmware/fsm.h | 1 + legacy/firmware/fsm_msg_debug.h | 16 ++++++++++++++++ legacy/firmware/protob/Makefile | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 legacy/firmware/.changelog.d/2115.added diff --git a/legacy/firmware/.changelog.d/2115.added b/legacy/firmware/.changelog.d/2115.added new file mode 100644 index 000000000..34ed07dd5 --- /dev/null +++ b/legacy/firmware/.changelog.d/2115.added @@ -0,0 +1 @@ +\[emulator] Added support for `DebugLinkReseedRandom`. diff --git a/legacy/firmware/fsm.h b/legacy/firmware/fsm.h index 8c65dbfab..3dfd195a9 100644 --- a/legacy/firmware/fsm.h +++ b/legacy/firmware/fsm.h @@ -94,6 +94,7 @@ void fsm_msgDebugLinkStop(const DebugLinkStop *msg); void fsm_msgDebugLinkMemoryWrite(const DebugLinkMemoryWrite *msg); void fsm_msgDebugLinkMemoryRead(const DebugLinkMemoryRead *msg); void fsm_msgDebugLinkFlashErase(const DebugLinkFlashErase *msg); +void fsm_msgDebugLinkReseedRandom(const DebugLinkReseedRandom *msg); #endif // ethereum diff --git a/legacy/firmware/fsm_msg_debug.h b/legacy/firmware/fsm_msg_debug.h index b264f1d99..1512a88b4 100644 --- a/legacy/firmware/fsm_msg_debug.h +++ b/legacy/firmware/fsm_msg_debug.h @@ -100,4 +100,20 @@ void fsm_msgDebugLinkFlashErase(const DebugLinkFlashErase *msg) { uint32_t dummy = svc_flash_lock(); (void)dummy; } + +void fsm_msgDebugLinkReseedRandom(const DebugLinkReseedRandom *msg) { +#if EMULATOR + RESP_INIT(Success); + random_reseed(msg->value); + msg_debug_write(MessageType_MessageType_Success, resp); +#else + (void)msg; + RESP_INIT(Failure); + resp->code = FailureType_Failure_UnexpectedMessage; + resp->has_message = true; + strlcpy(resp->message, "ReseedRandom not supported on hardware", + sizeof(resp->message)); + msg_debug_write(MessageType_MessageType_Failure, resp); +#endif +} #endif diff --git a/legacy/firmware/protob/Makefile b/legacy/firmware/protob/Makefile index e4d7b6d83..d6950d136 100644 --- a/legacy/firmware/protob/Makefile +++ b/legacy/firmware/protob/Makefile @@ -3,7 +3,7 @@ Q := @ endif SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \ - DebugLinkRecordScreen DebugLinkReseedRandom DebugLinkShowText DebugLinkEraseSdCard DebugLinkWatchLayout \ + DebugLinkRecordScreen DebugLinkEraseSdCard DebugLinkWatchLayout \ GetOwnershipProof OwnershipProof GetOwnershipId OwnershipId AuthorizeCoinJoin DoPreauthorized \ CancelAuthorization DebugLinkLayout GetNonce \ TxAckInput TxAckOutput TxAckPrev TxAckPaymentRequest \