Remove dead code related to downloadable TA
[platform/core/security/tef-simulator.git] / simulatordaemon / src / TABinaryManager / TABinaryManager.h
1 /**
2  * Copyright (c) 2015-2017 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file
19  * @author CHERYL (cb) (cheryl.b@samsung.com)
20  * @brief  TABinaryManager header file
21  */
22
23
24 #ifndef TABINARYMANAGER_H_
25 #define TABINARYMANAGER_H_
26
27 /*-----------------------------------------------------------------------------
28  *  Include files
29  *-----------------------------------------------------------------------------*/
30 #include <string>
31 #include <string.h>
32 #include <map>
33 #include <sstream>
34 #include <iomanip>
35 #include <fcntl.h>
36 #include "log.h"
37 #include "OsaLinuxUser.h"
38 #include "tee_client_api.h"
39 #include "TAManifest.h"
40 #include "TAUnpack.h"
41 #include "tee_internal_api.h"
42
43 using namespace std;
44
45 /*-----------------------------------------------------------------------------
46  *  Definitions
47  *-----------------------------------------------------------------------------*/
48 typedef struct {
49         string path;
50         string extractpath;
51         string imagePath;
52         string manifestPath;
53         TAManifest manifest;
54         string port;
55 } StructBinaryInfo;
56
57 /*-----------------------------------------------------------------------------
58  *  Class definitions
59  *-----------------------------------------------------------------------------*/
60 class TABinaryManager {
61 private:
62         static TABinaryManager *instance;
63         std::string base64_chars;
64         // map < string uuid, StructBinaryInfo>
65         map<string, StructBinaryInfo> binaryMap;
66         TABinaryManager();
67         bool unpackBinary(const string &uuid, StructBinaryInfo& info);
68         template<typename T>
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;
72                 return stream.str();
73         }
74         void decryptImage(StructBinaryInfo& info);
75         string base64_decode(std::string const& encoded_string);
76         bool is_base64(unsigned char c);
77 public:
78         /**
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
85          */
86         pthread_mutex_t taLock;
87         static TABinaryManager* getInstance();
88         bool initTA (const string &uuid);
89
90         /*
91          * Query functions on Binary Manager
92          */
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);
100
101         virtual ~TABinaryManager();
102 };
103
104 #endif /* TABINARYMANAGER_H_ */