[API changed] Add uid parameter
[platform/core/security/libwebappenc.git] / srcs / types.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        types.h
18  * @author      Kyungwook Tak (k.tak@samsung.com)
19  * @version     1.0
20  * @brief       Type definitions
21  */
22 #ifndef __WAE_TYPES_H
23 #define __WAE_TYPES_H
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 #include <stdbool.h>
30 #include <stddef.h>
31
32 #define API    __attribute__ ((visibility("default")))
33 #define UNUSED __attribute__ ((unused))
34
35 typedef enum {
36         WAE_DOWNLOADED_NORMAL_APP = 0,
37         WAE_DOWNLOADED_GLOBAL_APP = 1,
38         WAE_PRELOADED_APP         = 2
39 } wae_app_type_e;
40
41 typedef struct _raw_buffer_s {
42         unsigned char *buf;
43         size_t size;
44 } raw_buffer_s;
45
46 typedef struct _crypto_element_s {
47         raw_buffer_s *dek;
48         raw_buffer_s *iv;
49         bool is_migrated_app;
50 } crypto_element_s;
51
52 typedef struct _crypto_element_map_s crypto_element_map_s;
53
54 raw_buffer_s *buffer_create(size_t size);
55 raw_buffer_s *buffer_create_managed(unsigned char *buf, size_t size);
56 void buffer_destroy(raw_buffer_s *);
57 bool is_buffer_valid(const raw_buffer_s *);
58
59 crypto_element_s *crypto_element_create(raw_buffer_s *dek, raw_buffer_s *iv);
60 void crypto_element_destroy(crypto_element_s *c);
61 bool is_crypto_element_valid(const crypto_element_s *);
62
63 extern const size_t MAX_MAP_ELEMENT_SIZE;
64
65 void crypto_element_map_destroy(crypto_element_map_s *);
66 int crypto_element_map_add(crypto_element_map_s **map, const char *key, crypto_element_s *value);
67 void crypto_element_map_remove(crypto_element_map_s **map, const char *key);
68 crypto_element_s *crypto_element_map_get(crypto_element_map_s *map, const char *key);
69
70 #ifdef __cplusplus
71 }
72 #endif
73
74 #endif /* __WAE_TYPES_H */