2 * libcryptsvc - device unique key
4 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
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;
35 #define SHA256_DIGEST_VALUE_LEN 32
38 * This function provides an encryption of user data.
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
49 * return SEC_CRYPTO_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
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);
55 * This function provides an decryption of user data.
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
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
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);
73 * This function provides the length of a given src len
75 * @param [in] source length
77 * return length of cipher text
79 __attribute__((visibility("default")))
80 TZCRYPT_UINT32 SecGetCipherLen(TZCRYPT_UINT32 srclen);