merge with master
[platform/core/security/libcryptsvc.git] / include / tltzcrypt_api.h
1 /*
2  *
3  */
4 #ifndef TLTZCRYPT_API_H_
5 #define TLTZCRYPT_API_H_
6
7 #ifdef __cplusplus
8 extern "C"
9 {
10 #endif
11
12 #include "tci.h"
13
14 /* Command ID's for communication Trustlet Connector -> Trustlet. */
15 #define CMD_ENCRYPT_TZ_CRYPT            0x00000001
16 #define CMD_DECRYPT_TZ_CRYPT            0x00000002
17 #define CMD_WRAPIDENTITY_TZ_CRYPT                       0x00000003
18 #define CMD_UNWRAPIDENTITY_TZ_CRYPT                     0x00000004
19 #define CMD_HASH_TZ_CRYPT                               0x00000005
20
21 /* Return codes */
22 #define RET_TL_OK                       0x00000000
23
24 /* Error codes */
25 #define RET_ERR_ENCRYPT_TZ_CRYPT        0x10000001
26 #define RET_ERR_DECRYPT_TZ_CRYPT        0x10000002
27 #define RET_ERR_WRAPIDENTITY_TZ_CRYPT           0x10000003
28 #define RET_ERR_UNWRAPIDENTITY_TZ_CRYPT         0x10000004
29 #define RET_ERR_HASH_TZ_CRYPT           0x10000005
30
31 /* Termination codes */
32 #define EXIT_ERROR                      ((uint32_t)(-1))
33
34 #define SIZE_CHUNK              1024
35 #define SIZE_SECUREOBJECT       1116    // SO SIZE for 1024 byte (predefined)
36 #define SIZE_HASHAPPIDENTITY            32
37 #define SIZE_WRAPAPPIDENTITY            124
38
39 /* TCI message data. */
40 typedef struct {
41         uint32_t        id;
42         //uint32_t      data_len;
43         //uint8_t       *data_ptr;
44         //uint8_t       data[MAX_DATA_LEN];
45 } tci_cmd_t;
46
47 typedef struct {
48         uint32_t        id;
49         uint32_t        return_code;
50         //uint32_t      data_len;
51         //uint8_t       *data_ptr;
52         //uint8_t       data[MAX_DATA_LEN];
53 } tci_resp_t;
54
55
56 typedef union {
57         uint8_t input_data[SIZE_CHUNK];
58         uint8_t output_data[SIZE_SECUREOBJECT];
59 } buffer_t;
60
61 typedef union {
62         uint8_t hash_identity[SIZE_HASHAPPIDENTITY];
63         uint8_t wrap_identity[SIZE_WRAPAPPIDENTITY];
64 } identity_t;
65
66 typedef struct {
67         union {
68                 tci_cmd_t                       cmd;                    /* Command message structure */
69                 tci_resp_t                      resp;                   /* Response message structure */
70         };
71         uint32_t pData;
72         uint32_t pLen;
73         uint32_t cData;
74         uint32_t cLen;
75 } tciMessage_t;
76
77 /* Trustlet UUID. */
78 #define TL_TZ_CRYPT_UUID { { 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7 } }
79
80 #ifdef __cplusplus
81 }
82 #endif
83
84 #endif /* TLTZCRYPT_API_H_ */