Apply coding style of tizen by astyle
[platform/core/security/libwebappenc.git] / include / web_app_enc.h
1 /*
2  *  Copyright (c) 2016 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   APIs of WEB_APP_ENC module.
19 */
20 #ifndef __WEB_APP_ENC__
21 #define __WEB_APP_ENC__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <stddef.h>
28
29 /**
30  * @addtogroup CAPI_WEB_APP_ENC_MODULE
31  * @{
32  */
33
34 /**
35  * @brief WAE Errors.
36  * @since_tizen 3.0
37  */
38 typedef enum {
39         WAE_ERROR_NONE                     = 0x00,  /**< Successful */
40         WAE_ERROR_INVALID_PARAMETER        = -0x01, /**< Invalid function parameter */
41         WAE_ERROR_PERMISSION_DENIED        = -0x02, /**< Permission denied */
42         WAE_ERROR_NO_KEY                   = -0x03, /**< No key */
43         WAE_ERROR_KEY_EXISTS               = -0x04, /**< key already exists*/
44         WAE_ERROR_KEY_MANAGER              = -0x05, /**< key-manager internal error */
45         WAE_ERROR_CRYPTO                   = -0x06, /**< failed in crypto operation */
46         WAE_ERROR_MEMORY                   = -0x07, /**< failed to allocate memory */
47         WAE_ERROR_FILE                     = -0x08, /**< failed to read or write a file*/
48         WAE_ERROR_UNKNOWN                  = -0x09  /** < Unknown error */
49 } wae_error_e;
50
51 /**
52  * @brief Application Type.
53  * @since_tizen 3.0
54  */
55 typedef enum {
56         WAE_DOWNLOADED_NORMAL_APP = 0, /**< Downloaded Normal Application*/
57         WAE_DOWNLOADED_GLOBAL_APP = 1, /**< Downloaded Global Application*/
58         WAE_PRELOADED_APP         = 2  /**< Preloaded Application*/
59 } wae_app_type_e;
60
61 /**
62  * @brief Encrypts web application data with internal key(APP DEK: Application Data Encryption Key).
63  *
64  * @since_tizen 3.0
65  * @param[in] pPkgId   The package id of an application.
66  * @param[in] appType  The application type.
67  * @param[in] pData    The data block to be encrypted.
68  * @param[in] dataLen  The length of the data block.
69  * @param[out] ppEncryptedData The data block contaning encrypted data block. Memory allocated for ppEncryptedData. Has to be freed by free() function.
70  * @param[out] pEncDataLen The length of the encrypted data block.
71  *
72  * @return #WAE_ERROR_NONE on success, otherwise a negative error value
73  * @retval #WAE_ERROR_INVALID_PARAMETER   Invalid input parameter
74  * @retval #WAE_ERROR_PERMISSION_DENIED   Non-authenticated application request
75  * @retval #WAE_ERROR_NO_KEY              No internal key
76  * @retval #WAE_ERROR_KEY_MANAGER         key-manager internal error
77  * @retval #WAE_ERROR_CRYPTO              failed in crypto operation
78  * @retval #WAE_ERROR_UNKNOWN             Failed with unknown reason
79  *
80  * @see wae_decrypt_web_application()
81  */
82 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);
83
84 /**
85  * @brief Encrypts web application data with internal key.
86  *
87  * @since_tizen 3.0
88  * @param[in] pPkgId   The package id of an application.
89  * @param[in] appType  The application type.
90  * @param[in] pData    The data block to be decrypted.
91  * @param[in] dataLen  The length of the data block.
92  * @param[out] ppDecryptedData Data block contaning decrypted data block. Memory allocated for ppEncryptedData. Has to be freed by free() function.
93  * @param[out] pDecDataLen The length of the decrypted data block.
94  *
95  * @return #WAE_ERROR_NONE on success, otherwise a negative error value
96  * @retval #WAE_ERROR_INVALID_PARAMETER   Invalid input parameter
97  * @retval #WAE_ERROR_PERMISSION_DENIED   Non-authenticated application request
98  * @retval #WAE_ERROR_NO_KEY              No internal key
99  * @retval #WAE_ERROR_KEY_MANAGER         key-manager internal error
100  * @retval #WAE_ERROR_CRYPTO              failed in crypto operation
101  * @retval #WAE_ERROR_UNKNOWN             Failed with unknown reason
102  *
103  * @see wae_encrypt_web_application()
104  */
105 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);
106
107 /**
108  * @brief Remove a APP DEK(Application Data Encryption Key) used for encrytpion and decryption of a web application.
109  *
110  * @since_tizen 3.0
111  * @param[in] pPkgId   The package id of an application.
112  * @param[in] appType  The application type.
113  *
114  * @return #WAE_ERROR_NONE on success, otherwise a negative error value
115  * @retval #WAE_ERROR_INVALID_PARAMETER   Invalid input parameter
116  * @retval #WAE_ERROR_PERMISSION_DENIED   Non-authenticated application request
117  * @retval #WAE_ERROR_NO_KEY              No internal key
118  * @retval #WAE_ERROR_KEY_MANAGER         key-manager internal error
119  * @retval #WAE_ERROR_UNKNOWN             Failed with unknown reason
120  *
121  */
122 int wae_remove_app_dek(const char *pPkgId, wae_app_type_e appType);
123
124 /**
125  * @}
126  */
127
128 #ifdef __cplusplus
129 }
130 #endif
131
132 #endif /* __WEB_APP_ENC__ */