Skip to content

Commit

Permalink
New manifest, including necessary testing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
relatko committed Mar 8, 2024
1 parent c93e1d1 commit 048a5bf
Show file tree
Hide file tree
Showing 3,393 changed files with 8,551 additions and 31,355 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion src/apdu_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ __Z_INLINE void handleGetPubkey(volatile uint32_t *flags, volatile uint32_t *tx,
__Z_INLINE void handleSign(volatile uint32_t *flags, volatile uint32_t *tx, uint32_t rx) {
zemu_log("HandleSign.\n");
process_chunk_response_t callType = process_chunk(tx, rx);

switch (callType) {
case PROCESS_CHUNK_NOT_FINISHED:
zemu_log("Continue processing chunks.\n");
Expand Down
3 changes: 3 additions & 0 deletions src/common/app_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,23 @@ process_chunk_response_t process_chunk(__Z_UNUSED volatile uint32_t *tx, uint32_
case 0x03:
if (storeTxMetadata(&(G_io_apdu_buffer[OFFSET_DATA]), rx - OFFSET_DATA) != PARSER_OK) {
initStoredTxMetadata(); // delete merkle tree proof on error for redundant security
ZEMU_TRACE();
THROW(APDU_CODE_DATA_INVALID);
}
return PROCESS_CHUNK_NOT_FINISHED;
case 0x04:
if (validateStoredTxMetadataMerkleTreeLevel(&(G_io_apdu_buffer[OFFSET_DATA]),
rx - OFFSET_DATA) != PARSER_OK) {
initStoredTxMetadata(); // delete merkle tree proof on error for redundant security
ZEMU_TRACE();
THROW(APDU_CODE_DATA_INVALID);
}
return PROCESS_CHUNK_NOT_FINISHED;
case 0x05:
if (validateStoredTxMetadataMerkleTreeLevel(&(G_io_apdu_buffer[OFFSET_DATA]),
rx - OFFSET_DATA) != PARSER_OK) {
initStoredTxMetadata(); // delete merkle tree proof on error for redundant security
ZEMU_TRACE();
THROW(APDU_CODE_DATA_INVALID);
}
return PROCESS_CHUNK_FINISHED_WITH_METADATA;
Expand Down
1 change: 1 addition & 0 deletions src/parser_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ extern "C" {
parser_error_t __err = __CALL; \
CHECK_APP_CANARY() \
if (__err != PARSER_OK) { \
ZEMU_TRACE(); \
return __err; \
} \
}
Expand Down
13 changes: 7 additions & 6 deletions src/parser_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,16 @@ parser_error_t _readArguments(parser_context_t *c, flow_argument_list_t *v) {
CHECK_KIND(kind, RLP_KIND_LIST)

v->argCount = 0;
while (v->ctx.offset < v->ctx.bufferLen && v->argCount < PARSER_MAX_ARGCOUNT) {
while (v->ctx.offset < v->ctx.bufferLen) {
if (v->argCount >= PARSER_MAX_ARGCOUNT) {
return PARSER_UNEXPECTED_NUMBER_ITEMS;
}
CHECK_PARSER_ERR(rlp_decode(&v->ctx, &v->argCtx[v->argCount], &kind, &bytesConsumed))
CTX_CHECK_AND_ADVANCE(&v->ctx, bytesConsumed)
CHECK_KIND(kind, RLP_KIND_STRING)
v->argCount++;
}
v->ctx.offset = 0;
if (v->argCount >= PARSER_MAX_ARGCOUNT) {
return PARSER_UNEXPECTED_NUMBER_ITEMS;
}

return PARSER_OK;
}
Expand Down Expand Up @@ -585,10 +585,11 @@ void checkAddressUsedInTx() {
addressUsedInTx = 0;
uint16_t authCount = parser_tx_obj.authorizers.authorizer_count;
for (uint16_t i = 0; i < (uint16_t)(authCount + 2); i++) { //+2 for proposer and payer
parser_context_t *ctx = &parser_tx_obj.payer.ctx;
parser_context_t *ctx = NULL;
if (i > authCount) ctx = &parser_tx_obj.payer.ctx;
if (i == authCount) ctx = &parser_tx_obj.proposalKeyAddress.ctx;
if (i < authCount) ctx = &parser_tx_obj.authorizers.authorizer[i].ctx;

_Static_assert(sizeof(address_to_display) == ACCOUNT_SIZE, "Incorrect address length");
if (ctx->bufferLen == ACCOUNT_SIZE) {
if (!MEMCMP(ctx->buffer, &address_to_display, sizeof(address_to_display))) {
Expand Down
8 changes: 5 additions & 3 deletions src/tx_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct {
} txMetadataState;

static const uint8_t merkleTreeRoot[METADATA_HASH_SIZE] = {
0xfe, 0x82, 0x42, 0x09, 0x59, 0x87, 0x58, 0x26, 0xf6, 0xa6, 0x17, 0x95, 0x9b, 0x00, 0x6c, 0x31,
0xfa, 0x89, 0x75, 0xe4, 0x55, 0xdb, 0xf2, 0x49, 0x4f, 0x5f, 0xf3, 0x74, 0x0a, 0x1e, 0xce, 0x51,
0xfe, 0xd8, 0x31, 0x77, 0xf6, 0x98, 0x29, 0xb4, 0x55, 0xce, 0xa6, 0xea, 0x33, 0x4a, 0x22, 0x60,
0xd0, 0x72, 0x79, 0xa7, 0x3c, 0x3e, 0xf0, 0x99, 0xbf, 0x11, 0x01, 0x6b, 0x30, 0xbd, 0x25, 0x82,
};

parser_error_t _validateScriptHash(const uint8_t scriptHash[METADATA_HASH_SIZE],
Expand Down Expand Up @@ -47,7 +47,8 @@ parser_error_t _validateScriptHash(const uint8_t scriptHash[METADATA_HASH_SIZE],
return PARSER_OK;
}
}


ZEMU_TRACE();
return PARSER_UNEXPECTED_SCRIPT;
}

Expand Down Expand Up @@ -114,6 +115,7 @@ parser_error_t validateStoredTxMetadataMerkleTreeLevel(const uint8_t *hashes, si

static parser_error_t parseTxMetadataInternal(const uint8_t scriptHash[METADATA_HASH_SIZE],
parsed_tx_metadata_t *parsedTxMetadata) {
ZEMU_TRACE();
uint16_t parsed = 0;

#define READ_CHAR(where) \
Expand Down
Loading

0 comments on commit 048a5bf

Please sign in to comment.