Calm down warnings & errors for ARM build 91/206491/2 accepted/tizen/unified/20190602.221900 submit/tizen/20190522.051353 submit/tizen/20190529.045654
authorTomasz Swierczek <t.swierczek@samsung.com>
Mon, 20 May 2019 11:56:14 +0000 (13:56 +0200)
committerTomasz Swierczek <t.swierczek@samsung.com>
Tue, 21 May 2019 10:51:06 +0000 (12:51 +0200)
* make logs compile fully only in debug mode
* make logs use our own BUILD_TYPE_DEBUG definition
* remove not used OpenSSL header
* initialize possibly uninitialize pointer to calm down overreacting gcc
* change AES_BLOCK_SIZE to extern

Change-Id: Ide148262c2426931be08276671e625f9c043f78a

CMakeLists.txt
packaging/key-manager-ta.spec
ta/include/internal.h
ta/include/log.h
ta/src/internal.c
ta/src/km_ta.c
ta/src/log.c

index 46cefce23149713a4f5ada6d931c91d426cf0234..eafbd215749b78e997430ef677b019685a8df94a 100644 (file)
@@ -1,4 +1,4 @@
-# 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.
@@ -26,6 +26,11 @@ 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)
 
+IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
+    ADD_DEFINITIONS("-DBUILD_TYPE_DEBUG")
+ENDIF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
+
+
 INCLUDE_DIRECTORIES(
     ${KEY_MANAGER_TA_PATH}/include
     ${KEY_MANAGER_TA_SERIALIZATION_PATH}/include
index af7011fd57f14b92c9fc6e958e6613ddec487ea1..17320cdcc4cbafc8be4eaf39f549dc76b102d436 100644 (file)
@@ -38,7 +38,6 @@ Provides:   %{name}
 
 BuildRequires: cmake
 BuildRequires: unified-ta-devkit
-BuildRequires: openssl
 
 %description
 Key Manager Trusted Application working in the ARMĀ® TrustZoneĀ® environment.
index 2863866b62ca9c04ec32d98edc2a885b003fedf4..e1d8757baf4ebb3e8a2b2643fc467e9292344f97 100644 (file)
@@ -32,7 +32,7 @@
 
 #define S_VAR_NOT_USED(variable) (void)(variable);
 
-const uint32_t AES_BLOCK_SIZE;
+extern const uint32_t AES_BLOCK_SIZE;
 
 int KM_CheckAuthAESMode(uint32_t algo, uint32_t tagLen);
 
index 84a6b85b3233dabfa003570ed6465c13007c8a3c..fe61920fb46073cfc5783df325aa2b0be3800d60 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  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.
@@ -33,7 +33,7 @@ __attribute__((format(printf, 5, 6)));
        log_msg(" MSG ", __FILE__, __LINE__, __func__, __VA_ARGS__); \
 } while(0)
 
-#ifdef DEBUG
+#ifdef BUILD_TYPE_DEBUG
 #define LOGD(...) do { \
        log_msg("DEBUG", __FILE__, __LINE__, __func__, __VA_ARGS__); \
 } while(0)
index 740ff889163dc961df67d9057b1a6f249a346d38..37f84d2f67bd73d27f1fc8584de4bf8290778aa2 100644 (file)
@@ -511,6 +511,8 @@ static TEE_Result KM_DecryptAsymKeyData(const KM_KeyId *id,
        KM_BinaryData keyBuf, tmpDecKeyBuf;
        uint32_t read;
 
+       tmpDecKeyBuf.data = NULL;
+
        // Read encrypted key from persistent storage
        ret = TEE_OpenPersistentObject(TEE_STORAGE_PRIVATE, id->data, id->data_size,
                                                                TEE_DATA_FLAG_ACCESS_READ, &hndl);
index 82d75e2d999eb131336c9a770c51815032b0083a..39a612362a5a531bc115871edac464874e29984b 100644 (file)
@@ -25,7 +25,6 @@
 #include <cmd_exec.h>
 #include <log.h>
 #include <internal.h>
-#include <openssl/evp.h>
 
 TEE_Result TA_CreateEntryPoint(void)
 {
index 019da5cd8182f8132f4759d06a38d9919a4b2e7e..11d0d3cf7ce3b9771ebd3f203204d172757fa618 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  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.
@@ -28,6 +28,7 @@
 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];
@@ -38,4 +39,14 @@ void log_msg(const char* type, const char* location, int line, const char* func,
 
        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
 }