2 * Copyright (c) 2016 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
17 #ifndef __DMCRYPT_ENGINE_H__
18 #define __DMCRYPT_ENGINE_H__
23 #include "progress-bar.h"
29 void init(const std::string &src, const std::string &crypto_name);
30 long getFileSystemSize();
31 std::string getCryptoTypeName() const;
34 long getBlkdevSize(const std::string &src);
37 // TODO(seok85.hong): support fast-encryption
39 std::string crypto_type_name;
43 class DMCryptEngine final {
45 DMCryptEngine(const std::string &src, const std::string &dest, const ProgressBar &prgsBar);
46 DMCryptEngine(const DMCryptEngine &) = delete;
47 DMCryptEngine(DMCryptEngine &&) = delete;
50 DMCryptEngine &operator=(const DMCryptEngine &) = delete;
51 DMCryptEngine &operator=(DMCryptEngine &&) = delete;
53 const std::string &getSource()
58 const std::string &getDestination()
63 typedef std::vector<unsigned char> data;
65 void mount(const data &key, unsigned int options);
68 void encrypt(const data &key, unsigned int options);
69 void decrypt(const data &key, unsigned int options);
71 const data getKeyMeta();
72 void setKeyMeta(const data &data);
74 unsigned int getSupportedOptions();
77 void encryptInPlace(const std::string &dst_blkdev,
78 const std::string &src_blkdev,
79 const long src_blkdev_size);
82 std::string source, destination;
84 ProgressBar progressBar;
88 #endif // __DMCRYPT_ENGINE_H__