-
Notifications
You must be signed in to change notification settings - Fork 16
/
handlers.c
56 lines (49 loc) · 1.41 KB
/
handlers.c
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
#ifndef H_HANDLERS
#include <os_io_seproxyhal.h>
#include <stdlib.h>
#include "handlers.h"
#include "getVersion.h"
#include "getSerial.h"
#include "getPublicKeys.h"
#include "runTests.h"
#include "errors.h"
#include "deriveAddress.h"
#include "deriveNativeScriptHash.h"
#include "signTx.h"
#include "signMsg.h"
#include "signOpCert.h"
#include "signCVote.h"
// The APDU protocol uses a single-byte instruction code (INS) to specify
// which command should be executed. We'll use this code to dispatch on a
// table of function pointers.
handler_fn_t* lookupHandler(uint8_t ins)
{
switch (ins) {
#define CASE(INS, HANDLER) case INS: return HANDLER;
// 0x0* - app status calls
CASE(0x00, getVersion_handleAPDU);
CASE(0x01, getSerial_handleAPDU);
// 0x1* - public-key/address related
CASE(0x10, getPublicKeys_handleAPDU);
CASE(0x11, deriveAddress_handleAPDU);
#ifdef APP_FEATURE_NATIVE_SCRIPT_HASH
CASE(0x12, deriveNativeScriptHash_handleAPDU);
#endif // APP_FEATURE_NATIVE_SCRIPT_HASH
// 0x2* - signing related
CASE(0x21, signTx_handleAPDU);
#ifdef APP_FEATURE_OPCERT
CASE(0x22, signOpCert_handleAPDU);
#endif // APP_FEATURE_OPCERT
CASE(0x23, signCVote_handleAPDU);
CASE(0x24, signMsg_handleAPDU);
#ifdef DEVEL
// 0xF* - debug_mode related
CASE(0xF0, handleRunTests);
// 0xF1 reserved for INS_SET_HEADLESS_INTERACTION
#endif // DEVEL
#undef CASE
default:
return NULL;
}
}
#endif