b8fee34e651ba971c020e64c3e4006d9fffa9f1e
[framework/osp/security-service.git] / inc / TrustZoneService.h
1 //
2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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                TrustZoneService.h
19  * @brief               This is the header file of the TrustZone Service.
20  */
21
22 #ifndef _TRUST_ZONE_SERVICE_H_
23 #define _TRUST_ZONE_SERVICE_H_
24
25 #include <FIo_IIpcServerEventListener.h>
26 #include <FIo_IpcCommonDataTypes.h>
27
28 namespace Tizen { namespace Io
29 {
30         //class _IpcServer;
31         //class _IpcBuffer;
32 }}
33
34 namespace IPC
35 {
36         class Message;
37 }
38
39 namespace Tizen { namespace Base
40 {
41         class String;
42 }}
43
44 class _OSP_EXPORT_ TrustZoneService
45         : public Tizen::Io::_IIpcServerEventListener
46 {
47
48 public:
49         TrustZoneService(void);
50         ~TrustZoneService(void);
51         result Construct(void);
52
53 public:
54
55         virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server);
56         virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server);
57         virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId);
58         virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer& server, int clientId);
59         virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message);
60
61         bool OnEncrypt(const Tizen::Base::ByteBuffer& appInfo, const Tizen::Base::ByteBuffer& plainBuffer, Tizen::Io::_IpcBuffer* encryptedBuffer, result* pRes);
62         bool OnDecrypt(const Tizen::Base::ByteBuffer& appInfo, const Tizen::Base::ByteBuffer& encryptedBuffer, Tizen::Io::_IpcBuffer* plainBuffer, result* pRes);
63         result Encrypt(const Tizen::Base::ByteBuffer& appInfo, const Tizen::Base::ByteBuffer& plainBuffer, byte** pBuffer, int& pBufferSize);
64         result Decrypt(const Tizen::Base::ByteBuffer& appInfo, const Tizen::Base::ByteBuffer& encryptedBuffer, byte** pBuffer, int& pBufferSize);
65
66 private:
67         int SetPadding(const byte* pData, int dataLen, byte** ppOutData, int* outLen);
68 private:
69         Tizen::Io::_IpcServer* __pIpcServer;
70 }; // TrustZoneService
71
72 #endif // _TRUST_ZONE_SERVICE_H_