B2CA-2394 : handle split reception at apdu parsing step#205
B2CA-2394 : handle split reception at apdu parsing step#205mbrousset-ledger wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #205 +/- ##
=======================================
Coverage 90.81% 90.81%
=======================================
Files 5 5
Lines 98 98
Branches 22 22
=======================================
Hits 89 89
Misses 9 9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Refactors transaction signing APDU handling so chunk reassembly happens in the APDU dispatcher, and handler_sign_tx is invoked only once the full transaction payload is available.
Changes:
- Moved SIGN_TX / SIGN_TOKEN_TX chunk initialization + accumulation logic from
handler/sign_tx.cintoapdu/dispatcher.c. - Simplified
handler_sign_txAPI to only takeis_token_tx(no chunk/more parameters). - Bumped app patch version from
2.3.1to2.3.2.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/handler/sign_tx.h |
Updates SIGN_TX handler signature and header comment to reflect dispatcher-side reassembly. |
src/handler/sign_tx.c |
Removes per-chunk parsing/accumulation; handler now processes the already-reassembled raw transaction. |
src/apdu/dispatcher.c |
Adds transaction init + accumulation helpers; dispatcher now manages multi-APDU reassembly before calling the signing handler. |
Makefile |
Increments patch version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (G_called_from_swap) { | ||
| PRINTF("Error during transaction processing in swap context: %u\n", err); | ||
| // Suspicious error, Return to Exchange instead of simply return an error APDU | ||
| send_swap_error_simple(SW_SWAP_FAIL, SWAP_EC_ERROR_GENERIC, SWAP_ERROR_CODE); |
| * @see G_context.bip32_path, G_context.tx_info.raw_transaction, | ||
| * G_context.tx_info.signature and G_context.tx_info.v. |
| @@ -90,12 +135,28 @@ int apdu_dispatcher(const command_t *cmd) { | |||
| buf.size = cmd->lc; | |||
| buf.offset = 0; | |||
|
|
|||
| // We could have written a handler_sign_token_tx but in our example token TX are very | |||
| // simple so we just reuse handler_sign_tx + a boolean. | |||
| return handler_sign_tx(&buf, | |||
| cmd->p1, | |||
| (bool) (cmd->p2 & P2_MORE), | |||
| cmd->ins == SIGN_TOKEN_TX); | |||
| bool is_token_tx = (cmd->ins == SIGN_TOKEN_TX); | |||
| uint8_t req_type = is_token_tx ? CONFIRM_TOKEN_TRANSACTION : CONFIRM_TRANSACTION; | |||
|
|
|||
| if (cmd->p1 == P1_START) { | |||
| // First APDU chunk: initialize context and parse BIP32 path | |||
| return init_transaction_context(&buf, req_type); | |||
| } | |||
|
@claude review |
| G_context.req_type = req_type; | ||
| G_context.state = STATE_NONE; | ||
|
|
||
| if (!buffer_read_u8(cdata, &G_context.bip32_path_len) || |
There was a problem hiding this comment.
Maybe interesting to look at buffer_get_path_bip32 in SDK (lib_standard_app/buffer.c)
542ce3a to
99783e1
Compare
|
@claude review |
|
Claude finished @mbrousset-ledger's task in 1m 51s —— View job Code Review
SummaryThe refactor cleanly achieves its goal: moving multi-chunk APDU reassembly out of Issues1. Critical — Missing
|
99783e1 to
d0d1849
Compare
|
@claude review |
|
Claude finished @mbrousset-ledger's task in 1m 22s —— View job Code Review
SummaryGood refactor — moving multi-chunk APDU reassembly from Issues1. Critical — Missing
|
|
@claude review |
|
Claude finished @mbrousset-ledger's task in 1m 34s —— View job Code Review
SummaryThis PR moves multi-chunk APDU reassembly from Issues1. Critical — Missing
|
Checklist
develop