Refine spec file
[platform/core/security/libwebappenc.git] / include / web_app_enc.h
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  *
16  * @file    web_app_enc.h
17  * @version 1.0
18  * @brief   This file contains APIs of WEB_APP_ENC module.
19 */
20
21 #ifndef __WEB_APP_ENC__
22 #define __WEB_APP_ENC__
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 /**
29  * @addtogroup CAPI_WEB_APP_ENC_MODULE
30  * @{
31  */
32
33
34 /**
35  * @brief WAE Errors.
36  * @since_tizen 3.0
37  */
38 typedef enum
39 {
40     WAE_ERROR_NONE                     =   0x00, /**< Successful */
41     WAE_ERROR_INVALID_PARAMETER        = - 0x01, /**< Invalid function parameter */
42     WAE_ERROR_PERMISSION_DENIED        = - 0x02, /**< Permission denied */
43     WAE_ERROR_NO_KEY                   = - 0x03, /**< No key */
44     WAE_ERROR_KEY_EXISTS               = - 0x04, /**< key already exists*/
45     WAE_ERROR_KEY_MANAGER              = - 0x05, /**< key-manager internal error */
46     WAE_ERROR_CRYPTO                   = - 0x06, /**< failed in crypto operation */
47     WAE_ERROR_MEMORY                   = - 0x07, /**< failed to allocate memory */
48     WAE_ERROR_FILE                     = - 0x08, /**< failed to read or write a file*/
49     WAE_ERROR_UNKNOWN                  = - 0x09  /** < Unknown error */
50 } wae_error_e;
51
52 /**
53  * @brief Application Type.
54  * @since_tizen 3.0
55  */
56 typedef enum
57 {
58     WAE_DOWNLOADED_NORMAL_APP = 0, /**< Downloaded Normal Application*/
59     WAE_DOWNLOADED_GLOBAL_APP = 1, /**< Downloaded Global Application*/
60     WAE_PRELOADED_APP         = 2  /**< Preloaded Application*/
61 } wae_app_type_e;
62
63 /**
64  * @brief Encrypts web application data with internal key(APP DEK: Application Data Encryption Key).
65  *
66  * @since_tizen 3.0
67  * @param[in] pPkgId   The package id of an application.
68  * @param[in] appType  The application type.
69  * @param[in] pData    The data block to be encrypted.
70  * @param[in] dataLen  The length of the data block.
71  * @param[out] ppEncryptedData The data block contaning encrypted data block. Memory allocated for ppEncryptedData. Has to be freed by free() function.
72  * @param[out] pEncDataLen The length of the encrypted data block.
73  *
74  * @return #WAE_ERROR_NONE on success, otherwise a negative error value
75  * @retval #WAE_ERROR_INVALID_PARAMETER   Invalid input parameter
76  * @retval #WAE_ERROR_PERMISSION_DENIED   Non-authenticated application request
77  * @retval #WAE_ERROR_NO_KEY              No internal key
78  * @retval #WAE_ERROR_KEY_MANAGER         key-manager internal error
79  * @retval #WAE_ERROR_CRYPTO              failed in crypto operation
80  * @retval #WAE_ERROR_UNKNOWN             Failed with unknown reason
81  *
82  * @see wae_decrypt_web_application()
83  */
84 int wae_encrypt_web_application(const char* pPkgId, wae_app_type_e appType, const unsigned char* pData, size_t dataLen, unsigned char** ppEncryptedData, size_t* pEncDataLen);
85
86 /**
87  * @brief Encrypts web application data with internal key.
88  *
89  * @since_tizen 3.0
90  * @param[in] pPkgId   The package id of an application.
91  * @param[in] appType  The application type.
92  * @param[in] pData    The data block to be decrypted.
93  * @param[in] dataLen  The length of the data block.
94  * @param[out] ppDecryptedData Data block contaning decrypted data block. Memory allocated for ppEncryptedData. Has to be freed by free() function.
95  * @param[out] pDecDataLen The length of the decrypted data block.
96  *
97  * @return #WAE_ERROR_NONE on success, otherwise a negative error value
98  * @retval #WAE_ERROR_INVALID_PARAMETER   Invalid input parameter
99  * @retval #WAE_ERROR_PERMISSION_DENIED   Non-authenticated application request
100  * @retval #WAE_ERROR_NO_KEY              No internal key
101  * @retval #WAE_ERROR_KEY_MANAGER         key-manager internal error
102  * @retval #WAE_ERROR_CRYPTO              failed in crypto operation
103  * @retval #WAE_ERROR_UNKNOWN             Failed with unknown reason
104  *
105  * @see wae_encrypt_web_application()
106  */
107 int wae_decrypt_web_application(const char* pPkgId, wae_app_type_e appType, const unsigned char* pData, size_t dataLen, unsigned char** ppDecryptedData, size_t* pDecDataLen);
108
109 /**
110  * @brief Remove a APP DEK(Application Data Encryption Key) used for encrytpion and decryption of a web application.
111  *
112  * @since_tizen 3.0
113  * @param[in] pPkgId   The package id of an application.
114  * @param[in] appType  The application type.
115  *
116  * @return #WAE_ERROR_NONE on success, otherwise a negative error value
117  * @retval #WAE_ERROR_INVALID_PARAMETER   Invalid input parameter
118  * @retval #WAE_ERROR_PERMISSION_DENIED   Non-authenticated application request
119  * @retval #WAE_ERROR_NO_KEY              No internal key
120  * @retval #WAE_ERROR_KEY_MANAGER         key-manager internal error
121  * @retval #WAE_ERROR_UNKNOWN             Failed with unknown reason
122  *
123  */
124 int wae_remove_app_dek(const char* pPkgId, wae_app_type_e appType);
125
126
127 /**
128  * @}
129  */
130
131 #ifdef __cplusplus
132 }
133 #endif
134
135 #endif /* __WEB_APP_ENC__ */
136