Apply coding style of tizen by astyle
[platform/core/security/libwebappenc.git] / srcs / key_handler.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  *
17  * @file        key_handler.h
18  * @author      Dongsun Lee (ds73.lee@samsung.com)
19  * @version     1.0
20  * @brief       Key manupulatation.
21  */
22 #ifndef __WAE_KEY_HANDLER_H
23 #define __WAE_KEY_HANDLER_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <stdbool.h>
30 #include <stddef.h>
31 #include "web_app_enc.h"
32
33 #define MAX_PATH_LEN  512
34
35 /* functions with "_" prefix are internal static functions but declared here for testing */
36 void _initialize_cache();
37 unsigned char *_get_app_dek_from_cache(const char *pkgId);
38 void _add_app_dek_to_cache(const char *pkgId, unsigned char *dek);
39 void _remove_app_dek_from_cache(const char *pkgId);
40 int _get_random(size_t length, unsigned char *random);
41 void _get_alias(const char *pPkgId, wae_app_type_e appType, bool forSave, char *alias, size_t buff_len);
42 void _get_dek_kek_alias(char *alias, size_t buff_len);
43 void _get_dek_loading_done_alias(char *alias, size_t buff_len);
44 const char *_get_dek_kek_pub_key_path();
45 const char *_get_dek_kek_pri_key_path();
46 const char *_get_dek_store_path();
47 int _add_dek_to_key_manager(const char *pPkgId, wae_app_type_e appType, const unsigned char *pDek, size_t len);
48 int _get_preloaded_app_dek_file_path(const char *pPkgId, size_t size, char *path);
49 int _extract_pkg_id_from_file_name(const char *fileName, char *pkgId);
50 int _read_encrypted_app_dek_from_file(const char *pPkgId, unsigned char **encrypted_app_dek, size_t *len);
51 int _write_encrypted_app_dek_to_file(const char *pPkgId, const unsigned char *encrypted_app_dek, size_t len);
52 int _read_from_file(const char *path, unsigned char **data, size_t *len);
53 int _write_to_file(const char *path, const unsigned char *data, size_t len);
54 int _get_app_deks_loaded();
55 int _set_app_deks_loaded();
56 int _clear_app_deks_loaded();
57
58 /* functions for interface */
59 int get_app_dek(const char *pPkgId, wae_app_type_e appType, unsigned char **ppDek, size_t *dekLen);
60 int create_app_dek(const char *pPkgId, wae_app_type_e appType, unsigned char **ppDek, size_t *dekLen);
61 int get_preloaded_app_dek(const char *pPkgId, unsigned char **ppDek, size_t *dekLen);
62 int create_preloaded_app_dek(const char *pPkgId, unsigned char **ppDek, size_t *dekLen);
63 int load_preloaded_app_deks(bool reload);
64 int remove_app_dek(const char *pPkgId, wae_app_type_e appType);
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif /* __WAE_KEY_HANDLER_H */