diff --git a/src/main.c b/src/main.c index d42d390..067fab5 100644 --- a/src/main.c +++ b/src/main.c @@ -953,17 +953,6 @@ const bagl_element_t ui_data_parameter_blue[] = { {{BAGL_RECTANGLE | BAGL_FLAG_TOUCHABLE, 0x00, 165, 414, 115, 36, 0,18, BAGL_FILL, 0x41ccb4, COLOR_BG_1, BAGL_FONT_OPEN_SANS_REGULAR_11_14PX|BAGL_FONT_ALIGNMENT_CENTER|BAGL_FONT_ALIGNMENT_MIDDLE, 0 }, "CONFIRM", 0, 0x3ab7a2, COLOR_BG_1, io_seproxyhal_touch_data_ok, NULL, NULL}, }; -int local_strchr(char *string, char ch) { - unsigned int length = strlen(string); - unsigned int i; - for (i=0; icomponent.userid > 0) { @@ -1096,33 +1085,6 @@ unsigned int ui_address_nanos_button(unsigned int button_mask, unsigned int butt } #endif // #if defined(TARGET_NANOS) -uint32_t getV(txContent_t *txContent) { - uint32_t v = 0; - if (txContent->vLength == 1) { - v = txContent->v[0]; - } - else - if (txContent->vLength == 2) { - v = (txContent->v[0] << 8) | txContent->v[1]; - } - else - if (txContent->vLength == 3) { - v = (txContent->v[0] << 16) | (txContent->v[1] << 8) | txContent->v[2]; - } - else - if (txContent->vLength == 4) { - v = (txContent->v[0] << 24) | (txContent->v[1] << 16) | - (txContent->v[2] << 8) | txContent->v[3]; - } - else - if (txContent->vLength != 0) { - PRINTF("Unexpected v format\n"); - THROW(EXCEPTION); - } - return v; - -} - void io_seproxyhal_send_status(uint32_t sw) { G_io_apdu_buffer[0] = ((sw >> 8) & 0xff); G_io_apdu_buffer[1] = (sw & 0xff); @@ -1411,13 +1373,6 @@ uint32_t set_result_get_publicKey() { return tx; } -void convertUint256BE(uint8_t *data, uint32_t length, uint256_t *target) { - uint8_t tmp[32]; - os_memset(tmp, 0, 32); - os_memmove(tmp + 32 - length, data, length); - readu256BE(tmp, target); -} - uint32_t splitBinaryParameterPart(char *result, uint8_t *parameter) { uint32_t i; for (i=0; i<8; i++) { diff --git a/src/utils.c b/src/utils.c index d7e0602..e40c8ed 100644 --- a/src/utils.c +++ b/src/utils.c @@ -15,6 +15,12 @@ * limitations under the License. ********************************************************************************/ +#include +#include + +#include "ethUstream.h" +#include "uint256.h" + static const unsigned char hex_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; @@ -25,4 +31,48 @@ void array_hexstr(char *strbuf, const void *bin, unsigned int len) { bin = (const void *)((unsigned int)bin + 1); } *strbuf = 0; // EOS +} + +void convertUint256BE(uint8_t *data, uint32_t length, uint256_t *target) { + uint8_t tmp[32]; + os_memset(tmp, 0, 32); + os_memmove(tmp + 32 - length, data, length); + readu256BE(tmp, target); +} + +int local_strchr(char *string, char ch) { + unsigned int length = strlen(string); + unsigned int i; + for (i=0; ivLength == 1) { + v = txContent->v[0]; + } + else + if (txContent->vLength == 2) { + v = (txContent->v[0] << 8) | txContent->v[1]; + } + else + if (txContent->vLength == 3) { + v = (txContent->v[0] << 16) | (txContent->v[1] << 8) | txContent->v[2]; + } + else + if (txContent->vLength == 4) { + v = (txContent->v[0] << 24) | (txContent->v[1] << 16) | + (txContent->v[2] << 8) | txContent->v[3]; + } + else + if (txContent->vLength != 0) { + PRINTF("Unexpected v format\n"); + THROW(EXCEPTION); + } + return v; } \ No newline at end of file diff --git a/src/utils.h b/src/utils.h index 1c15584..d918475 100644 --- a/src/utils.h +++ b/src/utils.h @@ -18,6 +18,16 @@ #ifndef _UTILS_H_ #define _UTILS_H_ +#include + +#include "uint256.h" + void array_hexstr(char *strbuf, const void *bin, unsigned int len); +void convertUint256BE(uint8_t *data, uint32_t length, uint256_t *target); + +int local_strchr(char *string, char ch); + +uint32_t getV(txContent_t *txContent); + #endif /* _UTILS_H_ */ \ No newline at end of file