Integrate KeePass2RandomStream into KeePass2 reader and writer classes.

This hopefully completes support for reading/writing kdbx <= 2.14 files.

Also fix a bug in KeePass2XmlWriter so it sets Protected="True" in the Value
tag instead of Key.
This commit is contained in:
Felix Geyer 2011-07-07 00:15:52 +02:00
parent 58e048be96
commit a299dd9715
12 changed files with 200 additions and 45 deletions

View file

@ -23,6 +23,7 @@
#include "core/Endian.h"
#include "crypto/CryptoHash.h"
#include "crypto/Random.h"
#include "format/KeePass2RandomStream.h"
#include "format/KeePass2XmlWriter.h"
#include "streams/HashedBlockStream.h"
#include "streams/QtIOCompressor"
@ -91,11 +92,10 @@ void KeePass2Writer::writeDatabase(QIODevice* device, Database* db)
m_device = ioCompressor.data();
}
SymmetricCipher protectedStream(SymmetricCipher::Salsa20, SymmetricCipher::Stream, SymmetricCipher::Encrypt,
CryptoHash::hash(protectedStreamKey, CryptoHash::Sha256), KeePass2::INNER_STREAM_SALSA20_IV);
KeePass2RandomStream randomStream(protectedStreamKey);
KeePass2XmlWriter xmlWriter;
xmlWriter.writeDatabase(m_device, db, &protectedStream);
xmlWriter.writeDatabase(m_device, db, &randomStream);
}
bool KeePass2Writer::writeData(const QByteArray& data)