2 * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @author CHERYL (cb) (cheryl.b@samsung.com)
20 * @brief TABinaryManager header file
24 #ifndef TABINARYMANAGER_H_
25 #define TABINARYMANAGER_H_
27 /*-----------------------------------------------------------------------------
29 *-----------------------------------------------------------------------------*/
37 #include "OsaLinuxUser.h"
38 #include "tee_client_api.h"
39 #include "TAManifest.h"
41 #include "tee_internal_api.h"
45 /*-----------------------------------------------------------------------------
47 *-----------------------------------------------------------------------------*/
57 /*-----------------------------------------------------------------------------
59 *-----------------------------------------------------------------------------*/
60 class TABinaryManager {
62 static TABinaryManager *instance;
63 std::string base64_chars;
64 // map < string uuid, StructBinaryInfo>
65 map<string, StructBinaryInfo> binaryMap;
67 bool unpackBinary(const string &uuid, StructBinaryInfo& info);
69 std::string IntToHex(T i, int width = sizeof(T) * 2) {
70 std::stringstream stream;
71 stream << std::setfill('0') << std::setw(width) << std::hex << i;
74 void decryptImage(StructBinaryInfo& info);
75 string base64_decode(std::string const& encoded_string);
76 bool is_base64(unsigned char c);
79 * Gets pointer to singleton instance of TABinaryManager.
80 * Perform lazy creation of TABinaryManager. During lazy init,
81 * it also performs init of TABinaryManager where if UUID list XML is
82 * not readable then getInstance fails.
83 * @return Pointer to instance on successful initialization.
84 * Else null pointer on error
86 pthread_mutex_t taLock;
87 static TABinaryManager* getInstance();
88 bool initTA (const string &uuid);
91 * Query functions on Binary Manager
93 int isSingleInstance(string uuid, bool &SingleInstance);
94 int isMultipleSession(string uuid, bool &MultipleSession);
95 string getImagePath(string uuid);
96 const TAManifest* getManifest(string uuid);
97 string getUUIDAsString(TEEC_UUID uuid);
98 string getPort(string uuid);
99 int isKeepAlive(string uuid, bool &KeepAlive);
101 virtual ~TABinaryManager();
104 #endif /* TABINARYMANAGER_H_ */