Add data structures
[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
32 #include "web_app_enc.h"
33 #include "types.h"
34
35 #define MAX_PATH_LEN  512
36
37 /* functions with "_" prefix are internal static functions but declared here for testing */
38 void _remove_app_ce_from_cache(const char *pkg_id);
39 int _get_random(raw_buffer_s *rb);
40 int _get_preloaded_app_dek_file_path(const char *pkg_id, size_t size, char *path);
41 int _read_encrypted_app_dek_from_file(const char *pkg_id, raw_buffer_s **pencrypted);
42 int _write_encrypted_app_dek_to_file(const char *pkg_id, const raw_buffer_s *encrypted);
43
44 /* functions for interface */
45 int get_app_ce(const char *pkg_id, wae_app_type_e app_type, bool create_for_migrated_app,
46                            const crypto_element_s **pce);
47 int create_app_ce(const char *pkg_id, wae_app_type_e app_type,
48                                   const crypto_element_s **pce);
49 int get_preloaded_app_ce(const char *pkg_id, const crypto_element_s **pce);
50 int create_preloaded_app_ce(const char *pkg_id, const crypto_element_s **pce);
51 int load_preloaded_app_deks(bool reload);
52 int remove_app_ce(const char *pkg_id, wae_app_type_e app_type);
53
54 #ifdef __cplusplus
55 }
56 #endif
57
58 #endif /* __WAE_KEY_HANDLER_H */