Revert "Revert "Add CryptsetupEngine"" 84/142584/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 4 Aug 2017 10:40:08 +0000 (12:40 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 4 Aug 2017 10:41:35 +0000 (12:41 +0200)
This reverts commit 842d4ed10985953d402ff43e55fe2798656edd18.

Change-Id: I91c6798133fe772a88e65f15efda7e6806502c4f

packaging/ode.spec
server/CMakeLists.txt
server/engine/encryption/cryptsetup-engine.h [new file with mode: 0644]

index 75181d7..fe3f58f 100755 (executable)
@@ -19,6 +19,7 @@ BuildRequires: pkgconfig(key-manager)
 BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(cynara-session)
 BuildRequires: pkgconfig(openssl)
+BuildRequires: pkgconfig(libcryptsetup)
 
 %description
 The ode package provides a daemon which is responsible for encrypting/decryption storages and secure erasing.
index 4b781c2..7c0ee26 100644 (file)
@@ -29,6 +29,7 @@ SET(SERVER_SRCS       main.cpp
                                engine/encryption/ext4-engine.cpp
                                engine/encryption/dmcrypt-engine.cpp
                                engine/encryption/ecryptfs-engine.cpp
+                               engine/encryption/cryptsetup-engine.cpp
                                engine/erase/mmc-engine.cpp
                                key-manager/key-store.cpp
                                key-manager/key-manager.cpp
@@ -45,6 +46,7 @@ SET(DEPENDENCY        klay
                                cynara-client
                                cynara-session
                                openssl
+                               libcryptsetup
 )
 
 SET(SERVER_NAME ${PROJECT_NAME}d)
diff --git a/server/engine/encryption/cryptsetup-engine.h b/server/engine/encryption/cryptsetup-engine.h
new file mode 100644 (file)
index 0000000..55c4658
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ *  Copyright (c) 2017 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.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+#ifndef __CRYPTSETUP_ENGINE_H__
+#define __CRYPTSETUP_ENGINE_H__
+
+#include <string>
+#include <vector>
+
+namespace ode {
+
+class CryptsetupEngine final {
+public:
+       enum class DeviceType {
+               PLAIN,
+               LUKS,
+       };
+
+       CryptsetupEngine(const std::string &devicePath);
+       CryptsetupEngine(const CryptsetupEngine &) = delete;
+       CryptsetupEngine(CryptsetupEngine &&) = delete;
+       ~CryptsetupEngine();
+
+       CryptsetupEngine &operator=(const CryptsetupEngine &) = delete;
+       CryptsetupEngine &operator=(CryptsetupEngine &&) = delete;
+
+       // TODO make it common among engines
+       typedef std::vector<unsigned char> data;
+
+       void format(DeviceType type, const data &key);
+
+       // create new mapping, returns mapping path
+       std::string open(DeviceType type, const std::string &name, const data &key);
+
+       static void close(const std::string &name);
+
+       bool isKeyMetaSet();
+       const data getKeyMeta();
+       void setKeyMeta(const data &data);
+       void clearKeyMeta();
+
+private:
+       std::string devPath;
+};
+
+} // namespace ode
+#endif // __CRYPTSETUP_ENGINE_H__