SET(KEY_MANAGER_TA_ROOT_PATH ${PROJECT_SOURCE_DIR})
SET(KEY_MANAGER_TA_PATH ${KEY_MANAGER_TA_ROOT_PATH}/ta)
SET(KEY_MANAGER_TA_SERIALIZATION_PATH ${KEY_MANAGER_TA_ROOT_PATH}/serialization)
+SET(KEY_MANAGER_TA_COMMON_PATH ${KEY_MANAGER_TA_ROOT_PATH}/common)
IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
INCLUDE_DIRECTORIES(
${KEY_MANAGER_TA_PATH}/include
${KEY_MANAGER_TA_SERIALIZATION_PATH}/include
+ ${KEY_MANAGER_TA_COMMON_PATH}/include
)
ADD_DEFINITIONS("-D${CMAKE_BUILD_TYPE}")
--- /dev/null
+/*
+ * Copyright (c) 2017 - 2019 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 log.h
+ * @author Rafał Tyminski (r.tyminski@partner.samsung.com)
+ * @version 1.0
+ * @brief
+ */
+#ifndef __LOG_H__
+#define __LOG_H__
+
+#include <stdio.h>
+#include <string.h>
+
+void log_msg(const char* type, const char* location, int line, const char* func,
+ const char* format, ...)
+__attribute__((format(printf, 5, 6)));
+
+#define LOG(...) do { \
+ log_msg(" MSG ", __FILE__, __LINE__, __func__, __VA_ARGS__); \
+} while(0)
+
+#ifdef BUILD_TYPE_DEBUG
+#define LOGD(...) do { \
+ log_msg("DEBUG", __FILE__, __LINE__, __func__, __VA_ARGS__); \
+} while(0)
+#else
+#define LOGD(...) do { } while(0)
+#endif
+
+void log_id(const char* prefix, void* id, unsigned int size);
+
+#ifdef BUILD_TYPE_DEBUG
+#define LOGD_ID(prefix, id, size) do {\
+ log_id(prefix, id, size);\
+} while(0)
+#else
+#define LOGD_ID(...) do {} while(0)
+#endif
+
+#endif // __LOG_H__
--- /dev/null
+/*
+ * Copyright (c) 2017 - 2019 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 log.c
+ * @author Lukasz Kostyra (l.kostyra@samsung.com)
+ * @version 1.0
+ * @brief
+ */
+
+#include "log.h"
+#include <malloc.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+void log_msg(const char* type, const char* location, int line, const char* func,
+ const char* format, ...)
+{
+#ifdef BUILD_TYPE_DEBUG
+ va_list args;
+ const size_t logSize = 512; // increase this limit as needed
+ char logBuffer[logSize];
+
+ va_start(args, format);
+ vsnprintf(logBuffer, logSize, format, args);
+ va_end(args);
+
+ printf("[%s] %s @ %i (%s): %s \n\r", type, location, line, func, logBuffer);
+ fflush(stdout);
+#else
+// TODO actually code below is a mitigation for ARM compilation on OpTEE
+// TODO this entire ifdef should probably be replaced for TEE-OS specific logging
+// TODO but this should be done in separate commit
+ (void) type;
+ (void) location;
+ (void) line;
+ (void) func;
+ (void) format;
+#endif
+}
+
+void log_id(const char* prefix, void* id, unsigned int size) {
+#ifdef BUILD_TYPE_DEBUG
+ char* out = (char*)malloc(sizeof(char) * (size * 2 + 1));
+ for (unsigned int i = 0; i < size; i++)
+ snprintf(out + i*2, 3, "%02x", ((unsigned char*)id)[i]);
+ LOGD("%s%s", prefix, out);
+ free(out);
+#else
+// TODO actually code below is a mitigation for ARM compilation on OpTEE
+// TODO this entire ifdef should probably be replaced for TEE-OS specific logging
+// TODO but this should be done in separate commit
+ (void) prefix;
+ (void) id;
+ (void) size;
+#endif
+}
-# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2017 - 2019 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.
SET(KEY_MANAGER_TA_SERIALIZATION_SOURCES
${KEY_MANAGER_TA_SERIALIZATION_PATH}/src/km_serialization.c
- ${KEY_MANAGER_TA_PATH}/src/log.c
+ ${KEY_MANAGER_TA_COMMON_PATH}/src/log.c
)
SET(KEY_MANAGER_TA_SERIALIZATION_HEADERS
-# Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2017 - 2019 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.
${KEY_MANAGER_TA_PATH}/src/crypto_padding.c
${KEY_MANAGER_TA_PATH}/src/crypto_symmetric.c
${KEY_MANAGER_TA_PATH}/src/internal.c
- ${KEY_MANAGER_TA_PATH}/src/log.c
${KEY_MANAGER_TA_PATH}/src/km_ta.c
${KEY_MANAGER_TA_PATH}/src/base64.c
+ ${KEY_MANAGER_TA_COMMON_PATH}/src/log.c
${KEY_MANAGER_TA_SERIALIZATION_PATH}/src/km_serialization.c
)
+++ /dev/null
-/*
- * Copyright (c) 2017 - 2019 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 log.h
- * @author Rafał Tyminski (r.tyminski@partner.samsung.com)
- * @version 1.0
- * @brief
- */
-#ifndef __LOG_H__
-#define __LOG_H__
-
-#include <stdio.h>
-#include <string.h>
-
-void log_msg(const char* type, const char* location, int line, const char* func,
- const char* format, ...)
-__attribute__((format(printf, 5, 6)));
-
-#define LOG(...) do { \
- log_msg(" MSG ", __FILE__, __LINE__, __func__, __VA_ARGS__); \
-} while(0)
-
-#ifdef BUILD_TYPE_DEBUG
-#define LOGD(...) do { \
- log_msg("DEBUG", __FILE__, __LINE__, __func__, __VA_ARGS__); \
-} while(0)
-#else
-#define LOGD(...) do { } while(0)
-#endif
-
-void log_id(const char* prefix, void* id, unsigned int size);
-
-#ifdef BUILD_TYPE_DEBUG
-#define LOGD_ID(prefix, id, size) do {\
- log_id(prefix, id, size);\
-} while(0)
-#else
-#define LOGD_ID(...) do {} while(0)
-#endif
-
-#endif // __LOG_H__
+++ /dev/null
-/*
- * Copyright (c) 2017 - 2019 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 log.c
- * @author Lukasz Kostyra (l.kostyra@samsung.com)
- * @version 1.0
- * @brief
- */
-
-#include "log.h"
-#include <malloc.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-void log_msg(const char* type, const char* location, int line, const char* func,
- const char* format, ...)
-{
-#ifdef BUILD_TYPE_DEBUG
- va_list args;
- const size_t logSize = 512; // increase this limit as needed
- char logBuffer[logSize];
-
- va_start(args, format);
- vsnprintf(logBuffer, logSize, format, args);
- va_end(args);
-
- printf("[%s] %s @ %i (%s): %s \n\r", type, location, line, func, logBuffer);
- fflush(stdout);
-#else
-// TODO actually code below is a mitigation for ARM compilation on OpTEE
-// TODO this entire ifdef should probably be replaced for TEE-OS specific logging
-// TODO but this should be done in separate commit
- (void) type;
- (void) location;
- (void) line;
- (void) func;
- (void) format;
-#endif
-}
-
-void log_id(const char* prefix, void* id, unsigned int size) {
-#ifdef BUILD_TYPE_DEBUG
- char* out = (char*)malloc(sizeof(char) * (size * 2 + 1));
- for (unsigned int i = 0; i < size; i++)
- snprintf(out + i*2, 3, "%02x", ((unsigned char*)id)[i]);
- LOGD("%s%s", prefix, out);
- free(out);
-#else
-// TODO actually code below is a mitigation for ARM compilation on OpTEE
-// TODO this entire ifdef should probably be replaced for TEE-OS specific logging
-// TODO but this should be done in separate commit
- (void) prefix;
- (void) id;
- (void) size;
-#endif
-}