merge with master
[platform/core/security/libcryptsvc.git] / include / tlc_tzcrypt.h
1 /*
2  * tlc_tzcrypto.h
3  *
4  */
5
6 #ifndef TLC_TZCRYPT_H_
7 #define TLC_TZCRYPT_H_
8
9 #ifdef __cplusplus
10 extern "C"
11 {
12 #endif
13 /*
14 typedef unsigned int    TZCRYPT_Result;
15 typedef unsigned char   TZCRYPT_UINT8;
16 typedef unsigned int    TZCRYPT_UINT32;
17 typedef unsigned long   TZCRYPT_UINT64;
18 */
19
20 /* TLC error code */
21 #define TZCRYPT_SUCCESS                                 0x00000000
22 #define TZCRYPT_ERROR_INIT_FAILED                       0x20000001
23 #define TZCRYPT_ERROR_TERMINATE_FAILED                  0x20000002
24 #define TZCRYPT_ERROR_ENCRYPT_FAILED                    0x20000003
25 #define TZCRYPT_ERROR_DECRYPT_FAILED                    0x20000004
26 #define TZCRYPT_ERROR_WRAPIDENTITY_FAILED                       0x20000005
27 #define TZCRYPT_ERROR_UNWRAPIDENTITY_FAILED                     0x20000006
28 #define TZCRYPT_ERROR_HASH_FAILED                       0x20000007
29 #define TZCRYPT_ERROR_INVALID_PARAMETER                 0x20000008
30
31 /* Sec Crypto error code */
32 #define SEC_CRYPTO_SUCCESS                              0x00000000
33 #define SEC_CRYPTO_ENCRYPT_ERROR                                0x30000001
34 #define SEC_CRYPTO_DECRYPT_ERROR                                0x30000002
35 #define SEC_CRYPTO_WRAPIDENTITY_ERROR                           0x30000003
36 #define SEC_CRYPTO_UNWRAPIDENTITY_ERROR                         0x30000004
37 #define SEC_CRYPTO_HASH_ERROR                           0x30000005
38
39 /*
40  * This function provides an encryption of user data. 
41  *
42  * @param [in] Src  : User data to be encrypted 
43  * @param [in] SrcLen : Length of user data to be encrypted (multiple by chunk size, SIZE_CHUNK)
44  * @param [out] Dst : Encrypted data
45  * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_SECUREOBJECT)
46  *
47  * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the previous TLC error code)
48  */
49 TZCRYPT_Result TzCrypt_Encrypt(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);
50
51 /*
52  * This function provides an decryption of user data.
53  *
54  * @param [in] Src  : Cipher data to be decrypted
55  * @param [in] SrcLen : Length of Cipher data to be decrypted (multiple by chunk size, SIZE_SECUREOBJECT)
56  * @param [out] Dst : Encrypted data
57  * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_CHUNK)
58  *
59  * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
60  */
61 TZCRYPT_Result TzCrypt_Decrypt(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);
62
63 /*
64  * This function provides an hash of user data.
65  *
66  * @param [in] Src : Plain information
67  * @param [in] SrcLen : Length of Plain information
68  * @param [out] Dst : Hashed information
69  * @param [out] *DstLen : a pointer to length of hashed information
70
71  * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
72  */
73 TZCRYPT_Result TzCrypt_Hash(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);
74
75 /*
76  * This function provides an wrapping of App data. (+ include hash operation)
77  *
78  * @param [in] Src : Plain information
79  * @param [in] SrcLen : Length of Plain information
80  * @param [out] Dst : Wrapped information
81  * @param [out] *DstLen : a pointer to length of wrapped information
82
83  * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
84  */
85 TZCRYPT_Result TzCrypt_WrapIdentity(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);
86
87 /*
88  * This function provides an unwrapping of App data. (- exclude hash operation)
89  *
90  * @param [in] Src : Plain information
91  * @param [in] SrcLen : Length of Plain information
92  * @param [out] Dst : Wrapped information
93  * @param [out] *DstLen : a pointer to length of wrapped information
94
95  * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
96  */
97 TZCRYPT_Result TzCrypt_UnwrapIdentity(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);
98
99 /*
100  * This function provides the length of secure object from a given length of source data
101  *
102  * @param [in] SrcLen : Length of Plain information
103  *
104  * return TZCRYPT_UINT32 (size) if operation has been succesfully completed.
105  */
106 TZCRYPT_UINT32 TzCrypt_GetSOLen(TZCRYPT_UINT32 SrcLen);
107
108 #ifdef __cplusplus
109 }
110 #endif
111
112 #endif