signon 8.54

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

crypto-manager.h
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-2011 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
31 #ifndef SIGNON_CRYPTO_MANAGER_H
32 #define SIGNON_CRYPTO_MANAGER_H
33
34 #include <SignOn/AbstractCryptoManager>
35
36 #include <QObject>
37
38 #define MINUMUM_ENCRYPTED_FILE_SYSTEM_SIZE 4
39
45 class CryptoManager: public SignOn::AbstractCryptoManager
46 {
47 Q_OBJECT
48
49 // DO NOT change the order of the enum values!!!
50 enum FileSystemMountState {
51 Unmounted = 0,
52 LoopSet,
53 LoopLuksFormatted,
54 LoopLuksOpened,
55 Mounted
56 };
57
58 static const uint signonMinumumDbSize;
59 static const char signonDefaultFileSystemName[];
60 static const char signonDefaultFileSystemType[];
61
62 public:
63 // reimplemented virtual methods
64 bool initialize(const QVariantMap &configuration);
65
70 enum FileSystemType {
71 Ext2 = 0,
72 Ext3,
73 Ext4
74 };
75
80 CryptoManager(QObject *parent = 0);
81
85 ~CryptoManager();
86
96 bool setupFileSystem();
97
104 bool deleteFileSystem();
105
110 bool mountFileSystem();
111
116 bool unmountFileSystem();
117
121 QString fileSystemMountPath() const;
122
126 QStringList backupFiles() const;
127
135 bool encryptionKeyInUse(const SignOn::Key &key);
136
146 bool addEncryptionKey(const SignOn::Key &key,
147 const SignOn::Key &existingKey);
148
156 bool removeEncryptionKey(const SignOn::Key &key,
157 const SignOn::Key &remainingKey);
158
159 private:
160 bool setFileSystemType(const QString &type);
161 bool setFileSystemSize(const quint32 size);
162 void setFileSystemPath(const QString &path);
163
164 void checkFileSystemSetup();
165 void clearFileSystemResources();
166 bool mountMappedDevice();
167 bool unmountMappedDevice();
168 void updateMountState(const FileSystemMountState state);
169
170 static bool createPartitionFile(const QString &filePath);
171 static bool formatMapFileSystem(const QString &fileSystemPath);
172
173 const QString keychainFilePath() const;
174 void addKeyToKeychain(const QByteArray &key) const;
175 void removeKeyFromKeychain(const QByteArray &key) const;
176 bool keychainContainsKey(const QByteArray &key) const;
177
178 private:
179 //TODO remove this
180 void serializeData();
181
182 private:
183 QString m_fileSystemPath;
184 QString m_fileSystemMapPath;
185 QString m_fileSystemName;
186 QString m_fileSystemMountPath;
187 QString m_loopDeviceName;
188
189 FileSystemMountState m_mountState;
190 FileSystemType m_fileSystemType;
191 quint32 m_fileSystemSize;
192 };
193
194 #endif // SIGNON_CRYPTOMANAGER_H
CryptoManager::deleteFileSystem
bool deleteFileSystem()
Deletes the encrypted file system.
Definition: crypto-manager.cpp:383
CryptoManager::~CryptoManager
~CryptoManager()
Destroys a CryptoManager object.
Definition: crypto-manager.cpp:97
CryptoManager::mountFileSystem
bool mountFileSystem()
Mounts the encrypted file system.
Definition: crypto-manager.cpp:258
CryptoManager::removeEncryptionKey
bool removeEncryptionKey(const SignOn::Key &key, const SignOn::Key &remainingKey)
Releases an existing used keyslot in the LUKS partition&#39;s header.
Definition: crypto-manager.cpp:455
CryptoManager
Encrypted file system manager.
Definition: crypto-manager.h:45
CryptoManager::initialize
bool initialize(const QVariantMap &configuration)
Definition: crypto-manager.cpp:102
CryptoManager::backupFiles
QStringList backupFiles() const
Definition: crypto-manager.cpp:399
CryptoManager::Ext2
Definition: crypto-manager.h:71
CryptoManager::CryptoManager
CryptoManager(QObject *parent=0)
Constructs a CryptoManager object with the given parent.
Definition: crypto-manager.cpp:82
CryptoManager::encryptionKeyInUse
bool encryptionKeyInUse(const SignOn::Key &key)
Definition: crypto-manager.cpp:470
CryptoManager::fileSystemMountPath
QString fileSystemMountPath() const
Definition: crypto-manager.cpp:394
CryptoManager::Ext3
Definition: crypto-manager.h:72
CryptoManager::FileSystemType
FileSystemType
Supported encrypted partion filesystem type.
Definition: crypto-manager.h:70
CryptoManager::addEncryptionKey
bool addEncryptionKey(const SignOn::Key &key, const SignOn::Key &existingKey)
Adds an encryption key to one of the available keyslots of the LUKS partition&#39;s header.
Definition: crypto-manager.cpp:437
CryptoManager::Ext4
Definition: crypto-manager.h:73
CryptoManager::unmountFileSystem
bool unmountFileSystem()
Unmounts the encrypted file system.
Definition: crypto-manager.cpp:345
CryptoManager::setupFileSystem
bool setupFileSystem()
Sets up an encrypted file system.
Definition: crypto-manager.cpp:175