Use quint64 everywhere for the transform rounds number.

This commit is contained in:
Felix Geyer 2012-05-08 22:31:09 +02:00
parent ebce183925
commit 8122ab2b2c
8 changed files with 13 additions and 13 deletions

View File

@ -57,7 +57,7 @@ public:
m_backend->processInPlace(data);
}
inline void processInPlace(QByteArray& data, int rounds) {
inline void processInPlace(QByteArray& data, quint64 rounds) {
Q_ASSERT(rounds > 0);
m_backend->processInPlace(data, rounds);
}

View File

@ -30,7 +30,7 @@ public:
virtual QByteArray process(const QByteArray& data) = 0;
virtual void processInPlace(QByteArray& data) = 0;
virtual void processInPlace(QByteArray& data, int rounds) = 0;
virtual void processInPlace(QByteArray& data, quint64 rounds) = 0;
virtual void reset() = 0;
virtual int blockSize() const = 0;

View File

@ -113,20 +113,20 @@ void SymmetricCipherGcrypt::processInPlace(QByteArray& data)
Q_ASSERT(error == 0);
}
void SymmetricCipherGcrypt::processInPlace(QByteArray& data, int rounds)
void SymmetricCipherGcrypt::processInPlace(QByteArray& data, quint64 rounds)
{
// TODO check block size
gcry_error_t error;
if (m_direction == SymmetricCipher::Decrypt) {
for (int i = 0; i != rounds; ++i) {
for (quint64 i = 0; i != rounds; ++i) {
error = gcry_cipher_decrypt(m_ctx, data.data(), data.size(), 0, 0);
Q_ASSERT(error == 0);
}
}
else {
for (int i = 0; i != rounds; ++i) {
for (quint64 i = 0; i != rounds; ++i) {
error = gcry_cipher_encrypt(m_ctx, data.data(), data.size(), 0, 0);
Q_ASSERT(error == 0);
}

View File

@ -35,7 +35,7 @@ public:
QByteArray process(const QByteArray& data);
void processInPlace(QByteArray& data);
void processInPlace(QByteArray& data, int rounds);
void processInPlace(QByteArray& data, quint64 rounds);
void reset();
int blockSize() const;

View File

@ -74,11 +74,11 @@ void SymmetricCipherSalsa20::processInPlace(QByteArray& data)
reinterpret_cast<u8*>(data.data()), data.size());
}
void SymmetricCipherSalsa20::processInPlace(QByteArray& data, int rounds)
void SymmetricCipherSalsa20::processInPlace(QByteArray& data, quint64 rounds)
{
Q_ASSERT((data.size() < blockSize()) || ((data.size() % blockSize()) == 0));
for (int i = 0; i != rounds; ++i) {
for (quint64 i = 0; i != rounds; ++i) {
ECRYPT_encrypt_bytes(&m_ctx, reinterpret_cast<const u8*>(data.constData()),
reinterpret_cast<u8*>(data.data()), data.size());
}

View File

@ -37,7 +37,7 @@ public:
QByteArray process(const QByteArray& data);
void processInPlace(QByteArray& data);
void processInPlace(QByteArray& data, int rounds);
void processInPlace(QByteArray& data, quint64 rounds);
void reset();
int blockSize() const;

View File

@ -71,7 +71,7 @@ QByteArray CompositeKey::rawKey() const
return cryptoHash.result();
}
QByteArray CompositeKey::transform(const QByteArray& seed, int rounds) const
QByteArray CompositeKey::transform(const QByteArray& seed, quint64 rounds) const
{
Q_ASSERT(seed.size() == 32);
Q_ASSERT(rounds > 0);
@ -89,7 +89,7 @@ QByteArray CompositeKey::transform(const QByteArray& seed, int rounds) const
}
QByteArray CompositeKey::transformKeyRaw(const QByteArray& key, const QByteArray& seed,
int rounds) {
quint64 rounds) {
QByteArray iv(16, 0);
SymmetricCipher cipher(SymmetricCipher::Aes256, SymmetricCipher::Ecb,
SymmetricCipher::Encrypt, seed, iv);

View File

@ -33,14 +33,14 @@ public:
CompositeKey& operator=(const CompositeKey& key);
QByteArray rawKey() const;
QByteArray transform(const QByteArray& seed, int rounds) const;
QByteArray transform(const QByteArray& seed, quint64 rounds) const;
void addKey(const Key& key);
static int transformKeyBenchmark(int msec);
private:
static QByteArray transformKeyRaw(const QByteArray& key, const QByteArray& seed,
int rounds);
quint64 rounds);
QList<Key*> m_keys;
};