Display the data being signed

This commit is contained in:
BTChip github
2018-07-31 19:59:59 +02:00
parent 29a2b97b1f
commit adfcb0e6ec
3 changed files with 816 additions and 258 deletions

View File

@@ -278,9 +278,9 @@ static void processV(txContext_t *context) {
}
static parserStatus_e processTxInternal(txContext_t *context, uint32_t processingFlags) {
static parserStatus_e processTxInternal(txContext_t *context) {
for (;;) {
bool processedCustom = false;
customStatus_e customStatus = CUSTOM_NOT_HANDLED;
// EIP 155 style transasction
if (context->currentField == TX_RLP_DONE) {
return USTREAM_FINISHED;
@@ -341,13 +341,26 @@ static parserStatus_e processTxInternal(txContext_t *context, uint32_t processin
context->processingField = true;
}
if (context->customProcessor != NULL) {
processedCustom = context->customProcessor(context);
customStatus = context->customProcessor(context);
switch(customStatus) {
case CUSTOM_NOT_HANDLED:
case CUSTOM_HANDLED:
break;
case CUSTOM_SUSPENDED:
return USTREAM_SUSPENDED;
case CUSTOM_FAULT:
PRINTF("Custom processor aborted\n");
return USTREAM_FAULT;
default:
PRINTF("Unhandled custom processor status\n");
return USTREAM_FAULT;
}
}
if (!processedCustom) {
if (customStatus == CUSTOM_NOT_HANDLED) {
switch (context->currentField) {
case TX_RLP_CONTENT:
processContent(context);
if ((processingFlags & TX_FLAG_TYPE) == 0) {
if ((context->processingFlags & TX_FLAG_TYPE) == 0) {
context->currentField++;
}
break;
@@ -392,7 +405,8 @@ parserStatus_e processTx(txContext_t *context, uint8_t *buffer,
TRY {
context->workBuffer = buffer;
context->commandLength = length;
result = processTxInternal(context, processingFlags);
context->processingFlags = processingFlags;
result = processTxInternal(context);
}
CATCH_OTHER(e) {
result = USTREAM_FAULT;
@@ -403,3 +417,19 @@ parserStatus_e processTx(txContext_t *context, uint8_t *buffer,
END_TRY;
return result;
}
parserStatus_e continueTx(txContext_t *context) {
parserStatus_e result;
BEGIN_TRY {
TRY {
result = processTxInternal(context);
}
CATCH_OTHER(e) {
result = USTREAM_FAULT;
}
FINALLY {
}
}
END_TRY;
return result;
}

View File

@@ -21,7 +21,14 @@
struct txContext_t;
typedef bool (*ustreamProcess_t)(struct txContext_t *context);
typedef enum customStatus_e {
CUSTOM_NOT_HANDLED,
CUSTOM_HANDLED,
CUSTOM_SUSPENDED,
CUSTOM_FAULT
} customStatus_e;
typedef customStatus_e (*ustreamProcess_t)(struct txContext_t *context);
#define TX_FLAG_TYPE 0x01
@@ -43,6 +50,7 @@ typedef enum rlpTxField_e {
typedef enum parserStatus_e {
USTREAM_PROCESSING,
USTREAM_SUSPENDED,
USTREAM_FINISHED,
USTREAM_FAULT
} parserStatus_e;
@@ -75,6 +83,7 @@ typedef struct txContext_t {
uint32_t rlpBufferPos;
uint8_t *workBuffer;
uint32_t commandLength;
uint32_t processingFlags;
ustreamProcess_t customProcessor;
txContent_t *content;
void *extra;
@@ -84,5 +93,6 @@ void initTx(txContext_t *context, cx_sha3_t *sha3, txContent_t *content,
ustreamProcess_t customProcessor, void *extra);
parserStatus_e processTx(txContext_t *context, uint8_t *buffer,
uint32_t length, uint32_t processingFlags);
parserStatus_e continueTx(txContext_t *context);
void copyTxData(txContext_t *context, uint8_t *out, uint32_t length);
uint8_t readTxByte(txContext_t *context);

File diff suppressed because it is too large Load Diff