SEcube open-source SDK
L0_enumerations.h
Go to the documentation of this file.
1 
10 #ifndef _L0_ENUMERATIONS_H
11 #define _L0_ENUMERATIONS_H
12 
13 #ifdef _WIN32
14 //Windows
15 #include "Windows.h"
16 #endif
17 
18 namespace L0Communication {
19  struct Size {
20  enum {
21  //size of the magic block
22  //SE3_MAGIC_SIZE = 32,
23  MAGIC = 32,
24  //the hello message in bytes (uint8_t)
25  //SE3_HELLO_SIZE = 32,
26  HELLO = 32,
27  //the serial number size in bytes (uint8_t)
28  //SE3_SERIAL_SIZE = 32
29  SERIAL = 32
30  };
31  };
32 
33  struct Parameter {
34  enum {
35  //SE3_COMM_BLOCK = 512,
36  COMM_BLOCK = 512,
37  //SE3_COMM_N = 16
38  COMM_N = 16,
39  //MAX_PATH define is already declared in the windows library
40  SE3_MAX_PATH = 256
41  };
42  };
43 
44  /* TODO: change this with exception handling*/
45  struct Error {
46  enum {
47  //SE3C_OK = 0,
48  OK = 0,
49  //SE3C_ERR_NOT_FOUND = 1,
50  ERR_NOT_FOUND = 1,
51  //SE3C_ERR_TIMEOUT = 2,
52  ERR_TIMEOUT = 2,
53  //SE3C_ERR_NO_DEVICE = 3
54  ERR_NO_DEVICE = 3
55  };
56  };
57 }
58 
59 namespace L0DiscoverParameters {
60  struct Offset {
61  enum {
62  SE3_DISCO_OFFSET_MAGIC = 0,
63  //SE3_DISCO_OFFSET_SERIAL = 32,
64  SERIAL = 32,
65  //SE3_DISCO_OFFSET_HELLO = 2 * 32,
66  HELLO = 2 * 32,
67  //SE3_DISCO_OFFSET_STATUS = 3 * 32
68  STATUS = 3 * 32
69  };
70  };
71 }
72 
73 namespace L0Request {
74  struct Size {
75  enum {
76  //SE3_REQ_SIZE_HEADER = 16,
77  HEADER = 16,
78  //SE3_REQDATA_SIZE_HEADER = 4,
79  DATA_HEADER = 4,
80  SE3_REQ_SIZE_DATA = L0Communication::Parameter::COMM_BLOCK - HEADER,
81  SE3_REQDATA_SIZE_DATA = L0Communication::Parameter::COMM_BLOCK - DATA_HEADER,
82  //used in the L1 enumerations
83  //SE3_REQ_MAX_DATA = L0Communication::Parameter::COMM_BLOCK - HEADER +
84  //(L0Communication::Parameter::COMM_N - 2) * (L0Communication::Parameter::COMM_BLOCK - DATA_HEADER) - 8
85  MAX_DATA = L0Communication::Parameter::COMM_BLOCK - HEADER +
86  (L0Communication::Parameter::COMM_N - 2) * (L0Communication::Parameter::COMM_BLOCK - DATA_HEADER) - 8
87 
88  };
89  };
90 
91  struct Offset {
92  enum {
93  //SE3_REQ_OFFSET_CMD = 0,
94  CMD = 0, //offset of the command
95  //SE3_REQ_OFFSET_CMDFLAGS = 2,
96  CMD_FLAGS = 2, //offset of the command flags
97  //SE3_REQ_OFFSET_LEN = 4,
98  LEN = 4, //offset to write the length of the data and the header
99  //SE3_REQ_OFFSET_CMDTOKEN = 6,
100  CMD_TOKEN = 6, //offset of the command token
101  //SE3_REQ_OFFSET_PADDING = 10,
102  PADDING = 10, //offset for the padding
103  //SE3_REQ_OFFSET_CRC = 14,
104  CRC = 14, //offset of the CRC
105  //SE3_REQ_OFFSET_DATA = 16,
106  DATA = 16,
107  //SE3_REQDATA_OFFSET_CMDTOKEN = 0,
108  DATA_CMD_TOKEN = 0,
109  SE3_REQDATA_OFFSET_DATA = 4
110  };
111  };
112 }
113 
114 namespace L0Response {
115  struct Offset {
116  enum {
117  SE3_RESP_OFFSET_READY = 0,
118  //SE3_RESP_OFFSET_STATUS = 2,
119  STATUS = 2,
120  //SE3_RESP_OFFSET_LEN = 4,
121  LEN = 4,
122  //SE3_RESP_OFFSET_CMDTOKEN = 6,
123  CMD_TOKEN = 6,
124  SE3_RESP_OFFSET_CRC = 14,
125  //SE3_RESPDATA_OFFSET_CMDTOKEN = 0,
126  DATA_CMD_TOKEN = 0,
127  SE3_RESPDATA_OFFSET_DATA = 4
128  };
129  };
130 
131  struct Size {
132  enum {
133  //SE3_RESP_SIZE_HEADER = 16,
134  HEADER = 16,
135  //SE3_RESPDATA_SIZE_HEADER = 4,
136  DATA_HEADER = 4,
137  SE3_RESP_SIZE_DATA = L0Communication::Parameter::COMM_BLOCK - L0Request::Size::HEADER,
138  SE3_RESPDATA_SIZE_DATA = L0Communication::Parameter::COMM_BLOCK - L0Request::Size::HEADER,
139  //SE3_RESP_MAX_DATA = L0Communication::Parameter::COMM_BLOCK - L0Request::Size::HEADER +
140  //(L0Communication::Parameter::COMM_N - 2) * (L0Communication::Parameter::COMM_BLOCK - L0Request::Size::DATA_HEADER) - 8
141  MAX_DATA = L0Communication::Parameter::COMM_BLOCK - L0Request::Size::HEADER +
142  (L0Communication::Parameter::COMM_N - 2) * (L0Communication::Parameter::COMM_BLOCK - L0Request::Size::DATA_HEADER) - 8
143  };
144  };
145 }
146 
147 namespace L0Commands {
148  struct Command {
149  enum {
150  //SE3_CMD0_FACTORY_INIT = 1,
151  FACTORY_INIT = 1,
152  //SE3_CMD0_ECHO = 2,
153  ECHO = 2,
154  //SE3_CMD0_L1 = 3,
155  L1_CMD0 = 3,
156  SE3_CMD0_BOOT_MODE_RESET = 4
157  };
158  };
159 }
160 
161 namespace L0ErrorCodes {
162  struct Error {
163  enum {
164  //SE3_OK = 0, ///< success
165  OK = 0, //success
166  SE3_ERR_HW = 0xF001,
167  //SE3_ERR_COMM = 0xF002, ///< communication error
168  COMMUNICATION = 0xF002, //communication errors
169  SE3_ERR_BUSY = 0xF003,
170  SE3_ERR_STATE = 0xF004,
171  SE3_ERR_CMD = 0xF005,
172  SE3_ERR_PARAMS = 0xF006,
173  };
174  };
175 }
176 
177 //for generating random values in WINDOWS environment
178 #ifdef _WIN32
179 namespace L0Win32ApiCodes {
180  struct Codes {
181  enum {
182  //ADVAPI32_PROV_RSA_FULL = 1,
183  FULL = 1,
184  //ADVAPI32_CRYPT_NEWKEYSET = 0x00000008,
185  NEW_KEYSET = 0x00000008,
186  //ADVAPI32_NTE_BAD_KEYSET = _HRESULT_TYPEDEF_(0x80090016L)
187  BAD_KEYSET = _HRESULT_TYPEDEF_(0x80090016L)
188  };
189  };
190 }
191 #endif
192 
193 #endif
L0_error_manager.h
Exception classes.
L0.h
Prototype of the L0 library.