summaryrefslogtreecommitdiff
path: root/srcs/types.h
diff options
context:
space:
mode:
authorKyungwook Tak <k.tak@samsung.com>2016-07-21 16:46:00 +0900
committerKyungwook Tak <k.tak@samsung.com>2016-07-26 15:51:15 +0900
commitd6da3e3d9bc29e22103b094bee5ca68f5d8f0f61 (patch)
tree6439a58283180d86c72f4c30413d55be728f6dd4 /srcs/types.h
parent6818b8559b7d4d45adaeb1937d708a154dc00fd7 (diff)
downloadlibwebappenc-d6da3e3d9bc29e22103b094bee5ca68f5d8f0f61.tar.gz
libwebappenc-d6da3e3d9bc29e22103b094bee5ca68f5d8f0f61.tar.bz2
libwebappenc-d6da3e3d9bc29e22103b094bee5ca68f5d8f0f61.zip
Add data structures
For migrated web app, we need to more fields in cache e.g., IV and is_migrated flag to handle it separately. Because cipher algorithm, iv and key size could be different between old secure storage, it depends on product implementation. So this architecture needs more flexibility. A lot of code changed because of the principle data structure is added from the bottom. Change-Id: Id6a10b9f707f4da25016dd928ab4049be619a610 Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
Diffstat (limited to 'srcs/types.h')
-rw-r--r--srcs/types.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/srcs/types.h b/srcs/types.h
new file mode 100644
index 0000000..7e27aeb
--- /dev/null
+++ b/srcs/types.h
@@ -0,0 +1,65 @@
+/*
+ * 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>
+
+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 */