Moved EIP 712 commands handling into their own file & renamed some things
This commit is contained in:
@@ -182,13 +182,6 @@ void handleStarkwareUnsafeSign(uint8_t p1,
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EIP712_FULL_SUPPORT
|
||||
bool handle_eip712_struct_def(const uint8_t *const apdu_buf);
|
||||
bool handle_eip712_struct_impl(const uint8_t *const apdu_buf);
|
||||
bool handle_eip712_sign(const uint8_t *const apdu_buf);
|
||||
bool handle_eip712_filtering(const uint8_t *const apdu_buf);
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
|
||||
extern uint16_t apdu_response_code;
|
||||
|
||||
#endif // _APDU_CONSTANTS_H_
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "handle_swap_sign_transaction.h"
|
||||
#include "handle_get_printable_amount.h"
|
||||
#include "handle_check_address.h"
|
||||
#include "context.h"
|
||||
#include "commands_712.h"
|
||||
|
||||
#ifdef HAVE_STARKWARE
|
||||
#include "stark_crypto.h"
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
|
||||
#include "uint256.h"
|
||||
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
void array_hexstr(char* strbuf, const void* bin, unsigned int len);
|
||||
|
||||
void convertUint128BE(const uint8_t *const data, uint32_t length, uint128_t *const target);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "commands_712.h"
|
||||
#include "apdu_constants.h" // APDU response codes
|
||||
#include "eip712.h"
|
||||
#include "context.h"
|
||||
#include "field_hash.h"
|
||||
#include "path.h"
|
||||
@@ -164,13 +164,14 @@ bool handle_eip712_filtering(const uint8_t *const apdu_buf)
|
||||
bool handle_eip712_sign(const uint8_t *const apdu_buf)
|
||||
{
|
||||
bool ret = false;
|
||||
uint8_t length = apdu_buf[OFFSET_LC];
|
||||
|
||||
if (eip712_context == NULL)
|
||||
{
|
||||
apdu_response_code = APDU_RESPONSE_CONDITION_NOT_SATISFIED;
|
||||
}
|
||||
else if (parseBip32(&apdu_buf[OFFSET_CDATA],
|
||||
&apdu_buf[OFFSET_LC],
|
||||
&length,
|
||||
&tmpCtx.messageSigningContext.bip32) != NULL)
|
||||
{
|
||||
if (!N_storage.verbose_eip712 && (ui_712_get_filtering_mode() == EIP712_FILTERING_BASIC))
|
||||
@@ -6,10 +6,6 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// APDUs INS
|
||||
#define INS_STRUCT_DEF 0x18
|
||||
#define INS_STRUCT_IMPL 0x1A
|
||||
|
||||
// APDUs P1
|
||||
#define P1_COMPLETE 0x00
|
||||
#define P1_PARTIAL 0xFF
|
||||
@@ -24,17 +20,13 @@
|
||||
#define P2_KEY 0x00
|
||||
#define P2_VALUE 0xFF
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EIP712_TYPE_HASH,
|
||||
EIP712_FIELD_HASH,
|
||||
EIP712_STRUCT_HASH
|
||||
} e_eip712_hash_type;
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
#define DOMAIN_STRUCT_NAME "EIP712Domain"
|
||||
|
||||
bool handle_eip712_struct_def(const uint8_t *const apdu_buf);
|
||||
bool handle_eip712_struct_impl(const uint8_t *const apdu_buf);
|
||||
bool handle_eip712_sign(const uint8_t *const apdu_buf);
|
||||
bool handle_eip712_filtering(const uint8_t *const apdu_buf);
|
||||
|
||||
#endif // HAVE_EIP712_FULL_SUPPORT
|
||||
|
||||
#endif // EIP712_H_
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include "context.h"
|
||||
#include "eip712.h"
|
||||
#include "mem.h"
|
||||
#include "mem_utils.h"
|
||||
#include "sol_typenames.h"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <string.h>
|
||||
#include "encode_field.h"
|
||||
#include "mem.h"
|
||||
#include "eip712.h"
|
||||
#include "shared_context.h"
|
||||
#include "apdu_constants.h" // APDU response codes
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "path.h"
|
||||
#include "mem.h"
|
||||
#include "mem_utils.h"
|
||||
#include "eip712.h"
|
||||
#include "shared_context.h"
|
||||
#include "ui_logic.h"
|
||||
#include "ethUtils.h" // KECCAK256_HASH_BYTESIZE
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "ethUstream.h" // INT256_LENGTH
|
||||
#include "apdu_constants.h" // APDU return codes
|
||||
#include "context.h"
|
||||
#include "eip712.h"
|
||||
#include "commands_712.h"
|
||||
#include "typed_data.h"
|
||||
#include "path.h"
|
||||
#include "ui_logic.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "format_hash_field_type.h"
|
||||
#include "mem.h"
|
||||
#include "mem_utils.h"
|
||||
#include "eip712.h"
|
||||
#include "commands_712.h"
|
||||
#include "hash_bytes.h"
|
||||
#include "apdu_constants.h" // APDU response codes
|
||||
#include "typed_data.h"
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "path.h"
|
||||
#include "mem.h"
|
||||
#include "context.h"
|
||||
#include "eip712.h"
|
||||
#include "commands_712.h"
|
||||
#include "type_hash.h"
|
||||
#include "shared_context.h"
|
||||
#include "ethUtils.h"
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "sol_typenames.h"
|
||||
#include "eip712.h"
|
||||
#include "context.h"
|
||||
#include "mem.h"
|
||||
#include "os_pic.h"
|
||||
#include "apdu_constants.h" // APDU response codes
|
||||
#include "typed_data.h"
|
||||
#include "utils.h" // ARRAY_SIZE
|
||||
|
||||
// Bit indicating they are more types associated to this typename
|
||||
#define TYPENAME_MORE_TYPE (1 << 7)
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <stdbool.h>
|
||||
#include "mem.h"
|
||||
#include "mem_utils.h"
|
||||
#include "eip712.h"
|
||||
#include "type_hash.h"
|
||||
#include "shared_context.h"
|
||||
#include "ethUtils.h" // KECCAK256_HASH_BYTESIZE
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "ux_flow_engine.h"
|
||||
#include "ui_flow_712.h"
|
||||
#include "shared_context.h"
|
||||
#include "eip712.h" // get_struct_name
|
||||
#include "ethUtils.h" // getEthDisplayableAddress
|
||||
#include "utils.h" // uint256_to_decimal
|
||||
#include "common_712.h"
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "apdu_constants.h"
|
||||
#include "utils.h"
|
||||
#include "ui_flow.h"
|
||||
#include "eip712.h"
|
||||
#include "common_712.h"
|
||||
#include "ethUtils.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user