-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/m2 parser #1
Conversation
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
2060ee1
to
17df9e4
Compare
app/src/parser_impl.c
Outdated
|
||
static parser_error_t parser_verify_codec(parser_context_t *ctx) { | ||
uint16_t codec = 0; | ||
read_u16(ctx, &codec); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing CHECK_ERROR here
app/src/parser_print_common.c
Outdated
#include "zxformat.h" | ||
#include "zxmacros.h" | ||
|
||
#define ALPHABET_ENCODE "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is not used
app/src/parser_print_common.c
Outdated
const char *hrp = ""; | ||
switch (network_id) { | ||
case songbird: | ||
hrp = " song"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the space part of the HRP?
app/src/parser_print_common.c
Outdated
hrp = " song"; | ||
break; | ||
case coston: | ||
hrp = " costwo"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
app/src/parser_print_common.c
Outdated
// Calculate SHA256 checksum | ||
uint8_t checksum[CX_SHA256_SIZE] = {0}; | ||
#if defined(TARGET_NANOS) || defined(TARGET_NANOS2) || defined(TARGET_NANOX) || defined(TARGET_STAX) | ||
cx_hash_sha256(nodeId, NODE_ID_LEN, checksum, CX_SHA256_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing check that return code is CX_OK
|
||
static parser_error_t parser_handle_cchain_export(parser_context_t *c, parser_tx_t *v) { | ||
// Get destination chain | ||
v->tx.c_export_tx.destination_chain = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check that c->offset + BLOCKCHAIN_ID_LEN <= c->bufferLen
} | ||
|
||
// Pointer to inputs | ||
v->tx.c_export_tx.evm_inputs.ins = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar that above. Check that c->offset < c->bufferLen
|
||
// Pointer to outputs | ||
if (v->tx.c_export_tx.secp_outs.n_outs > 0) { | ||
v->tx.c_export_tx.secp_outs.outs = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
|
||
static parser_error_t parser_handle_cchain_import(parser_context_t *c, parser_tx_t *v) { | ||
// Get source chain | ||
v->tx.c_import_tx.source_chain = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same checks mentioned for parser_handle_cchain_export
|
||
// Pointer to outputs | ||
if (outputs->n_outs > 0) { | ||
outputs->outs = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check that c->offset < c->bufferLen
|
||
// Pointer to inputs | ||
if (inputs->n_ins > 0) { | ||
inputs->ins = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check that c->offset < c->bufferLen
CHECK_ERROR(parser_base_tx(c, &v->tx.p_export_tx.base_secp_ins, &v->tx.p_export_tx.base_secp_outs)); | ||
|
||
// Get destination chain | ||
v->tx.p_export_tx.destination_chain = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same checks mentioned for parser_handle_cchain_export
CHECK_ERROR(parser_base_tx(c, &v->tx.p_import_tx.base_secp_ins, &v->tx.p_import_tx.base_secp_outs)); | ||
|
||
// Get source chain | ||
v->tx.p_import_tx.source_chain = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same checks mentioned for parser_handle_cchain_export
CHECK_ERROR(parser_base_tx(c, &v->tx.add_del_val_tx.base_secp_ins, &v->tx.add_del_val_tx.base_secp_outs)); | ||
|
||
// Node ID | ||
v->tx.add_del_val_tx.node_id = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check that c->offset < c->bufferLen
} | ||
|
||
// Pointer to outputs | ||
v->tx.add_del_val_tx.staked_outs.outs = c->buffer + c->offset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check that c->offset < c->bufferLen
docs/APDUSPEC.md
Outdated
| Path[2] | byte (4) | Derivation Path Data | ? | | ||
| Path[3] | byte (4) | Derivation Path Data | ? | | ||
| Path[4] | byte (4) | Derivation Path Data | ? | | ||
| L | byte (1) | Bytes in payload | 0x0 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L should be variable
or ???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good! Just minor checks that might be found by the fuzzer 🚀
@ftheirs just added an extra context verification macro and two verification functions to use throughout the code |
54ad1ca
to
cbdc3ed
Compare
cbdc3ed
to
07bfa8d
Compare
No description provided.