-
Notifications
You must be signed in to change notification settings - Fork 232
/
apdu_constants.h
134 lines (118 loc) · 5.43 KB
/
apdu_constants.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#ifndef _APDU_CONSTANTS_H_
#define _APDU_CONSTANTS_H_
#include "shared_context.h"
#define APP_FLAG_DATA_ALLOWED 0x01
#define APP_FLAG_EXTERNAL_TOKEN_NEEDED 0x02
#define CLA 0xE0
#define INS_GET_PUBLIC_KEY 0x02
#define INS_SIGN 0x04
#define INS_GET_APP_CONFIGURATION 0x06
#define INS_SIGN_PERSONAL_MESSAGE 0x08
#define INS_PROVIDE_ERC20_TOKEN_INFORMATION 0x0A
#define INS_SIGN_EIP_712_MESSAGE 0x0C
#define INS_GET_ETH2_PUBLIC_KEY 0x0E
#define INS_SET_ETH2_WITHDRAWAL_INDEX 0x10
#define INS_SET_EXTERNAL_PLUGIN 0x12
#define INS_PROVIDE_NFT_INFORMATION 0x14
#define INS_SET_PLUGIN 0x16
#define INS_PERFORM_PRIVACY_OPERATION 0x18
#define INS_EIP712_STRUCT_DEF 0x1A
#define INS_EIP712_STRUCT_IMPL 0x1C
#define INS_EIP712_FILTERING 0x1E
#define INS_ENS_GET_CHALLENGE 0x20
#define INS_ENS_PROVIDE_INFO 0x22
#define P1_CONFIRM 0x01
#define P1_NON_CONFIRM 0x00
#define P2_NO_CHAINCODE 0x00
#define P2_CHAINCODE 0x01
#define P1_FIRST 0x00
#define P1_MORE 0x80
#define P2_EIP712_LEGACY_IMPLEM 0x00
#define P2_EIP712_FULL_IMPLEM 0x01
#define COMMON_CLA 0xB0
#define APDU_RESPONSE_OK 0x9000
#define APDU_RESPONSE_ERROR_NO_INFO 0x6a00
#define APDU_RESPONSE_INVALID_DATA 0x6a80
#define APDU_RESPONSE_INSUFFICIENT_MEMORY 0x6a84
#define APDU_RESPONSE_INVALID_INS 0x6d00
#define APDU_RESPONSE_INVALID_P1_P2 0x6b00
#define APDU_RESPONSE_CONDITION_NOT_SATISFIED 0x6985
#define APDU_RESPONSE_REF_DATA_NOT_FOUND 0x6a88
#define APDU_RESPONSE_UNKNOWN 0x6f00
enum { OFFSET_CLA = 0, OFFSET_INS, OFFSET_P1, OFFSET_P2, OFFSET_LC, OFFSET_CDATA };
#define ERR_APDU_EMPTY 0x6982
#define ERR_APDU_SIZE_MISMATCH 0x6983
void handleGetPublicKey(uint8_t p1,
uint8_t p2,
const uint8_t *dataBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handleProvideErc20TokenInformation(uint8_t p1,
uint8_t p2,
const uint8_t *workBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handleProvideNFTInformation(uint8_t p1,
uint8_t p2,
const uint8_t *dataBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handleSign(uint8_t p1,
uint8_t p2,
const uint8_t *dataBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handleGetAppConfiguration(uint8_t p1,
uint8_t p2,
const uint8_t *dataBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
bool handleSignPersonalMessage(uint8_t p1,
uint8_t p2,
const uint8_t *const payload,
uint8_t length);
void handleSignEIP712Message_v0(uint8_t p1,
uint8_t p2,
const uint8_t *dataBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handleSetExternalPlugin(uint8_t p1,
uint8_t p2,
const uint8_t *workBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handleSetPlugin(uint8_t p1,
uint8_t p2,
const uint8_t *workBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handlePerformPrivacyOperation(uint8_t p1,
uint8_t p2,
const uint8_t *workBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
#ifdef HAVE_ETH2
void handleGetEth2PublicKey(uint8_t p1,
uint8_t p2,
const uint8_t *dataBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
void handleSetEth2WinthdrawalIndex(uint8_t p1,
uint8_t p2,
uint8_t *dataBuffer,
uint8_t dataLength,
unsigned int *flags,
unsigned int *tx);
#endif
extern uint16_t apdu_response_code;
#endif // _APDU_CONSTANTS_H_