fe86f86487e9c80f7d1fca6adb34403c98ed5a4e
[platform/core/security/ode.git] / server / engine / ecryptfs-engine.h
1 /*
2  *  Copyright (c) 2015 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 #ifndef __ECRYPTFS_ENGINE_H__
18 #define __ECRYPTFS_ENGINE_H__
19
20 #include <vector>
21 #include <string>
22 #include <sys/mount.h>
23 #include <sys/syscall.h>
24 #include <sys/vfs.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <sys/ioctl.h>
28 #include <fcntl.h>
29 #include <unistd.h>
30 #include <utime.h>
31
32 #include "../progress-bar.h"
33
34 namespace ode {
35
36 class EcryptfsEngine final {
37 public:
38         EcryptfsEngine(const std::string& src, const std::string& dest, const ProgressBar& prgs);
39         EcryptfsEngine(const EcryptfsEngine&) = delete;
40         EcryptfsEngine(EcryptfsEngine&&) = delete;
41         ~EcryptfsEngine();
42
43         EcryptfsEngine& operator=(const EcryptfsEngine&) = delete;
44         EcryptfsEngine& operator=(EcryptfsEngine&&) = delete;
45
46         const std::string& getSource()
47         {
48                 return source;
49         }
50
51         const std::string& getDestination()
52         {
53                 return destination;
54         }
55
56         typedef std::vector<unsigned char> data;
57
58         void mount(const data& key, unsigned int);
59         void umount();
60
61         void encrypt(const data& key, unsigned int);
62         void decrypt(const data& key, unsigned int);
63
64         bool isKeyMetaSet();
65         const data getKeyMeta();
66         void setKeyMeta(const data &data);
67         void clearKeyMeta();
68
69         unsigned int getSupportedOptions();
70
71 private:
72         std::string source, destination;
73         ProgressBar progress;
74 };
75
76 } // namespace ode
77 #endif // __ECRYPTFS_ENGINE_H__
78