summaryrefslogtreecommitdiff
path: root/srcs/types.h
blob: 51ed9fcb2def41099b9753d56c5c6218ef7e4b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License
 *
 *
 * @file        types.h
 * @author      Kyungwook Tak (k.tak@samsung.com)
 * @version     1.0
 * @brief       Type definitions
 */
#ifndef __WAE_TYPES_H
#define __WAE_TYPES_H

#ifdef __cplusplus
extern "C" {
#endif

#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;
} raw_buffer_s;

typedef struct _crypto_element_s {
	raw_buffer_s *dek;
	raw_buffer_s *iv;
	bool is_migrated_app;
} crypto_element_s;

typedef struct _crypto_element_map_s crypto_element_map_s;

raw_buffer_s *buffer_create(size_t size);
raw_buffer_s *buffer_create_managed(unsigned char *buf, size_t size);
void buffer_destroy(raw_buffer_s *);
bool is_buffer_valid(const raw_buffer_s *);

crypto_element_s *crypto_element_create(raw_buffer_s *dek, raw_buffer_s *iv);
void crypto_element_destroy(crypto_element_s *c);
bool is_crypto_element_valid(const crypto_element_s *);

extern const size_t MAX_MAP_ELEMENT_SIZE;

void crypto_element_map_destroy(crypto_element_map_s *);
int crypto_element_map_add(crypto_element_map_s **map, const char *key, crypto_element_s *value);
void crypto_element_map_remove(crypto_element_map_s **map, const char *key);
crypto_element_s *crypto_element_map_get(crypto_element_map_s *map, const char *key);

#ifdef __cplusplus
}
#endif

#endif /* __WAE_TYPES_H */