* See the License for the specific language governing permissions and
* limitations under the License
*/
+#include <iomanip>
+
#include <linux/dm-ioctl.h>
#include <sys/mount.h>
#include <unistd.h>
#include "dmcrypt-engine.h"
-#define OPTION_INCLUDE_UNUSED_REGION (1 << 0)
+#define DM_MAX_BUFFER_SIZE 4096
+#define DM_KEY_MIN_LEN_BYTE 32
+#define DM_DEFAULT_LABEL_NAME "userdata"
+#define DM_DEFAULT_CRYPTO_NAME "aes-cbc-essiv:sha256"
-namespace ode {
+#define OPTION_INCLUDE_UNUSED_REGION (1 << 0)
-void CryptInfo::init(const std::string &src, const std::string &crypto_name)
-{
- crypto_type_name = crypto_name;
- fs_size = getBlkdevSize(src);
-}
+using namespace std::placeholders;
-long CryptInfo::getFileSystemSize()
-{
- return fs_size;
-}
+namespace ode {
-std::string CryptInfo::getCryptoTypeName() const
-{
- return crypto_type_name;
-}
+namespace {
-long CryptInfo::getBlkdevSize(const std::string &src)
+size_t getFileSystemSize(const std::string &src)
{
int fd = open(src.c_str(), O_RDONLY);
if (fd < 0)
return 0;
- long fs_size = 0;
- if ((ioctl(fd, BLKGETSIZE, &fs_size)) == -1)
- fs_size = 0;
+ size_t size = 0;
+ if ((ioctl(fd, BLKGETSIZE, &size)) == -1)
+ size = 0;
close(fd);
- return fs_size;
+ return size;
}
-
-static void convertKeyToHexASCII(const DMCryptEngine::data &key,
- DMCryptEngine::data &key_ascii)
+const std::string convertToHex(const DMCryptEngine::data &binary)
{
- unsigned int i, a;
- unsigned char nibble;
-
- for (i = 0, a = 0; i < key.size(); i++, a += 2) {
- // For each byte, write out two ascii hex digits
- nibble = (key[i] >> 4) & 0xf;
- key_ascii[a] = nibble + (nibble > 9 ? 0x37 : 0x30);
+ std::stringstream hex;
- nibble = key[i] & 0xf;
- key_ascii[a + 1] = nibble + (nibble > 9 ? 0x37 : 0x30);
+ hex << std::hex << std::setfill('0');
+ for (unsigned int byte : binary) {
+ hex << std::setw(2) << byte;
}
-
- // Add the null termination
- key_ascii[a] = '\0';
-}
-
-DMCryptEngine::DMCryptEngine(const std::string &src, const std::string &dest, const ProgressBar &prgsBar) :
- source(src), destination(dest), progressBar(prgsBar)
-{
- // 1. Get Real Block device(src)'s infomation
- cryptInfo.init(src, "aes-cbc-essiv:sha256");
+ return hex.str();
}
-DMCryptEngine::~DMCryptEngine()
+void initDMIoctl(char *buf, size_t size, const std::string &name, unsigned flags)
{
-}
+ struct dm_ioctl *io = (struct dm_ioctl *)buf;
-static void ioctlInit(struct dm_ioctl *io, size_t dataSize, const char *name, unsigned flags)
-{
- memset(io, 0, dataSize);
- io->data_size = dataSize;
+ ::memset(io, 0, size);
+ io->data_size = size;
io->data_start = sizeof(struct dm_ioctl);
io->version[0] = 4;
io->version[1] = 0;
io->version[2] = 0;
io->flags = flags;
- if (name) {
- memset(io->name, 0, sizeof(io->name));
- strncpy(io->name, name, sizeof(io->name) - 1);
- }
+ ::memset(io->name, 0, sizeof(io->name));
+ ::strncpy(io->name, name.c_str(), sizeof(io->name) - 1);
}
-#define DM_CRYPT_BUF_SIZE 4096
-#define DM_LABEL "userdata"
-
-static const std::string createCryptoBlkDev(const std::string &real_blkdev, const std::string &mount_name, const DMCryptEngine::data &key, long fileSystemSize, std::string cryptoTypeName)
+const std::string createCryptoBlkDev(const std::string &realBlkDev, const std::string &mountName, const DMCryptEngine::data &key, std::string cryptoTypeName)
{
+ size_t fileSystemSize = getFileSystemSize(realBlkDev);
+ std::string cryptoBlkDev;
int fd = -1;
- std::string crypto_blkdev;
- ode::DMCryptEngine::data key_ascii(512);
-
/*
- * dm_buffer |-------------------------------------------------| 4096
- * dm_io |----------| size of dm_ioctl
- * dm_ts |--------------| size of dm_Target_spec
- * crypt_params |---------------------|
+ * dmBuf |-------------------------------------------------| DM_MAX_BUFFER_SIZE(4096)
*/
- char dm_buffer[DM_CRYPT_BUF_SIZE]; // first: for dm_io, dm_ts
- struct dm_ioctl *dm_io;
- struct dm_target_spec *dm_ts;
- unsigned int dm_minor;
-
- char *crypt_params; // protocol for dm-crypt
+ char dmBuf[DM_MAX_BUFFER_SIZE]; // first: for dm_io, dm_ts
// Open dm control IOCTL
- if ((fd = open("/dev/mapper/control", O_RDWR)) < 0)
+ if ((fd = open("/dev/mapper/control", O_RDWR)) < 0) {
throw runtime::Exception("Cannot open device-mapper");
+ }
/*
- * dm_buffer |-------------------------------------------------| 4096
- * dm_io |----------| size of dm_ioctl
+ * dmBuf |-------------------------------------------------| DM_MAX_BUFFER_SIZE(4096)
+ * dmIo |----------| size of dm_ioctl
*/
- dm_io = (struct dm_ioctl *)dm_buffer;
+ auto dmIo = (struct dm_ioctl *)dmBuf;
- // Clean-up dm_ioctl
// Create Device (mount_name)
- ioctlInit(dm_io, DM_CRYPT_BUF_SIZE, mount_name.c_str(), 0);
- if (ioctl(fd, DM_DEV_CREATE, dm_io)) {
+ initDMIoctl(dmBuf, DM_MAX_BUFFER_SIZE, mountName, 0);
+ if (ioctl(fd, DM_DEV_CREATE, dmBuf)) {
close(fd);
throw runtime::Exception("Cannot create dm-crypt device");
}
- // Clean-up dm_ioctl
// Get the device status, in particular, the mount_name of it's device file
- ioctlInit(dm_io, DM_CRYPT_BUF_SIZE, mount_name.c_str(), 0);
- if (ioctl(fd, DM_DEV_STATUS, dm_io)) {
+ initDMIoctl(dmBuf, DM_MAX_BUFFER_SIZE, mountName, 0);
+ if (ioctl(fd, DM_DEV_STATUS, dmBuf)) {
close(fd);
throw runtime::Exception("Cannot retrieve dm-crypt device status");
}
// Store created device into crypto_blkdev
- dm_minor = (dm_io->dev & 0xff) | ((dm_io->dev >> 12) & 0xfff00);
- crypto_blkdev = "/dev/dm-" + std::to_string(dm_minor);
-
- // Load the mapping table for this device
- dm_ts = (struct dm_target_spec *)&dm_buffer[sizeof(struct dm_ioctl)];
+ unsigned int dmMinor = (dmIo->dev & 0xff) | ((dmIo->dev >> 12) & 0xfff00);
+ cryptoBlkDev = "/dev/dm-" + std::to_string(dmMinor);
/*
- * dm_buffer |-------------------------------------------------| 4096
- * dm_io |----------| size of dm_ioctl
- * dm_ts |--------------| size of dm_Target_spec
+ * dmBuf |-------------------------------------------------| DM_MAX_BUFFER_SIZE(4096)
+ * dmIo |----------| size of dm_ioctl
+ * dmTs |--------------| size of dm_Target_spec
*/
+ auto dmTs = (struct dm_target_spec *)(dmBuf + sizeof(struct dm_ioctl));
+
+ // Load the mapping table for this device
// Force clean-up whole dm_buffer
- ioctlInit(dm_io, 4096, mount_name.c_str(), 0);
- dm_io->target_count = 1;
- dm_ts->status = 0;
- dm_ts->sector_start = 0;
- dm_ts->length = fileSystemSize;
- strcpy(dm_ts->target_type, "crypt");
-
- // Prepare crypt_params
+ initDMIoctl(dmBuf, DM_MAX_BUFFER_SIZE, mountName, 0);
+ dmIo->target_count = 1;
+ dmTs->status = 0;
+ dmTs->sector_start = 0;
+ dmTs->length = fileSystemSize;
+ ::memset(dmTs->target_type, 0, sizeof(dmTs->target_type));
+ ::strncpy(dmTs->target_type, "crypt", sizeof(dmTs->target_type) - 1);
+
/*
- * dm_buffer |-------------------------------------------------| 4096
- * dm_io |----------| size of dm_ioctl
- * dm_ts |--------------| size of dm_Target_spec
- * crypt_params |---------------------|
+ * dmBuf |-------------------------------------------------| DM_MAX_BUFFER_SIZE(4096)
+ * dmIo |----------| size of dm_ioctl
+ * dmTs |--------------| size of dm_Target_spec
+ * cryptParams |---------------------|
*/
+ char *cryptParams = dmBuf + sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec);
- crypt_params = dm_buffer + sizeof(struct dm_ioctl) + sizeof(struct dm_target_spec);
-
- ode::convertKeyToHexASCII(key, key_ascii);
+ // Store cryptParams
+ snprintf(cryptParams, DM_MAX_BUFFER_SIZE - (cryptParams - dmBuf), "%s %s 0 %s 0", cryptoTypeName.c_str(), convertToHex(key).c_str(), realBlkDev.c_str());
- // Store crypt_params
- sprintf(crypt_params, "%s %s 0 %s 0", cryptoTypeName.c_str(), key_ascii.data(), real_blkdev.c_str());
-
- crypt_params += strlen(crypt_params) + 1;
+ cryptParams += strlen(cryptParams) + 1;
// Align to an 8 byte boundary
- crypt_params = (char *)(((unsigned long)crypt_params + 7) & ~8);
- dm_ts->next = crypt_params - dm_buffer;
+ cryptParams = (char *)(((unsigned long)cryptParams + 7) & ~8);
+ dmTs->next = cryptParams - dmBuf;
// Table load
- if (ioctl(fd, DM_TABLE_LOAD, dm_io) < 0) {
+ if (ioctl(fd, DM_TABLE_LOAD, dmBuf) < 0) {
close(fd);
throw runtime::Exception("Cannot load dm-crypt mapping table.");
}
- // Force clean-up whole dm_buffer
// Resume this device to activate it
- ioctlInit(dm_io, 4096, mount_name.c_str(), 0);
- if (ioctl(fd, DM_DEV_SUSPEND, dm_io)) {
+ initDMIoctl(dmBuf, DM_MAX_BUFFER_SIZE, mountName, 0);
+ if (ioctl(fd, DM_DEV_SUSPEND, dmBuf)) {
close(fd);
throw runtime::Exception("Cannot resume the dm-crypt device");
}
- // If fd is <0 from a failed open call,
- // it's safe to just ignore the close error
- if (fd >= 0)
- close(fd);
+ close(fd);
- return crypto_blkdev;
+ return cryptoBlkDev;
}
-static void destroyCryptoBlkDev(const std::string &mount_name)
+void destroyCryptoBlkDev(const std::string &cryptoBlkDev)
{
- int fd;
- char buffer[DM_CRYPT_BUF_SIZE];
- struct dm_ioctl *io;
+ char buf[DM_MAX_BUFFER_SIZE];
+ int fd, ret;
if ((fd = open("/dev/mapper/control", O_RDWR)) < 0)
throw runtime::Exception("Cannot open device-mapper");
- io = (struct dm_ioctl *)buffer;
+ initDMIoctl(buf, sizeof(buf), cryptoBlkDev, 0);
+ ret = ioctl(fd, DM_DEV_REMOVE, buf);
+ close(fd);
- ioctlInit(io, DM_CRYPT_BUF_SIZE, mount_name.c_str(), 0);
- if (ioctl(fd, DM_DEV_REMOVE, io)) {
- close(fd);
+ if (ret != 0) {
throw runtime::Exception("Cannot remove dm-crypt device");
}
+}
- if (fd >= 0)
- close(fd);
+ode::DMCryptEngine::data sanitizeKey(const ode::DMCryptEngine::data &key)
+{
+ ode::DMCryptEngine::data sanitized(key);
+ sanitized.resize(DM_KEY_MIN_LEN_BYTE);
+ return sanitized;
+}
+
+void copyInPlace(const std::string &source, const std::string &destination,
+ const std::function<bool(unsigned int)> &isTarget,
+ const std::function<void(int, int)> &addProgress)
+{
+ Ext4Tool ext4tool(source);
+ const size_t srcBlockSize = ext4tool.getBlockSize();
+ const size_t srcTotalBlockCount = ext4tool.getTotalBlockCount();
+ char buf[srcBlockSize];
+
+ runtime::File src(source, O_RDONLY);
+ runtime::File dst(destination, O_WRONLY);
+
+ for (size_t n = 0, pos = 0; n < srcTotalBlockCount;
+ n++, pos += srcBlockSize) {
+ if (!isTarget(n)) {
+ continue;
+ }
+
+ src.lseek(pos, SEEK_SET);
+ dst.lseek(pos, SEEK_SET);
+
+ src.read(buf, srcBlockSize);
+ dst.write(buf, srcBlockSize);
+
+ addProgress(n, srcTotalBlockCount);
+ }
}
-#define DMCRYPT_KEY_MIN_LEN_BYTE (32)
-#define DMCRYPT_KEY_MIN_LEN_BIT (DMCRYPT_KEY_MIN_LEN_BYTE*8)
+} // namepsace
-static ode::DMCryptEngine::data sanitizeKey(const ode::DMCryptEngine::data &key)
+DMCryptEngine::DMCryptEngine(const std::string &src, const std::string &dest, const ProgressBar &prgsBar) :
+ source(src), destination(dest), progress(prgsBar)
{
- if (key.size() < DMCRYPT_KEY_MIN_LEN_BYTE)
- throw runtime::Exception("Key length isn't enough to be used for dmcrypt");
- else if (key.size() > DMCRYPT_KEY_MIN_LEN_BYTE)
- return ode::DMCryptEngine::data(key.begin(), key.begin() + DMCRYPT_KEY_MIN_LEN_BYTE);
- else
- return key;
}
-void DMCryptEngine::mount(const DMCryptEngine::data &key, unsigned int options)
+DMCryptEngine::~DMCryptEngine()
{
- DMCryptEngine::data sanitized_key = sanitizeKey(key);
+}
+void DMCryptEngine::mount(const DMCryptEngine::data &key, unsigned int options)
+{
// create crypto type device mapping layer to mount the encrypted partition.
- const std::string crypto_blkdev = createCryptoBlkDev(source, DM_LABEL, sanitized_key, cryptInfo.getFileSystemSize(), cryptInfo.getCryptoTypeName());
+ auto cryptoBlkDev = createCryptoBlkDev(source, DM_DEFAULT_LABEL_NAME, sanitizeKey(key), DM_DEFAULT_CRYPTO_NAME);
- if (::mount(crypto_blkdev.c_str(), destination.c_str(), "ext4", 0, 0) < 0)
+ if (::mount(cryptoBlkDev.c_str(), destination.c_str(), "ext4", 0, 0) < 0)
throw runtime::Exception(runtime::GetSystemErrorMessage());
}
if (::umount(destination.c_str()))
throw runtime::Exception(runtime::GetSystemErrorMessage());
- destroyCryptoBlkDev(DM_LABEL);
-}
-
-void DMCryptEngine::encryptInPlace(const std::string &src_blkdev,
- const std::string &dst_blkdev,
- const bool isFastEncEnabled)
-{
- Ext4Tool ext4tool(src_blkdev);
- ext4tool.forceCleanUp();
-
- const unsigned int SRC_BLOCK_SIZE = ext4tool.getBlockSize();
- const unsigned int SRC_TOTAL_BLOCK_COUNT = ext4tool.getTotalBlockCount();
- char buff[SRC_BLOCK_SIZE] = {0, };
-
- runtime::File dst(dst_blkdev, O_WRONLY);
- runtime::File src(src_blkdev, O_RDONLY);
-
- for (unsigned int n = 0; n < SRC_TOTAL_BLOCK_COUNT; n++) {
- if (isFastEncEnabled && ext4tool.isUsedBlock(n) == false)
- continue;
-
- src.lseek(n * SRC_BLOCK_SIZE, SEEK_SET);
- dst.lseek(n * SRC_BLOCK_SIZE, SEEK_SET);
-
- src.read(buff, SRC_BLOCK_SIZE);
- dst.write(buff, SRC_BLOCK_SIZE);
-
- progressBar.update(n, SRC_TOTAL_BLOCK_COUNT, 1);
- }
- progressBar.done();
+ destroyCryptoBlkDev(DM_DEFAULT_LABEL_NAME);
}
void DMCryptEngine::encrypt(const DMCryptEngine::data &key, unsigned int options)
{
- DMCryptEngine::data sanitized_key = sanitizeKey(key);
+ // Force filesystem check via fcsf might be able to avoid fail situation during encryption.
+ Ext4Tool ext4Source(source);
+ ext4Source.forceCleanUp();
// create crypto type device mapping layer to mount the plain partition
// should be encrypted here.
- const std::string crypto_blkdev = createCryptoBlkDev(source, DM_LABEL, sanitized_key, cryptInfo.getFileSystemSize(), cryptInfo.getCryptoTypeName());
-
- bool isFastEncEnabled = true;
- if (options == OPTION_INCLUDE_UNUSED_REGION)
- isFastEncEnabled = false;
-
- INFO("FastEncryption: " + std::string(isFastEncEnabled ? "Enabled" : "Disabled"));
+ auto cryptoBlkDev = createCryptoBlkDev(source, DM_DEFAULT_LABEL_NAME, sanitizeKey(key), DM_DEFAULT_CRYPTO_NAME);
+
+ std::function<bool(unsigned int)> isTarget;
+ if (!(options & OPTION_INCLUDE_UNUSED_REGION)) {
+ INFO("FastEncryption: Disabled");
+ isTarget = std::bind(&Ext4Tool::isUsedBlock, &ext4Source, _1);
+ } else {
+ INFO("FastEncryption: Enabled");
+ isTarget = [](unsigned int n) {
+ return true;
+ };
+ }
// We always do In-place encryption
- encryptInPlace(source, crypto_blkdev, isFastEncEnabled);
+ copyInPlace(source, cryptoBlkDev, isTarget,
+ std::bind((void(ProgressBar::*)(int, int, int))&ProgressBar::update,
+ &progress, _1, _2, 1));
// remove crypto type device mapper
- destroyCryptoBlkDev(DM_LABEL);
+ destroyCryptoBlkDev(DM_DEFAULT_LABEL_NAME);
+
+ sync();
+ progress.done();
}
void DMCryptEngine::decrypt(const DMCryptEngine::data &key, unsigned int options)
{
- DMCryptEngine::data sanitized_key = sanitizeKey(key);
-
// create crypto type device mapping layer to mount the plain partition
// should be encrypted here.
- const std::string crypto_blkdev = createCryptoBlkDev(source, DM_LABEL, sanitized_key, cryptInfo.getFileSystemSize(), cryptInfo.getCryptoTypeName());
-
- bool isFastEncEnabled = true;
- if (options == OPTION_INCLUDE_UNUSED_REGION)
- isFastEncEnabled = false;
-
- INFO("FastEncryption: " + std::string(isFastEncEnabled ? "Enabled" : "Disabled"));
+ auto cryptoBlkDev = createCryptoBlkDev(source, DM_DEFAULT_LABEL_NAME, sanitizeKey(key), DM_DEFAULT_CRYPTO_NAME);
+
+ // Force filesystem check via fcsf might be able to avoid fail situation during decryption.
+ Ext4Tool ext4CryptoBlkDev(cryptoBlkDev);
+ ext4CryptoBlkDev.forceCleanUp();
+
+ std::function<bool(unsigned int)> isTarget;
+ if (!(options & OPTION_INCLUDE_UNUSED_REGION)) {
+ INFO("FastEncryption: Disabled");
+ isTarget = std::bind(&Ext4Tool::isUsedBlock, &ext4CryptoBlkDev, _1);
+ } else {
+ INFO("FastEncryption: Enabled");
+ isTarget = [](unsigned int n) {
+ return true;
+ };
+ }
- // We always do In-place encryption
- encryptInPlace(crypto_blkdev, source, isFastEncEnabled);
+ // We always do In-place decryption
+ copyInPlace(cryptoBlkDev, source, isTarget,
+ std::bind((void(ProgressBar::*)(int, int, int))&ProgressBar::update,
+ &progress, _1, _2, 1));
// remove crypto type device mapper
- destroyCryptoBlkDev(DM_LABEL);
+ destroyCryptoBlkDev(DM_DEFAULT_LABEL_NAME);
+
+ sync();
+ progress.done();
}
bool DMCryptEngine::isKeyMetaSet()
unsigned int DMCryptEngine::getSupportedOptions()
{
- return OPTION_INCLUDE_UNUSED_REGION;
+ return OPTION_INCLUDE_UNUSED_REGION;
}
} // namespace ode
// TEST DMCryptEngine STATIC Functions
////////////////////////////////////////////////////////////////////////////////////////
+TESTCASE(DMCryptGetFileSystemSizeWithDummyFile)
+{
+ try {
+ // we espect the sector size (20480) with our temporary created file
+ size_t test_fs_size = 20480;
+ if (test_fs_size != ode::getFileSystemSize(test_real_blkdev))
+ TEST_FAIL("FileSystemSize doesn't match");
+ //
+ } catch (runtime::Exception &e) {
+ TEST_FAIL(e.what());
+ }
+}
+
TESTCASE(DMCryptConvertKeyToHexAsciiSingle16byte)
{
try {
const ode::DMCryptEngine::data master_key = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F};
- ode::DMCryptEngine::data master_key_ascii(512);
ode::DMCryptEngine::data answer = {0x30, 0x30, 0x30, 0x31, 0x30, 0x32, 0x30, 0x33, 0x30, 0x34, 0x30, 0x35, 0x30, 0x36, 0x30, 0x37,
0x30, 0x38, 0x30, 0x39, 0x30, 0x41, 0x30, 0x42, 0x30, 0x43, 0x30, 0x44, 0x30, 0x45, 0x30, 0x46
};
- ode::convertKeyToHexASCII(master_key, master_key_ascii);
+ const std::string master_key_ascii = ode::convertToHex(master_key);
// check
for (unsigned int i = 0; i < master_key.size() * 2; i++) {
{
try {
const ode::DMCryptEngine::data master_key = {0xF0, 0xE1, 0xD2, 0xC3, 0xB4, 0xA5, 0x96, 0x87, 0x78, 0x69, 0x5A, 0x4B, 0x3C, 0x2D, 0x1E, 0x0F};
- ode::DMCryptEngine::data master_key_ascii(512);
ode::DMCryptEngine::data answer = {0x46, 0x30, 0x45, 0x31, 0x44, 0x32, 0x43, 0x33, 0x42, 0x34, 0x41, 0x35, 0x39, 0x36, 0x38, 0x37,
0x37, 0x38, 0x36, 0x39, 0x35, 0x41, 0x34, 0x42, 0x33, 0x43, 0x32, 0x44, 0x31, 0x45, 0x30, 0x46
};
- ode::convertKeyToHexASCII(master_key, master_key_ascii);
+ const std::string master_key_ascii = ode::convertToHex(master_key);
// check
for (unsigned int i = 0; i < master_key.size() * 2; i++)
}
}
-TESTCASE(DMCryptBlkDevCryptInfoWithDummyFile)
-{
- try {
- const std::string test_crypto_type_name = "test-crypto-type-name";
-
- ode::CryptInfo cryptInfo;
- cryptInfo.init(test_real_blkdev, test_crypto_type_name);
- if (test_crypto_type_name.compare(cryptInfo.getCryptoTypeName()))
- TEST_FAIL("CryptoTypeName doesn't match");
-
- // we espect the sector size (20480) with our temporary created file
- long test_fs_size = 20480;
- if (test_fs_size != cryptInfo.getFileSystemSize())
- TEST_FAIL("FileSystemSize doesn't match");
- //
- } catch (runtime::Exception &e) {
- TEST_FAIL(e.what());
- }
-}
TESTCASE(DMCryptCreateRemoveCryptoBlkDevWithTempkey)
{
try {
- ode::CryptInfo cryptInfo;
- cryptInfo.init(test_real_blkdev, "aes-cbc-essiv:sha256");
const std::string keystring = "01020304050607080910111213141516";
const ode::DMCryptEngine::data key32bit(keystring.begin(), keystring.end());
- const std::string crypto_blkdev = ode::createCryptoBlkDev(test_real_blkdev, "testdata", key32bit, cryptInfo.getFileSystemSize(), cryptInfo.getCryptoTypeName());
+ const std::string crypto_blkdev = ode::createCryptoBlkDev(test_real_blkdev, "testdata", key32bit, DM_DEFAULT_CRYPTO_NAME);
// check crypto device status using cryptsetup
{
FILE *fp = popen("cryptsetup status testdata", "r");
const ode::DMCryptEngine::data sanitized_key = ode::sanitizeKey(keyBig);
// check size
- TEST_EXPECT(sanitized_key.size(), (unsigned)DMCRYPT_KEY_MIN_LEN_BYTE);
+ TEST_EXPECT(sanitized_key.size(), (unsigned)DM_KEY_MIN_LEN_BYTE);
// check data
for (unsigned i = 0; i < sanitized_key.size(); i++) {