signon  8.56
crypto-handlers.cpp
Go to the documentation of this file.
1 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of signon
4  *
5  * Copyright (C) 2009-2010 Nokia Corporation.
6  *
7  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
8  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * version 2.1 as published by the Free Software Foundation.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23  */
24 
25 #include <sys/mount.h>
26 #include <errno.h>
27 #include <fcntl.h>
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <libcryptsetup.h>
31 
32 #include <QDataStream>
33 #include <QTextStream>
34 #include <QProcess>
35 #include <QLatin1Char>
36 #include <QFileInfo>
37 #include <QDir>
38 
39 #include "crypto-handlers.h"
40 #include "debug.h"
41 #include "misc.h"
42 
43 #define SIGNON_LUKS_DEFAULT_HASH "ripemd160"
44 
45 #define SIGNON_LUKS_CIPHER_NAME "aes"
46 #define SIGNON_LUKS_CIPHER_MODE "xts-plain"
47 #define SIGNON_LUKS_CIPHER \
48  SIGNON_LUKS_CIPHER_NAME "-" SIGNON_LUKS_CIPHER_MODE
49 #define SIGNON_LUKS_KEY_SIZE 256
50 #define SIGNON_LUKS_BASE_KEYSLOT 0
51 
52 #define SIGNON_EXTERNAL_PROCESS_READ_TIMEOUT 300
53 
54 #define KILO_BYTE_SIZE 1024
55 #define MEGA_BYTE_SIZE (KILO_BYTE_SIZE * 1024)
56 
57 /* ------------- SystemCommandLineCallHandler implementation -------------- */
58 
60 {
61  connect(&m_process, SIGNAL(error(QProcess::ProcessError)),
62  this, SLOT(error(QProcess::ProcessError)));
63 }
64 
66 {
67 }
68 
69 bool SystemCommandLineCallHandler::makeCall(const QString &appPath,
70  const QStringList &args,
71  bool readOutput)
72 {
73  QString trace;
74  QTextStream stream(&trace);
75  stream << appPath << QLatin1Char(' ') << args.join(QLatin1String(" "));
76  TRACE() << trace;
77 
78  m_process.start(appPath, args);
79  if (!m_process.waitForStarted()) {
80  BLAME() << "Wait for started failed";
81  return false;
82  }
83 
84  if (readOutput) {
85  m_output.clear();
86 
87  if (m_process.waitForReadyRead(SIGNON_EXTERNAL_PROCESS_READ_TIMEOUT)) {
88  if (!m_process.bytesAvailable()) {
89  BLAME() << "Coult not read output of external process ";
90  return false;
91  }
92 
93  while(m_process.bytesAvailable())
94  m_output += m_process.readAllStandardOutput();
95  }
96  }
97 
98  if (!m_process.waitForFinished()) {
99  TRACE() << "Wait for finished failed";
100  return false;
101  }
102 
103  return true;
104 }
105 
106 void SystemCommandLineCallHandler::error(QProcess::ProcessError err)
107 {
108  TRACE() << "Process erorr:" << err;
109 }
110 
111 
112 /* ------------------ PartitionHandler implementation --------------------- */
113 
114 bool PartitionHandler::createPartitionFile(const QString &fileName,
115  const quint32 fileSize)
116 {
117  int fd = open(fileName.toLatin1().data(),
118  O_RDWR | O_CREAT,
119  666);
120 
121  if (fd < 0) {
122  BLAME() << "FAILED to create signon secure FS partition file. ERRNO:"
123  << errno;
124  return false;
125  }
126 
127  if (ftruncate(fd, fileSize * MEGA_BYTE_SIZE) == -1) {
128  BLAME() << "FAILED to set signon secure FS partition file size. ERRNO:"
129  << errno;
130  return false;
131  }
132 
133  if (close(fd) < 0)
134  TRACE() << "Failed to close secure FS partition file after creation.";
135 
137  TRACE() << "Failed to set file permissions "
138  "for the secure storage container.";
139 
140  return true;
141 }
142 
143 bool PartitionHandler::formatPartitionFile(const QString &fileName,
144  const quint32 fileSystemType)
145 {
146  QString mkfsApp = QString::fromLatin1("/sbin/mkfs.ext2");
147  switch (fileSystemType) {
148  case Ext2: mkfsApp = QString::fromLatin1("/sbin/mkfs.ext2"); break;
149  case Ext3: mkfsApp = QString::fromLatin1("/sbin/mkfs.ext3"); break;
150  case Ext4: mkfsApp = QString::fromLatin1("/sbin/mkfs.ext4"); break;
151  default: break;
152  }
153 
155  return handler.makeCall(
156  mkfsApp,
157  QStringList() << fileName);
158 }
159 
160 
161 /* --------------------- MountHandler implementation ---------------------- */
162 
163 bool MountHandler::mount(const QString &toMount,
164  const QString &mountPath,
165  const QString &fileSystemTtpe)
166 {
167  /* Mount a filesystem. */
168  return (::mount(toMount.toUtf8().constData(),
169  mountPath.toUtf8().constData(),
170  fileSystemTtpe.toUtf8().constData(),
171  MS_SYNCHRONOUS | MS_NOEXEC, NULL) == 0);
172 }
173 
174 bool MountHandler::umount(const QString &mountPath)
175 {
176  /* Unmount a filesystem. */
177 
178  //TODO - investigate why errno is EINVAL
179 
180  TRACE() << mountPath.toUtf8().constData();
181  int ret = ::umount2(mountPath.toUtf8().constData(), MNT_FORCE);
182  TRACE() << ret;
183 
184  switch (errno) {
185  case EAGAIN: TRACE() << "EAGAIN"; break;
186  case EBUSY: TRACE() << "EBUSY"; break;
187  case EFAULT: TRACE() << "EFAULT"; break;
188  case EINVAL: TRACE() << "EINVAL"; break;
189  case ENAMETOOLONG: TRACE() << "ENAMETOOLONG"; break;
190  case ENOENT: TRACE() << "ENOENT"; break;
191  case ENOMEM: TRACE() << "ENOMEM"; break;
192  case EPERM: TRACE() << "EPERM"; break;
193  default: TRACE() << "umount unknown error - ignoring.";
194  }
195 
196  //TODO - Remove 1st, uncommend 2nd lines after the fix above.
197  // This is tmp hack so that the tests will work.
198  return true;
199  //return (ret == 0);
200 }
201 
202 /* ----------------------- LosetupHandler implementation ----------------------- */
203 
204 bool LosetupHandler::setupDevice(const QString &deviceName,
205  const QString &blockDevice)
206 {
208  return handler.makeCall(
209  QLatin1String("/sbin/losetup"),
210  QStringList() << deviceName << blockDevice);
211 }
212 
214 {
216  QString deviceName;
217  bool ret = handler.makeCall(
218  QLatin1String("/sbin/losetup"),
219  QStringList() << QLatin1String("-f"),
220  true);
221 
222  deviceName = QString::fromLocal8Bit(handler.output().trimmed());
223 
224  if (ret)
225  return deviceName;
226 
227  return QString();
228 }
229 
230 bool LosetupHandler::releaseDevice(const QString &deviceName)
231 {
233  return handler.makeCall(QLatin1String("/sbin/losetup"),
234  QStringList() <<
235  QString::fromLatin1("-d") << deviceName);
236 }
237 
238 /* -------------------- CrytpsetupHandler implementation ------------------ */
239 
240 // no longer used or defined by libcryptsetup, but used internally
241 #define MYCRYPT_FLAG_VERIFY (1 << 0)
242 #define MYCRYPT_FLAG_READONLY (1 << 1)
243 #define MYCRYPT_FLAG_VERIFY_IF_POSSIBLE (1 << 2)
244 #define MYCRYPT_FLAG_VERIFY_ON_DELKEY (1 << 3)
245 #define MYCRYPT_FLAG_NON_EXCLUSIVE_ACCESS (1 << 4)
246 
247 struct my_crypt_options {
248  const char *name;
249  const char *device;
250  const char *cipher;
251  const char *hash;
252  const char *key_file;
253  const char *new_key_file;
254  int key_size;
255  unsigned int flags;
256  int key_slot;
257  uint64_t iteration_time;
258  uint64_t timeout;
259  size_t align_payload;
260  int tries;
261  int (*icb_yesDialog)(char *msg);
262  void (*icb_log)(int klass, char *msg);
263 };
264 
265 /*
266  Callbacks for the interface callbacks struct in crypt_options struct.
267 */
268 static int yesDialog(char *msg)
269 {
270  Q_UNUSED(msg);
271  return 0;
272 }
273 
274 static void cmdLineLog(int type, char *msg)
275 {
276  switch (type) {
277  case CRYPT_LOG_NORMAL:
278  TRACE() << msg;
279  break;
280  case CRYPT_LOG_ERROR:
281  TRACE() << "Error: " << msg;
282  break;
283  default:
284  TRACE() << "Internal error on logging class for msg: " << msg;
285  break;
286  }
287 }
288 
289 static void log_wrapper(int level, const char *msg, void *usrptr)
290 {
291  void (*xlog)(int level, char *msg) = (void (*)(int, char*)) usrptr;
292  xlog(level, (char *)msg);
293 }
294 
295 static int yesDialog_wrapper(const char *msg, void *usrptr)
296 {
297  int (*xyesDialog)(char *msg) = (int (*)(char*)) usrptr;
298  return xyesDialog((char*)msg);
299 }
300 
301 int crypt_luksFormatBinary(struct my_crypt_options *options,
302  const char *pwd,
303  unsigned int pwdLen)
304 {
305  struct crypt_device *cd = NULL;
306  struct crypt_params_luks1 cp = {
307  options->hash,
308  options->align_payload,
309  NULL
310  };
311  int r;
312 
313  if ((r = crypt_init(&cd, options->device)))
314  return -EINVAL;
315 
316  crypt_set_log_callback(cd, log_wrapper, (void*) options->icb_log);
317  crypt_set_confirm_callback(cd, yesDialog_wrapper,
318  (void*) options->icb_yesDialog);
319 
320  crypt_set_timeout(cd, options->timeout);
321  crypt_set_password_retry(cd, options->tries);
322  crypt_set_iterarion_time(cd, options->iteration_time ?: 1000);
323  crypt_set_password_verify(cd, options->flags & MYCRYPT_FLAG_VERIFY);
324 
325  r = crypt_format(cd, CRYPT_LUKS1,
327  NULL, NULL, options->key_size, &cp);
328  if (r < 0)
329  goto out;
330 
331  /* Add keyslot using internally stored volume key generated during format */
332  r = crypt_keyslot_add_by_volume_key(cd, options->key_slot, NULL, 0,
333  pwd, pwdLen);
334 out:
335  crypt_free(cd);
336  return (r < 0) ? r : 0;
337 
338 }
339 
340 bool CryptsetupHandler::formatFile(const QByteArray &key,
341  const QString &deviceName)
342 {
343  struct my_crypt_options options;
344 
345  options.key_size = SIGNON_LUKS_KEY_SIZE / 8;
346  options.key_slot = SIGNON_LUKS_BASE_KEYSLOT;
347 
348  char *localDeviceName = (char *)malloc(deviceName.length() + 1);
349  Q_ASSERT(localDeviceName != NULL);
350 
351  strcpy(localDeviceName, deviceName.toLatin1().constData());
352  options.device = localDeviceName;
353 
354  options.cipher = SIGNON_LUKS_CIPHER;
355  options.new_key_file = NULL;
356 
357  char *localKey = (char *)malloc(key.length());
358  Q_ASSERT(localKey != NULL);
359  memcpy(localKey, key.constData(), key.length());
360 
361  options.flags = 0;
362  options.iteration_time = 1000;
363  options.timeout = 0;
364  options.align_payload = 0;
365 
366  options.icb_yesDialog = 0;
367  options.icb_log = 0;
368 
369  TRACE() << "Device: [" << options.device << "]";
370  TRACE() << "Key size:" << key.length();
371 
372  int ret = crypt_luksFormatBinary(&options, localKey, key.length());
373 
374  if (ret != 0)
375  TRACE() << "LUKS format API call result:" << ret << "." << error();
376 
377  if (localDeviceName)
378  free(localDeviceName);
379 
380  if (localKey) {
381  memset(localKey, 0x00, key.length());
382  free(localKey);
383  }
384 
385  return (ret == 0);
386 }
387 
388 int crypt_luksOpenBinary(struct my_crypt_options *options,
389  const char *pwd, unsigned int pwdLen)
390 {
391  struct crypt_device *cd = NULL;
392  uint32_t flags = 0;
393  int r;
394 
395  if ((r = crypt_init(&cd, options->device)))
396  return -EINVAL;
397 
398  crypt_set_log_callback(cd, log_wrapper, (void*) options->icb_log);
399  crypt_set_confirm_callback(cd, yesDialog_wrapper,
400  (void*) options->icb_yesDialog);
401 
402  crypt_set_timeout(cd, options->timeout);
403  crypt_set_password_retry(cd, options->tries);
404  crypt_set_iterarion_time(cd, options->iteration_time ?: 1000);
405  crypt_set_password_verify(cd, options->flags & MYCRYPT_FLAG_VERIFY);
406 
407  if ((r = crypt_load(cd, CRYPT_LUKS1, NULL))) {
408  crypt_free(cd);
409  return r;
410  }
411 
412  if (options->flags & MYCRYPT_FLAG_READONLY)
413  flags |= CRYPT_ACTIVATE_READONLY;
414 
415  if (options->flags & MYCRYPT_FLAG_NON_EXCLUSIVE_ACCESS)
416  flags |= CRYPT_ACTIVATE_NO_UUID;
417 
418  if (options->key_file)
419  r = -1;
420  else
421  r = crypt_activate_by_passphrase(cd, options->name,
422  CRYPT_ANY_SLOT,
423  pwd, pwdLen, flags);
424 
425  crypt_free(cd);
426  return (r < 0) ? r : 0;
427 }
428 
429 bool CryptsetupHandler::openFile(const QByteArray &key,
430  const QString &deviceName,
431  const QString &deviceMap)
432 {
433  struct my_crypt_options options;
434 
435  char *localDeviceMap = (char *)malloc(deviceMap.length() + 1);
436  Q_ASSERT(localDeviceMap != NULL);
437  strcpy(localDeviceMap, deviceMap.toLatin1().constData());
438  options.name = localDeviceMap;
439 
440  char *localDeviceName = (char *)malloc(deviceName.length() + 1);
441  Q_ASSERT(localDeviceName != NULL);
442  strcpy(localDeviceName, deviceName.toLatin1().constData());
443  options.device = localDeviceName;
444 
445  char *localKey = (char *)malloc(key.length());
446  Q_ASSERT(localKey != NULL);
447  memcpy(localKey, key.constData(), key.length());
448 
449  options.key_file = NULL;
450  options.timeout = 0;
451  /*
452  Do not change this:
453  1) In case of failure to open, libcryptsetup code will
454  enter infinite loop - library BUG/FEATURE.
455  2) There is no need for multiple tries, option is intended for
456  command line use of the utility.
457  */
458  options.tries = 0;
459  options.flags = 0;
460 
461  options.icb_yesDialog = yesDialog;
462  options.icb_log = cmdLineLog;
463 
464  TRACE() << "Device [" << options.device << "]";
465  TRACE() << "Map name [" << options.name << "]";
466  TRACE() << "Key size:" << key.length();
467 
468  int ret = crypt_luksOpenBinary(&options, localKey, key.length());
469 
470  if (ret != 0)
471  TRACE() << "LUKS open API call result:" << ret << "." << error() << ".";
472 
473  if (localDeviceName)
474  free(localDeviceName);
475 
476  if (localDeviceMap)
477  free(localDeviceMap);
478 
479  if (localKey) {
480  memset(localKey, 0x00, key.length());
481  free(localKey);
482  }
483 
484  return (ret == 0);
485 }
486 
487 int crypt_removeDevice(struct my_crypt_options *options)
488 {
489  struct crypt_device *cd = NULL;
490 
491  int r;
492 
493  if ((r = crypt_init_by_name(&cd, options->name)))
494  return -EINVAL;
495  r = crypt_deactivate(cd, options->name);
496  crypt_free(cd);
497  return r;
498 }
499 
500 bool CryptsetupHandler::closeFile(const QString &deviceMap)
501 {
502  struct my_crypt_options options;
503 
504  char *localDeviceMap = (char *)malloc(deviceMap.length() + 1);
505  Q_ASSERT(localDeviceMap != NULL);
506  strcpy(localDeviceMap, deviceMap.toLatin1().constData());
507  options.name = localDeviceMap;
508 
509  options.icb_yesDialog = yesDialog;
510  options.icb_log = cmdLineLog;
511 
512  TRACE() << "Map name [" << options.name << "]";
513 
514  int ret = crypt_removeDevice(&options);
515 
516  if (ret != 0)
517  TRACE() << "Cryptsetup remove API call result:" << ret <<
518  "." << error();
519 
520  if (localDeviceMap)
521  free(localDeviceMap);
522 
523  return (ret == 0);
524 }
525 
526 bool CryptsetupHandler::removeFile(const QString &deviceName)
527 {
528  Q_UNUSED(deviceName);
529  //todo - delete file system (wipe credentials storege) is based on this
530  return false;
531 }
532 
533 int crypt_luksAddKeyBinary(struct my_crypt_options *options,
534  const char *pwd, unsigned int pwdLen,
535  const char *newPwd, unsigned int newPwdLen)
536 {
537  struct crypt_device *cd = NULL;
538  int r;
539 
540  if ((r = crypt_init(&cd, options->device)))
541  return -EINVAL;
542 
543  crypt_set_log_callback(cd, log_wrapper, (void*) options->icb_log);
544  crypt_set_confirm_callback(cd, yesDialog_wrapper,
545  (void*) options->icb_yesDialog);
546 
547  crypt_set_timeout(cd, options->timeout);
548  crypt_set_password_retry(cd, options->tries);
549  crypt_set_iterarion_time(cd, options->iteration_time ?: 1000);
550  crypt_set_password_verify(cd, options->flags & MYCRYPT_FLAG_VERIFY);
551 
552  if ((r = crypt_load(cd, CRYPT_LUKS1, NULL))) {
553  crypt_free(cd);
554  return r;
555  }
556 
557  if (options->key_file || options->new_key_file)
558  r = -1;
559  else
560  r = crypt_keyslot_add_by_passphrase(cd, options->key_slot,
561  pwd, pwdLen, newPwd, newPwdLen);
562 
563  crypt_free(cd);
564  return (r < 0) ? r : 0;
565 }
566 
567 bool CryptsetupHandler::addKeySlot(const QString &deviceName,
568  const QByteArray &key,
569  const QByteArray &existingKey)
570 {
571  struct my_crypt_options options;
572 
573  options.key_size = SIGNON_LUKS_KEY_SIZE / 8;
574  options.cipher = SIGNON_LUKS_CIPHER;
575 
576  char *localDeviceName = (char *)malloc(deviceName.length() + 1);
577  Q_ASSERT(localDeviceName != NULL);
578  strcpy(localDeviceName, deviceName.toLatin1().constData());
579 
580  options.device = localDeviceName;
581  options.new_key_file = NULL;
582  options.key_file = NULL;
583  options.key_slot = -1;
584 
585  options.flags = 0;
586  options.iteration_time = 1000;
587  options.timeout = 0;
588  options.tries = 0;
589 
590  options.icb_yesDialog = yesDialog;
591  options.icb_log = cmdLineLog;
592 
593  int ret = crypt_luksAddKeyBinary(&options,
594  existingKey.constData(),
595  existingKey.length(),
596  key.constData(), key.length());
597 
598  if (localDeviceName)
599  free(localDeviceName);
600 
601  if (ret != 0)
602  TRACE() << "Cryptsetup add key API call result:" << ret <<
603  "." << error();
604 
605  return (ret == 0);
606 }
607 
608 #if 0
609 // there is no passphrase -> keyslot function in cryptsetup 1.6+
610 int crypt_luksRemoveKeyBinary(struct my_crypt_options *options,
611  const char *pwdToRemove,
612  unsigned int pwdToRemoveLen)
613 {
614  struct crypt_device *cd = NULL;
615  int key_slot;
616  int r;
617 
618  if ((r = crypt_init(&cd, options->device)))
619  return -EINVAL;
620 
621  crypt_set_log_callback(cd, log_wrapper, (void*) options->icb_log);
622  crypt_set_confirm_callback(cd, yesDialog_wrapper,
623  (void*) options->icb_yesDialog);
624 
625  crypt_set_timeout(cd, options->timeout);
626  crypt_set_password_retry(cd, options->tries);
627  crypt_set_iterarion_time(cd, options->iteration_time ?: 1000);
628  crypt_set_password_verify(cd, options->flags & MYCRYPT_FLAG_VERIFY);
629 
630  if ((r = crypt_load(cd, CRYPT_LUKS1, NULL))) {
631  crypt_free(cd);
632  return r;
633  }
634 
635  if ((key_slot = crypt_keyslot_by_passphrase(cd, NULL, pwdToRemove,
636  pwdToRemoveLen, 0, NULL)) < 0) {
637  r = -EPERM;
638  goto out;
639  }
640 
641  r = crypt_keyslot_destroy(cd, key_slot);
642 
643 out:
644  crypt_free(cd);
645  return (r < 0) ? r : 0;
646 }
647 
648 bool CryptsetupHandler::removeKeySlot(const QString &deviceName,
649  const QByteArray &key,
650  const QByteArray &remainingKey)
651 {
652  struct my_crypt_options options;
653 
654  options.key_size = SIGNON_LUKS_KEY_SIZE / 8;
655  options.cipher = SIGNON_LUKS_CIPHER;
656 
657  char *localDeviceName = (char *)malloc(deviceName.length() + 1);
658  Q_ASSERT(localDeviceName != NULL);
659  strcpy(localDeviceName, deviceName.toLatin1().constData());
660 
661  options.device = localDeviceName;
662  options.new_key_file = NULL;
663  options.key_file = NULL;
664  options.key_slot = -1;
665 
666  options.flags = 0;
667  options.timeout = 0;
668 
669  options.icb_yesDialog = yesDialog;
670  options.icb_log = cmdLineLog;
671 
672  int ret = crypt_luksRemoveKeyBinary(&options, key.constData(), key.length());
673 
674  if (localDeviceName)
675  free(localDeviceName);
676 
677  if (ret != 0)
678  TRACE() << "Cryptsetup remove key API call result:" << ret <<
679  "." << error();
680 
681  return (ret == 0);
682 }
683 #endif
684 
686 {
688  return handler.makeCall(
689  QLatin1String("/sbin/modprobe"),
690  QStringList() << QString::fromLatin1("dm_mod"));
691 }
692 
694 {
695  char buf[260];
696  crypt_get_error(buf, 256);
697  return QString::fromLocal8Bit(buf);
698 }
699 
static bool setupDevice(const QString &deviceName, const QString &blockDevice)
Mounts a block device to loopback device.
bool makeCall(const QString &appPath, const QStringList &args, bool readOutput=false)
Executes the application at appPath in a separate child process.
#define MYCRYPT_FLAG_READONLY
#define MYCRYPT_FLAG_NON_EXCLUSIVE_ACCESS
static bool formatPartitionFile(const QString &fileName, const quint32 fileSystemType)
Formats a file (block device) for a specific file system type (ext2,ext3,ext4)
static bool createPartitionFile(const QString &fileName, const quint32 fileSize)
Creates a random data file of fileSize Mb.
#define BLAME()
Definition: debug.h:32
~SystemCommandLineCallHandler()
Destructor.
QByteArray output() const
int crypt_luksOpenBinary(struct my_crypt_options *options, const char *pwd, unsigned int pwdLen)
static bool formatFile(const QByteArray &key, const QString &deviceName)
Formats the file system.
#define SIGNON_LUKS_CIPHER_MODE
#define MEGA_BYTE_SIZE
SystemCommandLineCallHandler()
Basic constructor.
#define SIGNON_LUKS_CIPHER_NAME
#define SIGNON_LUKS_KEY_SIZE
const QFile::Permissions signonFilePermissions
Definition: misc.h:29
static bool loadDmMod()
Loads the dm_mod kernel module.
static bool closeFile(const QString &deviceName)
Closes the file system.
static bool umount(const QString &target)
Unmounts a block device from a specific location.
static QString error()
bool setFilePermissions(const QString &filePath, const QFile::Permissions desiredPermissions, bool keepExisting)
Definition: misc.cpp:51
#define SIGNON_EXTERNAL_PROCESS_READ_TIMEOUT
static bool removeFile(const QString &deviceName)
Removes the file system.
#define SIGNON_LUKS_CIPHER
int crypt_luksAddKeyBinary(struct my_crypt_options *options, const char *pwd, unsigned int pwdLen, const char *newPwd, unsigned int newPwdLen)
Handles calls to system command line tools.
#define TRACE()
Definition: debug.h:28
int crypt_removeDevice(struct my_crypt_options *options)
int crypt_luksFormatBinary(struct my_crypt_options *options, const char *pwd, unsigned int pwdLen)
static bool addKeySlot(const QString &deviceName, const QByteArray &key, const QByteArray &existingKey)
Adds a key to a free encryption header slot.
#define SIGNON_LUKS_BASE_KEYSLOT
#define MYCRYPT_FLAG_VERIFY
static bool mount(const QString &source, const QString &target, const QString &fileSystemType=QLatin1String("ext2"))
Mounts a block device to a specific location.
static bool releaseDevice(const QString &deviceName)
Releases a used loopback device.
static QString findAvailableDevice()
Finds an available loopback device.
static bool openFile(const QByteArray &key, const QString &deviceName, const QString &deviceMap)
Opens the file system.