merge with master
[platform/core/security/libcryptsvc.git] / include / SecTzSvc.h
1 /*
2  * libcryptsvc - device unique key
3  *
4  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef _SEC_TZ_SVC_H
21 #define _SEC_TZ_SVC_H
22
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27
28 typedef unsigned int uint32_t;
29 typedef unsigned char uint8_t;
30 typedef unsigned int    TZCRYPT_Result;
31 typedef unsigned char   TZCRYPT_UINT8;
32 typedef unsigned int    TZCRYPT_UINT32;
33 typedef unsigned long   TZCRYPT_UINT64;
34
35 #define SHA256_DIGEST_VALUE_LEN         32
36
37 /*
38  * This function provides an encryption of user data. 
39  *
40  * @param [in] Src  : User data to be encrypted 
41  * @param [in] SrcLen : Length of user data to be encrypted (multiple by chunk size, SIZE_CHUNK)
42  * @param [out] Dst : Encrypted data
43  * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_SECUREOBJECT)
44  * @param [in] AppInfo : Application information
45  * @param [in] AppInfoLen : Length of Application information
46  * @param [out] WrapAppInfo : Hashed and wrapped Application Information  as an identifier
47  * @param [out] *WrapAppInfo : a pointer to length of hashed and wraped Application Information  as an identifier
48  *
49  * return SEC_CRYPTO_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
50  */
51 __attribute__((visibility("default")))
52 TZCRYPT_Result SecEncryptTZCrypt(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen, TZCRYPT_UINT8 *AppInfo, TZCRYPT_UINT32 AppInfoLen, TZCRYPT_UINT8 *WrapAppInfo, TZCRYPT_UINT32 *WrapAppInfoLen);
53
54 /*
55  * This function provides an decryption of user data.
56  *
57  * @param [in] Src  : Cipher data to be decrypted
58  * @param [in] SrcLen : Length of Cipher data to be decrypted (multiple by chunk size, SIZE_SECUREOBJECT)
59  * @param [out] Dst : Encrypted data
60  * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_CHUNK)
61  * @param [in] AppInfo : Application information
62  * @param [in] AppInfoLen : Length of Application information
63  * @param [in] WrapAppInfo : Hashed and wrapped Application Information  as an identifier
64  * @param [in] WrapAppInfo : Length of hashed and wraped Application Information  as an identifier
65  *
66  * return SEC_CRYPTO_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
67  * If a given application information (identifier) is wrong, then return UNIT_TEXT_HASH_ERROR
68  */
69 __attribute__((visibility("default")))
70 TZCRYPT_Result SecDecryptTZCrypt(TZCRYPT_UINT8 *Src, TZCRYPT_UINT32 SrcLen, TZCRYPT_UINT8 *Dst, TZCRYPT_UINT32 *DstLen, TZCRYPT_UINT8 *AppInfo, TZCRYPT_UINT32 AppInfoLen, TZCRYPT_UINT8 *WrapAppInfo, TZCRYPT_UINT32 WrapAppInfoLen);
71
72 /*
73  * This function provides the length of a given src len
74  *
75  * @param [in] source length
76  *
77  * return length of cipher text
78  */
79 __attribute__((visibility("default")))
80 TZCRYPT_UINT32 SecGetCipherLen(TZCRYPT_UINT32 srclen);
81
82 #ifdef __cplusplus
83 }
84 #endif
85
86 #endif