2 * Copyright (c) 2016 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 APIs of WEB_APP_ENC module.
20 #ifndef __WEB_APP_ENC__
21 #define __WEB_APP_ENC__
30 * @addtogroup CAPI_WEB_APP_ENC_MODULE
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 */
52 * @brief Application Type.
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*/
62 * @brief Encrypts web application data with internal key(APP DEK: Application Data Encryption Key).
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.
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
80 * @see wae_decrypt_web_application()
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);
85 * @brief Encrypts web application data with internal key.
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.
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
103 * @see wae_encrypt_web_application()
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);
108 * @brief Remove a APP DEK(Application Data Encryption Key) used for encrytpion and decryption of a web application.
111 * @param[in] pPkgId The package id of an application.
112 * @param[in] appType The application type.
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
122 int wae_remove_app_dek(const char *pPkgId, wae_app_type_e appType);
132 #endif /* __WEB_APP_ENC__ */