2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
18 * @brief This file contains APIs of WEB_APP_ENC module.
21 #ifndef __WEB_APP_ENC__
22 #define __WEB_APP_ENC__
29 * @addtogroup CAPI_WEB_APP_ENC_MODULE
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 */
53 * @brief Application Type.
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*/
64 * @brief Encrypts web application data with internal key(APP DEK: Application Data Encryption Key).
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.
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
82 * @see wae_decrypt_web_application()
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);
87 * @brief Encrypts web application data with internal key.
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.
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
105 * @see wae_encrypt_web_application()
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);
110 * @brief Remove a APP DEK(Application Data Encryption Key) used for encrytpion and decryption of a web application.
113 * @param[in] pPkgId The package id of an application.
114 * @param[in] appType The application type.
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
124 int wae_remove_app_dek(const char* pPkgId, wae_app_type_e appType);
135 #endif /* __WEB_APP_ENC__ */