1 /***************************************************************************
2 * Copyright (C) 2007 by Brad Hards <bradh@frogmouth.net> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 ***************************************************************************/
10 #ifndef OOO_MANIFEST_H
11 #define OOO_MANIFEST_H
13 #include <QtCore/QByteArray>
14 #include <QtCore/QMap>
15 #include <QtCore/QString>
24 OOO document manifest entry
26 This class holds the manifest information for a single file-entry element.
27 An example of the XML that could be passed in is shown below, although
28 not all manifest entries will have encryption-data.
30 <manifest:file-entry manifest:media-type="image/jpeg" manifest:full-path="Pictures/100000000000032000000258912EB1C3.jpg" manifest:size="66704">
31 <manifest:encryption-data>
32 <manifest:algorithm manifest:algorithm-name="Blowfish CFB" manifest:initialisation-vector="T+miu403484="/>
33 <manifest:key-derivation manifest:key-derivation-name="PBKDF2" manifest:iteration-count="1024" manifest:salt="aNYdmqv4cObAJSJjm4RzqA=="/>
34 </manifest:encryption-data>
35 </manifest:file-entry>
42 Create a new manifest entry
44 ManifestEntry( const QString
&fileName
);
47 Set the mimetype of the file.
49 void setMimeType( const QString
&mimeType
);
54 QString
fileName() const;
59 This is only required for files with encryption
61 void setSize( const QString
&size
);
66 QString
mimeType() const;
71 This is only meaningful for files with encryption
76 Set the checksum type.
78 This is only required for files with encryption
80 void setChecksumType( const QString
&checksumType
);
85 \param checksum the checksum in base64 encoding.
87 This is only required for files with encryption
89 void setChecksum( const QString
&checksum
);
94 This is only meaningful for files with encryption
96 QString
checksumType() const;
101 This is only meaningful for files with encryption
103 QByteArray
checksum() const;
106 Set the algorithm name
108 This is only required for files with encryption
110 void setAlgorithm( const QString
&algorithm
);
113 Get the algorithm name
115 This is only meaningful for files with encryption
117 QString
algorithm() const;
120 Set the initialisation vector for the cipher algorithm
122 \param initialisationVector the IV in base64 encoding.
124 This is only required for files with encryption
126 void setInitialisationVector( const QString
&initialisationVector
);
129 Get the initialisation vector for the cipher algorithm
131 This is only meaningful for files with encryption
133 QByteArray
initialisationVector() const;
136 Set the name of the key derivation function
138 This is only required for files with encryption
140 void setKeyDerivationName( const QString
&keyDerivationName
);
143 Get the name of the key derivation function
145 This is only meaningful for files with encryption
147 QString
keyDerivationName() const;
150 Set the iteration count for the key derivation function
152 This is only required for files with encryption
154 void setIterationCount( const QString
&iterationCount
);
157 Get the iteration count for the key derivation function
159 This is only meaningful for files with encryption
161 int iterationCount() const;
164 Set the salt for the key derivation function
166 \param salt the salt in base64 encoding.
168 This is only required for files with encryption
170 void setSalt( const QString
&salt
);
173 Get the salt for the key derivation function
175 This is only meaningful for files with encryption
177 QByteArray
salt() const;
180 const QString m_fileName
;
183 QString m_checksumType
;
184 QByteArray m_checksum
;
186 QByteArray m_initialisationVector
;
187 QString m_keyDerivationName
;
188 int m_iterationCount
;
194 OOO document manifest
196 The document manifest is described in the OASIS Open Office Specification
197 (Version 1.1) section 17.7. This class represents the same data.
203 Create a new manifest.
205 \param odfFileName the name of the parent ODF file
206 \param manifestData the data from the manifest file, as a byte array
207 of the XML format data.
209 Manifest( const QString
&odfFileName
, const QByteArray
&manifestData
);
214 Check if the manifest indicates that a file is encrypted
216 bool testIfEncrypted( const QString
&filename
);
219 Decrypt data associated with a specific file
221 QByteArray
decryptFile( const QString
&filename
, const QByteArray
&fileData
);
225 Retrieve the manifest data for a particular file
227 ManifestEntry
* entryByName( const QString
&filename
);
230 Try to get the password for this file from the wallet
232 void getPasswordFromWallet();
235 Save the password for this file to the wallet
237 void savePasswordToWallet();
240 Verify whether the password we have is the right one.
242 This verifies the provided checksum
244 void checkPassword( ManifestEntry
*entry
, const QByteArray
&fileData
, QByteArray
*decryptedData
);
247 Ask the user for a password
249 void getPasswordFromUser();
252 QCA::Initializer m_init
;
254 const QString m_odfFileName
;
255 QMap
<QString
, ManifestEntry
*> mEntries
;
256 bool m_haveGoodPassword
;
257 bool m_userCancelled
;