Deep copy subkeys when cloning CompositeKey.

This commit is contained in:
Felix Geyer 2011-11-13 14:52:43 +01:00
parent ac60f7ce70
commit 0014d50b59
5 changed files with 110 additions and 0 deletions

View file

@ -22,6 +22,15 @@
#include <QtCore/QtConcurrentRun>
CompositeKey::CompositeKey()
{
}
CompositeKey::CompositeKey(const CompositeKey& key)
{
*this = key;
}
CompositeKey::~CompositeKey()
{
qDeleteAll(m_keys);
@ -32,6 +41,14 @@ CompositeKey* CompositeKey::clone() const
return new CompositeKey(*this);
}
CompositeKey& CompositeKey::operator=(const CompositeKey& key)
{
Q_FOREACH (Key* subKey, key.m_keys) {
m_keys.append(subKey->clone());
}
return *this;
}
QByteArray CompositeKey::rawKey() const
{
@ -46,6 +63,9 @@ QByteArray CompositeKey::rawKey() const
QByteArray CompositeKey::transform(const QByteArray& seed, int rounds) const
{
Q_ASSERT(seed.size() == 32);
Q_ASSERT(rounds > 0);
QByteArray key = rawKey();
QFuture<QByteArray> future1 = QtConcurrent::run(transformKeyRaw, key.left(16), seed, rounds);

View file

@ -25,8 +25,11 @@
class CompositeKey : public Key
{
public:
CompositeKey();
CompositeKey(const CompositeKey& key);
~CompositeKey();
CompositeKey* clone() const;
CompositeKey& operator=(const CompositeKey& key);
QByteArray rawKey() const;
QByteArray transform(const QByteArray& seed, int rounds) const;