Regenerate key in Database::setTransformRounds().

Merge Database::updateKey() into Database::setTransformRounds() and
regenerate the key if the database already has a key.

Closes #34
This commit is contained in:
Felix Geyer 2012-07-17 10:31:00 +02:00
parent 2b694bab16
commit 66422437d3
2 changed files with 9 additions and 12 deletions

View File

@ -189,7 +189,15 @@ void Database::setCompressionAlgo(Database::CompressionAlgorithm algo)
void Database::setTransformRounds(quint64 rounds)
{
m_transformRounds = rounds;
if (m_transformRounds != rounds) {
m_transformRounds = rounds;
if (m_hasKey) {
m_transformedMasterKey = m_key.transform(m_transformSeed, m_transformRounds);
m_metadata->setMasterKeyChanged(Tools::currentDateTimeUtc());
Q_EMIT modifiedImmediate();
}
}
}
void Database::setKey(const CompositeKey& key, const QByteArray& transformSeed, bool updateChangedTime)
@ -209,16 +217,6 @@ void Database::setKey(const CompositeKey& key)
setKey(key, Random::randomArray(32));
}
void Database::updateKey(quint64 rounds)
{
if (m_transformRounds != rounds) {
m_transformRounds = rounds;
m_transformedMasterKey = m_key.transform(m_transformSeed, transformRounds());
m_metadata->setMasterKeyChanged(Tools::currentDateTimeUtc());
Q_EMIT modifiedImmediate();
}
}
bool Database::hasKey()
{
return m_hasKey;

View File

@ -86,7 +86,6 @@ public:
* Sets the database key and generates a random transform seed.
*/
void setKey(const CompositeKey& key);
void updateKey(quint64 rounds);
bool hasKey();
void recycleEntry(Entry* entry);
void recycleGroup(Group* group);