summaryrefslogtreecommitdiff
path: root/srcs
diff options
context:
space:
mode:
authorKyungwook Tak <k.tak@samsung.com>2016-07-27 16:54:50 +0900
committerkyungwook tak <k.tak@samsung.com>2016-08-02 21:45:45 -0700
commitcc76acebe224f4b8a273752b2400190ab0aab679 (patch)
tree9f131a30f794d8a11174a3ef06c18c91976a8bd6 /srcs
parenta025df2ca4ae9a4e13b5b803674da4dd1bd133e9 (diff)
downloadlibwebappenc-cc76acebe224f4b8a273752b2400190ab0aab679.tar.gz
libwebappenc-cc76acebe224f4b8a273752b2400190ab0aab679.tar.bz2
libwebappenc-cc76acebe224f4b8a273752b2400190ab0aab679.zip
[API changed] Add uid parametersubmit/tizen/20160811.013634
Installer will be run as system (from user) so we cannot retrieve user id from client credential(by key-manager). Change-Id: I1e091bfc0b88fce418cd209a7a1adab021b6c0d2 Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
Diffstat (limited to 'srcs')
-rw-r--r--srcs/key_handler.c165
-rw-r--r--srcs/key_handler.h14
-rw-r--r--srcs/key_manager.c50
-rw-r--r--srcs/key_manager.h8
-rw-r--r--srcs/types.h9
-rw-r--r--srcs/web_app_enc.c70
6 files changed, 204 insertions, 112 deletions
diff --git a/srcs/key_handler.c b/srcs/key_handler.c
index af7280b..cf3de1d 100644
--- a/srcs/key_handler.c
+++ b/srcs/key_handler.c
@@ -29,6 +29,7 @@
#include <tzplatform_config.h>
+#include "web_app_enc.h"
#include "wae_log.h"
#include "crypto_service.h"
#include "key_manager.h"
@@ -56,19 +57,28 @@ static void deinit_lib(void)
crypto_element_map_destroy(_map);
}
-static const crypto_element_s *_get_app_ce_from_cache(const char *pkg_id)
+char *_create_map_key(uid_t uid, const char *pkg_id)
{
- return crypto_element_map_get(_map, pkg_id);
+ char *key = NULL;
+
+ int ret = asprintf(&key, "%u-%s", uid, pkg_id);
+
+ return (ret == -1) ? NULL : key;
}
-static int _add_app_ce_to_cache(const char *pkg_id, crypto_element_s *ce)
+static const crypto_element_s *_get_app_ce_from_cache(const char *key)
{
- return crypto_element_map_add(&_map, pkg_id, ce);
+ return crypto_element_map_get(_map, key);
}
-void _remove_app_ce_from_cache(const char *pkg_id)
+static int _add_app_ce_to_cache(const char *key, crypto_element_s *ce)
{
- crypto_element_map_remove(&_map, pkg_id);
+ return crypto_element_map_add(&_map, key, ce);
+}
+
+void _remove_app_ce_from_cache(const char *key)
+{
+ crypto_element_map_remove(&_map, key);
}
int _get_random(raw_buffer_s *rb)
@@ -110,13 +120,13 @@ static const char *_get_dek_store_path()
static int _write_to_file(const char *path, const raw_buffer_s *data)
{
- if (path == NULL || data == NULL || data->buf == NULL || data->size == 0)
+ if (path == NULL || !is_buffer_valid(data))
return WAE_ERROR_INVALID_PARAMETER;
FILE *f = fopen(path, "w");
if (f == NULL) {
- WAE_SLOGE("WAE: Fail to open a file. file=%s", path);
+ WAE_SLOGE("Failed to open a file(%s)", path);
return WAE_ERROR_FILE;
}
@@ -125,7 +135,7 @@ static int _write_to_file(const char *path, const raw_buffer_s *data)
fclose(f);
if (write_len != (int)data->size) {
- WAE_SLOGE("WAE: Fail to write a file. file=%s", path);
+ WAE_SLOGE("Failed to write a file(%s)", path);
return WAE_ERROR_FILE;
}
@@ -226,110 +236,145 @@ int _write_encrypted_app_dek_to_file(const char *pkg_id, const raw_buffer_s *enc
return _write_to_file(path, encrypted);
}
-int get_app_ce(const char *pkg_id, wae_app_type_e app_type, bool create_for_migrated_app,
- const crypto_element_s **pce)
+int get_app_ce(uid_t uid, const char *pkg_id, wae_app_type_e app_type,
+ bool create_for_migrated_app, const crypto_element_s **pce)
{
if (pkg_id == NULL || pce == NULL)
return WAE_ERROR_INVALID_PARAMETER;
- const crypto_element_s *cached_ce = _get_app_ce_from_cache(pkg_id);
+ if (uid == 0 && app_type == WAE_DOWNLOADED_NORMAL_APP)
+ return WAE_ERROR_INVALID_PARAMETER;
+
+ const char *key = NULL;
+ char *_key_per_user = NULL;
+
+ if (app_type == WAE_DOWNLOADED_NORMAL_APP) {
+ _key_per_user = _create_map_key(uid, pkg_id);
+ if (_key_per_user == NULL)
+ return WAE_ERROR_MEMORY;
+
+ key = _key_per_user;
+ } else {
+ key = pkg_id;
+ }
+
+ int ret = WAE_ERROR_NONE;
+ const crypto_element_s *cached_ce = _get_app_ce_from_cache(key);
if (cached_ce != NULL) {
- WAE_SLOGD("cache hit of app ce for pkg_id(%s)", pkg_id);
+ WAE_SLOGD("cache hit of app ce for key(%s)", key);
*pce = cached_ce;
- return WAE_ERROR_NONE;
+ goto finish;
}
- WAE_SLOGD("cache miss of app ce for pkg_id(%s)", pkg_id);
+ WAE_SLOGD("cache miss of app ce for key(%s)", key);
crypto_element_s *ce = NULL;
- int ret = get_from_key_manager(pkg_id, app_type, &ce);
+ ret = get_from_key_manager(key, app_type, &ce);
if (create_for_migrated_app &&
(ret == WAE_ERROR_NO_KEY && app_type == WAE_DOWNLOADED_GLOBAL_APP)) {
- WAE_SLOGI("No dek found for pkg_id(%s)! It should be migrated app.", pkg_id);
+ WAE_SLOGI("No dek found for key(%s)! It should be migrated app.", key);
- if ((ret = get_old_ss_crypto_element(pkg_id, &ce)) != WAE_ERROR_NONE)
- goto error;
+ if ((ret = get_old_ss_crypto_element(key, &ce)) != WAE_ERROR_NONE)
+ goto finish;
// (k.tak) disable to save ce to key-maanger for migrated app because of permission issue.
- //ret = save_to_key_manager(pkg_id, app_type, ce);
+ //ret = save_to_key_manager(key, pkg_id, app_type, ce);
//if (ret != WAE_ERROR_NONE) {
// WAE_SLOGW("Failed to save migrated app ce to key-manager with ret(%d). "
// "Ignore this error because we can create ce later again.", ret);
// ret = WAE_ERROR_NONE;
//}
} else if (ret != WAE_ERROR_NONE) {
- WAE_SLOGE("Failed to get crypto element from key-manager. pkg_id=%s, ret=%d",
- pkg_id, ret);
- goto error;
+ WAE_SLOGE("Failed to get crypto element from key-manager. key(%s) ret(%d)",
+ key, ret);
+ goto finish;
}
- ret = _add_app_ce_to_cache(pkg_id, ce);
+ ret = _add_app_ce_to_cache(key, ce);
if (ret != WAE_ERROR_NONE) {
- WAE_SLOGE("Failed to add ce to cache for pkg_id(%s) ret(%d)", pkg_id, ret);
- goto error;
+ WAE_SLOGE("Failed to add ce to cache for key(%s) ret(%d)", key, ret);
+ goto finish;
}
*pce = ce;
- WAE_SLOGD("Successfully get ce! pkgid(%s)", pkg_id);
+ WAE_SLOGD("Successfully get ce! key(%s)", key);
- return WAE_ERROR_NONE;
+finish:
+ free(_key_per_user);
-error:
- crypto_element_destroy(ce);
+ if (ret != WAE_ERROR_NONE)
+ crypto_element_destroy(ce);
return ret;
}
-int create_app_ce(const char *pkg_id, wae_app_type_e app_type, const crypto_element_s **pce)
+int create_app_ce(uid_t uid, const char *pkg_id, wae_app_type_e app_type,
+ const crypto_element_s **pce)
{
raw_buffer_s *dek = buffer_create(DEK_LEN);
raw_buffer_s *iv = buffer_create(IV_LEN);
crypto_element_s *ce = crypto_element_create(dek, iv);
int ret = WAE_ERROR_NONE;
+ const char *key = NULL;
+ char *_key_per_user = NULL;
if (ce == NULL) {
ret = WAE_ERROR_MEMORY;
goto error;
}
+ if (app_type == WAE_DOWNLOADED_NORMAL_APP) {
+ _key_per_user = _create_map_key(uid, pkg_id);
+ if (_key_per_user == NULL) {
+ ret = WAE_ERROR_MEMORY;
+ goto error;
+ }
+
+ key = _key_per_user;
+ } else {
+ key = pkg_id;
+ }
+
memcpy(ce->iv->buf, AES_CBC_IV, ce->iv->size);
ret = _get_random(dek);
if (ret != WAE_ERROR_NONE) {
- WAE_SLOGE("Failed to get random for dek. pkg_id(%s) ret(%d)", pkg_id, ret);
+ WAE_SLOGE("Failed to get random for dek. key(%s) ret(%d)", key, ret);
goto error;
}
- ret = save_to_key_manager(pkg_id, app_type, ce);
+ ret = save_to_key_manager(key, pkg_id, app_type, ce);
if (ret != WAE_ERROR_NONE) {
- WAE_SLOGE("Failed to save ce to key-manager. pkg_id(%s) app_type(%d) ret(%d)",
- pkg_id, app_type, ret);
+ WAE_SLOGE("Failed to save ce to key-manager. key(%s) app_type(%d) ret(%d)",
+ key, app_type, ret);
goto error;
}
- ret = _add_app_ce_to_cache(pkg_id, ce);
+ ret = _add_app_ce_to_cache(key, ce);
if (ret != WAE_ERROR_NONE) {
- WAE_SLOGE("Failed to add ce to cache for pkg_id(%s) ret(%d)", pkg_id, ret);
+ WAE_SLOGE("Failed to add ce to cache for key(%s) ret(%d)", key, ret);
goto error;
}
*pce = ce;
- WAE_SLOGI("Success to create dek/iv and store it in key-manager. pkg_id(%s)", pkg_id);
-
- return WAE_ERROR_NONE;
+ WAE_SLOGI("Success to create dek/iv and store it in key-manager. key(%s)", key);
error:
- if (ce == NULL) {
- buffer_destroy(dek);
- buffer_destroy(iv);
- } else {
- crypto_element_destroy(ce);
+ if (ret != WAE_ERROR_NONE) {
+ if (ce == NULL) {
+ buffer_destroy(dek);
+ buffer_destroy(iv);
+ } else {
+ crypto_element_destroy(ce);
+ }
}
+ free(_key_per_user);
+
return ret;
}
@@ -542,7 +587,7 @@ int load_preloaded_app_deks(bool reload)
continue;
}
- ret = save_to_key_manager(pkg_id, WAE_PRELOADED_APP, ce);
+ ret = save_to_key_manager(pkg_id, pkg_id, WAE_PRELOADED_APP, ce);
if (ret == WAE_ERROR_KEY_EXISTS) {
WAE_SLOGI("Key Manager already has dek. It will be ignored. file=%s",
@@ -574,16 +619,34 @@ error:
return ret;
}
-int remove_app_ce(const char *pkg_id, wae_app_type_e app_type)
+int remove_app_ce(uid_t uid, const char *pkg_id, wae_app_type_e app_type)
{
- int ret = remove_from_key_manager(pkg_id, app_type);
+ if (uid == 0 && app_type == WAE_DOWNLOADED_NORMAL_APP)
+ return WAE_ERROR_INVALID_PARAMETER;
+
+ const char *key = NULL;
+ char *_key_per_user = NULL;
+
+ if (app_type == WAE_DOWNLOADED_NORMAL_APP) {
+ _key_per_user = _create_map_key(uid, pkg_id);
+ if (_key_per_user == NULL)
+ return WAE_ERROR_MEMORY;
+
+ key = _key_per_user;
+ } else {
+ key = pkg_id;
+ }
+
+ int ret = remove_from_key_manager(key, app_type);
if (ret != WAE_ERROR_NONE)
- WAE_SLOGE("Failed to remove app ce for pkg_id(%s) ret(%d)", pkg_id, ret);
+ WAE_SLOGE("Failed to remove app ce for key(%s) ret(%d)", key, ret);
else
- WAE_SLOGI("Success to remove app ce for pkg_id(%s)", pkg_id);
+ WAE_SLOGI("Success to remove app ce for key(%s)", key);
+
+ _remove_app_ce_from_cache(key);
- _remove_app_ce_from_cache(pkg_id);
+ free(_key_per_user);
return ret;
}
diff --git a/srcs/key_handler.h b/srcs/key_handler.h
index e64d81c..791e149 100644
--- a/srcs/key_handler.h
+++ b/srcs/key_handler.h
@@ -28,28 +28,30 @@ extern "C" {
#include <stdbool.h>
#include <stddef.h>
+#include <sys/types.h>
-#include "web_app_enc.h"
#include "types.h"
#define MAX_PATH_LEN 512
/* functions with "_" prefix are internal static functions but declared here for testing */
-void _remove_app_ce_from_cache(const char *pkg_id);
+char *_create_map_key(uid_t uid, const char *pkg_id);
+void _remove_app_ce_from_cache(const char *key);
int _get_random(raw_buffer_s *rb);
int _get_preloaded_app_dek_file_path(const char *pkg_id, size_t size, char *path);
int _read_encrypted_app_dek_from_file(const char *pkg_id, raw_buffer_s **pencrypted);
int _write_encrypted_app_dek_to_file(const char *pkg_id, const raw_buffer_s *encrypted);
/* functions for interface */
-int get_app_ce(const char *pkg_id, wae_app_type_e app_type, bool create_for_migrated_app,
- const crypto_element_s **pce);
-int create_app_ce(const char *pkg_id, wae_app_type_e app_type,
+int get_app_ce(uid_t uid, const char *pkg_id, wae_app_type_e app_type,
+ bool create_for_migrated_app, const crypto_element_s **pce);
+int create_app_ce(uid_t uid, const char *pkg_id, wae_app_type_e app_type,
const crypto_element_s **pce);
+int remove_app_ce(uid_t uid, const char *pkg_id, wae_app_type_e app_type);
+
int get_preloaded_app_ce(const char *pkg_id, const crypto_element_s **pce);
int create_preloaded_app_ce(const char *pkg_id, const crypto_element_s **pce);
int load_preloaded_app_deks(bool reload);
-int remove_app_ce(const char *pkg_id, wae_app_type_e app_type);
#ifdef __cplusplus
}
diff --git a/srcs/key_manager.c b/srcs/key_manager.c
index 4ef5b8a..aeee748 100644
--- a/srcs/key_manager.c
+++ b/srcs/key_manager.c
@@ -27,6 +27,7 @@
#include <ckmc/ckmc-manager.h>
+#include "web_app_enc.h"
#include "wae_log.h"
#define MAX_ALIAS_LEN 256
@@ -192,28 +193,14 @@ error:
return ret;
}
-static void _get_alias(const char *pkg_id, wae_app_type_e type, bool forSave,
+static void _get_alias(const char *name, UNUSED wae_app_type_e type, UNUSED bool forSave,
char *alias, size_t buff_len)
{
- if (type == WAE_DOWNLOADED_NORMAL_APP) {
- if (forSave) {
- snprintf(alias, buff_len, "%s%s",
- APP_DEK_ALIAS_PFX,
- pkg_id);
- } else {
- snprintf(alias, buff_len, "%c%s%s%s%s",
- '/', INSTALLER_LABEL,
- ckmc_owner_id_separator,
- APP_DEK_ALIAS_PFX,
- pkg_id);
- }
- } else { // system alias
- snprintf(alias, buff_len, "%s%s%s%s",
- ckmc_owner_id_system,
- ckmc_owner_id_separator,
- APP_DEK_ALIAS_PFX,
- pkg_id);
- }
+ snprintf(alias, buff_len, "%s%s%s%s",
+ ckmc_owner_id_system,
+ ckmc_owner_id_separator,
+ APP_DEK_ALIAS_PFX,
+ name);
}
static void _get_dek_loading_done_alias(char *alias, size_t buff_len)
@@ -276,16 +263,17 @@ int clear_app_deks_loaded_from_key_manager()
return _to_wae_error(ckmc_remove_alias(alias));
}
-int save_to_key_manager(const char *pkg_id, wae_app_type_e type, const crypto_element_s *ce)
+int save_to_key_manager(const char *name, const char *pkg_id, wae_app_type_e type,
+ const crypto_element_s *ce)
{
char alias[MAX_ALIAS_LEN] = {0, };
- _get_alias(pkg_id, type, true, alias, sizeof(alias));
+ _get_alias(name, type, true, alias, sizeof(alias));
ckmc_raw_buffer_s *buf = NULL;
int ret = _serialize(ce, &buf);
if (ret != WAE_ERROR_NONE) {
- WAE_SLOGE("Failed to serialize crypto element of pkg_id: %s", pkg_id);
+ WAE_SLOGE("Failed to serialize crypto element of name(%s)", name);
return ret;
}
@@ -298,8 +286,8 @@ int save_to_key_manager(const char *pkg_id, wae_app_type_e type, const crypto_el
ckmc_buffer_free(buf);
if (ret != WAE_ERROR_NONE) {
- WAE_SLOGE("Failed to add crypto element to ckm: pkg_id(%s) alias(%s) ret(%d)",
- pkg_id, alias, ret);
+ WAE_SLOGE("Failed to add crypto element to ckm: name(%s) alias(%s) ret(%d)",
+ name, alias, ret);
return ret;
}
@@ -312,19 +300,19 @@ int save_to_key_manager(const char *pkg_id, wae_app_type_e type, const crypto_el
return ret;
}
- WAE_SLOGI("Success to save crypto element to key-manager. pkg_id(%s)", pkg_id);
+ WAE_SLOGI("Success to save crypto element to key-manager. name(%s)", name);
return WAE_ERROR_NONE;
}
-int get_from_key_manager(const char *pkg_id, wae_app_type_e type, crypto_element_s **pce)
+int get_from_key_manager(const char *name, wae_app_type_e type, crypto_element_s **pce)
{
- if (pkg_id == NULL || pce == NULL)
+ if (name == NULL || pce == NULL)
return WAE_ERROR_INVALID_PARAMETER;
char alias[MAX_ALIAS_LEN] = {0, };
- _get_alias(pkg_id, type, false, alias, sizeof(alias));
+ _get_alias(name, type, false, alias, sizeof(alias));
ckmc_raw_buffer_s *buf = NULL;
int ret = _to_wae_error(ckmc_get_data(alias, NULL, &buf));
@@ -338,11 +326,11 @@ int get_from_key_manager(const char *pkg_id, wae_app_type_e type, crypto_element
return ret;
}
-int remove_from_key_manager(const char *pkg_id, wae_app_type_e type)
+int remove_from_key_manager(const char *name, wae_app_type_e type)
{
char alias[MAX_ALIAS_LEN] = {0, };
- _get_alias(pkg_id, type, true, alias, sizeof(alias));
+ _get_alias(name, type, true, alias, sizeof(alias));
return _to_wae_error(ckmc_remove_alias(alias));
}
diff --git a/srcs/key_manager.h b/srcs/key_manager.h
index ec84561..4566b09 100644
--- a/srcs/key_manager.h
+++ b/srcs/key_manager.h
@@ -28,12 +28,12 @@ extern "C" {
#include <stdbool.h>
-#include "web_app_enc.h"
#include "types.h"
-int save_to_key_manager(const char *pkg_id, wae_app_type_e type, const crypto_element_s *ce);
-int get_from_key_manager(const char *pkg_id, wae_app_type_e type, crypto_element_s **pce);
-int remove_from_key_manager(const char *pkg_id, wae_app_type_e type);
+int save_to_key_manager(const char *name, const char *pkg_id, wae_app_type_e type,
+ const crypto_element_s *ce);
+int get_from_key_manager(const char *name, wae_app_type_e type, crypto_element_s **pce);
+int remove_from_key_manager(const char *name, wae_app_type_e type);
bool is_app_deks_loaded_in_key_manager();
int set_app_deks_loaded_to_key_manager();
diff --git a/srcs/types.h b/srcs/types.h
index 7e27aeb..51ed9fc 100644
--- a/srcs/types.h
+++ b/srcs/types.h
@@ -29,6 +29,15 @@ extern "C" {
#include <stdbool.h>
#include <stddef.h>
+#define API __attribute__ ((visibility("default")))
+#define UNUSED __attribute__ ((unused))
+
+typedef enum {
+ WAE_DOWNLOADED_NORMAL_APP = 0,
+ WAE_DOWNLOADED_GLOBAL_APP = 1,
+ WAE_PRELOADED_APP = 2
+} wae_app_type_e;
+
typedef struct _raw_buffer_s {
unsigned char *buf;
size_t size;
diff --git a/srcs/web_app_enc.c b/srcs/web_app_enc.c
index 22da420..5846105 100644
--- a/srcs/web_app_enc.c
+++ b/srcs/web_app_enc.c
@@ -30,7 +30,7 @@
#include "wae_log.h"
int _wae_encrypt_downloaded_web_application(
- const char *pkg_id, wae_app_type_e app_type,
+ uid_t uid, const char *pkg_id, wae_app_type_e app_type,
const unsigned char *data, size_t data_len,
unsigned char **pencrypted_data, size_t *pencrypted_data_len)
{
@@ -39,10 +39,10 @@ int _wae_encrypt_downloaded_web_application(
return WAE_ERROR_INVALID_PARAMETER;
const crypto_element_s *e = NULL;
- int ret = get_app_ce(pkg_id, app_type, false, &e);
+ int ret = get_app_ce(uid, pkg_id, app_type, false, &e);
if (ret == WAE_ERROR_NO_KEY)
- ret = create_app_ce(pkg_id, app_type, &e);
+ ret = create_app_ce(uid, pkg_id, app_type, &e);
if (ret != WAE_ERROR_NONE)
return ret;
@@ -64,7 +64,8 @@ int _wae_encrypt_downloaded_web_application(
return WAE_ERROR_NONE;
}
-int _wae_decrypt_downloaded_web_application(const char *pkg_id, wae_app_type_e app_type,
+int _wae_decrypt_downloaded_web_application(
+ uid_t uid, const char *pkg_id, wae_app_type_e app_type,
const unsigned char *data, size_t data_len,
unsigned char **pdecrypted_data, size_t *pdecrypted_data_len)
{
@@ -77,7 +78,7 @@ int _wae_decrypt_downloaded_web_application(const char *pkg_id, wae_app_type_e a
_data.size = data_len;
const crypto_element_s *ce = NULL;
- int ret = get_app_ce(pkg_id, app_type, true, &ce);
+ int ret = get_app_ce(uid, pkg_id, app_type, true, &ce);
if (ret != WAE_ERROR_NONE)
return ret;
@@ -134,40 +135,69 @@ int _wae_encrypt_preloaded_web_application(const char *pkg_id,
return WAE_ERROR_NONE;
}
-int _wae_decrypt_preloaded_web_application(const char *pkg_id, wae_app_type_e app_type,
+int _wae_decrypt_preloaded_web_application(const char *pkg_id,
const unsigned char *data, size_t data_len,
unsigned char **pdecrypted_data, size_t *pdecrypted_data_len)
{
// same with the decryption of downloaded web application
- return _wae_decrypt_downloaded_web_application(pkg_id, app_type,
+ return _wae_decrypt_downloaded_web_application(0, pkg_id, WAE_PRELOADED_APP,
data, data_len, pdecrypted_data, pdecrypted_data_len);
}
-int wae_encrypt_web_application(const char *pkg_id, wae_app_type_e app_type,
- const unsigned char *data, size_t data_len,
- unsigned char **pencrypted_data, size_t *pencrypted_data_len)
+int wae_encrypt_web_application(
+ uid_t uid, const char *pkg_id,
+ const unsigned char *data, size_t data_len,
+ unsigned char **pencrypted_data, size_t *pencrypted_data_len)
{
- if (app_type == WAE_PRELOADED_APP)
+ return _wae_encrypt_downloaded_web_application(
+ uid, pkg_id, WAE_DOWNLOADED_NORMAL_APP,
+ data, data_len, pencrypted_data, pencrypted_data_len);
+}
+
+int wae_encrypt_global_web_application(
+ const char *pkg_id, bool is_preloaded,
+ const unsigned char *data, size_t data_len,
+ unsigned char **pencrypted_data, size_t *pencrypted_data_len)
+{
+ if (is_preloaded)
return _wae_encrypt_preloaded_web_application(pkg_id,
data, data_len, pencrypted_data, pencrypted_data_len);
else
- return _wae_encrypt_downloaded_web_application(pkg_id, app_type,
+ return _wae_encrypt_downloaded_web_application(
+ 0, pkg_id, WAE_DOWNLOADED_GLOBAL_APP,
data, data_len, pencrypted_data, pencrypted_data_len);
}
-int wae_decrypt_web_application(const char *pkg_id, wae_app_type_e app_type,
- const unsigned char *data, size_t data_len,
- unsigned char **pdecrypted_data, size_t *pdecrypted_data_len)
+int wae_decrypt_web_application(
+ uid_t uid, const char *pkg_id,
+ const unsigned char *data, size_t data_len,
+ unsigned char **pdecrypted_data, size_t *pdecrypted_data_len)
+{
+ return _wae_decrypt_downloaded_web_application(
+ uid, pkg_id, WAE_DOWNLOADED_NORMAL_APP,
+ data, data_len, pdecrypted_data, pdecrypted_data_len);
+}
+
+int wae_decrypt_global_web_application(
+ const char *pkg_id, bool is_preloaded,
+ const unsigned char *data, size_t data_len,
+ unsigned char **pdecrypted_data, size_t *pdecrypted_data_len)
{
- if (app_type == WAE_PRELOADED_APP)
- return _wae_decrypt_preloaded_web_application(pkg_id, app_type,
+ if (is_preloaded)
+ return _wae_decrypt_preloaded_web_application(pkg_id,
data, data_len, pdecrypted_data, pdecrypted_data_len);
else
- return _wae_decrypt_downloaded_web_application(pkg_id, app_type,
+ return _wae_decrypt_downloaded_web_application(
+ 0, pkg_id, WAE_DOWNLOADED_GLOBAL_APP,
data, data_len, pdecrypted_data, pdecrypted_data_len);
}
-int wae_remove_app_dek(const char *pkg_id, wae_app_type_e app_type)
+int wae_remove_app_dek(uid_t uid, const char *pkg_id)
+{
+ return remove_app_ce(uid, pkg_id, WAE_DOWNLOADED_NORMAL_APP);
+}
+
+int wae_remove_global_app_dek(const char *pkg_id, bool is_preloaded)
{
- return remove_app_ce(pkg_id, app_type);
+ return remove_app_ce(0, pkg_id, is_preloaded ? WAE_PRELOADED_APP : WAE_DOWNLOADED_GLOBAL_APP);
}