summaryrefslogtreecommitdiff
path: root/include/tlc_tzcrypt.h
blob: 7234cb1bdcb273d931b8fc5f158aa660912a9ebe (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 * tlc_tzcrypto.h
 *
 */

#ifndef TLC_TZCRYPT_H_
#define TLC_TZCRYPT_H_

#ifdef __cplusplus
extern "C"
{
#endif
/*
typedef unsigned int	TZCRYPT_Result;
typedef unsigned char	TZCRYPT_UINT8;
typedef unsigned int	TZCRYPT_UINT32;
typedef unsigned long	TZCRYPT_UINT64;
*/

/* TLC error code */
#define TZCRYPT_SUCCESS					0x00000000
#define TZCRYPT_ERROR_INIT_FAILED			0x20000001
#define TZCRYPT_ERROR_TERMINATE_FAILED			0x20000002
#define TZCRYPT_ERROR_ENCRYPT_FAILED			0x20000003
#define TZCRYPT_ERROR_DECRYPT_FAILED			0x20000004
#define TZCRYPT_ERROR_WRAPIDENTITY_FAILED			0x20000005
#define TZCRYPT_ERROR_UNWRAPIDENTITY_FAILED			0x20000006
#define TZCRYPT_ERROR_HASH_FAILED			0x20000007
#define TZCRYPT_ERROR_INVALID_PARAMETER			0x20000008

/* Sec Crypto error code */
#define SEC_CRYPTO_SUCCESS				0x00000000
#define SEC_CRYPTO_ENCRYPT_ERROR				0x30000001
#define SEC_CRYPTO_DECRYPT_ERROR				0x30000002
#define SEC_CRYPTO_WRAPIDENTITY_ERROR				0x30000003
#define SEC_CRYPTO_UNWRAPIDENTITY_ERROR				0x30000004
#define SEC_CRYPTO_HASH_ERROR				0x30000005

/*
 * This function provides an encryption of user data. 
 *
 * @param [in] Src  : User data to be encrypted 
 * @param [in] SrcLen : Length of user data to be encrypted (multiple by chunk size, SIZE_CHUNK)
 * @param [out] Dst : Encrypted data
 * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_SECUREOBJECT)
 *
 * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the previous TLC error code)
 */
TZCRYPT_Result TzCrypt_Encrypt(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);

/*
 * This function provides an decryption of user data.
 *
 * @param [in] Src  : Cipher data to be decrypted
 * @param [in] SrcLen : Length of Cipher data to be decrypted (multiple by chunk size, SIZE_SECUREOBJECT)
 * @param [out] Dst : Encrypted data
 * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_CHUNK)
 *
 * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
 */
TZCRYPT_Result TzCrypt_Decrypt(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);

/*
 * This function provides an hash of user data.
 *
 * @param [in] Src : Plain information
 * @param [in] SrcLen : Length of Plain information
 * @param [out] Dst : Hashed information
 * @param [out] *DstLen : a pointer to length of hashed information

 * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
 */
TZCRYPT_Result TzCrypt_Hash(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);

/*
 * This function provides an wrapping of App data. (+ include hash operation)
 *
 * @param [in] Src : Plain information
 * @param [in] SrcLen : Length of Plain information
 * @param [out] Dst : Wrapped information
 * @param [out] *DstLen : a pointer to length of wrapped information

 * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
 */
TZCRYPT_Result TzCrypt_WrapIdentity(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);

/*
 * This function provides an unwrapping of App data. (- exclude hash operation)
 *
 * @param [in] Src : Plain information
 * @param [in] SrcLen : Length of Plain information
 * @param [out] Dst : Wrapped information
 * @param [out] *DstLen : a pointer to length of wrapped information

 * return TZCRYPT_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
 */
TZCRYPT_Result TzCrypt_UnwrapIdentity(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen);

/*
 * This function provides the length of secure object from a given length of source data
 *
 * @param [in] SrcLen : Length of Plain information
 *
 * return TZCRYPT_UINT32 (size) if operation has been succesfully completed.
 */
TZCRYPT_UINT32 TzCrypt_GetSOLen(TZCRYPT_UINT32 SrcLen);

#ifdef __cplusplus
}
#endif

#endif