diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-16 01:17:53 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-16 01:17:53 +0900 |
commit | af4aafeb01279cc095a610cf4125923df0514e2f (patch) | |
tree | 8457c05c3f8199fcc8bf63908834c43bfcc7c431 /include | |
parent | 2c7ecdbd74111c96bfc63b2752a4ed8ebc5755fc (diff) | |
download | libcryptsvc-af4aafeb01279cc095a610cf4125923df0514e2f.tar.gz libcryptsvc-af4aafeb01279cc095a610cf4125923df0514e2f.tar.bz2 libcryptsvc-af4aafeb01279cc095a610cf4125923df0514e2f.zip |
merge with master
Diffstat (limited to 'include')
-rwxr-xr-x | include/SecCryptoSvc.h | 1 | ||||
-rwxr-xr-x | include/SecTzSvc.h | 86 | ||||
-rwxr-xr-x | include/tci.h | 54 | ||||
-rwxr-xr-x | include/tlc_tzcrypt.h | 112 | ||||
-rwxr-xr-x | include/tltzcrypt_api.h | 84 |
5 files changed, 337 insertions, 0 deletions
diff --git a/include/SecCryptoSvc.h b/include/SecCryptoSvc.h index 13ef3c3..d6d4a2b 100755 --- a/include/SecCryptoSvc.h +++ b/include/SecCryptoSvc.h @@ -92,6 +92,7 @@ typedef enum {false, true} bool; //#define SEC_CRYPTP_ARR_LENGTH 1024 #define SEC_FRAME_OSP_KEY "uniqueKey" //#define SHA1_DIGEST_VALUE_LEN 20 +#define SHA256_DIGEST_VALUE_LEN 32 //#define KDF_KEYLEN 16 #define HASH_LEN 20 //#define SEC_KEYMGR_FEK_SIZE 16 diff --git a/include/SecTzSvc.h b/include/SecTzSvc.h new file mode 100755 index 0000000..ee107ea --- /dev/null +++ b/include/SecTzSvc.h @@ -0,0 +1,86 @@ +/* + * libcryptsvc - device unique key + * + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef _SEC_TZ_SVC_H +#define _SEC_TZ_SVC_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +typedef unsigned int TZCRYPT_Result; +typedef unsigned char TZCRYPT_UINT8; +typedef unsigned int TZCRYPT_UINT32; +typedef unsigned long TZCRYPT_UINT64; + +#define SHA256_DIGEST_VALUE_LEN 32 + +/* + * 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) + * @param [in] AppInfo : Application information + * @param [in] AppInfoLen : Length of Application information + * @param [out] WrapAppInfo : Hashed and wrapped Application Information as an identifier + * @param [out] *WrapAppInfo : a pointer to length of hashed and wraped Application Information as an identifier + * + * return SEC_CRYPTO_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code) + */ +__attribute__((visibility("default"))) +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); + +/* + * 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) + * @param [in] AppInfo : Application information + * @param [in] AppInfoLen : Length of Application information + * @param [in] WrapAppInfo : Hashed and wrapped Application Information as an identifier + * @param [in] WrapAppInfo : Length of hashed and wraped Application Information as an identifier + * + * return SEC_CRYPTO_SUCCESS if operation has been succesfully completed. (Refer to the tlc error code) + * If a given application information (identifier) is wrong, then return UNIT_TEXT_HASH_ERROR + */ +__attribute__((visibility("default"))) +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); + +/* + * This function provides the length of a given src len + * + * @param [in] source length + * + * return length of cipher text + */ +__attribute__((visibility("default"))) +TZCRYPT_UINT32 SecGetCipherLen(TZCRYPT_UINT32 srclen); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/tci.h b/include/tci.h new file mode 100755 index 0000000..e27984c --- /dev/null +++ b/include/tci.h @@ -0,0 +1,54 @@ +/* + * tci.h + * + * Created on: 05.05.2010 + * Author: galkag + * modified ckyu.han@samsung.com + */ + +#ifndef TCI_H_ +#define TCI_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* +typedef unsigned int uint32_t; +typedef unsigned char uint8_t; +*/ + +typedef uint32_t tciCommandId_t; +typedef uint32_t tciResponseId_t; +typedef uint32_t tciReturnCode_t; + +/* Responses have bit 31 set */ +#define RSP_ID_MASK (1U << 31) +#define RSP_ID(cmdId) (((uint32_t)(cmdId)) | RSP_ID_MASK) +#define IS_CMD(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == 0) +#define IS_RSP(cmdId) ((((uint32_t)(cmdId)) & RSP_ID_MASK) == RSP_ID_MASK) + +/* Return codes of Trustlet commands. */ +#define RET_OK 0 /* Set, if processing is error free */ +#define RET_ERR_UNKNOWN_CMD 1 /* Unknown command */ +#define RET_CUSTOM_START 2 +#define RET_ERR_MAP 3 +#define RET_ERR_UNMAP 4 + +/* TCI command header. */ +typedef struct { + tciCommandId_t commandId; /* Command ID */ +} tciCommandHeader_t; + +/* TCI response header. */ +typedef struct { + tciResponseId_t responseId; /* Response ID (must be command ID | RSP_ID_MASK )*/ + tciReturnCode_t returnCode; /* Return code of command */ +} tciResponseHeader_t; + +#ifdef __cplusplus +} +#endif + +#endif /* TCI_H_ */ diff --git a/include/tlc_tzcrypt.h b/include/tlc_tzcrypt.h new file mode 100755 index 0000000..7234cb1 --- /dev/null +++ b/include/tlc_tzcrypt.h @@ -0,0 +1,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 diff --git a/include/tltzcrypt_api.h b/include/tltzcrypt_api.h new file mode 100755 index 0000000..6a56d97 --- /dev/null +++ b/include/tltzcrypt_api.h @@ -0,0 +1,84 @@ +/* + * + */ +#ifndef TLTZCRYPT_API_H_ +#define TLTZCRYPT_API_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "tci.h" + +/* Command ID's for communication Trustlet Connector -> Trustlet. */ +#define CMD_ENCRYPT_TZ_CRYPT 0x00000001 +#define CMD_DECRYPT_TZ_CRYPT 0x00000002 +#define CMD_WRAPIDENTITY_TZ_CRYPT 0x00000003 +#define CMD_UNWRAPIDENTITY_TZ_CRYPT 0x00000004 +#define CMD_HASH_TZ_CRYPT 0x00000005 + +/* Return codes */ +#define RET_TL_OK 0x00000000 + +/* Error codes */ +#define RET_ERR_ENCRYPT_TZ_CRYPT 0x10000001 +#define RET_ERR_DECRYPT_TZ_CRYPT 0x10000002 +#define RET_ERR_WRAPIDENTITY_TZ_CRYPT 0x10000003 +#define RET_ERR_UNWRAPIDENTITY_TZ_CRYPT 0x10000004 +#define RET_ERR_HASH_TZ_CRYPT 0x10000005 + +/* Termination codes */ +#define EXIT_ERROR ((uint32_t)(-1)) + +#define SIZE_CHUNK 1024 +#define SIZE_SECUREOBJECT 1116 // SO SIZE for 1024 byte (predefined) +#define SIZE_HASHAPPIDENTITY 32 +#define SIZE_WRAPAPPIDENTITY 124 + +/* TCI message data. */ +typedef struct { + uint32_t id; + //uint32_t data_len; + //uint8_t *data_ptr; + //uint8_t data[MAX_DATA_LEN]; +} tci_cmd_t; + +typedef struct { + uint32_t id; + uint32_t return_code; + //uint32_t data_len; + //uint8_t *data_ptr; + //uint8_t data[MAX_DATA_LEN]; +} tci_resp_t; + + +typedef union { + uint8_t input_data[SIZE_CHUNK]; + uint8_t output_data[SIZE_SECUREOBJECT]; +} buffer_t; + +typedef union { + uint8_t hash_identity[SIZE_HASHAPPIDENTITY]; + uint8_t wrap_identity[SIZE_WRAPAPPIDENTITY]; +} identity_t; + +typedef struct { + union { + tci_cmd_t cmd; /* Command message structure */ + tci_resp_t resp; /* Response message structure */ + }; + uint32_t pData; + uint32_t pLen; + uint32_t cData; + uint32_t cLen; +} tciMessage_t; + +/* Trustlet UUID. */ +#define TL_TZ_CRYPT_UUID { { 0xff, 0xff, 0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7 } } + +#ifdef __cplusplus +} +#endif + +#endif /* TLTZCRYPT_API_H_ */ |