se051plugntrust  2.1.0.0
se051plugntrust.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef SE051PLUGNTRUST_H
29 #define SE051PLUGNTRUST_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
70 #define SE051PLUGNTRUST_NAD_WRITE 0x5A
71 #define SE051PLUGNTRUST_NAD_READ 0xA5
72 
78 #define SE051PLUGNTRUST_PCB_BLOCK_I 0x00
79 #define SE051PLUGNTRUST_PCB_BLOCK_I_NS_ENCODE 0x40
80 #define SE051PLUGNTRUST_PCB_BLOCK_I_M_CHAIN 0x20
81 
87 #define SE051PLUGNTRUST_PCB_BLOCK_R 0x80
88 #define SE051PLUGNTRUST_PCB_BLOCK_R_NR_ENCODE 0x10
89 #define SE051PLUGNTRUST_PCB_BLOCK_R_ERROR_CRC 0x01
90 #define SE051PLUGNTRUST_PCB_BLOCK_R_ERROR_OTHER 0x02
91 
97 #define SE051PLUGNTRUST_PCB_BLOCK_S 0xC0
98 #define SE051PLUGNTRUST_PCB_BLOCK_S_RESYNC_REQ 0x00
99 #define SE051PLUGNTRUST_PCB_BLOCK_S_RESYNC_RSP 0x20
100 #define SE051PLUGNTRUST_PCB_BLOCK_S_IFS_REQ 0x01
101 #define SE051PLUGNTRUST_PCB_BLOCK_S_IFS_RSP 0x21
102 #define SE051PLUGNTRUST_PCB_BLOCK_S_ABORT_REQ 0x02
103 #define SE051PLUGNTRUST_PCB_BLOCK_S_ABORT_RSP 0x22
104 #define SE051PLUGNTRUST_PCB_BLOCK_S_WTX_REQ 0x03
105 #define SE051PLUGNTRUST_PCB_BLOCK_S_WTX_RSP 0x23
106 #define SE051PLUGNTRUST_PCB_BLOCK_S_SOFT_RESET_REQ 0x0F
107 #define SE051PLUGNTRUST_PCB_BLOCK_S_SOFT_RESET_RSP 0x2F
108 #define SE051PLUGNTRUST_PCB_BLOCK_S_END_APDU_SESSION_REQ 0x05
109 #define SE051PLUGNTRUST_PCB_BLOCK_S_END_APDU_SESSION_RSP 0x25
110 #define SE051PLUGNTRUST_PCB_BLOCK_S_SE_RESET_REQ 0x06
111 #define SE051PLUGNTRUST_PCB_BLOCK_S_SE_RESET_RSP 0x26
112 #define SE051PLUGNTRUST_PCB_BLOCK_S_GET_ATR_REQ 0x07
113 #define SE051PLUGNTRUST_PCB_BLOCK_S_GET_ATR_RSP 0x27
114  // pcb
116 
131 #define SE051PLUGNTRUST_CLA_SECURE 0x84
132 #define SE051PLUGNTRUST_CLA_NOT_SECURE 0x80
133 
138 #define SE051PLUGNTRUST_INS_MASK_INS_CHAR 0xE0
139 #define SE051PLUGNTRUST_INS_MASK_INSTRUCTION 0x1F
140 #define SE051PLUGNTRUST_INS_TRANSIENT 0x80
141 #define SE051PLUGNTRUST_INS_AUTH_OBJECT 0x40
142 #define SE051PLUGNTRUST_INS_ATTEST 0x20
143 #define SE051PLUGNTRUST_INS_WRITE 0x01
144 #define SE051PLUGNTRUST_INS_READ 0x02
145 #define SE051PLUGNTRUST_INS_CRYPTO 0x03
146 #define SE051PLUGNTRUST_INS_MGMT 0x04
147 #define SE051PLUGNTRUST_INS_PROCESS 0x05
148 #define SE051PLUGNTRUST_INS_IMPORT_EXTERNAL 0x06
149 
154 #define SE051PLUGNTRUST_P1_UNUSED 0x80
155 #define SE051PLUGNTRUST_P1_MASK_KEY_TYPE 0x60
156 #define SE051PLUGNTRUST_P1_MASK_CRED_TYPE 0x1F
157 #define SE051PLUGNTRUST_P1_KEY_PAIR 0x60
158 #define SE051PLUGNTRUST_P1_PRIVATE 0x40
159 #define SE051PLUGNTRUST_P1_PUBLIC 0x20
160 #define SE051PLUGNTRUST_P1_DEFAULT 0x00
161 #define SE051PLUGNTRUST_P1_EC 0x01
162 #define SE051PLUGNTRUST_P1_RSA 0x02
163 #define SE051PLUGNTRUST_P1_AES 0x03
164 #define SE051PLUGNTRUST_P1_DES 0x04
165 #define SE051PLUGNTRUST_P1_HMAC 0x05
166 #define SE051PLUGNTRUST_P1_BINARY 0x06
167 #define SE051PLUGNTRUST_P1_USERID 0x07
168 #define SE051PLUGNTRUST_P1_COUNTER 0x08
169 #define SE051PLUGNTRUST_P1_PCR 0x09
170 #define SE051PLUGNTRUST_P1_CURVE 0x0B
171 #define SE051PLUGNTRUST_P1_SIGNATURE 0x0C
172 #define SE051PLUGNTRUST_P1_MAC 0x0D
173 #define SE051PLUGNTRUST_P1_CIPHER 0x0E
174 #define SE051PLUGNTRUST_P1_TLS 0x0F
175 #define SE051PLUGNTRUST_P1_CRYPTO_OBJ 0x10
176 #define SE051PLUGNTRUST_P2_DEFAULT 0x00
177 #define SE051PLUGNTRUST_P2_GENERATE 0x03
178 #define SE051PLUGNTRUST_P2_CREATE 0x04
179 #define SE051PLUGNTRUST_P2_SIZE 0x07
180 #define SE051PLUGNTRUST_P2_SIGN 0x09
181 #define SE051PLUGNTRUST_P2_VERIFY 0x0A
182 #define SE051PLUGNTRUST_P2_INIT 0x0B
183 #define SE051PLUGNTRUST_P2_UPDATE 0x0C
184 #define SE051PLUGNTRUST_P2_FINAL 0x0D
185 #define SE051PLUGNTRUST_P2_ONESHOT 0x0E
186 #define SE051PLUGNTRUST_P2_DH 0x0F
187 #define SE051PLUGNTRUST_P2_DIVERSIFY 0x10
188 #define SE051PLUGNTRUST_P2_AUTH_FIRST_PART2 0x12
189 #define SE051PLUGNTRUST_P2_AUTH_NONFIRST_PART2 0x13
190 #define SE051PLUGNTRUST_P2_DUMP_KEY 0x14
191 #define SE051PLUGNTRUST_P2_CHANGE_KEY_PART1 0x15
192 #define SE051PLUGNTRUST_P2_CHANGE_KEY_PART2 0x16
193 #define SE051PLUGNTRUST_P2_KILL_AUTH 0x17
194 #define SE051PLUGNTRUST_P2_IMPORT 0x18
195 #define SE051PLUGNTRUST_P2_EXPORT 0x19
196 #define SE051PLUGNTRUST_P2_SESSION_CREATE 0x1B
197 #define SE051PLUGNTRUST_P2_SESSION_CLOSE 0x1C
198 #define SE051PLUGNTRUST_P2_SESSION_REFRESH 0x1E
199 #define SE051PLUGNTRUST_P2_SESSION_POLICY 0x1F
200 #define SE051PLUGNTRUST_P2_VERSION 0x20
201 #define SE051PLUGNTRUST_P2_MEMORY 0x22
202 #define SE051PLUGNTRUST_P2_LIST 0x25
203 #define SE051PLUGNTRUST_P2_TYPE 0x26
204 #define SE051PLUGNTRUST_P2_EXIST 0x27
205 #define SE051PLUGNTRUST_P2_DELETE_OBJECT 0x28
206 #define SE051PLUGNTRUST_P2_DELETE_ALL 0x2A
207 #define SE051PLUGNTRUST_P2_SESSION_USERID 0x2C
208 #define SE051PLUGNTRUST_P2_HKDF 0x2D
209 #define SE051PLUGNTRUST_P2_PBKDF 0x2E
210 #define SE051PLUGNTRUST_P2_I2CM 0x30
211 #define SE051PLUGNTRUST_P2_I2CM_ATTESTED 0x31
212 #define SE051PLUGNTRUST_P2_MAC 0x32
213 #define SE051PLUGNTRUST_P2_UNLOCK_CHALLENGE 0x33
214 #define SE051PLUGNTRUST_P2_CURVE_LIST 0x34
215 #define SE051PLUGNTRUST_P2_SIGN_ECDAA 0x35
216 #define SE051PLUGNTRUST_P2_ID 0x36
217 #define SE051PLUGNTRUST_P2_ENCRYPT_ONESHOT 0x37
218 #define SE051PLUGNTRUST_P2_DECRYPT_ONESHOT 0x38
219 #define SE051PLUGNTRUST_P2_ATTEST 0x3A
220 #define SE051PLUGNTRUST_P2_ATTRIBUTES 0x3B
221 #define SE051PLUGNTRUST_P2_CPLC 0x3C
222 #define SE051PLUGNTRUST_P2_TIME 0x3D
223 #define SE051PLUGNTRUST_P2_TRANSPORT 0x3E
224 #define SE051PLUGNTRUST_P2_VARIANT 0x3F
225 #define SE051PLUGNTRUST_P2_PARAM 0x40
226 #define SE051PLUGNTRUST_P2_DELETE_CURVE 0x41
227 #define SE051PLUGNTRUST_P2_ENCRYPT 0x42
228 #define SE051PLUGNTRUST_P2_DECRYPT 0x43
229 #define SE051PLUGNTRUST_P2_VALIDATE 0x44
230 #define SE051PLUGNTRUST_P2_GENERATE_ONESHOT 0x45
231 #define SE051PLUGNTRUST_P2_VALIDATE_ONESHOT 0x46
232 #define SE051PLUGNTRUST_P2_CRYPTO_LIST 0x47
233 #define SE051PLUGNTRUST_P2_RANDOM 0x49
234 #define SE051PLUGNTRUST_P2_TLS_PMS 0x4A
235 #define SE051PLUGNTRUST_P2_TLS_PRF_CLI_HELLO 0x4B
236 #define SE051PLUGNTRUST_P2_TLS_PRF_SRV_HELLO 0x4C
237 #define SE051PLUGNTRUST_P2_TLS_PRF_CLI_RND 0x4D
238 #define SE051PLUGNTRUST_P2_TLS_PRF_SRV_RND 0x4E
239 #define SE051PLUGNTRUST_P2_RAW 0x4F
240 #define SE051PLUGNTRUST_P2_IMPORT_EXT 0x51
241 #define SE051PLUGNTRUST_P2_SCP 0x52
242 #define SE051PLUGNTRUST_P2_AUTH_FIRST_PART1 0x53
243 #define SE051PLUGNTRUST_P2_AUTH_NONFIRST_PART1 0x54
244 
249 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_EC_KEY_PAIR 0x01
250 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_EC_PRIV_KEY 0x02
251 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_EC_PUB_KEY 0x03
252 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_RSA_KEY_PAIR 0x04
253 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_RSA_KEY_PAIR_CRT 0x05
254 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_RSA_PRIV_KEY 0x06
255 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_RSA_PRIV_KEY_CRT 0x07
256 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_RSA_PUB_KEY 0x08
257 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_AES_KEY 0x09
258 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_DES_KEY 0x0A
259 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_BINARY_FILE 0x0B
260 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_USERID 0x0C
261 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_COUNTER 0x0D
262 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_PCR 0x0F
263 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_CURVE 0x10
264 #define SE051PLUGNTRUST_SECURE_OBJECT_TYPE_HMAC_KEY 0x11
265 
270 #define SE051PLUGNTRUST_MEM_PERSISTENT 0x01
271 #define SE051PLUGNTRUST_MEM_TRANSIENT_RESET 0x02
272 #define SE051PLUGNTRUST_MEM_TRANSIENT_DESELECT 0x03
273 
278 #define SE051PLUGNTRUST_ORIGIN_EXTERNAL 0x01
279 #define SE051PLUGNTRUST_ORIGIN_INTERNAL 0x02
280 #define SE051PLUGNTRUST_ORIGIN_PROVISIONED 0x03
281 
286 #define SE051PLUGNTRUST_TLV_TAG_SESSION_ID 0x10
287 #define SE051PLUGNTRUST_TLV_TAG_POLICY 0x11
288 #define SE051PLUGNTRUST_TLV_TAG_MAX_ATTEMPTS 0x12
289 #define SE051PLUGNTRUST_TLV_TAG_IMPORT_AUTH_DATA 0x13
290 #define SE051PLUGNTRUST_TLV_TAG_IMPORT_AUTH_KEY_ID 0x14
291 #define SE051PLUGNTRUST_TLV_TAG_1 0x41
292 #define SE051PLUGNTRUST_TLV_TAG_2 0x42
293 #define SE051PLUGNTRUST_TLV_TAG_3 0x43
294 #define SE051PLUGNTRUST_TLV_TAG_4 0x44
295 #define SE051PLUGNTRUST_TLV_TAG_5 0x45
296 #define SE051PLUGNTRUST_TLV_TAG_6 0x46
297 #define SE051PLUGNTRUST_TLV_TAG_7 0x47
298 #define SE051PLUGNTRUST_TLV_TAG_8 0x48
299 #define SE051PLUGNTRUST_TLV_TAG_9 0x49
300 #define SE051PLUGNTRUST_TLV_TAG_10 0x4A
301 
306 #define SE051PLUGNTRUST_ECS_SIG_ECDSA_PLAIN 0x09
307 #define SE051PLUGNTRUST_ECS_SIG_ECDSA_SHA 0x11
308 #define SE051PLUGNTRUST_ECS_SIG_ECDSA_SHA_224 0x25
309 #define SE051PLUGNTRUST_ECS_SIG_ECDSA_SHA_256 0x21
310 #define SE051PLUGNTRUST_ECS_SIG_ECDSA_SHA_384 0x22
311 #define SE051PLUGNTRUST_ECS_SIG_ECDSA_SHA_512 0x26
312 #define SE051PLUGNTRUST_ECS_SIG_ED25519PH_SHA_512 0xA3
313 #define SE051PLUGNTRUST_ECS_SIG_ECDAA 0xF4
314 
319 #define SE051PLUGNTRUST_RSA_SHA1_PKCS1_PSS 0x15
320 #define SE051PLUGNTRUST_RSA_SHA224_PKCS1_PSS 0x2B
321 #define SE051PLUGNTRUST_RSA_SHA256_PKCS1_PSS 0x2C
322 #define SE051PLUGNTRUST_RSA_SHA384_PKCS1_PSS 0x2D
323 #define SE051PLUGNTRUST_RSA_SHA512_PKCS1_PSS 0x2E
324 #define SE051PLUGNTRUST_RSA_SHA1_PKCS1 0x0A
325 #define SE051PLUGNTRUST_RSA_SHA_224_PKCS1 0x27
326 #define SE051PLUGNTRUST_RSA_SHA_256_PKCS1 0x28
327 #define SE051PLUGNTRUST_RSA_SHA_384_PKCS1 0x29
328 #define SE051PLUGNTRUST_RSA_SHA_512_PKCS1 0x2A
329 #define SE051PLUGNTRUST_RSA_NO_PAD 0x0C
330 #define SE051PLUGNTRUST_RSA_PKCS1 0x0A
331 #define SE051PLUGNTRUST_RSA_PKCS1_OAEP 0x0F
332 #define SE051PLUGNTRUST_RSA_512 512
333 #define SE051PLUGNTRUST_RSA_1024 1024
334 #define SE051PLUGNTRUST_RSA_1152 1152
335 #define SE051PLUGNTRUST_RSA_2048 2048
336 #define SE051PLUGNTRUST_RSA_3072 3072
337 #define SE051PLUGNTRUST_RSA_4096 4096
338 #define SE051PLUGNTRUST_RSA_COMP_MOD 0x00
339 #define SE051PLUGNTRUST_RSA_COMP_PUB_EXP 0x01
340 #define SE051PLUGNTRUST_RSA_COMP_PRIV_EXP 0x02
341 #define SE051PLUGNTRUST_RSA_COMP_P 0x03
342 #define SE051PLUGNTRUST_RSA_COMP_Q 0x04
343 #define SE051PLUGNTRUST_RSA_COMP_DP 0x05
344 #define SE051PLUGNTRUST_RSA_COMP_DQ 0x06
345 #define SE051PLUGNTRUST_RSA_COMP_INVQ 0x07
346 
351 #define SE051PLUGNTRUST_DIGEST_NO_HASH 0x00
352 #define SE051PLUGNTRUST_DIGEST_SHA 0x01
353 #define SE051PLUGNTRUST_DIGEST_SHA224 0x07
354 #define SE051PLUGNTRUST_DIGEST_SHA256 0x04
355 #define SE051PLUGNTRUST_DIGEST_SHA384 0x05
356 #define SE051PLUGNTRUST_DIGEST_SHA512 0x06
357 
362 #define SE051PLUGNTRUST_HMAC_SHA1 0x18
363 #define SE051PLUGNTRUST_HMAC_SHA256 0x19
364 #define SE051PLUGNTRUST_HMAC_SHA384 0x1A
365 #define SE051PLUGNTRUST_HMAC_SHA512 0x1B
366 #define SE051PLUGNTRUST_CMAC_128 0x31
367 
372 #define SE051PLUGNTRUST_ECC_UNUSED 0x00
373 #define SE051PLUGNTRUST_ECC_NIST_P192 0x01
374 #define SE051PLUGNTRUST_ECC_NIST_P224 0x02
375 #define SE051PLUGNTRUST_ECC_NIST_P256 0x03
376 #define SE051PLUGNTRUST_ECC_NIST_P384 0x04
377 #define SE051PLUGNTRUST_ECC_NIST_P521 0x05
378 #define SE051PLUGNTRUST_ECC_Brainpool160 0x06
379 #define SE051PLUGNTRUST_ECC_Brainpool192 0x07
380 #define SE051PLUGNTRUST_ECC_Brainpool224 0x08
381 #define SE051PLUGNTRUST_ECC_Brainpool256 0x09
382 #define SE051PLUGNTRUST_ECC_Brainpool320 0x0A
383 #define SE051PLUGNTRUST_ECC_Brainpool384 0x0B
384 #define SE051PLUGNTRUST_ECC_Brainpool512 0x0C
385 #define SE051PLUGNTRUST_ECC_Secp160k1 0x0D
386 #define SE051PLUGNTRUST_ECC_Secp192k1 0x0E
387 #define SE051PLUGNTRUST_ECC_Secp224k1 0x0F
388 #define SE051PLUGNTRUST_ECC_Secp256k1 0x10
389 #define SE051PLUGNTRUST_ECC_TPM_ECC_BN_P256 0x11
390 #define SE051PLUGNTRUST_ECC_ID_ECC_ED_25519 0x40
391 #define SE051PLUGNTRUST_ECC_ID_ECC_MONT_DH_25519 0x41
392 #define SE051PLUGNTRUST_ECC_CURVE_PARAM_A 0x01
393 #define SE051PLUGNTRUST_ECC_CURVE_PARAM_B 0x02
394 #define SE051PLUGNTRUST_ECC_CURVE_PARAM_G 0x04
395 #define SE051PLUGNTRUST_ECC_CURVE_PARAM_N 0x08
396 #define SE051PLUGNTRUST_ECC_CURVE_PARAM_PRIME 0x10
397 
402 #define SE051PLUGNTRUST_CIPHER_DES_CBC_NOPAD 0x01
403 #define SE051PLUGNTRUST_CIPHER_DES_CBC_ISO9797_M1 0x02
404 #define SE051PLUGNTRUST_CIPHER_DES_CBC_ISO9797_M2 0x03
405 #define SE051PLUGNTRUST_CIPHER_DES_CBC_PKCS5 0x04
406 #define SE051PLUGNTRUST_CIPHER_DES_ECB_NOPAD 0x05
407 #define SE051PLUGNTRUST_CIPHER_DES_ECB_ISO9797_M1 0x06
408 #define SE051PLUGNTRUST_CIPHER_DES_ECB_ISO9797_M2 0x07
409 #define SE051PLUGNTRUST_CIPHER_DES_ECB_PKCS5 0x08
410 #define SE051PLUGNTRUST_CIPHER_AES_ECB_NOPAD 0x0E
411 #define SE051PLUGNTRUST_CIPHER_AES_CBC_NOPAD 0x0D
412 #define SE051PLUGNTRUST_CIPHER_AES_CBC_ISO9797_M1 0x16
413 #define SE051PLUGNTRUST_CIPHER_AES_CBC_ISO9797_M2 0x17
414 #define SE051PLUGNTRUST_CIPHER_AES_CBC_PKCS5 0x18
415 #define SE051PLUGNTRUST_CIPHER_AES_CTR 0xF0
416 
421 #define SE051PLUGNTRUST_CONFIG_ECDAA 0x0001
422 #define SE051PLUGNTRUST_CONFIG_ECDSA_ECDH_ECDHE 0x0002
423 #define SE051PLUGNTRUST_CONFIG_EDDSA 0x0004
424 #define SE051PLUGNTRUST_CONFIG_DH_MONT 0x0008
425 #define SE051PLUGNTRUST_CONFIG_HMAC 0x0010
426 #define SE051PLUGNTRUST_CONFIG_RSA_PLAIN 0x0020
427 #define SE051PLUGNTRUST_CONFIG_RSA_CRT 0x0040
428 #define SE051PLUGNTRUST_CONFIG_AES 0x0080
429 #define SE051PLUGNTRUST_CONFIG_DES 0x0100
430 #define SE051PLUGNTRUST_CONFIG_PBKDF 0x0200
431 #define SE051PLUGNTRUST_CONFIG_TLS 0x0400
432 #define SE051PLUGNTRUST_CONFIG_MIFARE 0x0800
433 #define SE051PLUGNTRUST_CONFIG_FIPS_MODE_DISABLED 0x1000
434 #define SE051PLUGNTRUST_CONFIG_I2CM 0x2000
435 #define SE051PLUGNTRUST_CONFIG_ECC_ALL 0x000F
436 #define SE051PLUGNTRUST_CONFIG_RSA_ALL 0x0060
437 #define SE051PLUGNTRUST_CONFIG_ALL 0x3FFF
438 
443 #define SE051PLUGNTRUST_TRANSIENT_LOCK 0x01
444 #define SE051PLUGNTRUST_PERSISTENT_LOCK 0x02
445 
450 #define SE051PLUGNTRUST_LOCKED 0x01
451 
456 #define SE051PLUGNTRUST_CC_DIGEST 0x01
457 #define SE051PLUGNTRUST_CC_CIPHER 0x02
458 #define SE051PLUGNTRUST_CC_SIGNATURE 0x03
459 
464 #define SE051PLUGNTRUST_RESULT_SUCCESS 0x01
465 #define SE051PLUGNTRUST_RESULT_FAILURE 0x02
466 
471 #define SE051PLUGNTRUST_PERSISTENT 0x01
472 #define SE051PLUGNTRUST_TRANSIENT 0x02
473 
478 #define SE051PLUGNTRUST_NOT_SET 0x01
479 #define SE051PLUGNTRUST_SET 0x02
480 
485 #define SE051PLUGNTRUST_NO_MORE 0x01
486 #define SE051PLUGNTRUST_MORE 0x02
487 
492 #define SE051PLUGNTRUST_SCP_REQUIRED 0x01
493 #define SE051PLUGNTRUST_SCP_NOT_REQUIRED 0x02
494 
499 #define SE051PLUGNTRUST_APPLET_RES_ID_TRANSPORT 0x7FFF0200ul
500 #define SE051PLUGNTRUST_APPLET_RES_ID_KP_FASTSCP_USER 0x7FFF0201ul
501 #define SE051PLUGNTRUST_APPLET_RES_ID_KP_FASTSCP_IMPORT 0x7FFF0202ul
502 #define SE051PLUGNTRUST_APPLET_RES_ID_PUB_FASTSCP_IMPORT 0x7FFF0203ul
503 #define SE051PLUGNTRUST_APPLET_RES_ID_FEATURE 0x7FFF0204ul
504 #define SE051PLUGNTRUST_APPLET_RES_ID_FACTORY_RESET 0x7FFF0205ul
505 #define SE051PLUGNTRUST_APPLET_RES_ID_UNIQUE_ID 0x7FFF0206ul
506 #define SE051PLUGNTRUST_APPLET_RES_ID_PLATFORM_SCP 0x7FFF0207ul
507 
512 #define SE051PLUGNTRUST_SW_NOERROR 0x9000
513 #define SE051PLUGNTRUST_SW_CONDITIONS_NOT_SATISFIED 0x6985
514 #define SE051PLUGNTRUST_SW_SECURITY_STATUS 0x6982
515 #define SE051PLUGNTRUST_SW_WRONG_DATA 0x6A80
516 #define SE051PLUGNTRUST_SW_DATA_INVALID 0x6984
517 #define SE051PLUGNTRUST_SW_COMMAND_NOT_ALLOWED 0x6986
518 
523 #define SE051PLUGNTRUST_OBJECT_DOES_EXISTS 1
524 #define SE051PLUGNTRUST_OBJECT_DOESNT_EXIST 2
525 
530 #define SE051PLUGNTRUST_OBJID_SE05X_APPLET_RES_START 0x7FFF0000ul
531 #define SE051PLUGNTRUST_SSS_OBJID_DEMO_AUTH_START 0x7DA00000ul
532 #define SE051PLUGNTRUST_SSS_OBJID_IOT_HUB_A_START 0xF0000000ul
533 
538 #define SE051PLUGNTRUST_OBJID_APPLET_MASK 0xFFFF0000ul
539 #define SE051PLUGNTRUST_OBJID_IOT_MASK 0xF0000000ul
540 
541  // apdu
543 
558 #define SE051PLUGNTRUST_INTERFACE_ISO14443 0
559 #define SE051PLUGNTRUST_INTERFACE_I2C 1
560 
565 #define SE051PLUGNTRUST_CARD_MANAGER_WITH_RSP 1
566 #define SE051PLUGNTRUST_CARD_MANAGER_WITHOUT_RSP 0
567 
573 #define SE051PLUGNTRUST_DEVICE_ADDRESS 0x48
574  // se051plugntrust_set
576 
591 #define SE051PLUGNTRUST_MAP_MIKROBUS( cfg, mikrobus ) \
592  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
593  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
594  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
595  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
596  // se051plugntrust_map // se051plugntrust
599 
604 typedef struct
605 {
606  // Output pins
607  digital_out_t en;
608  digital_out_t rst;
610  // Modules
611  i2c_master_t i2c;
613  // I2C slave address
614  uint8_t slave_address;
616  uint8_t interface;
619 
624 typedef struct
625 {
626  pin_name_t scl;
627  pin_name_t sda;
629  pin_name_t en;
630  pin_name_t rst;
632  uint32_t i2c_speed;
633  uint8_t i2c_address;
636 
641 typedef struct
642 {
643  uint8_t cla;
644  uint8_t ins;
645  uint8_t p1;
646  uint8_t p2;
647  uint8_t payload_len;
648  uint8_t payload[ 0xFF ];
649  uint16_t rsp_len;
650  uint16_t status;
653 
658 typedef struct
659 {
660  uint8_t nad;
661  uint8_t pcb;
662  uint8_t len;
664  uint16_t crc16;
667 
672 typedef struct
673 {
675  uint8_t vendor_id[ 5 ];
676 
678  uint8_t data_link_layer_parameters[ 0x04 ];
679 
681 
683  uint8_t physical_layer_parameters[ 0x0B ];
684 
685  uint8_t historical_len;
686  uint8_t historical[ 0x0A ];
687 
689 
694 typedef struct
695 {
696  uint8_t major_version;
697  uint8_t minor_version;
698  uint8_t patch_version;
699 
700  uint16_t applet_config;
701  uint16_t secure_box;
702 
704 
709 typedef enum
710 {
715 
717 
734 
749 
763 
777 
791 
801 void se051plugntrust_set_en_pin ( se051plugntrust_t *ctx, uint8_t state );
802 
812 void se051plugntrust_set_rst_pin ( se051plugntrust_t *ctx, uint8_t state );
813 
824 
840 void se051plugntrust_set_tlv_u8 ( uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t value );
841 
858 void se051plugntrust_set_tlv_u16 ( uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value );
859 
876 void se051plugntrust_set_tlv_u16_optional ( uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value );
877 
894 void se051plugntrust_set_tlv_u32 ( uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint32_t value );
895 
916 err_t se051plugntrust_set_tlv_u8buf ( uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len );
917 
938 err_t se051plugntrust_set_tlv_u8buf_optional ( uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len );
939 
958 err_t se051plugntrust_get_tlv_u8 ( uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint8_t *rsp );
959 
978 err_t se051plugntrust_get_tlv_u16 ( uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint16_t *rsp );
979 
1002 err_t se051plugntrust_get_tlv_u8buf ( uint8_t *buf, uint32_t *buf_index, uint8_t buf_len,
1003  uint8_t tag, uint8_t *rsp, uint32_t *rsp_len );
1004 
1014 
1026 
1039 err_t se051plugntrust_object_id_list ( se051plugntrust_t *ctx, uint32_t *id_list, uint8_t *list_len );
1040 
1054 
1069 
1084  uint8_t *cardmanager_rsp, uint8_t *cardmanager_rsp_len );
1085 
1102 err_t se051plugntrust_get_free_memory ( se051plugntrust_t *ctx, uint8_t memory_type, uint16_t *free_memory );
1103 
1119 err_t se051plugntrust_get_random_numbers ( se051plugntrust_t *ctx, uint8_t *random_buf, uint8_t buf_len );
1120 
1136 err_t se051plugntrust_check_object_exist ( se051plugntrust_t *ctx, uint32_t object_id );
1137 
1152 err_t se051plugntrust_delete_object ( se051plugntrust_t *ctx, uint32_t object_id );
1153 
1172 err_t se051plugntrust_read_object ( se051plugntrust_t *ctx, uint32_t object_id, uint16_t offset,
1173  uint16_t read_len, uint8_t *data_buf, uint32_t *data_len );
1174 
1193 err_t se051plugntrust_write_binary_object ( se051plugntrust_t *ctx, uint32_t object_id, uint16_t offset,
1194  uint16_t data_len, uint8_t *data_buf );
1195 
1212 
1213 #ifdef __cplusplus
1214 }
1215 #endif
1216 #endif // SE051PLUGNTRUST_H
1217  // se051plugntrust
1219 
1220 // ------------------------------------------------------------------------ END
se051plugntrust_get_free_memory
err_t se051plugntrust_get_free_memory(se051plugntrust_t *ctx, uint8_t memory_type, uint16_t *free_memory)
Reads Applet free memory.
se051plugntrust_t::i2c
i2c_master_t i2c
Definition: se051plugntrust.h:611
se051plugntrust_t::interface
uint8_t interface
Definition: se051plugntrust.h:616
se051plugntrust_cfg_t::i2c_address
uint8_t i2c_address
Definition: se051plugntrust.h:633
se051plugntrust_read_object
err_t se051plugntrust_read_object(se051plugntrust_t *ctx, uint32_t object_id, uint16_t offset, uint16_t read_len, uint8_t *data_buf, uint32_t *data_len)
Read object data.
se051plugntrust_get_random_numbers
err_t se051plugntrust_get_random_numbers(se051plugntrust_t *ctx, uint8_t *random_buf, uint8_t buf_len)
Get random data.
se051plugntrust_apdu_t::status
uint16_t status
Definition: se051plugntrust.h:650
se051plugntrust_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: se051plugntrust.h:632
se051plugntrust_cfg_t::rst
pin_name_t rst
Definition: se051plugntrust.h:630
se051plugntrust_apdu_write
err_t se051plugntrust_apdu_write(se051plugntrust_t *ctx, se051plugntrust_frame_data_t *frame_data)
Writing frame data function.
se051plugntrust_sw_reset
err_t se051plugntrust_sw_reset(se051plugntrust_t *ctx, se051plugntrust_atr_t *atr_data)
Sends request to reset device and reads ATR data.
se051plugntrust_frame_data_t::len
uint8_t len
Definition: se051plugntrust.h:662
se051plugntrust_apdu_t::p1
uint8_t p1
Definition: se051plugntrust.h:645
se051plugntrust_atr_t::historical_len
uint8_t historical_len
Definition: se051plugntrust.h:685
se051plugntrust_apdu_t
APDU data object.
Definition: se051plugntrust.h:642
se051plugntrust_delete_object
err_t se051plugntrust_delete_object(se051plugntrust_t *ctx, uint32_t object_id)
Delete object.
SE051PLUGNTRUST_ERROR
@ SE051PLUGNTRUST_ERROR
Definition: se051plugntrust.h:712
se051plugntrust_set_tlv_u8buf_optional
err_t se051plugntrust_set_tlv_u8buf_optional(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len)
Add TLV data buffer in payload buffer if TLV data buffer length greater then 0.
se051plugntrust_version_info_t::secure_box
uint16_t secure_box
Definition: se051plugntrust.h:701
se051plugntrust_set_tlv_u8buf
err_t se051plugntrust_set_tlv_u8buf(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t *cmd, uint32_t cmd_len)
Add TLV data buffer in payload buffer.
se051plugntrust_atr_t::physical_layer_id
uint8_t physical_layer_id
Definition: se051plugntrust.h:680
se051plugntrust_end_apdu_session
err_t se051plugntrust_end_apdu_session(se051plugntrust_t *ctx)
Sends command for ending APDU session.
se051plugntrust_set_rst_pin
void se051plugntrust_set_rst_pin(se051plugntrust_t *ctx, uint8_t state)
Set Reset pin state.
se051plugntrust_select_card_manager
err_t se051plugntrust_select_card_manager(se051plugntrust_t *ctx, uint8_t rsp, uint8_t *cardmanager_rsp, uint8_t *cardmanager_rsp_len)
Select card manager.
se051plugntrust_version_info_t::major_version
uint8_t major_version
Definition: se051plugntrust.h:696
se051plugntrust_cfg_t::en
pin_name_t en
Definition: se051plugntrust.h:629
se051plugntrust_atr_t::physical_layer_parameters_len
uint8_t physical_layer_parameters_len
Definition: se051plugntrust.h:682
se051plugntrust_set_en_pin
void se051plugntrust_set_en_pin(se051plugntrust_t *ctx, uint8_t state)
Set Enable pin state.
SE051PLUGNTRUST_ERROR_TIMEOUT
@ SE051PLUGNTRUST_ERROR_TIMEOUT
Definition: se051plugntrust.h:713
se051plugntrust_select_applet
err_t se051plugntrust_select_applet(se051plugntrust_t *ctx, uint8_t ns_encode, se051plugntrust_version_info_t *ver_info)
Selects Clicks Applet and returns info that device sends back to host.
se051plugntrust_apdu_t::p2
uint8_t p2
Definition: se051plugntrust.h:646
se051plugntrust_frame_data_t::apdu
se051plugntrust_apdu_t * apdu
Definition: se051plugntrust.h:663
se051plugntrust_apdu_t::rsp_len
uint16_t rsp_len
Definition: se051plugntrust.h:649
se051plugntrust_set_tlv_u8
void se051plugntrust_set_tlv_u8(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint8_t value)
Add TLV data of 1 byte value in payload buffer.
se051plugntrust_frame_data_t::nad
uint8_t nad
Definition: se051plugntrust.h:660
SE051PLUGNTRUST_ERROR_DATA_OVF
@ SE051PLUGNTRUST_ERROR_DATA_OVF
Definition: se051plugntrust.h:714
se051plugntrust_atr_t::protocol_version
uint8_t protocol_version
Definition: se051plugntrust.h:674
se051plugntrust_version_info_t::minor_version
uint8_t minor_version
Definition: se051plugntrust.h:697
se051plugntrust_object_id_list
err_t se051plugntrust_object_id_list(se051plugntrust_t *ctx, uint32_t *id_list, uint8_t *list_len)
Reads all Object ID's from Applet.
se051plugntrust_check_object_exist
err_t se051plugntrust_check_object_exist(se051plugntrust_t *ctx, uint32_t object_id)
Check if object exists.
se051plugntrust_frame_data_t::crc16
uint16_t crc16
Definition: se051plugntrust.h:664
se051plugntrust_set_tlv_u32
void se051plugntrust_set_tlv_u32(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint32_t value)
Add TLV data of 4 bytes value in payload buffer.
se051plugntrust_reset
void se051plugntrust_reset(se051plugntrust_t *ctx)
Reset function.
se051plugntrust_set_tlv_u16_optional
void se051plugntrust_set_tlv_u16_optional(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value)
Add TLV data of 2 bytes value in payload buffer if value is greater then 0.
se051plugntrust_get_tlv_u8buf
err_t se051plugntrust_get_tlv_u8buf(uint8_t *buf, uint32_t *buf_index, uint8_t buf_len, uint8_t tag, uint8_t *rsp, uint32_t *rsp_len)
Parses TLV data from payload buffer to find data for desired tag.
se051plugntrust_set_tlv_u16
void se051plugntrust_set_tlv_u16(uint8_t *buf, uint8_t *buf_len, uint8_t tag, uint16_t value)
Add TLV data of 2 bytes value in payload buffer.
se051plugntrust_cfg_setup
void se051plugntrust_cfg_setup(se051plugntrust_cfg_t *cfg)
SE051 Plug n Trust configuration object setup function.
se051plugntrust_atr_t
Data after reset.
Definition: se051plugntrust.h:673
se051plugntrust_write_binary_object
err_t se051plugntrust_write_binary_object(se051plugntrust_t *ctx, uint32_t object_id, uint16_t offset, uint16_t data_len, uint8_t *data_buf)
Create/Write to binary object.
se051plugntrust_apdu_t::payload_len
uint8_t payload_len
Definition: se051plugntrust.h:647
se051plugntrust_get_tlv_u16
err_t se051plugntrust_get_tlv_u16(uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint16_t *rsp)
Parses TLV data from payload buffer to find data for desired tag.
se051plugntrust_apdu_t::ins
uint8_t ins
Definition: se051plugntrust.h:644
se051plugntrust_t::en
digital_out_t en
Definition: se051plugntrust.h:607
se051plugntrust_frame_data_t
Communication frame data object.
Definition: se051plugntrust.h:659
se051plugntrust_frame_data_t::pcb
uint8_t pcb
Definition: se051plugntrust.h:661
se051plugntrust_t::slave_address
uint8_t slave_address
Definition: se051plugntrust.h:614
se051plugntrust_cfg_t::sda
pin_name_t sda
Definition: se051plugntrust.h:627
se051plugntrust_atr_t::data_link_layer_parameters_len
uint8_t data_link_layer_parameters_len
Definition: se051plugntrust.h:677
se051plugntrust_version_info_t::patch_version
uint8_t patch_version
Definition: se051plugntrust.h:698
SE051PLUGNTRUST_OK
@ SE051PLUGNTRUST_OK
Definition: se051plugntrust.h:711
se051plugntrust_apdu_transfer
err_t se051plugntrust_apdu_transfer(se051plugntrust_t *ctx, se051plugntrust_frame_data_t *frame_data)
Write-Read frame data function.
se051plugntrust_get_applet_info
err_t se051plugntrust_get_applet_info(se051plugntrust_t *ctx, se051plugntrust_version_info_t *ver_info)
Get Version info from Applet.
se051plugntrust_calculate_apdu_size
uint8_t se051plugntrust_calculate_apdu_size(se051plugntrust_apdu_t *apdu_data)
Calculates APDU object size.
se051plugntrust_version_info_t
Version info data.
Definition: se051plugntrust.h:695
se051plugntrust_cfg_t
SE051 Plug n Trust Click configuration object.
Definition: se051plugntrust.h:625
se051plugntrust_t::rst
digital_out_t rst
Definition: se051plugntrust.h:608
se051plugntrust_apdu_read
err_t se051plugntrust_apdu_read(se051plugntrust_t *ctx, se051plugntrust_frame_data_t *frame_data)
Reading frame data function function.
se051plugntrust_version_info_t::applet_config
uint16_t applet_config
Definition: se051plugntrust.h:700
se051plugntrust_return_value_t
se051plugntrust_return_value_t
SE051 Plug n Trust Click return value data.
Definition: se051plugntrust.h:710
se051plugntrust_t
SE051 Plug n Trust Click context object.
Definition: se051plugntrust.h:605
se051plugntrust_apdu_t::cla
uint8_t cla
Definition: se051plugntrust.h:643
se051plugntrust_init
err_t se051plugntrust_init(se051plugntrust_t *ctx, se051plugntrust_cfg_t *cfg)
SE051 Plug n Trust initialization function.
se051plugntrust_cfg_t::scl
pin_name_t scl
Definition: se051plugntrust.h:626
se051plugntrust_get_tlv_u8
err_t se051plugntrust_get_tlv_u8(uint8_t *buf, uint32_t *buf_index, uint8_t tag, uint8_t *rsp)
Parses TLV data from payload buffer to find data for desired tag.