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
37 /* Sec Crypto error code */
38 #define SEC_CRYPTO_SUCCESS 0x00000000
39 #define SEC_CRYPTO_ENCRYPT_ERROR 0x30000001
40 #define SEC_CRYPTO_DECRYPT_ERROR 0x30000002
41 #define SEC_CRYPTO_WRAPIDENTITY_ERROR 0x30000003
42 #define SEC_CRYPTO_UNWRAPIDENTITY_ERROR 0x30000004
43 #define SEC_CRYPTO_HASH_ERROR 0x30000005
44 #define SEC_CRYPTO_GENERATE_KEY_ERROR 0x30000006
45 #define SEC_CRYPTO_RETRIEVE_KEY_ERROR 0x30000007
47 * This function provides an encryption of user data.
49 * @param [in] Src : User data to be encrypted
50 * @param [in] SrcLen : Length of user data to be encrypted (multiple by chunk size, SIZE_CHUNK)
51 * @param [out] Dst : Encrypted data
52 * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_SECUREOBJECT)
53 * @param [in] AppInfo : Application information
54 * @param [in] AppInfoLen : Length of Application information
55 * @param [out] WrapAppInfo : Hashed and wrapped Application Information as an identifier
56 * @param [out] *WrapAppInfo : a pointer to length of hashed and wraped Application Information as an identifier
58 * return SEC_CRYPTO_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
60 __attribute__((visibility("default")))
61 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);
64 * This function provides an decryption of user data.
66 * @param [in] Src : Cipher data to be decrypted
67 * @param [in] SrcLen : Length of Cipher data to be decrypted (multiple by chunk size, SIZE_SECUREOBJECT)
68 * @param [out] Dst : Encrypted data
69 * @param [out] *DstLen : a pointer to length of encrypted data (multiple by secure object size, SIZE_CHUNK)
70 * @param [in] AppInfo : Application information
71 * @param [in] AppInfoLen : Length of Application information
72 * @param [in] WrapAppInfo : Hashed and wrapped Application Information as an identifier
73 * @param [in] WrapAppInfo : Length of hashed and wraped Application Information as an identifier
75 * return SEC_CRYPTO_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code)
76 * If a given application information (identifier) is wrong, then return UNIT_TEXT_HASH_ERROR
78 __attribute__((visibility("default")))
79 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);
82 * This function provides the length of a given src len
84 * @param [in] source length
86 * return length of cipher text
88 __attribute__((visibility("default")))
89 TZCRYPT_UINT32 SecGetCipherLen(TZCRYPT_UINT32 srclen);